akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)

lli n, k;

int main(void){
	cin >> n >> k;
	vector<lli> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	lli m = n;
	rep(i, n){
		if(a[i] == a[0]) m--;
	}
	cout << (m+k-2)/(k-1) << endl;
	return 0;
}


Measured memory_bytes: 4060
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<cmath>
#include<cstring>
#include<map>
#include<climits>
#include <iomanip>
#include<unordered_map>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;

int main(){
  FAST
  int a, b;
  cin >> a >> b;
  if(a >= 1 && a <= 9 && b >= 1 && b <= 9) cout << a * b;
  else cout << -1;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>


int gcd(int m, int n){
  int mi, ni;

  while(n){
    mi = n;
    ni = m%n;
    m = mi;
    n = ni;
  };//m is gcd
  return m;
}

int main(){
  int a, b;
  int found;

  while(scanf("%d %d", &a, &b) == 2){
    if (a >= b){
      found = gcd (a, b);
      printf("%d %d\n", found, a/found*b);
    }else{
      found = gcd (b, a);
      printf("%d %d\n", found, b/found*a);
    }
  }
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int i;
    bool strong = true;
    for(i=0;i<s.size();i++){
        if(s[i] != s[s.size()-i-1]) strong = false;
    }
    for(i=0;i<s.size()/2;i++){
        if(s[i] != s[s.size()/2-i-1]) strong = false;
    }

    if(strong) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

#define FOR(i,n) for(i=0;i<n;++i)
#define INF 1e9

int i,j;

int main(void){
    
    char a,b;
    cin>>a>>b;
    
    if(a=='H'){
        if(b=='H')cout<<'H';
        else cout<<'D';
    }
    else {
        if(b=='H')cout<<'D';
        else cout<<'H';
    }
    
    return 0;
    
}


Measured memory_bytes: 256
function main(n) {
    for (var i = 1; i <= 9; i++) {
        if (n % i === 0 && n / i < 10) {
            console.log('Yes');
            return;
        }
    }
    console.log('No');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def cross_point(p0, q0, p1, q1):
    x0, y0 = p0; x1, y1 = q0
    x2, y2 = p1; x3, y3 = q1
    dx0 = x1 - x0
    dy0 = y1 - y0
    dx1 = x3 - x2
    dy1 = y3 - y2

    s = (y0-y2)*dx1 - (x0-x2)*dy1
    sm = dx0*dy1 - dy0*dx1
    if sm == 0:
        return None
    return x0 + s*dx0/sm, y0 + s*dy0/sm

def solve():
    W, H, N, R = map(int, readline().split())
    if W == H == 0:
        return False
    L = [tuple(map(int, readline().split())) for i in range(N)]
    L.extend([
        (0, 0, W, 0, 0),
        (0, 0, 0, H, 0),
        (0, H, W, H, 0),
        (W, 0, W, H, 0),
    ])
    EPS = 1e-9
    pp = ((1, 1), (1, -1), (-1, 1), (-1, -1))
    for i in range(N+4):
        xi1, yi1, xi2, yi2, t0 = L[i]
        p0 = (xi1, yi1); q0 = (xi2, yi2)
        dx0 = (xi2 - xi1); dy0 = (yi2 - yi1)
        d0 = (dx0**2 + dy0**2)**.5
        for j in range(i):
            xj1, yj1, xj2, yj2, t1 = L[j]
            p1 = (xj1, yj1); q1 = (xj2, yj2)
            dx1 = (xj2 - xj1); dy1 = (yj2 - yj1)
            d1 = (dx1**2 + dy1**2)**.5
            cp = cross_point(p0, q0, p1, q1)
            if cp is None:
                continue
            x0, y0 = cp
            sv = abs(dx0*dy1 - dx1*dy0)
            for p, q in pp:
                a = p*d1*(t1+R)
                b = q*d0*(t0+R)
                x = x0 + (a * dx0 + b * dx1) / sv
                y = y0 + (a * dy0 + b * dy1) / sv
                if not R - EPS < x < W-R + EPS or not R - EPS < y < H-R + EPS:
                    continue
                ok = 1
                for k in range(N):
                    xk1, yk1, xk2, yk2, t2 = L[k]
                    dxp = xk2 - xk1; dyp = yk2 - yk1
                    dxq = x - xk1; dyq = y - yk1
                    d2 = (dxp**2 + dyp**2)**.5
                    if abs(dxp*dyq - dxq*dyp) < (R + t2) * d2 - EPS:
                        ok = 0
                if ok:
                    write("Yes\n")
                    return True
    write("No\n")
    return True
while solve():
    ...


Measured memory_bytes: 5700
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000009
using P = pair<int,int>;

int main(){
    int n,m;
    cin >> n >> m;
    int sum = 0;
    vint A(n);
    rep(i,n){
        cin >> A[i];
        sum += A[i];
    }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    bool flag = true;
  //cout << sum << endl;
    rep(i,m){
      //cout << A[i]*4*m << endl;
        if(sum > A[i]*4*m){
            flag = false;
            break;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<vector<pair<Int,Int>>> G(n);
  for(Int i=1;i<n;i++){
    Int u,v,w;
    cin>>u>>v>>w;
    u--;v--;
    G[u].push_back({v,w});
    G[v].push_back({u,w});
  }
  priority_queue<Int,vector<Int>,greater<Int> > pq;
  vector<Int> ans(n),used(n,0);
  pq.emplace(0);
  used[0]=1;
  ans[0] = 1;
  while(!pq.empty()){
    Int v=pq.top();pq.pop();
    for(pair<Int,Int> u:G[v]){
    	Int x = u.first;
    	Int y = u.second;
      if(used[x]) continue;
      if(y%2 == 0){
      	ans[x] = ans[v];
      }
      else{
      	if(ans[v] == 0){
      		ans[x] = 1;
      	}
      	else{
      		ans[x] = 0;
      	}
      }
      used[x]=1;
      pq.emplace(x);
    }
  }
  
  for(Int i=0;i<n;i++){
  	cout<<ans[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 9472
{-# LANGUAGE OverloadedLists     #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
import           Data.IORef
import           Data.Maybe
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           System.IO

import qualified Data.IntMap   as I
import qualified Data.Map      as M
import qualified Data.Set      as S
import qualified Data.Vector   as V

(+.+) = T.append
(!.!) = T.index

readT :: Read a => T.Text -> a
readT = read . T.unpack

getLineSpc :: Read a => IO [a]
getLineSpc = do
  t <- T.getLine
  let xs = map readT $ T.split (== ' ') t
  return xs

main :: IO ()
main = chocolate

chocolate :: IO ()
chocolate = do
  n  :: Int <- readLn
  dx :: [Int] <- getLineSpc
  let [d, x] = dx
  as :: [Int] <- replicateM n readLn
  let modAs = map (\m -> (d - 1) `div` m + 1) as
      ans = x + sum modAs
  print ans

Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],d,ab[500][50];
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>d;
    rep(i,26){
        cin>>aa[i];
    }
    rep(i,d){
        rep(j,26){
            cin>>ab[i][j];
        }
    }
    rep(i,d){
        m=0;
        int k=0;
        rep(j,26){
            if(m<ab[i][j]){
                k=j+1;
                m=ab[i][j];
            }
        }
        cout<<k<<endl;
    }
}

Measured memory_bytes: 10624
M,D=map(int,input().split())
ans=0
if D<21:
    print(ans)
    
else:
    for i in range(22,D+1):
        d1=i%10
        d10=(i-d1)/10
        if d1<2 or d10<2:
            pass
        else:
            if 2<=d1*d10<=M:
                ans+=1
            else:
                pass
    print(ans)    
        

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;
    
    int ans = 0;
    N -= K;
    ans = 1;
    while(N > 0) {
        N -= (K-1);
        ans++;
    }

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

Measured memory_bytes: 384
s = input()
n = len(s)
lst = [0] * n

cnt_r = 0
cnt_l = 0
i = 0
sakaime = 0
s += 'R'
while i < n+1:
    if s[i] == 'R':
        if sakaime == 0:
            cnt_r += 1
            i += 1
        else:
            if cnt_r % 2 == 0:
                lst[sakaime-1] += cnt_r // 2
                lst[sakaime] += cnt_r // 2
            else:
                lst[sakaime-1] += cnt_r // 2 + 1
                lst[sakaime] += cnt_r // 2
            if cnt_l % 2 == 0:
                lst[sakaime-1] += cnt_l // 2
                lst[sakaime] += cnt_l // 2
            else:
                lst[sakaime-1] += cnt_l // 2
                lst[sakaime] += cnt_l // 2 + 1
            cnt_r = 1
            cnt_l = 0
            i += 1
            sakaime = 0
    else:
        cnt_l += 1
        if sakaime == 0:
            sakaime = i
        i += 1

print(' '.join(map(str, lst)))

Measured memory_bytes: 10484
#include <string>
using std::string;

#include <iostream>
using std::cout;
using std::cin;

#include <vector>
using std::vector;

#include <cmath>
using std::abs;

int main(){
    int N, L;

    cin >> N >> L;

    vector<int> apps(N);


    int count = 0;
    bool zeroFlag = false;
    for(auto& app : apps){
        app = L + count ;
        count++;
    }

    int result = 0;
    int minAbs = 65535;
    int minAbsValue;
    for(const auto& app:apps){
        result += app;
        if(minAbs > abs(app)){
            minAbs = abs(app);
            minAbsValue = app;
        }
    }

    result = result - minAbsValue;

    cout << result;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
    int i, j;
    char s[27];
    char comp;

    scanf("%s", s);

    for(j = 0; j < strlen(s)-1; j++){
        comp = s[j];
        for(i = j+1; i < strlen(s); i++){
            if(comp == s[i]){
                printf("no\n");
                return 0;
            }
        }
    }

    printf("yes\n");
    return 0;
}

Measured memory_bytes: 128
/**
 * MatrixVectorMultiplication.cpp
 * Create:20180423
 * Description:行列の積を出力するプログラム
 */
#include <iostream>
#include <array>

int main(int argc, char* argv[]){
  // 行列の大きさを設定する。
  int height;
  int width;

  std::cin >> height >> width;

  int a[height][width];
  int b[width];

  // 行列aの入力
  for (int i = 0; i < height; i++){
    for (int j = 0; j < width; j++){
      std::cin >> a[i][j];
    }
  }

  // 行列bの入力
  for (int k = 0; k < width; k++){
    std::cin >> b[k];
  }

  for (int i = 0; i < height; i++){
    int ans = 0;
    for (int j = 0; j < width; j++){
      ans += a[i][j] * b[j];
    }
    std::cout << ans << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3128
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int a[10],i,x,b[10];
  double n,z,y;
  while(1){
    scanf("%lf\n",&n);
    if(n<0){
      return 0;
    }
    x=n;
    z=x;
    y=n-z;
    if(x>=256 || y>0.9375){
      printf("NA\n");
      continue;
    }
    for(i=0;i<8;i++){
      a[i]=0,b[i]=8;
    }
    for(i=0;i<8;i++){
      a[i]=x%2;
      x=x/2;
    }
    for(i=0;i<4;i++){
      y=y*2;
      x=y;
      b[i]=x;
      if(y>=1.00000){
        y=y-1.00000;
      }
    }
    if(y>0.00000){
      printf("NA\n");
      continue;
    }
    for(i=7;i>=0;i--){
      printf("%d",a[i]);
    }
    printf(".");
    for(i=0;i<4;i++){
      printf("%d",b[i]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
char a[250][250];
char b[250][250];
int di[]={1,1,0,-1,-1,-1,0,1};
int dj[]={0,-1,-1,-1,0,1,1,1};
int main()
{
	int n,m;cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	 for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(a[i][j]=='#')
            {
                cout<<'#';
            }
            else
            {
                int num=0;
                for(int m=0;m<8;m++)
                {
                    if(a[i][j]!='.')
                    {
                        continue;
                    }
                    if(a[i+di[m]][j+dj[m]]=='#')
                    {
                        num++;}
                }
                cout<<num;
            }
        }
        cout<<"\n";
    }
	return 0;
}


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

#define sz(x) (int)(x.size())
#define FOR(i,L,R) for(int i = L; i <= R; i++)
#define int long long

const int N = 2e5 + 2, inf = 1e18;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int x, y;
    cin >> x >> y;

    int ans = 1;

    while (2 * x <= y) {
        ++ans;
        x = x * 2;
    }

    cout << ans;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;



int main(){
	int n;
	cin >> n;
	ll a,b,c;
	cin >> a;
	for(int i = 0; i < n - 1; i++) {
		cin >> b;
		c = __gcd(a,b);
		a = a/c*b;
	}
	cout << a << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
int pow_d(int d) {
    if(d == 0) return 1;
    else if(d==1) return 100;
    else return 10000;
}
int main(void) {
    int d, n; cin >> d >> n;
    if(n==100) n++;
    cout << n * pow_d(d);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,d;

int s(char tebl[][101],int i,int j,int k){
	if(k>=d){
		return 1;
	}
	if(j<m&&tebl[i][j+1]=='.'){
		if(1==s(tebl,i,j+1,k+1)){
			return 1;
		}
	}
	return 0;
}

int t(char tebl[][101],int i,int j,int k){
	if(k>=d){
		return 1;
	}
	if(i<n&&tebl[i+1][j]=='.'){
		if(1==t(tebl,i+1,j,k+1)){
			return 1;
		}
	}
	return 0;
}

int main(){
	cin>>n>>m>>d;
	int ans=0;
	char tebl[n][101];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>tebl[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(tebl[i][j]=='.'){
				ans+=s(tebl,i,j,1);
				ans+=t(tebl,i,j,1);
			}
		}
	}
	cout<<ans<<endl;
}
		
	



Measured memory_bytes: 3112
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef pair<int, pii> pip;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;

int v[1010][1010];
//char s[1010][1010];

bool check(int x1, int y1, int x2, int y2){
	x1--; y1--;
	return (v[y2][x2]-v[y2][x1]-v[y1][x2]+v[y1][x1])==0;
}

int  main(){
	int n;
	vector<string> s;
	while(cin>>n && n){
		s = vector<string>(n);
		rep(i, n) {
			//scanf("%s", s[i]);
			cin>>s[i];
		}
		for(int i = 0; i < n+2; i++){
			for(int j = 0; j < n + 2; j++){
				v[i][j] = 0;
			}
		}
		rep(i, n){
			rep(j, n){
				v[i+1][j+1] = v[i+1][j]+(s[i][j] == '*' ? 1:0);
			}
		}
		rep(i, n){
			rep(j, n){
				v[i+1][j+1]+=v[i][j+1];
			}
		}
		int ans = 0;
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				int l = 1, h = n-max(i,j), m;
				//while(l+1<h){
				rep(k, 30){
					m = (l+h)/2;
					if(check(i, j, i+m, j+m)){
						l = m ;//+ 1;
					}else{
						h = m ;//- 1;
					}
				}
				//while(!check(i, j, i + l, j + l)) l--;
				if(check(i, j, i + h, j + h)) ans = max(ans, h + 1);
				if(check(i, j, i + l, j + l)) ans = max(ans, l + 1);
			}
		}
		//cout<<ans<<endl;
		printf("%d\n", ans);
		// rep(i, n + 1){
		// 	rep(j, n + 1){
		// 		printf("%d ", v[i][j]);
		// 	}
		// 	printf("\n");
		// }
		//ep(i, n) cout<<s[i]<<endl;
	}
}

Measured memory_bytes: 7788
#include <bits/stdc++.h>
using namespace std;
 
#define oo 1e9
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)
#define _cos(xxxx) cos(xxxx*acos(-1)/180)
#define _sin(xxxx) sin(xxxx*acos(-1)/180)
#define _tan(xxxx) tan(xxxx*acos(-1)/180)
#define PE cout<<fixed
 
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;
 
const ld pi=acos(-1);

ll n,i;
string s;

int main() {
    IO;
    cin>>n;
    cin>>s;
    for (i=0;i<s.length();i++) {
        s[i]=(s[i]-'A'+n)%26+'A';
    }
    cout<<s;
}
    

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

const int mod = 998244353;
signed main(void)
{
	long long n, m, ans;
	vector<long long> v(100010), cnt(100010);

	cin >> n;
	rep(i, n) cin >> v[i]; 
	rep(i, n) cnt[v[i]]++;
	m = 0;
	rep(i, n) m = max(m, v[i]);
	if (cnt[0] != 1 || v[0] != 0)
	{
		cout << 0 << endl;
		return 0;
	}
	ans = 1;
	for(int i = 1; i <= m; i++)
	{
		if (cnt[i] == 0)
		{
			ans = 0;
			break;
		}
		rep(j, cnt[i])
		{
			ans *= cnt[i - 1] % mod;
			ans %= mod;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
from collections import Counter

U = 10**5+1
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD
    
def comb(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[k]
    z %= MOD
    z *= fact_inv[n-k]
    z %= MOD
    return z
  
n = int(input())
A = list(map(int, input().split()))
x = Counter(A).most_common()[0][0]
left = A.index(x)
right = A[::-1].index(x)
print(n)
for k in range(2, n+2):
  ans = comb(n+1, k) - comb(left+right, k-1)
  ans %= MOD
  print(ans)

Measured memory_bytes: 29916
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n;
  string s;
  cin >> n >> s;

  if (n & 1) {
    cout << "No" << endl;
    return 0;
  }

  int half = n / 2;
  rep(i, 0, half) {
    if (s[i] != s[i + half]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int mod=1000000007;
int fact[500006];
int n,m;
int inv(int x)
{
    int r,y;
    for(r=1,y=mod-2;y>0;x=(x*x)%mod,y/=2)
        if(y%2==1)
            r=r*x%mod;
    return r;
}
int nCr(int n, int m)
{
    return fact[n] *inv(fact[m])%mod *inv(fact[n-m])%mod ;
}
int power(int x,int y,int p)
{ 
    int res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if((y & 1)==1) 
            res = (res * x) % p; 
        y = y >> 1;  
        x = (x * x) % p;  
    } 
    return res; 
}
int32_t main() 
{
    IOS;
    fact[0]=1;
    for(int i=1;i<=500005;i++)
        fact[i]=(i*fact[i-1])%mod;
    cin>>n>>m;
    int ans=(nCr(m,n)*fact[n])%mod;
    int get=ans;
    for(int i=1;i<=n;i++)
    {
        int a=(fact[n]*inv(fact[i]))%mod;
        a=(a*nCr(m-i,n-i))%mod;
        if(i%2==0)
            get=(get+a)%mod;
        else
            get=(get-a+mod)%mod;
    }
    print((get*ans)%mod);
}   

Measured memory_bytes: 7560
# coding: utf8

def read_int():
    return int(input())
 
 
def read_int_n():
    return list(map(int, input().split()))
 
 
def read_str():
    return input()
 
 
def read_str_n():
    return list(map(int, input().split()))


def main():
    n = read_int()
    h = read_int_n()
    h[0] -= 1
    for i in range(1, n - 1):
        if h[i-1] < h[i]:
            h[i] -= 1
        if h[i] > h[i + 1]:
            print('No')
            return
    print('Yes')

main()

Measured memory_bytes: 14704
sx,sy,tx,ty=map(int,input().split())
X=tx-sx;Y=ty-sy
print("R"*X+"U"*Y+"L"*X+"D"*Y+"D"+"R"*(X+1)+"U"*(Y+1)+"L"+"U"+"L"*(X+1)+"D"*(Y+1)+"R")

Measured memory_bytes: 38256
import sys
import queue
input = sys.stdin.readline
sys.setrecursionlimit(int(1E+7))
dxdy = ((-1,0), (1,0), (0,-1), (0,1))
H, W = map(int,input().split())
maze = []
visited = [ [0]*W for _ in range(H)]
black = 0
for h in range(H):
    s = input()
    maze.append(s)
    for c in s:
        if c=='#':
            black += 1
q = queue.Queue()
q.put((0,0,0))
cost = -1
while(not q.empty()):
    y, x, d = q.get()
    if x == W-1 and y == H-1:
        cost = d
        break
    if visited[y][x] == 1:
        continue
    else:
        visited[y][x] = 1
        for dx, dy in  dxdy:
            if (0<= x+dx < W) and (0<= y+dy < H):                
                if visited[y+dy][x+dx] == 0 and maze[y+dy][x+dx]=='.':
                    q.put((y+dy,x+dx,d+1))
if cost==-1:
    print (-1)
else:
    print (H*W-cost-1-black)

Measured memory_bytes: 3948
import sys
input = sys.stdin.readline
N=int(input())
A=0
B=0
table=[]
for i in range(N):
    a,b=map(int,input().split())
    table.append((a,i))
    table.append((b,i))
    A+=a
    B+=b
ans=min(A,B)
table.sort()
num=0
for i in range(N):
    num+=table[i][0]
L=[0]*N
#print(table)
for i in range(N):
    c,j=table[i]
    if L[j]!=0:
        ans=min(num,ans)
        print(ans)
        #print(L)
        sys.exit()
    L[j]+=1
c,n=table[N-1]
if n!=table[N][1]:
    num=num-table[N-1][0]+table[N][0]
    ans = min(num, ans)
    print(ans)
    sys.exit()
num1=num-table[N-1][0]+table[N+1][0]
num2=num-table[N-2][0]+table[N][0]
print(min(ans,num1,num2))




Measured memory_bytes: 58460
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 100000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
int main() {
	long long a, b, c, n;
	cin >> a >> b >> c >> n;
	long long ans = 0;
	for (int i = 0; i * a <= n; ++i) {
		for (int q = 0; i * a + q*b <= n; ++q) {
			long long geko = n - i * a - q * b;
			if (geko % c == 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

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

int main(){
	string s;
	cin>>s;
  	for(int i=0;i<s.size();++i){
      if(s[i]=='1')s[i]='9';
      else s[i]='1';
    }cout<<s<<endl;return 0;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
ct = [list(map(int, input().split())) for _ in range(N)]
ret = 10 ** 9
for c, t in ct:
	if t <= T:
		ret = min(ret, c)
if ret < 10 ** 9:
	print(ret)
else:
	print("TLE")

Measured memory_bytes: 3060
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val intArray = IntArray(n)
    repeat(n) {
        intArray[it] = sc.nextInt()
    }

    val sorted = countingSort(intArray)
    println(sorted.joinToString(" "))
}

private fun countingSort(intArray: IntArray): IntArray {
    val k = 10000
    val sortedArray = IntArray(intArray.size)
    val counterArray = IntArray(k + 1)

    for (i in intArray) {
        counterArray[i]++
    }

    for (i in 1..k) {
        counterArray[i] += counterArray[i - 1]
    }

    for (i in intArray.size - 1 downTo 0) {
        sortedArray[--counterArray[intArray[i]]] = intArray[i]
    }

    return sortedArray
}


Measured memory_bytes: 556520
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, k = MI()
    H = LI()
    H.sort()
    H.reverse()

    terget = H[k:]
    print(sum(terget))


main()


Measured memory_bytes: 104512
#include <stdio.h>
#include <memory.h>
int main(void){
  int n,c,i,j,f,k=1,a[11][11];
  while(1){
    scanf("%d",&n);
    if(!n)
      break;
    memset(a,0,sizeof(a));
    i=j=1;
    f=0;
    c=1;
    if(n==1)
      a[i][j]=c;
    while(c<=n*n/2){
      if(f%4==0){
	  a[i][j]=c;
	  a[n-i+1][n-j+1]=n*n-c+1;
	  j++;
	  c++;
	  f++;
      }
      else if(f%4==1){
	while(j>1){
	  a[i][j]=c;
	  a[n-i+1][n-j+1]=n*n-c+1;
	  i++;
	  j--;
	  c++;
	}
	f++;
      }
      else if(f%4==2){
	a[i][j]=c;
	a[n-i+1][n-j+1]=n*n-c+1;
	i++;
	c++;
	f++;
      }
      else if(f%4==3){
	while(i>1){
	  a[i][j]=c;
	  a[n-i+1][n-j+1]=n*n-c+1;
	  i--;
	  j++;
	  c++;
	}
	f++;
      }
    }
    printf("Case %d:\n",k++);
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	printf("%3d",a[i][j]);
      }
      puts("");
    }
  }
  return 0;
}

Measured memory_bytes: 620
n = int(input())
a = list(map(int, input().split()))

b = [0] * n

for i in range(n):
  if i < n/2:
    b[i] = a[(n-1) - (2*i)]
  else:
    b[i] = a[2*i - n]
print(' '.join(list(map(str, b))))


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin>>n;
	vll h(n);
	ll ans=0;
	rep(i, n) cin >> h[i];
	rep(i, n-1){
		if (h[i]>h[i+1]){
			ans += h[i]-h[i+1];
		}
	}
	ans += h.back();
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * @Author:      H S-J
 * @DateTime:    2017-11-11 20:00:27
 * @Description: 
 */
#include <bits/stdc++.h>
using namespace std;
#define MST(a, b) memset(a, b, sizeof(a));
#define CLR(a) MST(a, 0);
#define DBG(x) cout << '#' << " = " << (x) << endl;
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define lson(x) (x) << 1
#define rson(x) (x) << 1|1
#define pb push_back
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define ech(x, y, z) for (auto x = z.begin(), y = z.end(); x != y; ++x)
#define lowbit(x) (x & (-x))
#define opr operator
#define _st first
#define _nd second
#define prior_q1(x) priority_queue<x>
#define prior_q2(x) priority_queue<x, vector<x>, greater<x> >
typedef long long LL;
typedef stringstream strstm;
struct FastIO {
    static const int S = 1310720;
    int wpos;
    char wbuf[S];
    FastIO() : wpos(0) {}
    inline int xchar() {
        static char buf[S];
        static int len = 0, pos = 0;
        if (pos == len)
            pos = 0, len = fread(buf, 1, S, stdin);
        if (pos == len) return -1;
        return buf[pos ++];
    }
    inline int xuint() {
        int c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x;
    }
    inline int xint() {
        int s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline LL xlongint() {
        LL s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline void xstring(char *s) {
        int c = xchar();
        while (c <= 32) c = xchar();
        for (; c> 32; c = xchar()) * s++ = c;
        *s = 0;
    }
    inline void wchar(int x) {
        if (wpos == S) fwrite(wbuf, 1, S, stdout), wpos = 0;
        wbuf[wpos ++] = x;
    }
    inline void wint(LL x) {
        if (x < 0) wchar('-'), x = -x;
        char s[24];
        int n = 0;
        while (x || !n) s[n ++] = '0' + x % 10, x /= 10;
        while (n--) wchar(s[n]);
    }
    inline void wstring(const char *s) {
        while (*s) wchar(*s++);
    }
    ~FastIO() {
        if (wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
    }
} io;
map<char, int> mmp;
int main(int argc, char const *argv[]) {
	mmp['1'] = 1;
	mmp['2'] = 2;
	mmp['3'] = 3;
	mmp['4'] = 4;
	mmp['5'] = 5;
	mmp['6'] = 5;
	mmp['7'] = 7;
	mmp['8'] = 8;
	mmp['9'] = 9;
	mmp['A'] = 10;
	mmp['B'] = 11;
	mmp['C'] = 12;
	mmp['D'] = 13;
	mmp['E'] = 14;
	mmp['F'] = 15;
	ios::sync_with_stdio(0);cin.tie(0);
	char X, Y;
	cin >> X >> Y;
	int x = mmp[X], y = mmp[Y];
	if(x == y) cout << "=" << endl;
	if(x > y) cout << ">" << endl;
	if(x < y) cout << "<" << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main()
{
    ll t = 1;
    int n; cin >> n;
    for(int i = 1; i <= n; i++){t *= i;t %= mod;}
    cout << t << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main () {
    int A;
    int B;
    scanf("%d", &A);
    scanf("%d", &B);
    if (B == 1) {
        printf("%d\n", 0);
        return 0;
    }

    if (A >= B) {
        printf("%d\n", 1);
        return 0;
    }
    int ans = 2;
    for(;;) {
        if ((A + (ans - 1) * (A - 1)) >= B) {
            printf("%d\n", ans);
            return 0;
        }

        ans++;
    }

    return 0;
}


Measured memory_bytes: 128
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,le,ri,h,sta;
  string s,t;
  cin >> n;
  cout << 0<<endl;
  cin >> s;
  if(s=="Vacant"){
    return 0;
  }
  le = 1;
  ri = n;
  sta = 0;
  while(true){
    h = (le+ri)/2;
    cout << h << endl;
    cin >> t;
    if(t=="Vacant"){
      break;
    }else if((h%2==1)^(t==s)){
      le = h+1;
    }else{
      ri = h;
    }
  }
}


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

int main() {
    int tc = 1;
    while(tc--) {
        long long a, b, c, d;
        cin>>a>>b>>c>>d;
        cout<<max(max(min(a, b) * min(c, d), max(a, b) * max(c, d)), 
            max(min(a, b) * max(c, d), max(a, b) * min(c, d)));        
    }
    return 0;
}

Measured memory_bytes: 3632
import sys
INF = 10**18
import sys
from heapq import heapify,heappop,heappush,heappushpop


class PriorityQueue:
    
    #初期化
    def __init__(self,heap):
        self.heap = heap
        heapify(self.heap)
    
    #値の追加
    def push(self,item):
        heappush(self.heap,item)
    
    #値の取り出し
    def pop(self):
        return heappop(self.heap)
    
    #値を追加して取り出し
    def pushpop(self,item):
        return heappushpop(self.heap,item)
    
    #データ構造の中身を見る
    def __call__(self):
        return self.heap
    
    #heapの長さ
    def __len__(self):
        return len(self.heap)

def dijkstra(s):
    #始点sから各頂点への最短距離
    d = [INF] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    q = PriorityQueue(edgelist)
    for e in edge[s]:
        q.push(e)
    while len(edgelist):
        minedge = q.pop()
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                q.push([e[0]+d[v],e[1]])
    return d

if __name__ == "__main__":
    n = int(input())
    edge = [[] for i in range(n)]
    for i in range(n-1):
        u,v,w = map(int,input().split())
        u-=1
        v-=1
        edge[u].append([w,v])
        edge[v].append([w,u])
    ans = dijkstra(0)
    c_ans = [0]*n
    for i in range(n):
        if ans[i]%2 == 0:
            c_ans[i] = 0
        else:
            c_ans[i] = 1
    for i in range(n):
        print(c_ans[i])

Measured memory_bytes: 50988
cir :: [Int] -> String
cir (w:h:x:y:r:_)
  | ((0 <= (x - r)) && ((x + r) <= w)) && ((0 <= (y - r)) && ((y + r) <= h)) = "Yes"
  | otherwise = "No"

main = do
  s <- getLine
  let whxyr = map (read :: String -> Int) $ words s
  putStrLn $ cir whxyr

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

bool useLeft(char c)
{
    string t = "qwertasdfgzxcvb";

    bool ok = false;
    for (auto &&cc : t)
    {
        if (c == cc)
        {
            ok = true;
            break;
        }
    }
    return ok;
}

void solve(string &s)
{
    bool cur = useLeft(s[0]);
    int ret = 0;
    for (auto &&c : s)
    {
        if (cur != useLeft(c))
        {
            cur ^= true;
            ret++;
        }
    }
    cout << ret << endl;
}

int main()
{

    string s;
    while (cin >> s, s != "#")
    {
        solve(s);
    }
    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int n, k, c; cin >> n >> k >> c;
    string s; cin >> s;
    vector<int> cnt = {-1000000};
    int cn = 0;
    rep(i,n){
        if (s[i] == 'o'){
            if (cnt[cn] + c + 1 <= i){
                cnt.emplace_back(i);
                cn++;
            }
        }
    }
    if (cn > k) return 0;
    vector<int> cntt = {1000000};
    int cnn = 0;
    rep(i,n){
        if (s[n-1-i] == 'o'){
            if (cntt[cnn] - c - 1 >= n-1-i){
                cntt.emplace_back(n-1-i);
                cnn++;
            }
        }
    }
    reverse(cntt.begin()+1,cntt.end());
    rep(i,cnt.size()){
        if (cnt[i] == cntt[i]) cout << cnt[i]+1 << endl; 
    }
    //printvec(cnt);
    //printvec(cntt);
    return 0;
}

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

int main(){
    int w, a, b;
    cin >> w >> a >> b;
    if(a > b){
        int t = a; a = b; b = t;
    }
    if(b-(a+w) > 0) cout << b-(a+w) << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;
typedef long long LL;

const int N=(int)1e9,P=(int)1e5;
const int W[9][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,0},{0,1},{1,-1},{1,0},{1,1}};

int h,w,n;
struct node
{
	int a,b;
}t,p[P+5];
inline bool operator < (node a,node b)
{return a.a==b.a?a.b<b.b:a.a<b.a;}

map<node,int> M;

inline bool Check(int a,int b)
{
	return a>=2&&a+1<=h&&b>=2&&b+1<=w;
}

int main()
{
	scanf("%d %d %d",&h,&w,&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&p[i].a,&p[i].b);
		for(int j=0;j<9;j++)
			if(Check(p[i].a+W[j][0],p[i].b+W[j][1]))
			{
				t.a=p[i].a+W[j][0],t.b=p[i].b+W[j][1];
				M[t]++;
			}
	}
	
	int ans[15]={};
	for(int i=1;i<=n;i++)
		for(int j=0;j<9;j++)
			if(Check(p[i].a+W[j][0],p[i].b+W[j][1]))
			{
				t.a=p[i].a+W[j][0],t.b=p[i].b+W[j][1];
				if(M[t]!=-1)
					ans[M[t]]++,M[t]=-1;
			}
	
	LL Ans=0;
	for(int i=1;i<=9;i++)
		Ans-=ans[i];
	printf("%lld\n",Ans+(1ll*(h-2)*(w-2)));
	
	for(int i=1;i<=9;i++)
		printf("%d\n",ans[i]);
	
	return 0;
}

Measured memory_bytes: 57344
#include<bits/stdc++.h>
using namespace std;
main(){
  int a[44],n;
  a[0]=a[1]=1;
  for(int i=2;i<=44;i++)a[i]=a[i-1]+a[i-2];
  cin>>n;
  cout<<a[n]<<endl; 
}

Measured memory_bytes: 1160
s=input()
t=input()
import sys
a=0
b=[]
c=[]
if len(s)==len(t):
    for i in range(len(s)):
        if s[i]!=t[i]:
            a+=1
    print(a)
    sys.exit()
for i in range(len(s)-len(t)):
    b.append(s[i:len(t)+i])


for i in range(len(b)):
    for j in range(len(b[i])):
        if b[i][j]!=t[j]:
            a+=1
    c.append(a)
    a=0
        
print(min(c))

    



Measured memory_bytes: 9144
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
int MOD = 1000000007; //10^9 + 7

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


  // DP テーブル  
  long long dp[110][100100] = {0};  
int main(void){
  int n, w;
  cin >> n >> w;
  vvi wv(n+2, vi(2));
  rep(i,n)rep(j,2) cin >> wv[i][j];

  // 無限大の値
  const long long INF = 1LL << 60;


  // 初期条件
  for(int j=0;j<=w;++j)dp[0][j] = 0;

  // ループ
  for (int i = 0; i < n; ++i) {
    for(int j = 0; j <= w; ++j){                                 
      if(j+wv[i][0]<=w) chmax(dp[i+1][j+wv[i][0]], dp[i][j] + wv[i][1]); //i+1の品物を入れる
      chmax(dp[i+1][j], dp[i][j]);
    }
  }

  // 解を得て出力
  cout << dp[n][w] << endl;
  return 0;
}

Measured memory_bytes: 82536
#include <iostream>
using namespace std;
int a[100001],fa[100001];
int findfa(int x){
    return fa[x]==x?x:fa[x]=findfa(fa[x]);
}
int main(void){
    int n,m;
    int tx,ty,x,y,ans=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        fa[i]=i;
    }
    for(int i=0;i<m;i++){
        cin>>x>>y;
        tx=findfa(x);
        ty=findfa(y);
        fa[tx]=ty;
    }
    for(int i=0;i<n;i++){
        if(findfa(a[i+1])==findfa(i+1))ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
inf = float("inf")
N = int(input())
if N==1:
    print(0)
    exit()
lr = inf
ll = inf
rr = -inf
rl = -inf
ud = -inf
uu = -inf
dd = inf
du = inf
l_stop = inf
r_stop = -inf
u_stop = -inf
d_stop = inf
for _ in range(N):
    x, y, d = input().split()
    x, y = int(x), int(y)
    if d=="R":
        lr = min(lr, x)
        rr = max(rr, x)
    elif d=="L":
        rl = max(rl, x)
        ll = min(ll, x)
    elif d=="U":
        du = min(du, y)
        uu = max(uu, y)
    else:
        ud = max(ud, y)
        dd = min(dd, y)
    if d=="R" or d=="L":
        u_stop = max(u_stop, y)
        d_stop = min(d_stop, y)
    else:
        l_stop = min(l_stop, x)
        r_stop = max(r_stop, x)


def f(t):
    r = max(r_stop, rr+t, rl-t)
    l = min(l_stop, ll-t, lr+t)
    u = max(u_stop, uu+t, ud-t)
    d = min(d_stop, dd-t, du+t)
    return (r-l) * (u-d)
#print(f(1))

high = 10**8
high = float(high)
low = 0.0
while high - low > 0.000001:
    #print(high, low)
    mid_left = high/3+low*2/3
    mid_right = high*2/3+low/3
    if f(mid_left) >= f(mid_right):
        low = mid_left
    else:
        high = mid_right
print(f(round(high, 3)))


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

int main() {
    string S;
    cin>>S;
    string A="", B="";
    int Q;
    cin>>Q;
    int gyaku=0;
    int query, F;
    char C;
    for(int i=0;i<Q;++i){
        cin>>query;
        if(query==1){
            gyaku+=1;
            gyaku%=2;
        }
        else{
            cin>>F>>C;
            if(F==1){
                if(gyaku) B += C;
                else A+=C;
            }
            else {
                if(gyaku) A = A+C;
                else B=B+C;
            }
        }
    }
    if(gyaku){
        reverse(B.begin(), B.end());
        reverse(S.begin(), S.end());
        cout<<B+S+A<<endl;
    }
    else{
        reverse(A.begin(), A.end());
        cout<<A+S+B<<endl;
    }
}


Measured memory_bytes: 1480
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
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;}


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

int main(){
    int n;cin>>n;
    int a[n];rep(i,0,n-1)cin>>a[i];
    int ans=0;
    int pos=1;
    int count=1;
    while(pos<=n-1){
        if(a[pos]==a[pos-1]){
            count++;
        }else{
            ans+=count/2;
            count=1;
        }
        
        pos++;
    }
    ans+=count/2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include<stdlib.h>
#include<cmath>
#include<list>
#define ll long long int
#define lll unsigned long long
using namespace std;
ll a[100005]={0};
int main()
{ll x,m,n,s,k=0;
scanf("%lld%lld%lld",&m,&n,&s);
while(k<s)
{
    scanf("%lld",&x);
    a[x]++;
    k++;
}
k=1;x=0;
while(k<=m)
{
    if(s-a[k]>=n)
    {
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }
    k++;
}
return 0;
}


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

int main(void){
    ll N,K; cin >> N >> K;
    vector<ll> A(N);

    for(int i=0; i<N; i++) cin >> A[i];
    ll ans=pow(10,10);

    for(int i=0; i<N+1-K; i++){
        ll left=A[i], right=A[i+K-1];
        ll tmp;
        if(right<=0) tmp=abs(left);
        else if(left>=0) tmp=abs(right);
        else{
            tmp=2*min(abs(left),right)+max(abs(left),right);
        }

        ans=min(ans,tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int h,i;
  int ln;
  char c[256];
  string s;
  for(;;){
    fgets(c,256,stdin);
    s=c;
    ln=s.length();
    if(ln==2)
      break;
    for(i=0;i<ln;i++){
      if(s[i]!='('&&s[i]!=')'&&s[i]!='['&&s[i]!=']'){
	s.erase(i,1);
	ln--;
	i--;
      }
    }
    do{
      h=0;
      for(i=1;i<ln;i++){
	if(0){
	}else if(s[i-1]=='('&&s[i]==')'){
	  s.erase(i-1,2);
	  ln-=2;
	  h=1;
	  break;
	}else if(s[i-1]=='['&&s[i]==']'){
	  s.erase(i-1,2);
	  ln-=2;
	  h=1;
	  break;
	}
      }
    }while(h);
    if(ln)
      cout<<"no"<<endl;
    else
      cout<<"yes"<<endl;
  }
  return 0;
}

Measured memory_bytes: 884
#include<bits/stdc++.h>
    using namespace std;
    signed main(){
      cin.tie(NULL);
      ios::sync_with_stdio(false);
      char a[5],b[5];
      int sum=0;
      for(int i=0;i<3;i++) cin>>a[i];
      for(int i=0;i<3;i++){
        cin>>b[i];
        if(a[i]==b[i]) sum++;
      }
      cout<<sum<<'\n';
      return 0;
    }

Measured memory_bytes: 256
type Point = (Double,Double)
toStr :: Point -> String
toStr (x,y) = (show x) ++ " " ++ (show y)

add :: Point -> Point -> Point
add (x1,y1) (x2,y2) = (x1+x2, y1+y2)

smult :: Double -> Point -> Point
smult c (x,y) = (c*x,c*y)

divide :: Point -> Point -> Double -> Point
divide v w a = smult a v `add` smult (1-a) w

rotate :: Double -> Point -> Point
rotate theta (x,y) = (cos theta * x - sin theta * y, sin theta * x + cos theta * y)

tri :: Point -> Point -> Point
tri v w = v `add` rotate (pi/3) (w `add` (smult (-1) v))

calcKP :: Int -> [Point] -> [Point]
calcKP 0 xs = xs
calcKP _ [] = []
calcKP n xs = calcKP (n-1) (calcKPOne xs)

foldfunc :: [Point] -> (Point,Point) -> [Point]
foldfunc acc (left,right) = acc ++ [x, tri x z, z, right]
    where x = divide left right (2/3)
          z = divide left right (1/3)

calcKPOne :: [Point] -> [Point]
calcKPOne points = foldl foldfunc [head points] (zip points (tail points))

o = (0,0) :: Point
p = (100,0) :: Point

main = do
    n <- getLine >>= return . read
    let points = calcKP n [o,p]
    mapM_ (putStrLn . toStr) points


Measured memory_bytes: 5728