akhauriyash/Code-Regression huggingface dataset:
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
pii pos[100005];
int a[305][305];
vector<vi > vec(300005);
int main(){
	std::ios::sync_with_stdio(false);
	int h,w,i,j,l,r,d,q;
	ll prev,val;
	cin>>h>>w>>d;
	rep(i,h){
		rep(j,w){
			cin>>a[i][j];
			pos[a[i][j]].ff=i;
			pos[a[i][j]].ss=j;
		}
	}		
	cin>>q;
	f(i,1,d+1){
		j=i;
		prev=0;
		while(j<=h*w){
			if(j==i){
				val=prev;
			}
			else{
				val=prev+abs(pos[j-d].ff-pos[j].ff)+abs(pos[j-d].ss-pos[j].ss);
				prev=val;
			}
			vec[i%d+1].pb(val);
			// if(i==2){
			// 	cout<<val<<" "<<prev<<endl;
			// }
			j+=d;
		}
	}
	rep(i,q){
		cin>>l>>r;
		if(r%d==0)
			val=vec[l%d+1][r/d-1];
		else{
			val=vec[l%d+1][r/d];
		}
		if(l/d>0){
			if(l%d==0)
				val-=vec[l%d+1][l/d-1];
			else{
				val-=vec[l%d+1][l/d];
			}
		}
		cout<<val<<endl;
	}
} 
	

Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 1e5 + 10;
bitset<N> visited;
vector<int> graph[N];
vector<int> rgraph[N];
int dp[N];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
void update(int v) {
	for(int k : graph[v])
		dp[k] = max(dp[k], dp[v] + 1);
}
vector<int> tsort;
void dfs(int v) {
	visited.set(v);
	for(int i : graph[v]) 
		if(!visited.test(i))
			dfs(i);
	tsort.push_back(v);
}
void topsort() {
	reverse(tsort.begin(), tsort.end());
	for(int i : tsort)
		update(i);
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		int v1, v2;
		cin >> v1 >> v2;
		graph[v1].push_back(v2);
		rgraph[v2].push_back(v1);
	}
	for(int i = 1; i <= n; i++)
		if(rgraph[i].size() == 0)
			dfs(i);
			
	topsort();
	
	int ans = 0;
	for(int i = 1; i <= n; i++)
		ans = max(ans, dp[i]);
	cout << ans << "\n";
	return 0;
}

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

int main(){
string s;
cin >> s;
for(int i=0;i<s.size()-1;i++){
if(s[i]=='A' && s[i+1]=='C'){
cout<<"Yes"<<endl;
return 0;
}
}
cout << "No" << endl;
return 0;
}

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


void solve(long long N, long long K){
    cout << K * (int) pow((K-1), (N-1)) << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


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

 int main() {
 int n;
 string s;
 cin >> n >> s;
 int ans = 0;
 for(int i = 0; i <= n - 3; i++) {
 if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
   }
 cout << ans << endl;
 return 0;
 }

Measured memory_bytes: 3624
#include <stdio.h>

int main() {
	int a, b, ans = 0, temp, rev;
	scanf("%d %d", &a, &b);
	for (int i = a; i <= b; i++) {
		temp = i;
		rev = 0;
		while (temp) {
			rev = (10 * rev) + (temp % 10);
			temp /= 10;
		}
		if (rev == i)
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
from itertools import product
H, W = tuple(map(int, input().split()))

C = [tuple(map(int, input().split())) for _ in range(H)]
S = [[1]*W for _ in range(H)]
for h, w in product(range(H), range(W)):
    if C[h][w] == 1:
        S[h][w] = 0

for h, w in product(range(1, H), range(1, W)):
    if S[h][w]:
        S[h][w] = min(S[h-1][w-1], S[h-1][w], S[h][w-1]) + 1

result = 0
for sh in S:
    result = max(max(sh), result)

print(result**2)

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

using namespace std;

int main() {

	long n,k;

	cin >> n >> k;

	vector<double> p(n+1);

	p[0] = 0;
	for (long i = 1; i <= n; i++) {
		cin >> p[i];
		p[i] = (1 + p[i]) / 2;
	}

	vector<double> ki(n+1);
	ki[0] = p[0];
	for (long i = 1; i <= n; i++) {
		ki[i]=ki[i-1]+p[i];
	}

	double res = 0;
	double kii = 0;
	for (long i = k; i <= n; i++) {

		kii = ki[i] - ki[i - k];
		res = max(res,kii);
	}

	cout << setprecision(10) << res << endl;
	return 0;
}

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

int selectionSort(int* A,int N){
    int i,j,minj,tmp,count=0;
    for(i=0;i<N;i++){
        minj = i;
        for(j=i;j<N;j++){
            if(A[j]<A[minj]){
                minj = j;
            }
        }
        if(i!=minj){
            tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
            count++;
        }
    }
    return count;
}

int main(){
    int N,*A,i,cnt;
    cin >> N;
    A = new int[N];
    for(i=0;i<N;i++){
        cin >> A[i];
    }
    cnt = selectionSort(A,N);
    for(i=0;i<N;i++){
        if(i!=0){
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl << cnt << endl;
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define all(e) e.begin(), e.end()
#define vi vector<int>
#define vd vector<double>

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;

typedef long long ll;
typedef unsigned long long ull;

const int INF = ~(1 << 31);

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi v1(n);
    vi v2(n);
    rep(i, n) cin >> v1[i];
    rep(i, n) cin >> v2[i];

    int max = 0;
    int tmp;
    rep(i, n){
        tmp = 0;
        rep(j, n){
            if(j > i){
                tmp += v2[j];
            }else if(j == i){
                tmp += v2[i];
                tmp += v1[i];
            }else{
                tmp += v1[j];
            }
            //cerr << tmp << endl;
        }
        if(max < tmp){
            max = tmp;
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,l;
  ci(n>>l);
  vll A(n);
  ll pi=0;
  FOR(i,0,n){
    A[i]=i+l;
    pi+=A[i];
  }
  if(0<=l) co(pi-A[0])
    else if(l<=-n) co(pi-A[n-1])
      else co(pi)
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	vector<vector<int>> v(n, vector<int>(26, -1));
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j < 26; j++) {
			if (j + 'a' == s[i]) {
				v[i][j] = i;
			} else {
				if (i + 1 < n) v[i][j] = v[i + 1][j];
			}
		}
	}
	int res = 0;
	int m = t.size();
	int index = 0;
	for (int i = 0; i < m; i++) {
		if (index == 0 && v[index][t[i] - 'a'] == -1) {
			cout << -1 << endl;
			return 0;
		}

		if (index == 0) res++;
		if (v[index][t[i] - 'a'] == -1) {
			index = 0;
			res++;
			if (v[index][t[i] - 'a'] == -1) {
				cout << -1 << endl;
				return 0;
			}
		}
		index = v[index][t[i] - 'a'] + 1;
		if (i == m - 1) {
			cout << (long long int)(res - 1) * n + index << endl;
			return 0;
		}
		if (index >= n) index = 0;
	
	}
	cout << res << endl;
}


Measured memory_bytes: 16708
#include<iostream>
using namespace std;
string s;
long k;
main()
{
	cin>>s>>k;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='1')k--;
		else k=0;
		if(k==0)
		{
			cout<<s[i]<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,i,j;
    char s[100],t[100],x[201] = "0";
    scanf("%d %s %s",&n,s,t);
    for(i = 0 ; i < 2 * n ; i++)
    {
        if(i % 2 == 0)
        {
            x[i] = s[i / 2];
        }
        else
        {
            x[i] = t[(i - 1) / 2];
        }
        
    }
    printf("%s\n",x);
    return 0;
}

Measured memory_bytes: 1620
N = $stdin.gets.chomp.to_i

1.upto(3500) do |h|
  1.upto(3500) do |w|
    u = N * h * w
    d = 4 * h * w - N * w - N * h
    if d > 0 && u % d == 0
      puts "#{h} #{u / d} #{w}"
      exit
    end
  end
end


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define ll int 
int main() {
	// your code goes here
	ll i,j,k,n,m;
	string s;
	cin>>n;
	cin>>s;
	if(n>=3200) cout<<s<<"\n";
	else cout<<"red\n";
	return 0;
}


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

H, W = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
B = [list(map(int, input().split())) for i in range(H)]
D = [[0]*W for i in range(H)]
for i in range(H):
    for j in range(W):
        D[i][j] = abs(A[i][j]-B[i][j])
buf = 80*(H+W)
dp = [[0]*W for i in range(H)]
dp[0][0] = 1<<(buf+D[0][0]) | 1<<(buf-D[0][0])
for i in range(H):
    for j in range(W):
        d = D[i][j]
        if i:
            dp[i][j] |= dp[i-1][j]<<d | dp[i-1][j]>>d
        if j:
            dp[i][j] |= dp[i][j-1]<<d | dp[i][j-1]>>d
ans = 10**18
for i in range(buf*2+1):
    if dp[H-1][W-1]&(1<<i):
        ans = min(ans, abs(buf-i))
print(ans)


Measured memory_bytes: 20340
N = int(input())
for n in range(1,3501):
  for w in range(n,3501):
    if (4*n*w-w*N-n*N) > 0:
      h = n*w*N/(4*n*w-w*N-n*N)
      if h == int(h) and h > 0:
        print(int(h),n,w)
        exit()

Measured memory_bytes: 3060
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N = int(readline())
  V = np.array(readline().split(), np.int64)
  C = np.array(readline().split(), np.int64)
  D = V-C
  E = np.where(D<0,0,D)
  print(E.sum())
  
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 12488
//#define _LIBCPP_DEBUG 0
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define acc(v) accumulate(v.begin(), v.end(),0);
#define MOD 1e+7
#define inf 1e9
#define fi first
#define se second
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s = "", t = "", per = "";

  rep(i,n) {
    char c;
    cin >> c;
    s.push_back(c);
  }

  rep(i,n) {
    char c;
    cin >> c;
    t.push_back(c);
  }

  reps(i,1,n+1) per.push_back((char)(i+48));

  int cnt = 0, resp, resq;

  do {
    cnt++;
    if(s == per) resp = cnt;
    if(t == per) resq = cnt;
  } while(next_permutation(per.begin(), per.end()));

  cout << abs(resp - resq) << endl;
  return 0;
}
//templete by private_yusuke

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

public class Main {
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve() {
		Scanner sc=new Scanner(System.in);
		int[] val=new int[4];
		double[] q=new double[4]; 
		for(int i=0;i<4;i++) {
			val[i]=sc.nextInt();
		}
		q[0]=0.25;
		q[1]=0.5;
		q[2]=1;
		q[3]=2;
		
		double n=sc.nextDouble();
		double[] valp=new double[4];
		valp[0]=val[0]*4;
		valp[1]=val[1]*2;
		valp[2]=val[2];
		valp[3]=val[3]/2;
		int[] id=new int[4];
		for(int i=0;i<4;i++) {
			id[i]=i;
		}
		for(int j=0;j<4;j++) {
			for(int i=0;i<4-1;i++) {
				if(valp[i]>valp[i+1]) {
					double temp=valp[i];
					valp[i]=valp[i+1];
					valp[i+1]=temp;
					
					int tempid=id[i];
					id[i]=id[i+1];
					id[i+1]=tempid;
				}
			}
		}

		long ans=0;
		for(int i=0;i<4;i++) {
			if(n>0) {
				ans+=(long)(n/q[id[i]])*val[id[i]];
				n=n%q[id[i]];
			}
		}
		System.out.println(ans);
	}
}


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

#define ll long long
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define int long long
#define INF 1e9
#define pii pair<int, int>
#define pt(xx) cout << "\n" \
                    << xx << "\n"
#define debugv(x, n)               \
    cout << "\n"                   \
         << #x << ": ";            \
    rep(i, n) cout << x[i] << " "; \
    cout << endl
#define debug2d(x, m, n)            \
    cout << "\n"                    \
         << #x << " is: \n";        \
    for (int i = 0; i < m; ++i)     \
    {                               \
        for (int j = 0; j < n; ++j) \
        {                           \
            cout << x[i][j] << " "; \
        }                           \
        cout << endl;               \
    }
#define nl cout << endl

#define MOD 1000000007

int N, K;
int ans;

int A[100001];
// 10^12 < (2^10)^4
int dp[43][2] = {}; // dp[上からi桁][smaller(flag)];
const int maxd = 41;


signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //==============================================
    string s;
    cin>>s;

    bool bbb = false;
    rep(i,3){if (s[i] == s[i+1]) bbb = true;}

    if (bbb)
        cout<<"Bad"<<endl;
    else cout<< "Good" << endl;
    

    return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a < b)
  {
    REP(i, b)
    {
      cout << a;
    }
  }
  else
  {
    REP(i, a)
    {
      cout << b;
    }
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t A, B, K;
  cin >> A >> B >> K;
  
  int64_t TAK,AOK;//Takahashi, Aoki
  
  if(K<=A){
    TAK = A-K;
    AOK = B;
  }else if(A< K && K<= A+B){
    TAK = 0;
    AOK = B-(K-A);
  }else {
    TAK = 0;
    AOK = 0;
  }
  
  cout << TAK << " " << AOK << endl;
  
}

Measured memory_bytes: 3552
#include <stdio.h>
#define N 44

int main(){
  int n,i;
  int fib[N+1];

  scanf("%d",&n);

  fib[0] = fib[1] = 1;

  for(i=2 ; i<=n ; i++){
    fib[i] = fib[i-2] + fib[i-1];
  }

  printf("%d\n",fib[n]);

  return 0;
}



Measured memory_bytes: 2056
Q = 10**9 + 7
def getInv(N):#Qはmod
    inv = [0] * (N + 1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q%i]) % Q
    return inv
modfunctional = [1]*(10**5+2)
modinv = getInv(10**5+2)
modinvfunctional = [1]*(10**5+2)
for i in range(10**5+1):
    modinvfunctional[i+1] = (modinvfunctional[i]*modinv[i+1])%Q
for i in range(10**5+1):
    modfunctional[i+1] = (modfunctional[i]*(i+1))%Q

n = int( input())
A = list( map( int, input().split()))
V = [0 for _ in range(n+1)]
for i in range(n+1):
    if V[A[i]] == 1:
        b = A[i]
        break
    V[A[i]] = 1
b_1 = -1
for i in range(n+1):
    if A[i] == b:
        if b_1 == -1:
            b_1 = i
        else:
            b_2 = i
            break
d = b_1 + n - b_2
for k in range(1, n+2):
    if k-1 > d:
        print(((modfunctional[n+1]*modinvfunctional[k])*modinvfunctional[n+1-k])%Q)
    else:
        print( (modfunctional[n+1]*modinvfunctional[k]%Q*modinvfunctional[n+1-k]%Q - modfunctional[d]*modinvfunctional[k-1]%Q*modinvfunctional[d-k+1]%Q)%Q)


Measured memory_bytes: 60780
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String b = sc.next();
		
		Map<String, String> map = new HashMap<String, String>();
		
		map.put("A", "T");
		map.put("T", "A");
		map.put("G", "C");
		map.put("C", "G");
		
		System.out.println(map.get(b));
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,m,c;
  cin >> n >> m >> c;
  vec b(m);
  for(ll i=0;i<m;i++) cin >> b[i];
  mat a(n,vec(b));
  for(ll i=0;i<n;i++) for(ll j=0;j<m;j++) cin >> a[i][j];
  ll ans=0;
  for(ll i=0;i<n;i++) {
    ll tmp=c;
    for(ll j=0;j<m;j++) {
      tmp+=a[i][j]*b[j];
    }
    ans+=(tmp>0);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
ll n,x,d;
ll ans=0,f[N],sum[N];
int main()
{
    scanf("%lld%lld%lld",&n,&x,&d);
    if(x==0&&d==0)
    {
        cout<<1<<endl;return 0;
    }
    if(x<0&&d<0)
        x*=-1,d*=-1;
    for(int i=1;i<=n;i++)
        sum[i]=sum[i-1]+i-1;
    ll k=__gcd(x,d),xx=x/k,dd=d/k;
    if(xx>=0&&dd>=0)
    {
        for(int i=0;i<=n;i++)
        {
            ll l=sum[i],r=sum[n]-sum[n-i];
            if(l>r) swap(l,r);
            ans+=r-l+1;
            if(i+dd<=n)
            {
                l=max(l,sum[i+dd]+xx);
                ans-=max(0ll,r-l+1);
            }
        }
    }
    else
    {
        if(xx<0) xx*=-1;
        if(dd<0) dd*=-1;
        for(int i=0;i<=n;i++)
        {
            ll l=sum[i],r=sum[n]-sum[n-i];
            if(l>r) swap(l,r);
            ans+=r-l+1;
            if(i+dd<=n)
            {
                r=min(r,sum[n]-sum[n-i-dd]-xx);
                l=max(l,sum[i+dd]-xx);
                ans-=max(0ll,r-l+1);
            }
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1792
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0）
        self.rank = [0] * (n + 1)

    # 探索
    # 根ならその場号を返す
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            # 走査していく過程で親を書き換えていく（パス圧縮）
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)


n, q = map(int, input().split())

uf = UnionFind(n)
for i in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        uf.union(x, y)
    if com == 1:
        if uf.same(x, y):
            print(1)
        else:
            print(0)


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

int main(){
    int n; cin >> n;
    int l, r;
    int sum=0;
    rep(i, n){
        cin >> l >> r;
        sum += r-l+1;
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 5;

ll mod_pow(ll k, ll p)
{
    if (k == 0)
    {
        return 1 % p;
    }
    if (k == 1)
    {
        return 2 % p;
    }

    if (k % 2 == 0)
    {
        ll tmp = mod_pow(k / 2, p);
        return tmp * tmp % p;
    }
    else
    {
        ll tmp = mod_pow((k - 1) / 2, p);
        tmp *= tmp;
        tmp %= p;
        tmp *= 2;
        tmp %= p;
        return tmp;
    }
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2) % MOD;
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, (k - 1) / 2);
        return tmp * tmp * 2;
    }
}

int main()
{
    vector<ll> memo(1e6 + 1, 0);
    for (ll i = 1; i <= 1e6; i++)
    {
        bitset<64> bits(i);
        memo[i] += memo[i % bits.count()] + 1;
    }

    ll N;
    cin >> N;
    string S;
    cin >> S;
    vector<ll> X(N);
    ll popcount = 0;
    for (size_t i = 0; i < N; i++)
    {
        X[i] = S[i] - '0';
        if (X[i] == 1)
        {
            popcount += 1;
        }
    }

    vector<ll> UP(N, 0);
    vector<ll> DOWN(N, 0);

    for (ll i = 0; i < N; i++)
    {
        if (i == 0)
        {
            UP[i] = 1 % (popcount + 1);
            continue;
        }
        UP[i] = UP[i - 1] * 2 % (popcount + 1);
    }
    for (ll i = 0; i < N; i++)
    {
        if (popcount - 1 == 0) {
            break;
        }
        if (i == 0)
        {
            DOWN[i] = 1 % (popcount - 1);
            continue;
        }
        DOWN[i] = DOWN[i - 1] * 2 % (popcount - 1);
    }

    ll up = 0;
    ll down = 0;
    for (ll i = 0; i < N; i++)
    {
        if (X[i] == 0)
        {
            continue;
        }
        up += UP[N - 1 - i];
        up %= (popcount + 1);
    }
    for (ll i = 0; i < N; i++)
    {
        if (popcount - 1 == 0) {
            break;
        }
        if (X[i] == 0)
        {
            continue;
        }
        down += DOWN[N - 1 - i];
        down %= (popcount - 1);
    }

    ll cnt = 0;
    for (ll i = 0; i < N; i++)
    {
        if (X[i] == 1)
        {
            ll f = popcount - 1;
            if (f == 0) {
                cout << 0 << endl;
                continue;
            }

            ll n = (down - DOWN[N - 1 - i] + f) % f;
            cout << (memo[n] + 1) << endl;
        }
        else
        {
            ll f = popcount + 1;
            ll n = (up + UP[N - 1 - i] + f) % f;

            cout << (memo[n] + 1) << endl;
        }
    }
}

Measured memory_bytes: 16144
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const ll mod=1e9+7;
const int INF=1<<30;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

map<ll,ll> pfmp; //各素因数の指数を格納
vector<ll> pfv(0); //異なる素因数を昇順に格納

void PF(ll N){
  ll n=N;
  if(n<=1) return;
  ll exp;
  if(n%2==0){
    if(pfmp[2]==0) pfv.push_back(2);
    exp=0;
    while(n%2==0){
      n/=2;
      exp++;
    }
    if(exp>pfmp[2]) pfmp[2]=exp;
  }
  for(ll i=3;i<=sqrt(N);i+=2){
    if(n%i==0){
      if(pfmp[i]==0) pfv.push_back(i);
      exp=0;
      while(n%i==0){
        n/=i;
        exp++;
      }
      if(exp>pfmp[i]) pfmp[i]=exp;
    }
  }
  if(n!=1){
    if(pfmp[n]==0){
      pfv.push_back(n);
      pfmp[n]=1;
    }
  } 
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
  ll N; cin >> N;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  rep(i,N){
    PF(a[i]);
  }
  mint LCM=1;
  rep(i,pfv.size()){
    rep(j,pfmp[pfv[i]]){
      LCM*=pfv[i];
    }
  }
  //cout << "LCM:" << LCM << endl;
  mint ans=0;
  rep(i,N){
    ans+=LCM/a[i];
  }
  /*
  for(auto c:pfv){
    cout << c << " " << pfmp[c] << endl;
  }
  */
  cout << ans.x << endl;
}

Measured memory_bytes: 1024
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
ll ans = 100000000000;
ll n,k;
void calc(ll i,ll v){
  if(i==n){
    ans = min(ans,v);
    return;
  }
  i++;
  calc(i,v*2);
  calc(i,v+k);
}
signed main(){
  cin >> n >> k;
  calc(0,1);
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);

			int x = sc.nextInt();
			
			while(!prime(x)) {
				x++;
			}
			System.out.println(x);
			
			
		}
		
		static boolean prime(int x) {
			for(int i=2;i<x;i++) {
				if(x%i==0) {
					return false;
				}
			}
			return true;
		}
		
	}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

#define x(p) real(p)
#define y(p) imag(p)

const double eps=1e-10;
const double inf=1e12;
typedef complex<double> P;

namespace std{
  bool operator<(const P& a,const P& b){
    return x(a)==x(b)?y(a)<y(b):x(a)<x(b);
  }
}
double cross(const P& a,const P& b){
  return y(conj(a)*b);
}
double dot(const P& a,const P& b){
  return x(conj(a)*b);
}
struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};

P projection(const L& l,const P& p){
  //double t=dot(p-l[0],l[0]-l[1])/norm(l[0]-l[1]);
  P b=l[1]-l[0],c=p-l[0];
  return l[0]+b*x(c/b);
}

int main(){
	cin.sync_with_stdio(false);
  int q;
  double x1,x2,x3,y1,y2,y3;
  cin>>x1>>y1>>x2>>y2;
  cin>>q;
  rep(i,q){
    cin>>x3>>y3;
    P res=projection(L(P(x1,y1),P(x2,y2)),P(x3,y3));
    printf("%.10f %.10f\n", x(res),y(res));
  }
	return 0;
}

Measured memory_bytes: 3312
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n,m;
int main(){
    cin >> n >> m;
    vector<pair<ll,ll>> v;
    rep(i,n){
        ll a;
        int b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(),v.end());
   //rep(i,n) cout<<v[i].first<<" "<<v[i].second<<endl;
    ll now =0;
    ll ans = 0;
    ll i = 0;
    while(1){
        if(now+v[i].second>=m){
            ans += v[i].first*(m-now);
            cout<<ans<<endl;
            return 0;
        }
        ans += v[i].first*v[i].second;
        now += v[i].second;
        //cout<<ans<<endl;
        i++;
    }
    
    return 0;
}

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

int main() {
  int N, t, x, y, i, j, T = 0, X = 0, Y = 0;
  cin >> N;
  string s = "Yes";
  for (i = 0; i < N; i++) {
    cin >> t >> x >> y;
    T = t - T, X = abs(x - X), Y = abs(y - Y);
    if (X + Y > T || (t + x + y) % 2 != 0) {
      s = "No";
      break;
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size() 配列名.Length()
using namespace std;
typedef unsigned long long ll;

int main(void){
	int n;
	cin >> n;
	string s;
	int cnt = 0;

	for(int i = 1; i <= n; i++){
		s = to_string(i);
		if(s.size() % 2 == 1) cnt++;
	}
	cout << cnt;
}


Measured memory_bytes: 256
//////////////      VATSAL AGARWAL       ////////////////////////
////////////// Codeforces id : warhead38 ////////////////////////
////////////// Codechef   id : vatsal38  //////////////////////// 


#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;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define endl '\n'
#define loop(var,a,b,c) for(ll var=a;var<=b;var+=c)
#define intarr(arr,n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i]
#define inparr(arr,n) for(ll i=0;i<n;i++)cin>>arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define newline cout<<endl
#define ump unordered_map<ll,ll>
#define vec vector<ll>
#define mkp make_pair
#define disp(var1,var2) cout<<var1<<" "<<var2<<endl;
#define all(v)             v.begin(),v.end()
#define cout(var) cout<<var<<endl
#define mod2 998244353
#define fbo find_by_order  /// find kth smallest by passing k-1
#define ook order_of_key  //// find no of smaller items less than k
#define teensort(a,r,g,b) a[0]=r;a[1]=g;a[2]=b;sort(a,a+3);
#define ss second
#define ff first
#define displayarray(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
#define pi pair<ll,ll>
#define meramax 1e18
#define meramin -1e18
#define percentile 1000000007
#define PI 3.14159265358979323846
#define input2darr(n,m,in) ll a[n+1][m+1];if(in==0){loop(i,0,n-1,1)loop(j,0,m-1,1)cin>>a[i][j];}else{loop(i,1,n,1)loop(j,1,m,1)cin>>a[i][j];}
#define minheap priority_queue<ll>
#define maxheap priority_queue<ll,vector<ll>,greater<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
////////////////////////////////////////              CODE                   ///////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
void AcDegaYe()
{
    ll x,y;
    cin>>x>>y;
    if(y&1)
    {
        cout("No");
        return;
    }
    else
    {
        if(4*x<y || 2*x>y)
        {
            cout("No");
            return;
        }
    }
    cout("Yes");
    
}
int main()
{   
    fastio
    //ll t;
    //cin>>t;
    ll t=1;
    while(t--)
    {
        AcDegaYe();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <string.h>
int main(void){
    int n;
    scanf("%d", &n);
    int cnt=0;
    for(int i=0; i<n; i++){
        int d1, d2;
        scanf("%d %d", &d1, &d2);
        if(d1==d2){
            cnt++;
            if(cnt>=3){
                printf("Yes\n");
                return 0;
            }
        }else cnt=0;
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 1648
import java.util.ArrayDeque;
import java.util.Scanner;
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        ArrayDeque<Integer> a = new ArrayDeque<>();
 
        int n = sc.nextInt();
        for(int i = 0; i < n; i++){
            String s = sc.next();
            switch(s){
                case "insert":
                    a.push(sc.nextInt());
                    break;
                case "delete":
                    a.remove(sc.nextInt());
                    break;
                case "deleteFirst":
                    a.removeFirst();
                    break;
                case "deleteLast":
                    a.removeLast();
                    break;
            }
        }
        StringBuilder sb = new StringBuilder();
        sb.append(a.poll());
        for(int i : a){
            sb.append(" ").append(i);
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 487020
stdin.ReadLine()
|> int
|> fun n ->
  (
    n |> float,
    [1..n] |> List.map (fun _ -> stdin.ReadLine() |> fun x -> x.Split(' ') |> Array.map float |> fun x -> (x.[0], x.[1]))
  )
|> fun (n, ps) ->
  ps
  |> List.fold (
    fun (ps, ds) (x1, y1) ->
      match ps with
      | [] -> ([], ds)
      | _ ->
        (
          ps |> List.tail,
          ds @ (ps |> List.map (fun (x2, y2) -> ((x2 - x1) ** 2. + (y2 - y1) ** 2.) |> sqrt))
        )
  ) (ps |> List.tail, [])
  |> fun (_, ds) -> ds |> List.average
  |> fun avg -> avg * (n - 1.)
|> printfn "%A"


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

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

using ll = long long;
#define INF 1e9

int N, M;
vector<int> a, b;

int main(){
  int n, m;
  cin >> n >> m;
  cout << (n-1) * (m-1) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		if (n >= m) {
		    System.out.println(0);
		    return;
		}
		int[] arr = new int[m];
		for (int i = 0; i < m; i++) {
		    arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		int total = arr[m - 1] - arr[0];
		int[] dis = new int[m - 1];
		for (int i = 0; i < m - 1; i++) {
		    dis[i] = arr[i + 1] - arr[i];
		}
		Arrays.sort(dis);
		int save = 0;
		for (int i = 1; i < n; i++) {
		    save += dis[m - 1 - i];
		}
		System.out.println(total - save);
	}
}


Measured memory_bytes: 47420
fn main() {
  let (_, a, b): (usize, i64, i64) = read_tuple();
  let vec: Vec<i64> = read_vec();
  
  let ans: i64 = vec.iter().fold((0,vec[0]), |(acc,p),&x| (acc + std::cmp::min((x-p)*a, b), x)).0;
  println!("{}", ans);
}

fn read_tuple<T1: std::str::FromStr, T2: std::str::FromStr, T3: std::str::FromStr>() -> (T1, T2, T3) {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  let mut it = buf.trim().split_whitespace();
  let x = it.next().unwrap().parse::<T1>().ok().unwrap();
  let y = it.next().unwrap().parse::<T2>().ok().unwrap();
  let z = it.next().unwrap().parse::<T3>().ok().unwrap();
  (x, y, z)
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
}

Measured memory_bytes: 6396
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, C, D = map(int, readline().split())

    lower = max(A, C)
    upper = min(B, D)
    ans = max(upper - lower, 0)

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

class QInfo {
public:
	int x;
	int y;
	int dir;
	int cost;

	QInfo(int x, int y, int dir, int cost) {
		this->x = x;
		this->y = y;
		this->dir = dir;
		this->cost = cost;
	}

	bool operator < (const QInfo &a) const {
		return cost > a.cost;
	}
};

int w, h;

bool inBoard(int y, int x) {
	return x >= 0 && x < w && y >= 0 && y < h;
}

int nextDir(int now, int op) {
	if (op == 1) {
		now--;
		if (now < 0) now += 4;
	} else if (op == 2) {
		now -= 2;
		if (now < 0) now += 4;
	} else if (op == 3) {
		now++;
		if (now > 3) now -= 4;
	}
	return now;
}

signed main() {
	while (true) {
		cin >> w >> h;

		if (w == 0) break;

		vector<string> board;
		rep(y, h) {
			string tmp = "";
			rep(x, w) {
				tmp += nextChar();
			}
			board.push_back(tmp);
		}

		int c[4];
		cin >> c[0] >> c[1] >> c[2] >> c[3];

		bool visit[30][30][4];
		bool pushed[30][30][4];
		int cost[30][30][4];
		memset(visit, false, sizeof(visit));
		memset(pushed, false, sizeof(pushed));
		rep(y, h) {
			rep(x, w) {
				rep(dir, 4) {
					cost[y][x][dir] = INT_MAX;
				}
			}
		}

		priority_queue<QInfo> q;
		q.push(QInfo(0, 0, 0, 0));
		cost[0][0][0] = 0;
		while (!q.empty()) {
			QInfo nowInfo = q.top(); q.pop();
			int nowX = nowInfo.x;
			int nowY = nowInfo.y;
			int nowDir = nowInfo.dir;
			int nowCost = nowInfo.cost;

			if (nowCost > cost[nowY][nowX][nowDir]) continue;

			rep(i, 4) {
				int ndir = nextDir(nowDir, i);
				int nx = nowX + dx[ndir];
				int ny = nowY + dy[ndir];
				int ncost = ((i == board[nowY][nowX] - '0') ? 0 : c[i]);
				if (!inBoard(ny, nx)) continue;
				if (nowCost + ncost >= cost[ny][nx][ndir]) continue;

				cost[ny][nx][ndir] = nowCost + ncost;
				q.push(QInfo(nx, ny, ndir, cost[ny][nx][ndir]));
			}
		}

		int ret = INT_MAX;
		rep(i, 4) {
			ret = min(ret, cost[h - 1][w - 1][i]);
		}
		cout << ret << endl;
	}

    return 0;
}

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

#define pb         push_back

const int INF = 1000000000;
const int MOD = 1000000007;

typedef struct _team{
	int tid;
	int solve;
	int wr[100] = {};
	int pen;
}Team;

bool CmpSolve(const Team& a, const Team& b){
	return (a.solve == b.solve) ? (a.pen == b.pen ? a.tid < b.tid : a.pen < b.pen) : a.solve > b.solve ;
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);

	while(1){
		int t, p, r;
		cin >> t >> p >> r;
		if(t == 0 && p == 0 && r == 0) break;

		vector<Team> teams;

		for(int i=1; i<=t; i++){
			Team tmp;
			tmp.tid = i;
			tmp.solve = 0;
			tmp.pen = 0;
			teams.push_back(tmp);
		}

		for(int i=0; i<r; i++){
			int tid, pid, time;
			string mes;
			cin >> tid >> pid >> time >> mes;
			tid--;

			if(mes == "WRONG"){
				teams[tid].wr[pid]++;
			}else if(mes == "CORRECT"){
				teams[tid].solve++;
				teams[tid].pen += teams[tid].wr[pid]*1200 + time;
			}
		}

		sort(teams.begin(), teams.end(), CmpSolve);

		for(int i=0; i<t; i++){
			printf("%d %d %d\n", teams[i].tid, teams[i].solve, teams[i].pen);
		}

	}
	

	return 0;
}

Measured memory_bytes: 3392
h,w=map(int,input().split())
S=[["."]*(w+2)]+[["."]+list(input())+["."] for _ in range(h)]+[["."]*(w+2)]
ans=[[0 for i in range(w)] for j in range(h)]
for i in range(1,h+1):
  for j in range(1,w+1):
    if S[i][j]=="#":
      ans[i-1][j-1]="#"
    else:
      count=(S[i-1][j-1]=="#")+(S[i-1][j]=="#")+(S[i-1][j+1]=="#")+(S[i][j-1]=="#")+(S[i][j+1]=="#")+(S[i+1][j-1]=="#")+(S[i+1][j]=="#")+(S[i+1][j+1]=="#")
      ans[i-1][j-1]=count
for i in range(h):
  print(*ans[i],sep="")

Measured memory_bytes: 3444
S = input().strip()
A = [0 for _ in range(len(S))]
cnt = 0
for i in range(len(S)):
    if S[i]=="B":
        cnt += 1
    A[i] = cnt
cntW = 0
for i in range(len(S)):
    if S[i]=="W":
        cntW += A[i]
print(cntW)

Measured memory_bytes: 11368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 10000000;
typedef pair<int,int> P;
typedef long long ll;
/*
*/

int main() {
  string S,T;
  cin >> S >> T;
  int A,B;
  cin >> A >> B;
  string U;
  cin >> U;
  if(U == S) A--;
  else B--;

  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int compare(int C1[2], int C2[2])
{
    if (C1[0] < C2[0]) return 1;
    else if (C1[0] == C2[0]) {
        if (C1[1] < C2[1]) return 1;
    }
    return 0;
}

void insertionSort(int A[][2], int n, int g)
{
    int i;
    int C[2];
    for (i = g; i < n; i++) {
        int x, y, j;
        C[0] = A[i][0];
        C[1] = A[i][1];
        j = i - g;
        while (j >= 0 && compare(C, A[j])) {
            A[j + g][0] = A[j][0];
            A[j + g][1] = A[j][1];
            j -= g;
        }
        A[j + g][0] = C[0];
        A[j + g][1] = C[1];
    }
}

void shellSort(int A[][2], int n)
{
    int i, m = 0;
    int G[10] = {262913, 65921, 16577, 4193, 1073, 281, 77, 23, 8, 1};

    for (i = 0; i < 10; i++) {
        if (G[i] <= n) {
            m++;
            insertionSort(A, n, G[i]);
        }
    }
}

int main(void)
{
    int n;
    scanf("%d", &n);

    int A[100000][2];
    int i;
    for (i = 0; i < n; i++) scanf("%d %d", &A[i][0], &A[i][1]);

    shellSort(A, n);

    for (i = 0; i < n; i++) printf("%d %d\n", A[i][0], A[i][1]);

    return 0;
}


Measured memory_bytes: 2572
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
#define MOD 1000000007
#define pll pair<ll,ll>
#define pii pair<int,int>
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
 
ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b) ;} 

template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}
 
void solve(){
	ll n;
	cin>>n;
	vector<ll> vec(n);
	for(int i=0;i<n;i++){
		cin>>vec[i];
	}
	vector<ll> pref(n);
	pref[n-1] = vec[n-1];
	for(int i=n-2;i>=0;i--){
		pref[i] = (pref[i+1]+vec[i])%MOD;
	}
	ll ans = 0;
	for(int i=0;i<n-1;i++){
		ans = (ans + (vec[i]*pref[i+1])%MOD)%MOD;
	}
	cout<<ans<<endl;
}
 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	ll t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}    
    return 0;
}

Measured memory_bytes: 6360
#include <iostream>
#include <cstdio>
#include <vector>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


int main(){

    string s;
    cin >> s;

    rep(i, 3){
        if (s[i]=='1') s[i] = '9';
        else s[i] = '1';
    }


    cout << s << endl;

    return 0;
}





//              g++ -std=c++1z

Measured memory_bytes: 256
N,D = map(int,input().split())
l = [list(map(int,input().split())) for number in range(N)]

sum = 0

for i in range(N):
    dis = (l[i][0]**2 + l[i][1]**2)**0.5

    if dis <= D:
        sum += 1

print(sum)

Measured memory_bytes: 45760