akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
using namespace std;

vector<int> G;
int cnt = 0;
int pow(int j, int k) {
	if (k == 0)
		return 1;
	else return j*pow(j, k - 1);
}
void insertionSort(int*p,int n,int g) {
	for (int i = g; i < n; i++) {
		int v = p[i];
		int j = i - g;
		while (j >= 0 && p[j] > v) {
			p[j + g] = p[j];
			j -= g;
			cnt=cnt+1;
		}
		p[j + g] = v;
	}
}

void shellSort(int*p, int n) {
	int h = 0;
	for (int i=0;;i++) {
		if (i % 2 == 0)
			h = 9 * pow(4, i / 2) - 9 * pow(2, i / 2) + 1;
		else if (i % 2 == 1)
			h = pow(2, i / 2 + 2)*(pow(2, i / 2 + 2) - 3) + 1;
		if (h > n) break;
		G.push_back(h);
		
	}
	
    for (int i= G.size()-1;i>=0;i--)
	{
		insertionSort(p, n, G[i]);
	}
}

int main()
{
	int n;
	int*seq;
	scanf("%d", &n);
	seq = new int[n];
	for (int i = 0; i < n; i++)
		scanf("%d", &seq[i]);


	shellSort(seq, n);
	printf("%d \n", G.size());
	for (int i = G.size()-1; i >= 0; i--) {
		printf("%d ", G[i]);
		if (i) printf(" ");
	}
	printf("\n%d\n", cnt);
	for (int i = 0; i < n; i++)
		printf("%d\n", seq[i]);



    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 4000005
using namespace std;
typedef long long ll;
ll n, a[30][30], dp[23][N];

ll f(ll i, ll bit){
	ll &r = dp[i][bit];
	if(r != -1)
		return r;
	if(i == n)
		return r = 1;
	// cout << i << " " << bit << endl;
	r = 0;
	for(ll j = 0; j < n; j++)
		if(a[i][j] and !(bit&(1<<j)))
			r = (r + f(i + 1, bit + (1<<j)))%mod;
	return r;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	memset(dp, -1, sizeof dp);
	scanf("%lld",&n);
	for(ll i = 0; i < n; i++)
		for(ll j = 0; j < n; j++)
			scanf("%lld",&a[i][j]);
	printf("%lld\n", f(0, 0));
	return 0;
}

Measured memory_bytes: 719104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
int dp[50][500][500];

void chmin(int &a, int b){if (a > b) a = b;}

int main(){
    int n, ma, mb; cin >> n >> ma >> mb;
    vector<int> a(n), b(n), c(n);
    rep(i,n) cin >> a[i] >> b[i] >> c[i];
    rep(i,50)rep(j,500)rep(k,500) dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    rep(i,n)rep(wa,500)rep(wb,500){
        if(dp[i][wa][wb]==INF) continue;
        chmin(dp[i+1][wa][wb], dp[i][wa][wb]);
        chmin(dp[i+1][wa+a[i]][wb+b[i]], dp[i][wa][wb] + c[i]);
    }
    int res = INF;
    for(int wa = 1; wa < 500; wa++){
        for(int wb = 1; wb < 500; wb++){
            if(wa*mb != wb*ma) continue;
            chmin(res, dp[n][wa][wb]);
        }
    }
    if(res < INF) cout << res << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 49152
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		char[] s = sc.next().toCharArray();
		long K = sc.nextLong();

		for (int i = 0; i < s.length; i++) {
			int n = (26 - (s[i] - 'a')) % 26;
			if (n > K)
				continue;
			s[i] = 'a';
			K -= n;
		}
		K %= 26;
		s[s.length - 1] = (char) (s[s.length - 1] + K);
		System.out.println(s);
	}

}

class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 10068
n,y = gets.strip.split.map(&:to_i)
I,J,K = -1,-1,-1

(0..n).each do |i|
  (0..n-i).each do |j|
    if i * 10000 + j * 5000 + (n-i-j) * 1000 == y
      I,J,K = i,j,n-i-j
    end
  end
end

puts "#{I} #{J} #{K}"

Measured memory_bytes: 1916
#include <iostream>
using namespace std;
int main(){
    while(1){
        int T,D,L;
        cin >> T >> D >> L;
        if(T==0 && D==0 && L==0){
            break;
        }

        int last=-D;
        int ans=0;
        for(int t=1; t<=T; t++){
            int x;
            cin >> x;

            if(t<=last+D){
                ans++;
            }

            if(x>=L){
                last=t;
            }
        }

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


Measured memory_bytes: 3088
#[allow(dead_code)]
fn main() {
    let s = i::s();
    let mut li = 0;
    let mut ri = s.len() - 1;
    let mut ans = 0;
    while li < ri {
        if s[li] == s[ri] {
            li += 1;
            ri -= 1;
            continue;
        }
        if s[li] == 'x' && s[ri] != 'x' {
            ans += 1;
            li += 1;
            continue;
        }
        if s[li] != 'x' && s[ri] == 'x' {
            ans += 1;
            ri -= 1;
            continue;
        }
        println!("{}", -1);
        return;
    }
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007

#+++++

def main():
	k = int(input())
	#b , c = tin()
	s = input()
	
	if k >= len(s):
		print(s)
		return 
	ret = s[:k]+'...'
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 62044
class Node():
    def __init__(self, parent, left, right):
        self.parent = parent
        self.left = left
        self.right = right

def Preorder_Tree_Walk(T, u):    
    if u == -1:
        return
    
    print(" " + str(u), end="")
    Preorder_Tree_Walk(T, T[u].left)
    Preorder_Tree_Walk(T, T[u].right)

def Inorder_Tree_Walk(T, u):   
    if u == -1:
        return

    Inorder_Tree_Walk(T, T[u].left)
    print(" " + str(u), end="")
    Inorder_Tree_Walk(T, T[u].right)

def Postorder_Tree_Walk(T, u):    
    if u == -1:
        return

    Postorder_Tree_Walk(T, T[u].left)
    Postorder_Tree_Walk(T, T[u].right)
    print(" " + str(u), end="")

def Main():

    n = int(input())
    T = [Node(-1, -1, -1) for i in range(n)]

    for i in range(n):
        node_id, left, right = map(int, input().split())

        T[node_id].left = left
        T[node_id].right = right

        if left != -1:
            T[left].parent = node_id
        if right != -1:
            T[right].parent = node_id

    r = 0
    for i in range(len(T)):
        if T[i].parent == -1:
            r = i
            
    print("Preorder")
    Preorder_Tree_Walk(T, r)
    print()
    print("Inorder")
    Inorder_Tree_Walk(T, r)
    print()
    print("Postorder")
    Postorder_Tree_Walk(T, r)
    print()

Main()


Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=100005;
struct edge{
	int to,next,f;
}e[N*10];
int head[N*2],tot=1;
int dis[N*2],q[N*2];
int n,S,T,sum;
int fa[N],mat[N],vis[N];
vector<int> vec[N],adj[N];
void add(int x,int y,int f){
	e[++tot]=(edge){y,head[x],f};
	head[x]=tot;
	e[++tot]=(edge){x,head[y],0};
	head[y]=tot;
}
bool bfs(){
	For(i,1,T) dis[i]=-1;
	int h=0,t=1;
	q[1]=S; dis[S]=0;
	while (h!=t){
		int x=q[++h];
		for (int i=head[x];i;i=e[i].next)
			if (dis[e[i].to]==-1&&e[i].f){
				dis[e[i].to]=dis[x]+1;
				q[++t]=e[i].to;
				if (e[i].to==T) return 1;
			}
	}
	return 0;
}
int dfs(int x,int flow){
	if (x==T) return flow;
	int k,rest=flow;
	for (int i=head[x];i;i=e[i].next)
		if (dis[e[i].to]==dis[x]+1&&e[i].f){
			k=dfs(e[i].to,min(rest,e[i].f));
			e[i].f-=k; e[i^1].f+=k; rest-=k;
		}
	if (rest) dis[x]=-1;
	return flow-rest;
}
void dfs(int x){
	vis[x]=1;
	for (auto i:vec[x])
		if (!vis[mat[i]]){
			fa[i]=x;
			dfs(mat[i]);
		}
}
int main(){
	scanf("%d",&n);
	S=2*n; T=2*n+1;
	For(i,1,n-1){
		int cnt;
		scanf("%d",&cnt);
		add(n+i,T,1);
		For(j,1,cnt){
			int x;
			scanf("%d",&x);
			add(x,n+i,1);
			vec[x].PB(i);
			//adj[i].PB(x);
		}
	}
	For(i,2,n)
		add(S,i,1);
	for (;bfs();sum+=dfs(S,1<<30));
	if (sum!=n-1)
		return puts("-1"),0;
	For(i,1,n-1)
		for (int j=head[n+i];j;j=e[j].next)
			if (e[j].f==1&&e[j].to<=n)
				mat[i]=e[j].to;
	dfs(1);
	For(i,1,n) if (!vis[i])
		return puts("-1"),0;
	For(i,1,n-1)
		printf("%d %d\n",fa[i],mat[i]);
}

Measured memory_bytes: 28800
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long 
#define rep(i, s, n) for(int i = s; i < n; i++) 

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

    vector<ll> a(n);
    rep(i, 0, n) {
        cin >> a[i];
    }

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

    vector<pair<ll, ll> > list;
    ll count = 1;
    ll tmp = -1;
    rep(i, 0, n-1) {
        if(a[i] == a[i+1]) {
            count++;
        }
        else {
            list.push_back(make_pair(a[i], count));
            count = 1;
        }

        tmp = a[i];
        //cout << a[i] << " ";
    }
    //cout << endl;

    if(a[n-1] == tmp) {
        //count++;
        list.push_back(make_pair(a[n-1], count));
    }
    else {
        list.push_back(make_pair(a[n-1], 1));
    }   

    ll ans = 0;
    rep(i, 0, list.size()) {
        //ans += abs(list[i].first-list[i].second);
        if(list[i].first < list[i].second) {
            ans += list[i].second-list[i].first;
        }
        else if(list[i].first > list[i].second) {
            ans += list[i].second;
        }
    }

    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }

int32_t dp[1 << 26];
    
int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  
  REP (i, 1 << 26) {
    dp[i] = 1e9;
  }
  dp[0] = 0;
  string s;
  cin>>s;
  int bil = 0;
  REP (i, SZ(s)) {
    int bit = s[i] - 'a';
    bil ^= (1 << bit);
    int32_t res = dp[bil] + 1;
    REP (j, 26) {
      mini(res, dp[bil ^ (1 << j)] + 1);
    }
    if (i == SZ(s) - 1) {
      cout<<res<<endl;
      return 0;
    }
    mini(dp[bil], (int32_t)res);
  }
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;
}


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

#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll power(ll a,ll b){ll ans=1;while(b>0){if(b&1){ans = (ans*a);}b>>=1;a=a*a;}return ans;}
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}

int main() {
   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   // cout << fixed << setprecision(10);
   ll n;
   cin>>n;
   string s;
   ll ac=0,wa=0,tle=0,re=0;
   for(ll i=0;i<n;i++){
       cin>>s;
       if(s=="AC"){
           ac++;
       }
       if(s=="WA"){
           wa++;
       }
       if(s=="TLE"){
           tle++;
       }
       if(s=="RE"){
           re++;
       }
   }
   cout<<"AC x "<<ac<<endl;
   cout<<"WA x "<<wa<<endl;
   cout<<"TLE x "<<tle<<endl;
   cout<<"RE x "<<re<<endl;
	return 0;
}


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

using namespace std;


int main() {
    int N,K; cin >> N >> K;
    string S; cin >> S;
    int count = 0;
    for(int i=1;i<N;i++) {
        if(S[i-1] == S[i]) count++;
    }
    cout << min(count + 2*K, N-1) << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define LL long long
#define RG register
#define il inline
#define N 400010
#define mod 924844033
using namespace std;
struct ed{int nxt,to;}e[N*2];
int head[N],tot,n,m,R[N*2],A[N*2],B[N*2],fac[N*2],_fac[N*2],sz[N];
void link(int u,int v){e[tot].nxt=head[u];e[tot].to=v;head[u]=tot++;}
void lnk(int u,int v){link(u,v),link(v,u);}
void dfs(int u,int faa){
  A[n]++;
  sz[u]=1;
  for(int i=head[u];i!=-1;i=e[i].nxt){
    int v=e[i].to;if(v==faa)continue;
    dfs(v,u);sz[u]+=sz[v];
    A[sz[v]]--;if(A[sz[v]]<0)A[sz[v]]+=mod;
  }
  A[n-sz[u]]--;if(A[n-sz[u]]<0)A[n-sz[u]]+=mod; 
}
int qp(int a,int b){
  if(!b)return 1;if(a==1)return a;
  int temp=qp(a,(b>>1));
  temp=1ll*temp*temp%mod;
  if(b&1)temp=1ll*temp*a%mod;
  return temp;
}
void NTT(int *a,int f){
  for(int i=0;i<n;++i)if(i<R[i])swap(a[i],a[R[i]]);
  for(int i=1;i<n;i<<=1){
    int gn=qp(5,(mod-1)/(i<<1));
    for(int j=0;j<n;j+=(i<<1)){
      int g=1;
      for(int k=0;k<i;++k,g=1ll*g*gn%mod){
    int x=a[j+k],y=1ll*g*a[j+k+i]%mod;
    a[j+k]=(x+y)%mod;
    a[j+k+i]=(x-y+mod)%mod;
      }
    }
  }
  if(f==-1){
    reverse(a+1,a+n);
    int _n=qp(n,mod-2);
    for(int i=0;i<n;++i)a[i]=1ll*a[i]*_n%mod;
  }
}
int main(){
  memset(head,-1,sizeof(head));
  scanf("%d",&n);for(int i=1;i<n;++i){int u,v;scanf("%d%d",&u,&v),lnk(u,v);}
  dfs(1,1);
  fac[1]=1;fac[0]=1;
  for(int i=2;i<=n;++i)fac[i]=1ll*fac[i-1]*i%mod,A[i]=1ll*A[i]*fac[i]%mod;
  _fac[n]=qp(fac[n],mod-2);for(int i=n;i;--i)_fac[i-1]=1ll*_fac[i]*i%mod;
  for(int i=1;i<=n;++i)B[i]=_fac[n-i];
  m=n;int L=0;
  for(n=1;n<=(m<<1);n<<=1)L++;
  for(int i=0;i<n;++i)R[i]=(R[i>>1]>>1)|((i&1)<<(L-1));
  NTT(A,1),NTT(B,1);
  for(int i=0;i<n;++i)A[i]=1ll*A[i]*B[i]%mod;
  NTT(A,-1);
  for(int i=1;i<=m;++i)printf("%d\n",1ll*A[m+i]*_fac[i]%mod);
  return 0;
}

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

using namespace std;

int main(){
  
  int N,M; cin >> N >> M;
  vector<vector<int>> to(N);
  
  for(int i = 0; i < M; i++){ 
    int a,b; cin >> a >> b; a--; b--;
    to[a].push_back(b); to[b].push_back(a);}
  
  bool flag = false;
  
    for(int i = 0; i < to[0].size(); i++){
      int b = to[0][i];
      for(int j = 0; j < to[b].size(); j++){
        if(to[b][j] == N - 1){ flag = true;}}}
  
  if(flag){ cout << "POSSIBLE" << endl;}
else{ cout << "IMPOSSIBLE" << endl;}
  return 0;}
          

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

class team{
	private:
		int teamID, penalty, accept;
		vector<int> wrong;
	public:
		team(int ID, int numpro):teamID(ID), penalty(0),accept(0), wrong(numpro, 0){}
		void correct(int pID, int time){
			accept++;	
			penalty+=1200*wrong[pID]+time;
		}
		void notCorrect(int pID){
			wrong[pID]++;
		}
		void print()const {
			cout << teamID << " " << accept << " " << penalty << endl;
		}
		bool operator<(const team & t)const{
			if(accept != t.accept) return accept < t.accept;
			if(penalty != t.penalty) return penalty > t.penalty;
			return teamID > t.teamID;
		}
};
int main(){
	int T,P,R;
	while((cin>>T>>P>>R)&&T!=0){
		vector<team> teams;
		for(int i=1;i<=T;i++){
			teams.push_back(team(i,P));
		}
		for(int i=1;i<=R;i++){
			int tid, pid, time;
			string message;
			cin>>tid>>pid>>time>>message;
			tid--;
			pid--;
			if(message == "CORRECT"){
				teams[tid].correct(pid,time);
			}
			else{
				teams[tid].notCorrect(pid);
			}
		}
		sort(teams.rbegin(), teams.rend());
		for(const team& t : teams) {
			t.print();
		}
	}
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
const int N=32e4;

int l[N],r[N];
int vl[N],vr[N];
int t[N];
int main(){
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>l[i]>>r[i];
		vl[i]=l[i], vr[i]=r[i];
		t[l[i]]++, t[r[i]]--;
	}
	int a1=0,a2=0;
	for(int i=1;i<N;i++){
		t[i]+=t[i-1];
		a2=max(a2,t[i]);
	}
	sort(vl,vl+n);
	sort(vr,vr+n);
	for(int i=0;i<n;i++){
		int u=n-(lower_bound(vl,vl+n,r[i])-vl),
			v=upper_bound(vr,vr+n,l[i])-vr;
		a1=max(a1,n-u-v);
	}
	cout<<a1<<' '<<a2<<'\n';
	return 0;
}


Measured memory_bytes: 7544
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
'''for i in range(n):
  x = l[i][1] - l[i][0]
  l[i][2] = x'''
l.sort(key=lambda x: x[1])
#print(l)

check = []
c = 0
for i in range(n):
  if c != l[i][1]:
    check.append(l[i][1])
    c = l[i][1]
#print(check)

sum_t = 0
limit = l[0][1]
ans = 0
for i in range(n):
  if limit != l[i][1]:
    limit = l[i][1]
  sum_t += l[i][0]
  if sum_t > limit:
    ans += 1
#print(ans)
if ans == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 53724
A,B = map(int, input().split())

# でかいブロック分だけ引いておく
A,B = A-1,B-1
ANS = []
def calc(X):
  if X>49:
    X -= 49
    wk = 49
  else:
    wk = X
    X = 0
  return X,wk

while A > 0:
  ANS.append("#"*100)
  A,wk = calc(A)
  ANS.append("#" + ".#" * wk + "##" * (49-wk) + "#")
  A,wk = calc(A)
  ANS.append("#" + "#." * wk + "##" * (49-wk) + "#")
ANS.append("#"*100)
while B > 0:
  ANS.append("."*100)
  B,wk = calc(B)
  ANS.append("." + ".#" * wk + ".." * (49-wk) + ".")
  B,wk = calc(B)
  ANS.append("." + "#." * wk + ".." * (49-wk) + ".")
ANS.append("."*100)

print(len(ANS), 100)
for a in ANS:
  print("".join(a))
  
"""
こう言うブロックを繰り返すと、３−４行で98分離成分が稼げる
100/2= 50行あれば、A、BのMAX500は稼げる。構築する
####################
#.#.#.#.#.#.#.#.#.##49
##.#.#.#.#.#.#.#.#.#49
####################
"""


Measured memory_bytes: 9248
/*
Main AC Solution
*/

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

const int MT = 300;
const ll MD = TEN(18);

mt19937 gen;
void reseed(ll seed) {
    gen = mt19937(seed);
    for (int i = 0; i < 10000; i++) {
        gen(); // skip
    }
}

ll rand_int(ll l, ll r) { //[l, r]
    using D = uniform_int_distribution<ll>;
    assert(l <= r);
    return D(l, r)(gen);
}

template<class T> void myshuffle(T &v) {
    shuffle(begin(v), end(v), gen);
}


ll min_c_for_yes(ll a, ll b, ll d) {
    //初期量, 購入量, 入荷しきい値, 入荷量
    assert(b <= a && b <= d);
    ll g = __gcd(b, d);
    return b - g + a % g; //在庫はここまで減りうる
}

bool answer(ll a, ll b, ll c, ll d) {
    //初期量, 購入量, 入荷しきい値, 入荷量
    if (a < b) return false;
    if (d < b) return false;
    if (b <= c) return true;
    ll g = __gcd(b, d);
    ll z = b - g + a % g; //在庫はここまで減りうる
    return z <= c;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

bool solve(ll a, ll b, ll c, ll d) {
    //初期量, 購入量, 入荷しきい値, 入荷量
    if (a < b) return false;
    if (d < b) return false;
    if (b <= c) return true;
    ll g = gcd(b, d);
    ll z = b - g + a % g; //在庫はここまで減りうる
    return z <= c;
}

int main() {
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        ll f = solve(a, b, c, d);
        if (f) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
   int n,k,i,a[10];

   scanf("%d",&k);
   if (k<10) {
      printf("%d\n",k);
      return 0;
   }
  
   for (i=2;i<10;i++) a[i]=0;
   a[1]=1;a[0]=0;n=1;
   for (k-=10;k>0;k--) {
      a[0]++;
      for (i=0;i<=n;i++)
         if (a[i]>9 || (i+1<=n && a[i]>(a[i+1]+1))) a[i+1]++;
         else break;
      if (i==n+1 && a[n]==10) {
         n++;
         a[n]=1;
      }
      for (i--;i>=0;i--)
         if (a[i+1]<=1) a[i]=0;
         else           a[i]=a[i+1]-1;
   }
   for (i=n;i>=0;i--) printf("%d",a[i]);
   puts("");
   return 0;
}


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

d = {}
ans = 0

for i in range(N):
    a = int(input())
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1

for v in d.values():
    if v % 2 == 1:
        ans += 1

print(ans)


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  st s, t;
  cin >> s >> t;
  vchar vs(s.size()), vt(t.size());
  rep(i , 0, s.size()) vs.at(i) = s.at(i);
  rep(i, 0, t.size()) vt.at(i) = t.at(i);
  sort(all(vs));
  sort(all(vt), greater<char>());
  st anss = "", anst = "";
  rep(i , 0, s.size()) anss += vs.at(i);
  rep(i, 0, t.size()) anst += vt.at(i);
  cout << (anss < anst ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N=int(input())
a=[*map(int,input().split())]
d=[[0]*21 for _ in[0]*~-N]
d[0][a[0]]=1
for i in range(1,N-1):
 for j in range(21):
  d[i][j]=(21>j+a[i]and d[i-1][j+a[i]])+(j>=a[i]and d[i-1][j-a[i]])
print(d[N-2][a[N-1]])


Measured memory_bytes: 5608
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

int main()
{
    std::string s;
    while (std::getline(std::cin, s)) {
        if (!s.empty()) {
            break;
        }
    }

    std::stringstream ss(s);

    int tmp[3];

    int cnt = 0;
    std::string buf;

    while (std::getline(ss, buf, ' ')) {
        tmp[cnt++] = ::atoi(buf.c_str());
    }

    int n = tmp[0];
    int a = tmp[1];
    int b = tmp[2];

    int result = 0;

    for (int i = 1; i <= n; i++) {
        int sum = 0;
        int x = i;
        for (int p = 0; p <= 4; p++) {
            sum += (x % 10);
            x /= 10;
        }
        if (a <= sum && sum <= b) {
            result += i;
        }
    }

    std::cout << result << std::endl;

    return 0;
}

Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

S = sys.stdin.buffer.readline().decode().rstrip()
N = len(S)


def test(S):
    s = S[:]
    while 'ST' in s:
        s = s.replace('ST', '')
        print(s)
    return len(s)


S = np.array(list(S), dtype='U1')
st = np.zeros(N, dtype=int)
st[S == 'S'] = 1
st[S == 'T'] = -1
print(min(st.cumsum()) * -2)


Measured memory_bytes: 17160
#include <stdio.h>
#include <math.h>


/*

????????¢?????¨?????¨

?????? r ???????????¢?????¨?????¨?????????????±???????????????°?????????????????????????????????

Input
1???????????° r ????????????????????????

Output
??¢?????¨?????¨????????????1??????????????§????????£???1??????????????????????????????????????????????°???°?????°??¨??????0.00001 ??\???????????????????????§?????????????????¨????????????

*/

int main( )
{
	double r, pi = M_PI;

	scanf( "%lf", &r );

	printf( "%lf %lf\n", r * r * pi, 2 * pi * r );

	return 0;
}

Measured memory_bytes: 648
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

if N % 2 == 1:

    memo = {key:0 for key in [i for i in range(2, N, 2)]}

    for a in A:
        try:
            memo[a] += 1
        except:
            memo[a] = 1

# print(memo)

    check_list = {}
    for i in range(2, N, 2):
        check_list[i] = False

    for check_num in check_list.keys():
        if check_num == 0:
            if memo[check_num] != 1:
                print(0)
                quit()
        if memo[check_num] != 2:
            print(0)
            quit()

else:
    memo = {key:0 for key in [i for i in range(1, N, 2)]}

    for a in A:
        try:
            memo[a] += 1
        except:
            memo[a] = 1

# print(memo)

    check_list = {}
    for i in range(1, N, 2):
        check_list[i] = False

    for check_num in check_list.keys():
        if memo[check_num] != 2:
            print(0)
            quit()

ans = pow(2, len(check_list))
ans %= mod
print(ans)


Measured memory_bytes: 19552
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a, b, c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], p[N], dp[N];
string str; bool h[N];
pll pp[N]; vll v;

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

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  cin >> n >> k >> q;
  for(int i = 1; i <= q; i++) {
    cin >> a;
    ar[a]++;
  }
  for(int i = 1; i <= n; i++) {
    if(-q + ar[i] + k > 0)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}

Measured memory_bytes: 4736
l,r = gets.chomp.split.map(&:to_i)
ans = 10**18
if r - l > 2019
	ans = 0
else
	(l..r).each do |i|
		(l..r).each do |j|
			next if i == j
			t = i*j % 2019
			ans = t if ans > t
		end
	end
end

puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <stack>
#include <vector>
using namespace std;

class Water {
public:
	int size;
	int position;
	Water(int _size, int _position) {
		size = _size;
		position = _position;
	}
	void fill(int addition) {
		size += addition;
	}
	void merge(Water* water) {
		if (water) {
			size += water->size;
			delete water;
		}
	}
};

// it returns false if no action is committed
bool mergeWaters(int position, vector<Water*>& waters) {
	Water* accum = NULL;
	Water* water;
	while (! waters.empty() && (water = waters.back())->position >= position) {
		waters.pop_back();
		water->merge(accum);
		accum = water;
	}
	if (accum) {
		waters.push_back(accum);
		return true;
	} else {
		return false;
	}
}

int main() {
	string pattern;
	vector<Water*> waters;
	stack<int> positions;
	int total = 0;
	
	cin >> pattern;
	
	for (int pos = 0, len = pattern.length(); pos < len; pos++) {
		switch (pattern[pos]) {
		case '\\':
			positions.push(pos);
			break;
		case '/':
			if (! positions.empty()) {
				int top = positions.top(); positions.pop();
				int addition = pos - top;
				if (mergeWaters(top, waters))
					waters.back()->fill(addition);
				else
					waters.push_back(new Water(addition, top));
				total += addition;
			}
			break;
		case '_':
			break;
		}
	}
	
	cout << total << endl;
	cout << waters.size();
	for (Water* water : waters) {
		cout << ' ' << water->size;
	}
	cout << endl;
}

Measured memory_bytes: 3272
#include <iostream>

using namespace std;


int n,x,ans,i,p;

int main()
{
    cin>>n;
    p=1;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        if(x==p)
            p++;
        else ans++;
    }
    if(ans==n)
        cout<<"-1\n";
    else cout<<ans<<"\n";
    return 0;
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  
  vector<pair<pair<int, int>, bool>> red(n);
  vector<pair<int, int>> blue(n);
  
  for(int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    red[i] = make_pair(make_pair(a, b), true);
  }
  
  for(int i = 0; i < n; i++){
    int c, d;
    cin >> c >> d;
    blue[i] = make_pair(c, d);
  }
  
  sort(blue.begin(), blue.end());
  
  long long count = 0;
  for(int i = 0; i < n; i++){
    priority_queue<pair<int, int>> q;
    for(int j = 0; j < n; j++){
      if(red[j].second && red[j].first.first < blue[i].first && red[j].first.second < blue[i].second){
        q.push(make_pair(red[j].first.second, j));
      }
    }
    if(!q.empty()){
      count++;
      red[q.top().second].second = false;
    }
  }
  
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10, mod=1e9+7;

int main ()
{
    FASTIO
    int n;
    cin >> n;
    map<int,int> Map;
    for(int i=1;i<=n;i++)Map[i]=0;
    for(int i=2;i<=n;i++){
        ll a;
        cin >> a;
        Map[a]++;
    }
    for(auto x:Map){
        cout << x.S << endl;
    }
    return 0;
}
/**

*/


Measured memory_bytes: 12968
#include<bits/stdc++.h>
using namespace std;
/*
如果是\，推入
如果是/，则造成积水
	如果sc里没有\了，没法积水了
	如果sc里有\，查看这个\距离多远，造成 底长度 l+1的积水，
		同时干掉一个\，距离+2 
其实不是距离，是位置
 	如果sc里有\，查看这个\的位置，计算距离，抛弃这个\ 
*/
struct point{
	int l,v;
	point(){;}
	point(int a,int b):l(a),v(b){;}
};
string s;
stack<int> sp;
stack<point>res;
vector<int> tt;
int main(){
//	freopen("a.txt","r",stdin);
	cin>>s;	
	int ans=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='\\'){
			sp.push(i);
		}else if(s[i]=='_'){
			;
		}else{
			if(sp.empty())continue;
			int p=sp.top();
			sp.pop();
			int d=i-p-1;
			ans+=d+1;
			int v=0;
			while(!res.empty()&&p<res.top().l){
				v+=res.top().v;
				res.pop();
			}
			v+=d+1;
			res.push(point(p,v));
		}
	}
	cout<<ans<<endl;
	while(!res.empty()){
		tt.push_back(res.top().v);res.pop();
	}
	cout<<tt.size();
	for(int i=tt.size()-1;i>=0;i--){
		cout<<' '<<tt[i];
	}cout<<endl;
	return 0;
}



Measured memory_bytes: 3272
import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys

sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


S = si()

digit = len(S)

head, remaining = S[0], S[1:]

ans = int(head) + 9 * (digit-1)
if remaining != '9' * (digit-1):
    ans -= 1

print(ans)



Measured memory_bytes: 5068
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main()
{
	char x, y;
	scanf("%c %c",&x, &y);
	if(x > y)
	{
		printf(">\n");
	}
	else if(x < y)
	{
		printf("<\n");
	}
	else
		printf("=\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

using namespace std;

const ll N = 3e5 + 5;

int n;
int a[N];
int dp[N];

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i = 1; i <= n; i++)
        cin>>a[i];
    dp[1] = 0;
    dp[2] = abs (a[1] - a[2]);
    for (int i = 3; i <= n; i++)
        dp[i] = min (dp[i - 2] + abs (a[i] - a[i - 2]), dp[i - 1] + abs (a[i] - a[i - 1]));
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <map>
using namespace std;

int N;
typedef pair<int,int> P;
int H[100005];

void mv(queue<P>& q, int n,int i,int c) {
  if( H[n-i] < 0 ) {
    H[n-i] = c+1;
    q.push( P(n-i,c+1) );
  }
}

int main() {
  cin >> N;
  queue<P> q;
  memset(H,-1,sizeof(H));
  q.push(P(N,0));
  while(!q.empty( )) {
    P p = q.front(); q.pop();
    int n = p.first;
    int c = p.second;

    mv(q, n, 1, c);
    for(int i=6;i<=n;i*=6)
      mv(q, n, i, c);
    for(int i=9;i<=n;i*=9)
      mv(q, n, i, c);
  }
  cout << H[0] << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopb(i,a,b) for(int i=a;i>=b;i--)
#define loopm(i,a,b,step) for(int i=a;i<b;i+=step)
#define loopbm(i,a,b,step) for(int i=a;i>=b;i-=step)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define INF 1000000007
#define MOD 1000000007
#define BINF 1000000000000000001
#define int long long int
#define double long double

using namespace std;

int dp[3][105];
int arr[3][105];

int go(int N,int M)
{
    if(N==1 and M==1)
     return arr[N][M];
    else if(N==0 or M==0)
     return 0;
    else if(dp[N][M]>0)
     return dp[N][M];
    else
    {
        dp[N][M]=max(go(N-1,M),go(N,M-1))+arr[N][M];
        return dp[N][M];
    }
}

#undef int
int main()
{
#define int long long int
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    loop(i,1,3)
    {
        loop(j,1,n+1)
         cin>>arr[i][j];
    }
    
    int ans=go(2,n);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int n;
string f[102];
void solve() {
    int left = 0, right = 0;
    // テヲツャツ。テ」ツ?ォテァツ崢ョテヲツ個?」ツ?凖ァツ環カテヲツ??1テ」ツ?ェテ」ツつ嘉、ツクツ甘ッツシツ?テ」ツ?ェテ」ツつ嘉、ツクツ?
    int next_status = 1;
    int ans = 0;
    rep(i, n) {
        if (f[i][0] == 'l') {
            if (left == 0 and f[i][1] == 'u') {
                left ^= 1;
            }
            if (left == 1 and f[i][1] == 'd') {
                left ^= 1;
            }
        } else {
            if (right == 0 and f[i][1] == 'u') {
                right ^= 1;
            }
            if (right == 1 and f[i][1] == 'd') {
                right ^= 1;
            }
        }
        if (left == right) {
            if (next_status == left) {
                ans++;
                next_status ^= 1;
            }
        }
    }
    cout << ans << endl;
}
int main() {
    while (cin >> n, n) {
        rep(i, n) cin >> f[i];
        solve();
    }
    return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T,V> &x){cerr<<'{';__print(x.first);cerr<<',';__print(x.second);cerr<<'}';}
template<typename T>
void __print(const T &x){int f=0;cerr<<'{';for(auto &i:x)cerr<<(f++ ? "," : ""),__print(i);cerr<<"}";}
void _print(){cerr<<"]\n";}
template<typename T,typename... V>
void _print(T t, V... v) {__print(t);if(sizeof...(v))cerr<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define sz(x) (int)x.size()                         					
#define all(x) x.begin(), x.end()           		
#define lb lower_bound                  	
#define ub upper_bound             		
                                   	
typedef long long ll;           		
typedef pair<int, int> pii;     	
typedef pair<ll, ll> pll;       	
typedef long double ld;
          						
template<typename T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;    
template<typename T> void print(T x){cerr<<x<<'\n';}
inline ll bip(ll x,ll n,ll mod){ll res=1;while(n){if(n&1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}                 		
																															 
const int maxn = 1e9;
const ll inf = 1e18;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const int N = 3e5 + 10;


void solve() {
	int n, k;
	cin >> n >> k;

	vector <int> a(n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i];

	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		ll pre = sum;
		sum += a[i];
		sum -= a[max(0, i - k)];
		if (i > k) {
			if (sum > pre) cout << "Yes\n";
			else cout << "No\n";
		}
	}
}   	            
 
int main() {
    SpeedForce;
    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
        cout << '\n';
    }
}    

Measured memory_bytes: 3972
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
string s,s1,s2;
int n;
bool p(string a)
{
	for(int i=0,j=a.size()-1;i++,j--;i<j)
		if(a[i]!=a[j])
			return 0;
	return 1;
}
int main(){
	cin>>s;
	n=s.size();
	if(!p(s))
	{
		cout<<"No";
		return 0;
	}
	for(int i=0;i<=(n-1)/2-1;i++)
		s1+=s[i];
	if(!p(s1))
	{
		cout<<"No";
		return 0;
	}
	for(int i=(n+3)/2-1;i<n;i++)
		s2+=s[i];
	if(!p(s2))
	{
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

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

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

   s[1] = (s[1] == 'B') ? 'R' : 'B';

   cout << s << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

const ll mod = 1000000000+7;

ll mod_pow(ll a, ll n, ll p){
    if(n == 0)  return 1;
    if(n%2 == 1)    return (a * mod_pow(a, n-1, p)) % p;
    ll t = mod_pow(a, n/2, p);
    return (t*t) % p;
}

ll fact[2000010];
ll invfact[2000010];

ll nCr(ll n, ll r){
    ll ret = fact[n];
    (ret *= invfact[n-r]) %= mod;
    (ret *= invfact[r]) %= mod;
    return ret;
}

int main(){
    ll r1,c1,r2,c2;    cin >> r1 >> c1 >> r2 >> c2;
    for(ll i = 0; i <= 2000009; i++){
        if(!i)  fact[i] = 1;
        else fact[i] = fact[i-1] * i;
        fact[i] %= mod;
        invfact[i] = mod_pow(fact[i], mod-2, mod);
    }
    ll ans = nCr(r2+c2+2, r2+1);
    ans = ans - nCr(r2+c1+1, c1) + mod;
    ans %= mod;
    ans = ans - nCr(r1+c2+1, r1) + mod;
    ans %= mod;
    ans += nCr(r1+c1, r1);
    ans %= mod;
    cout << ans << endl;
}


Measured memory_bytes: 31488
k, s = map(int, input().split())
c = 0

for x in range(k+1):
    for y in range(x, k+1):
        z = s-x-y
        if y <= z <= k:
            if x == y == z:
                c += 1
            elif x == y or y == z:
                c += 3
            else:
                c += 6

print(c)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    ll ans=0;
    rep(i,A+1){
        rep(j,B+1){
            rep(k,C+1){
                if(500*i+100*j+50*k==X){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;

int main() {
    ll A, B, C, K,sum = 0;
    cin >> A >> B >> C >> K;
    if(A <= K){
        sum += A;
        if(A + B <= K){
            sum -= K - (A + B);
        }
    } else {
        sum = K;
    }

    cout << sum << endl;
}

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



int main(){
    int a, b;
    cin >> a >> b;   
    int i = 1;
    while(true) {
        if(b == 1){
            i = 0;
            break;
        }
        if(a + (a-1) * (i-1) >= b) 
            break;        
        ++i;
    }
    cout << i;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int is7 =0;
        
        if(N/100 == 7){
            is7 = 1;
        }
        N=N-(N/100)*100;
        if(N/10 == 7){
            is7 =1;
        }
        N=N-(N/10)*10;
        if(N == 7){
            is7 = 1;
        }

        if(is7 == 1)
            System.out.print("Yes");
        else
            System.out.print("No");
        
    }
}

Measured memory_bytes: 35772