akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
#define ff first
#define pb push_back
#define ss second
#define ll long long
#define MAX 5000
#define mpi map<int, int>
#define mpll map<ll, ll>
#define pll pair<ll, ll>
#define plld pair<ll, double>
#define SKILLER ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi std::vector<int>
#define vll std::vector<ll>
#define vs std::vector<string>
#define vvi std::vector<std::vector<int>>
#define vvll std::vector<std::vector<ll>>
#define all(v) v.begin(), v.end()
#define loop(i, a, b) for(int i = a; i < b; i++)
const int Maxn = 1e5+1, Mod = 1e9 + 7;
int main(){
    SKILLER;
  
           
         ll n, m; cin >> n >> m;
         ll sum = 0;
         while(m--){
         	ll x; cin >> x;
         	sum += x;
         }
         if(sum > n)
         	cout << "-1";
         else cout<<n-sum ;
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int Solve(int a){
  int ans=0;
  while(a){
    ans+=a%10;
    a/=10;
  }
  return ans;
}
int main(void){
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  for(int i=1;i<=n;i++){
    int k=Solve(i);
    if(a<=k && k<=b){
      ans+=i;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a,b) for(ll i=(a);i<(b);i++)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;


    int n, x;
    cin>>n;
    vector<int> v;

    loop(i, 0, n){
        cin>>x;
        v.pb(x);
    }

    unq(v);

    cout<<v.size();



}






























Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll A;
    double B;
    cin >> A >> B;
    ll iB = (ll)B;
    ll dB = ll(100 * B) - 100 * iB;
    ll ans = (A *dB) / 100ll + A * iB;
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  long long r = 0, g = 0, b = 0;
  for (auto c : S) {
    if (c == 'R')
      ++r;
    else if (c == 'G')
      ++g;
    else
      ++b;
  }
  long long all = r * g * b;
  long long sub = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      if (S[i] == S[j]) continue;
      int k = j * 2 - i;
      if (k >= N || S[k] == S[i] || S[k] == S[j]) continue;
      ++sub;
    }
  }
  cout << all - sub << endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vi a(M), b(M);
  rep(i, M) cin >> a[i] >> b[i];

  vi perm(N);
  int ans = 0;
  rep(i, N) perm[i]=i+1;
  do {
    if (perm[0] != 1) continue;
    bool check = false;
    for (int i =1; i < N; i++) {
      check = false;
      rep(j, M) {
        if ((perm[i-1] == a[j] && perm[i] == b[j]) || (perm[i-1] == b[j] && perm[i] == a[j])) check = true;
      }
      if (!check) break;
    }
    if (check) ans+=1;
  }while(next_permutation(all(perm)));
  cout << ans << endl;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str=sc.nextLine();
        int q=sc.nextInt();
        String order[][] = new String[q][4];

        for( int i = 0; i < q; i++) {
        	order[i][0]= sc.next();
        	order[i][1]= sc.next();
        	order[i][2]= sc.next();
        	if("replace".equals(order[i][0])) {
            	order[i][3]= sc.next();
        	}
        }
        sc.close();
        for( int i = 0; i < q; i++) {
        	String command = order[i][0];
        	int start = Integer.parseInt(order[i][1]);
        	int end = Integer.parseInt(order[i][2]);
        	if ("replace".equals(command)) {
        		StringBuffer sb = new StringBuffer(str);
        		str = sb.replace(start, end+1, order[i][3]).toString();
        	} else if ("print".equals(command)) {
        		System.out.println(str.substring(start,end +1));
        	} else if ("reverse".equals(command)) {
        		StringBuffer sb = new StringBuffer(str.substring(start,end + 1));
        		String bef = str.substring(start,end+1);
        		String aft = sb.reverse().toString();
        		str = str.replace(bef, aft);
        	}
        }
    }
}



Measured memory_bytes: 30180
n=int(input())
cnt=0
*s,=map(int,input().split())
for i in range(n-2):
	if (s[i]<s[i+1]<=s[i+2])or(s[i+2]<s[i+1]<=s[i]):
		cnt += 1
	else:
		pass
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mm=1000000007;
const int n=10000000;

void solve()
{
	int t;
	cin>>t;
	int d=1;
	while(t--)
	{
		int t1,x,y;
		
		cin>>t1>>x>>y;
		if((x+y)>=-t1&&(x+y)<=t1)
		{
			if(((x+y)%2)==(t1%2))
			{
			if(d==1)
				d=1;
		}
			else
			{
				//cout<<"No\n";
				d=0;
			}
		}
		else
		{
			//cout<<"No\n";
			d=0;
		}
		
	}
	if(d==0)
	{
		cout<<"No\n";
	}
	else
	{
		cout<<"Yes\n";
	}
}

int main(){
	ios::sync_with_stdio(0);
	//int t; cin >> t; while(t--)
	solve();
	//cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}

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

using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define pi acos(-1.0)
const ll maxn = 2e5 + 100;
const ll mod = 1e9;
int c[10];
int val[10];
map<int, int> mat;
signed main(){
	int tmp;
	_rep(i, 1, 9)cin >> c[i], mat[c[i]] = i;
	int n;
	cin >> n;
	_rep(i, 1, n){
		cin >> tmp;
		if(mat.count(tmp)){
			val[mat[tmp]] = 1;
		}
	}
	string res = "No";
	_rep(i, 1, 3){
		if(val[i] & val[i+3] & val[i+6])res = "Yes";
	}
	for(int i = 1; i<=9;i+=3){
		if(val[i] & val[i+1] & val[i+2])res = "Yes";
	}
	if(val[1] & val[5] & val[9])res = "Yes";
	if(val[3] & val[5] & val[1+6])res = "Yes";
	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const int inf = 1e9;
int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int a[n][3];   //on the ith day if he did j the work
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	int dp[n][3];
	for (int i = 0; i < n; i++) {
		for (int k = 0; k < 3; k++) {
			dp[i][k] = 0;
		}
	}
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	for (int i = 1; i < n; i++) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + a[i][1];
		dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + a[i][2];
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
}

Measured memory_bytes: 2560
def show2dlist(nlist,r,c):
    for x in xrange(0,r):
        nlist[x] = map(str,nlist[x])
        ans = " ".join(nlist[x])
        print ans
# input
n,m,l = map(int,raw_input().split())
a_matrix = [[0 for x in xrange(m)] for y in xrange(n)]
b_matrix = [[0 for x in xrange(l)] for y in xrange(m)]
for x in xrange(n):
    a_matrix[x] = map(int,raw_input().split())
for x in xrange(m):
    b_matrix[x] = map(int,raw_input().split())

c_matrix = [[0 for x in xrange(l)] for y in xrange(n)]

# calc
for ni in xrange(n):
    for li in xrange(l):
        for mi in xrange(m):
            c_matrix[ni][li] += a_matrix[ni][mi] * b_matrix[mi][li]

# show result
show2dlist(c_matrix,n,l)

Measured memory_bytes: 7736
#include<cstdio>
int main(){
	long long int n;
	scanf("%lld",&n);
	int a[25]={};
	long long int m=1;
	int k;
	for(int i=0;0==0;i++){
		a[i]=(n/m)%10;
		m=m*10;
		if(m>n){
			k=i;
			break;
		}
	}
	int ans=0;
	int q=0;
	for(int i=0;i<=k;i++){
		if(q==0 && a[i]==9){
			ans+=9;
		}else if(q==0 && k==i){
			ans+=a[i];
		}else if(k==i){
			ans+=a[i]-1;
			q=1;
		}else{
			ans+=9;
			q=1;
		}
	}
	printf("%d\n",ans);
	return 0;
}
		

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

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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;
}
const long long INF = 1LL << 60;

int main() {
    ll X, Y;
    cin >> X >> Y;
    if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll m = (2 * X - Y) / 3;
    ll n = (2 * Y - X) / 3;
    if (m < 0 || n < 0) {
        cout << 0 << endl;
        return 0;
    }

    COMinit();
    cout << COM((X + Y) / 3, n) << endl;

    return 0;
}


Measured memory_bytes: 23680
#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    if(m%2==1){
        for(int i=1;i<=m/2;i++)cout<<i<<' '<<(m+1-i)<<endl;
        for(int i=1;i<=m/2+1;i++)cout<<m+i<<' '<<(2*m+2-i)<<endl;
    }else{
        for(int i=1;i<=m/2;i++)cout<<i<<' '<<(m+2-i)<<endl;
        for(int i=1;i<=m/2;i++)cout<<m+1+i<<' '<<(2*m+2-i)<<endl;
    }
}

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

int main(void){
	int n, a, b, m, sum = 0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; ++i){
		m = 0;
		if (i < 10){
			m += i;
		}else if (i < 100){
			m = i/10 + i%10;
		}else if (i < 1000){
			m = i/100 + i%100/10 + i%100%10;
		}else if (i < 10000){
			m = i/1000 + i%1000/100 + i%1000%100/10 + i%1000%100%10;
		}else{
			m = 1;
		}
		if (a <= m && m <= b){
			sum += i;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,l,c,f;
	cin>>n;
	vc a(n+1);
	for(i=1;i<=n;i++)cin>>a[i];
	sort(a.begin(),a.end());
	ll ans=0;
	for(i=1;i<=n;i++)
	{
	    for(j=i+1;j<=n;j++)
	    {
	        for(k=j+1;k<=n;k++)
	        {
	            if((a[k]<a[i]+a[j])&&(a[i]+a[k]>a[j])&&(a[k]+a[j]>a[i])&&(a[i]!=a[j]&&(a[j]!=a[k])))
	                ans++;
	        }
	    }
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3656
program arc067c
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: i,j,n,num
    integer(int32), allocatable:: pf(:)
    integer(int64),parameter:: md=10**9+7
    integer(int64):: ans
    read*, n
    allocate(pf(n))
    pf(:) = 0
    pf(1) = 0
    do i=2,n
        num = i
        j=2
        do while(j*j <= num)
            do while (mod(num,j) == 0)
                num=num/j
                pf(j)=pf(j)+1
            end do
            j=j+1
        end do
        if (num /= 1) pf(num)=pf(num)+1
    end do

    pf(:)=pf(:)+1
    ans = 1
    do i=1,n
        ans = mod(ans*pf(i),md)
    end do
    print'(i0)', ans

end program arc067c

Measured memory_bytes: 256
//#include<atcoder/all>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
//using namespace atcoder;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

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

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


int main(){
	ll n,ans=0,cnt=0;
	cin >> n;
	for(ll i=0;i<n;i++){
		ll a,b;
		cin >> a >> b;
		if(a==b){
			cnt++;
			chmax(ans,cnt);
		}else{
			cnt=0;
		}
	}
	if(ans>2){
		cout << "Yes"<<endl;
	}else{
		cout << "No" << endl;
	}
}

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

int main() {
    int a, b;
    cin >> a >> b;
    string A = string(b, '0' + a);
    string B = string(a, '0' + b);
    string ans = min(A, B);
    cout << ans << endl;
    return 0;
}

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

int main() {
  int h, w;
  while(true) {
    scanf("%d %d", &h, &w);
    if(h == 0 && w == 0) break;
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) printf("#");
      printf("\n");
    }
    printf("\n");
  }
}


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

int main(){
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if(a < b &&(a + v*t) >= (b + w*t)){
        cout << "YES" << endl; 
    }
    else if(a > b && (a - v*t) <= (b - w*t)){
        cout << "YES" << endl; 
    }
    else cout << "NO" << endl;
}

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



int main()
{
  ll n,m;
  cin>>n>>m;
  char a[n][m];

  for(ll i=0;i<n;i++)
  {
      for(ll j=0;j<m;j++)
        cin>>a[i][j];
  }


  ll dp[n][m];
  memset(dp,0,sizeof(dp));
  dp[0][0] = 1;
  for(int j=1;j<m;j++)
  {
      if(a[0][j] == '.')
      {
        dp[0][j] = dp[0][j-1];
      }
  }



  for(int j=1;j<n;j++)
  {
      if(a[j][0] == '.')
      {
        dp[j][0] = dp[j-1][0];
      }
  }



 

  for(int i=1;i<n;i++)
  {
    for(int j=1;j<m;j++)
    {
        if(a[i][j] == '.')
        {
           dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        }
    }
  }
  cout<<(dp[n-1][m-1])%mod<<endl;
}

Measured memory_bytes: 9088
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a != b || b != c || c != a) {
			pr.println("No");
		} else {
			pr.println("Yes");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21588
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#include <random>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

random_device gen;
mt19937 rnd(gen());

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

int n, m, d;

char getcol(int x, int y) {
    x += 5000, y += 5000;
    int x1 = (x / (d)) % 2;
    int y1 = (y / (d)) % 2;
    if (x1 == 0 && y1 == 0) {
        return 'R';
    } else if (x1 == 0 && y1 == 1) {
        return 'G';
    } else if (x1 == 1 && y1 == 0) {
        return 'B';
    } else {
        return 'Y';
    }
}

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
    cin >> n >> m >> d;
    if (d & 1) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if ((i + j) & 1) {
                    printf("R");
                } else {
                    printf("B");
                }
            }
            printf("\n");
        }
    } else {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                printf("%c", getcol(i - j, i + j));
            }
            printf("\n");
        }
    }
	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B,K,ans;
    cin >> A >> B >> K;
    for (int i = A;i <= B;i++) {
        if (A+K > i || B-K <i) {
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


int aa[200000],bb[200000],cc[2000000];
 
void t(){
  aa[0]=aa[1]=1;
  bb[0]=bb[1]=1;
  cc[1]=1;
  repi(i,2,200000){
    aa[i]=aa[i-1]*i%MOD;
    cc[i]=MOD-cc[MOD%i]*(MOD/i)%MOD;
    bb[i]=bb[i-1]*cc[i]%MOD;
  }
}
 
int calc(int n,int k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return aa[n]*(bb[k]*bb[n-k]%MOD)%MOD;
}


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k;
  t();
  cin>>n>>k;
  deque<int> d,e;
  d.push_back(1);
  d.push_back(1);
  rep(i,k){
    int num;
    num=calc(n-k+1,i+1);
    //cout<<num<<endl;
    int ans=calc(k-1,i)*num;
    
    ans%=MOD;
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 6272
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int a, b, m;
    bool b1 = false;
    string s;
    cin>> s;
    b1 = true;
    for (int i = 0; i<s.length(); i++){
        if (i%2 ==0){  //if odd
            if (s[i] == 'L'){
                b1 = false;
                break;
            }
        }
        if (i%2 == 1){ //if even
            if (s[i] == 'R'){
                b1 = false;
                break;
            }
        }
    }
    if (b1 == true){
        cout << "Yes";
    }
    if (b1==false){
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
G = [[] for _ in range(n)]
H = LI()
for _ in range(m):
    a, b = LI()
    G[a - 1] += [b - 1]
    G[b - 1] += [a - 1]

ans = 0
for i in range(n):
    j = H[i]
    for v in G[i]:
        if H[v] >= j:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 98696
#include<iostream>
#include<unordered_set>
using namespace std;
typedef long long int ll;
int main()
{

    unordered_set<int>fn;
    ll c = 1;


    ll x;
    cin>>x;
    int temp = 7;
    fn.insert(7);
    if(x%2==0)
    {

        cout<<-1;
        return 0;
    }

    while((temp%x)!=0)
    {

        ll r = temp%x;
        temp = r*10+7;

        c++;
        if(fn.find(temp)!=fn.end())
        {
            cout<<-1;
            return 0;
        }
        fn.insert(temp);
    }
    cout<<c;


}


Measured memory_bytes: 42636
//
//  main.cpp
//  Move_And_Win
//
//  Created by Uttam Datta on 02/06/19.
//  Copyright © 2019 Uttam Datta. All rights reserved.
//

#include <iostream>
#include <vector>
using namespace std;

int N, alice,bores;

void ans(){
    int less = min(alice,bores);
    int more = max(alice,bores);
    int k = (more-less)/2;
    if(k == 0){
        cout << "Borys" << endl;
    }
    else if(less + k != more-k){
        cout << "Borys" << endl;
    }
    else{
        cout << "Alice" << endl;
    }
    
}


int main(){
    cin >> N >> alice >> bores;
    ans();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 250005
#define MAXL 505
using namespace std;

const int d[4][2]={
	{-1,0},{1,0},
	{0,-1},{0,1}
};

int n,ans,p[MAXN],dis[MAXL][MAXL],ndis[MAXL][MAXL];
queue <pair<int,int> > q;

inline void add(int x,int y)
{
	if (!dis[x][y]) return ;
	dis[x][y]=0;q.push({x,y});
	return ;
}

inline void BFS(int x,int y)
{
	ans+=dis[x][y];q.push({x,y});ndis[x][y]=0;
	while (!q.empty())
	{
		int x,y;tie(x,y)=q.front();q.pop();
		for (int i=0;i<4;i++)
		{
			int tx=x+d[i][0],ty=y+d[i][1];
			if (tx<1||tx>n||ty<1||ty>n) continue;
			if (dis[tx][ty]>dis[x][y]+ndis[x][y])
			{
				dis[tx][ty]=dis[x][y]+ndis[x][y];
				q.push({tx,ty});
			}
		}
	}
	return ;
}

int main()
{
	memset(dis,0x3f,sizeof dis);
	scanf("%d",&n);
	for (int i=1,x=n*n;i<=x;i++) scanf("%d",&p[i]);
	for (int i=1;i<=n;i++) add(1,i),add(n,i),add(i,1),add(i,n);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++) ndis[i][j]=1;
	while (!q.empty())
	{
		int x,y;tie(x,y)=q.front();q.pop();
		for (int i=0;i<4;i++)
		{
			int tx=x+d[i][0],ty=y+d[i][1];
			if (tx<1||tx>n||ty<1||ty>n) continue;
			if (dis[tx][ty]>dis[x][y]+1)
			{
				dis[tx][ty]=dis[x][y]+1;
				q.push({tx,ty});
			}
		}
	}
	for (int i=1,x=n*n;i<=x;i++) BFS((p[i]-1)/n+1,(p[i]-1)%n+1);
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >>D;
  
  while(A>0 && C>0){
  A=A-D;
  C=C-B; 
  }
  
    if(C<=0){
    cout << "Yes" <<endl;
  }
   else{
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 3592
import sys


table = [0]*26

letters = "abcdefghijklmnopqrstuvwxyz"
input_str = sys.stdin.read()

for A in input_str:
    index = 0
    for B in letters:
        if A == B or A == B.upper():
            table[index] += 1
            break
        index += 1

for i in range(len(letters)):
    print("%s : %d"%(letters[i],table[i]))


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


int main(void) {
  int64 N, M;
  cin >> N >> M;
  vector<int64> v(N, 0);
  REP(i, M) v[N-i-1] = 1;
  vector<double> L(N), a(N), b(N);
  double res = 0;
  REP(i, N) cin >> L[i] >> a[i] >> b[i];
  do {
    vector<int64> idx;
    REP(i, N) {
      if (v[i] == 1) idx.push_back(i);
    }
    double sum = 0;
    for (auto i : idx) {
      for (auto j : idx) {
        if (i >= j) continue;
        sum += pow(L[i]-L[j], 2) + pow(a[i]-a[j], 2) + pow(b[i]-b[j], 2);
      }
    }
    chmax(res, sum);
  } while (next_permutation(all(v)));
  cout << fixed << setprecision(10) << res << endl;
}


Measured memory_bytes: 3296
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <functional>

template <class Cost = int>
struct Edge {
    int from, to;
    Cost cost;
    Edge(int from = -1, int to = -1, Cost cost = 1)
        : from(from), to(to), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
class Graph {
public:
    int size;
    std::vector<std::vector<Edge<Cost>>> path;

    explicit Graph(int N = 0) : size(N), path(size) {}
    void span(int from, int to, Cost cost = 1) {
        path[from].push_back(Edge<Cost>(from, to, cost));
    }
    std::vector<Edge<Cost>>& operator[](int v) { return path[v]; }
};


using namespace std;

vector<int> build(vector<int>& arr) {
    int cur = 1;  // 次に使われるもの
    vector<int> ret;
    for (auto d : arr) {
        for (int i = 1; i <= d; ++i) {
            ret.push_back(cur + i);
        }
        ret.push_back(cur);
        if (cur == 1) swap(ret.front(), ret.back());
        cur += d + 1;
    }
    swap(ret[ret.size() - 2], ret[ret.size() - 1]);
    return ret;
}

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

    if (N == 2) {
        // 葉を除くと何もなくなるので例外処理
        cout << 1 << " " << 2 << endl;
        return 0;
    }

    vector<pair<int, int>> edges(N - 1);
    vector<int> deg(N, 0);
    for (auto& e : edges) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        e = make_pair(u, v);
        ++deg[u], ++deg[v];
    }

    // 葉を取り除いたグラフ
    Graph<> path(N);
    vector<int> ch(N, 0);
    for (auto e : edges) {
        int u, v;
        tie(u, v) = e;
        if (deg[u] > deg[v]) swap(u, v);
        if (deg[u] == 1) {
            ++ch[v];
        } else {
            path.span(u, v);
            path.span(v, u);
        }
    }

    // 存在判定 葉を除いたグラフがpathかどうか
    for (int v = 0; v < N; ++v) {
        if (path[v].size() > 2) {
            cout << -1 << endl;
            return 0;
        }
    }

    // pathの端点からDFSして、葉の数の配列を作る
    int r;
    for (r = 0; r < N && (ch[r] == 0 || path[r].size() > 1); ++r) {}

    vector<int> arr;
    function<void(int, int)> dfs = [&](int v, int p) {
        arr.push_back(ch[v]);
        for (auto e : path[v]) {
            if (e.to != p) dfs(e.to, v);
        }
    };
    dfs(r, -1);

    // 両端から順列を作って小さい方が答え
    auto ans = build(arr);
    reverse(arr.begin(), arr.end());
    auto revans = build(arr);
    if (revans < ans) ans = revans;

    for (int i : ans) cout << i << " ";
    cout << endl;

    return 0;
}


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

int main()
{
    int K;
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> K;
    cout << a.at(K - 1) << endl;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
class UnionFind
{
public:
	int p[N];
	void init(int n = N)
	{
		memset(p, -1, sizeof(int) * n);
	}
	int treesize(int x)
	{
		return -p[Find(x)];
	}
	int Find(int x)
	{
		int s = x;
		while (p[s] >= 0) s = p[s];
		while (x != s)
		{
			int t = p[x];
			p[x] = s;
			x = t;
		}
		return s;
	}
	void Union(int x, int y)
	{
		int px = Find(x);
		int py = Find(y);
		if (p[px] > p[py]) swap(px, py);
		p[px] += p[py];
		p[py] = px;
	}
} uf1, uf2;
vector<int> v1[N], v2[N];
int ans[N];
int getans(vector<int>& v1, vector<int>& v2)
{
	int ans = 0;
	for (auto& x : v1)
	{
		if (upper_bound(v2.begin(), v2.end(), x) - lower_bound(v2.begin(), v2.end(), x))
			ans++;
	}
	return ans;
}
int check(vector<int>& v1, vector<int>& v2)
{
	if (v1.size() > v2.size()) return getans(v2, v1);
	else return getans(v1, v2);
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	uf1.init();
	uf2.init();
	int n, m1, m2;
	scanf("%d%d%d", &n, &m1, &m2);
	vector<pair<int, int>> vp;
	while (m1--)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		if (uf1.Find(x) != uf1.Find(y))
			uf1.Union(x, y);
	}
	while (m2--)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		if (uf2.Find(x) != uf2.Find(y))
			uf2.Union(x, y);
	}
	for (int i = 1; i <= n; i++)
	{
		v1[uf1.Find(i)].push_back(i);
		v2[uf2.Find(i)].push_back(i);
	}
	for (int i = 1; i <= n; i++)
	{
		map<int, int> mc;
		for (auto& x : v1[i])
		{
			int y = uf2.Find(x);
			if (!mc.count(y))
				mc[y] = check(v1[i], v2[uf2.Find(x)]);
			ans[x] = mc[y];
		}
	}
	for (int i = 1; i <= n; i++)
		printf("%d%c", ans[i], " \n"[i == n]);
	return 0;
}

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int n; cin >> n;
   int a[n+1];
   for(int i = 1; i <=n; i++)
      cin >> a[i];

   int ans = 0;
   int button = 1;
   int last = button;
   while(n--)
   {

      if(button ==2)
      {
         cout << ans << nl;
         return 0;
      }
      ans++;
      last = button;
      button = a[button];


   }
   cout << -1 << nl;

}


Measured memory_bytes: 4052
#include<stdio.h>
int main ()
{
   long long int a,b,c,k,i,s;
   scanf("%lld %lld %lld %lld",&a,&b,&c,&k) ;
      if(k>=(a+b)){
       s=a+((-1)*(k-(a+b)));
       printf("%lld\n",s);}
      else{
        if(k==a || k<a)
        printf("%lld\n",k);
        else if (k>a)
            printf("%lld\n",a);
      }
}



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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    vector<string> sub;
    map<string, int> match;

    rep(i, s.size()) {
        string substring = "";
        substring += s[i];
        if (match.count(substring) == 0) {
            match[substring] = 1;
            sub.push_back(substring);
        } 
        repd(j, i + 1, min(i + 6, (int)s.size())) {
            substring += s[j];
            if (match.count(substring) == 0) {
                match[substring] = 1;
                sub.push_back(substring);
            } 
        }
    }

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

    cout << sub[K - 1] << endl;
    return 0;
}

Measured memory_bytes: 2556
N,M = map(int,input().split())
x_list = list(map(int,input().split()))

if N >= M:
    print(0)
else:
    x_list.sort()

    diff_list = []
    
    for i in range(M-1):
        diff_list.append(x_list[i+1]-x_list[i])

    diff_list.sort(reverse=True)
    ans = x_list[-1] - x_list[0]
    for i in range(N-1):
        ans -= diff_list[i]
    print(ans)

Measured memory_bytes: 56744
#include<bits/stdc++.h>
using namespace std;
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1,
    x=-x;
  }
  while(x){
    f[s++]=x%10,
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  string s;
  cin >> s;
  int n = s.size();
  int l = (n-1)/2;
  int r = n/2;
  char c = s[l];
  while (l >= 0){
    if (s[l] != c){
      break;
    }
    if (s[r] != c){
      break;
    }
    l--;
    r++;
  }
  int w = (n+r-l-1)/2;
  wt_L(w);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170910-1

// --- original code ---
// {
//   string s;
//   cin >> s;
//   inplace_L int n = s.size();
//   inplace_L int l = (n-1)/2, r = n/2;
//   inplace_L char c = s[l];
//   while (l >= 0) {
//     if (s[l] != c) break;
//     if (s[r] != c) break;
//     l--; r++;
//   }
//   inplace_L int w = (n+r-l-1)/2;
//   wt(w);
// }

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6+9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}




void test_case() {
	
    char c;
    cin>>c;

    c++;

    cout<<c<<endl;

   




}


signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while(t--)
    {   
        test_case();
    }
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll n;
    cin >> n;
    FOR(i, 1, 3501) FOR(j, i, 3501) {
        if ((4 * i * j) - (n * (i + j)) < 1) continue;
        if ((n * i * j) % ((4 * i * j) - (n * (i + j))) == 0) {
            cout << i << " " << j << " " << (n * i * j) / ((4 * i * j) - (n * (i + j))) << endl;
            return;
        }
    }
}


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

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') insert(key);
    else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L') deleteLast();
      } else deleteKey(key);
    }
  }
  printList();
  return 0;
}


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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int GCD(int x,int y){
    int temp;
    if(x<y){
        temp=x,x=y,y=temp;
    }
    if(y<1){
        return -1;
    }
    if(x%y==0){
        return y;
    }
    return GCD(x,x%y);
}

int main(){
    long long N,sum=0;
    cin >> N;
    vector<long long> vec(N);
    for(long long i=0;i<N;i++){
        cin >> vec[i];
    }
    for(long long i=0;i<N;i++){
        for(long long j=i+1;j<N;j++){
            sum+=vec[i]*vec[j];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;

    ll w,h,x,y;
    cin >> w >> h >> x >> y;
    ld ans = w*h/2.0;
    cout << fixed << setprecision(10) << ans << endl;
    if(x == w/2.0 and y == h/2.0) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while(A[i] != key) ++i;
    return i != n;
}

int main()
{
    int i, n, A[10001], q, key, sum = 0;
    scanf("%d", &n);
    rep(i,n) scanf("%d", &A[i]);

    scanf("%d", &q);
    rep(i,q) {
        scanf("%d", &key);
        if(search(A,n,key)) sum++;
    }
    P(sum);

    return 0;
}

Measured memory_bytes: 3212
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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; }



int main()
{
  ll H,W,K; cin>>H>>W>>K;
  vector<string> grid(H); rep(i,H) cin>>grid.at(i);
  
  ll ans=0;
  rep(i,1<<H){
    rep(j,1<<W){
      
      ll count=0;
      rep(k,H){
        rep(l,W){
          if(!(i&(1<<k))&&!(j&(1<<l))&&grid.at(k).at(l)=='#') count++;
        }
      }
      if(count==K) ans++;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


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


int main(void)
{
	//変数の宣言
	int n,y;
	int i,j;
	int ans[3]={0,0,0};
	
	//データの読み込み
	scanf("%d %d",&n,&y);
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=0;i<n+1;i++){
		for(j=0;j<n-i+1;j++){
			if(i*10000+j*5000+(n-i-j)*1000==y){
				ans[0]=i;
				ans[1]=j;
				ans[2]=n-i-j;
			}
		}
	}
	
//	printf("計算部分終了\n");
	
	//出力
	
	if(ans[0]==0&&ans[1]==0&&ans[2]==0){
		printf("%d %d %d",-1,-1,-1);
	}else{
		printf("%d %d %d",ans[0],ans[1],ans[2]);
	}
//	printf("結果の出力終了\n");
	
	return 0;
}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define fo(i, n) for(int i = 1; i <= n; ++i)
#define rep(i, a, b) for(int (i) = (a); (i) < (b); ++(i))

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

const int N = 200200;
const int mod = 1e9 + 7;
const ll INF = 1e18;
ll n,m;

ll ans;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>m;
	
		ll x=min(n,m/2);
		n-=x,m-=2*x;
			
	cout<<x+m/4;
	return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  vector<P> p(N);
  rep(i,N) {
    p[i].second = i + 1;
    cin >> p[i].first;
  }
  sort(p.begin(), p.end());
  rep(i,N) cout << p[i].second << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 3560
d = int(input())
c = {}
s = []
C = list(map(int, input().split()))
for i in range(26):
    c[i] = C[i]
for i in range(d):
    s.append(list(map(int, input().split())))

for i in range(d):
    a = -1
    b = 0
    for j in range(26):
        if b < s[i][j]:
            a = j
            b = s[i][j]
    print(a+1)

Measured memory_bytes: 9400
#include<iostream>
#include<algorithm>
 
using namespace std;
 
 
int main(){
	int a[3];
  	for(int i=0;i<3;i++){
		cin>>a[i];
    }
  	sort(a,a+3);
  	
  if(a[0]==5 && a[1]==5 && a[2]==7){
    cout << "YES" << endl;
  }
    else{
      cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: usize = 998244353;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: usize,
        S: usize,
        A: [usize; N],
    }

    let mut dp = vec![0; S + 1];
    dp[0] = 1;

    for a in &A {
        let mut newDp: Vec<usize> = dp.iter().map(|d| d * 2).collect();
        for s in 0..(S + 1) {
            if s + a <= S {
                newDp[s + a] += dp[s];
            }
        }
        dp = newDp.into_iter().map(|d| d % MOD).collect();
    }

    println!("{}", dp[S]);
}


Measured memory_bytes: 2280
import itertools
n = int(input())
f = []
for i in range(n):
    f.append(list(map(int, input().split())))
p = []
for i in range(n):
    p.append(list(map(int, input().split())))

a = [i for i in range(10)]
combi = []
for i in range(10):
    combi.extend(list(itertools.combinations(a,i+ 1)))
#print(combi)

ans =  - float("inf")
for i in combi:
    #print(i)
    cnt = [0]*n
    for j in i:
        for k in range(n):
            cnt[k] += f[k][j]
    profit = sum([p[k][cnt[k]] for k in range(n)])
    ans = max(ans, profit)
print(ans)

Measured memory_bytes: 3188