akhauriyash/Code-Regression huggingface dataset:
/// a.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < ll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    const int mod = 1e9 + 7;
    fi>>n;
    vi s;
    int ans = 1;
    int cnt = 0;
    for (int i = 1;i <= n;++i)
    {
        int v;
        fi>>v;
        if (v <= cnt + cnt)
            ans = (1ll * ans * (cnt + 1)) % mod;
        else
            ++cnt;
    }
    while (cnt --) ans = (1ll * ans * (cnt + 1)) % mod;
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 256
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

ans = 0
for i in range(n):
    if i != n-1:
        if a[i] <= x:
            x -= a[i]
            ans += 1
    else:
        if a[i] == x:
            ans += 1
print(ans)

Measured memory_bytes: 3060
mod=10**9+7
n,k=map(int,input().split())
ans=0
l=sum(range(k-1))
r=sum(range(n,n-k+1,-1))
for i in range(k,n+2):
  l+=i-1
  r+=n-i+1
  ans+=r-l+1
  ans%=mod
print(ans)

Measured memory_bytes: 9200
#include <stdio.h>

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0000

int main() {
    int i;
    int j;
    for (i = 1; i < 10; i++) {
        for (j = 1; j < 10; j++) {
            printf("%dx%d=%d\n", i, j, i*j);
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)

using namespace std;

int main(){

    ll l,r;
    cin >> l >> r;

    ll ans = 2020;

    if(l / 2019 != r / 2019 || l == 0){
        ans = 0;
    }else{

        for(ll i = l; i < r; i++){
            for(ll j = i + 1; j <= r; j++){
                ans = min(ans, (i * j) % 2019);
            }
        }
    }

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

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,m = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	s = sum(a)
	k = 0
	for i in 1:n
		if a[i]>=s/(4*m)
			k += 1
		end
	end
	println(k>=m?"Yes":"No")
end

main()

Measured memory_bytes: 110220
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class B
{
	public static void Main()	
	{
		int N = GetInt();
		int[] T = new int[N];
		for(int i = 0; i < N; i++)
			T[i] = GetInt();
		int M = GetInt();
		int[] P = new int[M];
		int[] X = new int[M];
		for(int i = 0; i < M; i++)
		{
			P[i] = GetInt();
			X[i] = GetInt();
		}

		int sum = 0;
		for(int i = 0; i < N; i++)
			sum += T[i];
		
		for(int i = 0; i < M; i++)
			Console.WriteLine(sum - T[P[i]-1] + X[i]);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

void fnPrimeNumber(const vector<int> &a_cnrviNum, int &a_riPrimeCnt)
{
  for (int i = 0; i < a_cnrviNum.size(); i++)
  {
    bool bPrimeNo = true;
    if (a_cnrviNum[i] > 2  &&  a_cnrviNum[i] % 2 == 0)
      bPrimeNo = false;
    else
    {
      double dSqrt = sqrt((double)a_cnrviNum[i]);
      int iMaxDivisor = (int)dSqrt;

      for (int iDivisor = 2; iDivisor <= iMaxDivisor; iDivisor++)
      {
        if (a_cnrviNum[i] % iDivisor == 0)
        {
          bPrimeNo = false;
          break;
        }
      }
      if (bPrimeNo) a_riPrimeCnt++;
    }
  }
}

int main()
{
  vector<int> viNum;
  int iMaxSize;
  int iPrimeCnt = 0;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    int iNum;
    cin >> iNum;
    viNum.push_back(iNum);
  }

  fnPrimeNumber(viNum, iPrimeCnt);
  cout << iPrimeCnt << endl;

  return 0;
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  rep(i, n) {
    if(i == k - 1)
      cout << (char)(s[i] + 32);
    else
      cout << s[i];
  }
  cout << endl;
}

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

int main(){
    int a ;
    cin >> a ;
    for(int i = 1; i<=9 ;i++){
        for(int j = 1; j <=9; j++){
            if(i*j==a){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int A, B;
	cin >> A >> B;

	int n, m;
	n = max(A, B);
	m = min(A, B);

	int ans = 0;
	ans += n--;
	ans += max(n, m);

	cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<bool> big(n,false);
  int MAX=0;
  int MAX2=0;
  rep(i,n){
    cin >> a[i];
    MAX=max(MAX,a[i]);
  }
  int maxcount=0;
  rep(i,n){
    if(a[i]!=MAX)MAX2=max(MAX2,a[i]);
    if(a[i]==MAX){
      big[i]=true;
      maxcount++;
    }
  }
  
  rep(i,n){
    big[i]&&maxcount==1 ? cout << MAX2 << endl : cout << MAX << endl ;
  }
  //cout << endl;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string i_t_s(int x){
	string t="";
	while(x){
		t+=x%10+'0';
		x/=10;
	}
	reverse(all(t));
	re t;
}
int s_t_i(string t){
	int x=0;
	rep(i,sz(t)){
		x=x*10+(t[i]-'0');
	}
	re x;
}
int n,m;
vi v[100001];
bool f[100001];
void dfs(int x){
	f[x]=true;
	rep(i,v[x].size())
	if(!f[v[x][i]])
	dfs(v[x][i]);
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	rep(i,m){
		int x,y;
		cin>>x>>y;
		x--,y--;
		v[x].pb(y);
		v[y].pb(x);
	}
	int cnt=0;
	rep(i,n){
		if(!f[i]){
			cnt++;
			dfs(i);
		}
	}
	cout<<cnt-1;
	re 0;
}

Measured memory_bytes: 9720
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
   set<int> s;
   s={3,5,7};
   int n;
   cin>>n;
   cout<<(s.find(n)==s.end()?"NO":"YES")<<endl;
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}

Measured memory_bytes: 256
#ifndef ___Geometry_Library
#define ___Geometry_Library

// ------ Includes ------ //
#include <cmath>
#include <complex>
#include <utility>
#include <algorithm>

// ------ Defines ------ //
typedef long double GType;
typedef std::complex<GType> Point;
typedef std::pair<Point, Point> Segment;

// ------ Constants ------ //
const GType EPS = 1.0e-10L;

// ------ Functions Level 1 ------ //
GType dot(const Point& p1, const Point& p2) {
	return (std::conj(p1) * p2).real();
}
GType cross(const Point& p1, const Point& p2) {
	return (std::conj(p1) * p2).imag();
}
int ccw(const Point& p1, const Point& p2, const Point& p3) {
	Point v1 = p2 - p1, v2 = p3 - p1;
	if (cross(v1, v2) > EPS) return +1;
	if (cross(v1, v2) < -EPS) return -1;
	if (dot(v1, v2) < -EPS) return +2;
	if (std::norm(v1) < std::norm(v2)) return -2;
	return 0;
}

// ------ Functions Level 2 ------ //
bool intersect(const Segment& s1, const Point& p1, bool segflag) {
	if (!segflag) return std::abs(cross(s1.second - p1, s1.first - p1)) < EPS;
	return (std::abs(s1.first - p1) + std::abs(s1.second - p1) - std::abs(s1.second - s1.first)) < EPS;
}
bool intersect(const Segment& s1, const Segment& s2, bool segflag) {
	if (!segflag) return cross(s1.second - s1.first, s2.first - s1.first) * cross(s1.second - s1.first, s2.second - s1.first) < EPS;
	return (ccw(s1.first, s1.second, s2.first) * ccw(s1.first, s1.second, s2.second)) <= 0 && (ccw(s2.first, s2.second, s1.first) * ccw(s2.first, s2.second, s1.second)) <= 0;
}
Point crosspoint(const Segment& s1, const Segment& s2) {
	GType r1 = cross(s1.second - s1.first, s2.second - s2.first);
	GType r2 = cross(s1.second - s1.first, s1.second - s2.first);
	if (std::abs(r1) < EPS && std::abs(r2) < EPS) return s2.first;
	return s2.first + r2 / r1 * (s2.second - s2.first);
}

#endif

#include <iomanip>
#include <iostream>
using namespace std;
int q, xa, ya, xb, yb; Segment s1, s2;
int main() {
	cin >> q;
	while (q--) {
		cin >> xa >> ya >> xb >> yb; s1 = make_pair(Point(xa, ya), Point(xb, yb));
		cin >> xa >> ya >> xb >> yb; s2 = make_pair(Point(xa, ya), Point(xb, yb));
		Point ret = crosspoint(s1, s2);
		cout << fixed << setprecision(15) << ret.real() << ' ' << ret.imag() << endl;
	}
	return 0;
}

Measured memory_bytes: 3304
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int INF = INT_MAX / 2;

int main()
{
	int n, ma, mb;
	cin >> n >> ma >> mb;

	vector<int> a(n), b(n), c(n);
	for(int i=0; i<n; ++i)
		cin >> a[i] >> b[i] >> c[i];

	vector<vector<int> > dp(500, vector<int>(500, INF));
	dp[0][0] = 0;
	for(int i=0; i<n; ++i){
		for(int x=500-1; x>=0; --x){
			for(int y=500-1; y>=0; --y){
				if(dp[x][y] == INF)
					continue;
				
				int x2 = x + a[i];
				int y2 = y + b[i];
				dp[x2][y2] = min(dp[x2][y2], dp[x][y] + c[i]);
			}
		}
	}

	int x = 0;
	int y = 0;
	int ans = INF;
	for(;;){
		x += ma;
		y += mb;
		if(!(x < 500 && y < 500))
			break;
		ans = min(ans, dp[x][y]);
	}
	if(ans < INF)
		cout << ans << endl;
	else
		cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 1280
require 'set'
s = gets.to_i
def f(n)
  if n.even?
    n/2
  else
    n*3 + 1
  end
end
set = Set.new
m = 2

am = f(s)
set << s
until set.include?(am)
  set << am
  m += 1
  am = f(am)
end
puts m
  

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

using namespace std;
using ll = long long;

int main() {
	string s;
	cin >> s;
	set<char> st;
	for (int i = 0; i < s.size(); ++i) { st.insert(s[i]); }

	if (st.size() == 2) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}


Measured memory_bytes: 384
//
//  main.c
//  atcoder
//
//  Created by k20043kk on 2020/09/13.
//  Copyright © 2020 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    long long int a,b,c,d;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    long long int box[4];
    box[0]=a*c;
    box[1]=a*d;
    box[2]=b*c;
    box[3]=b*d;
    long long int max=-999999999999999999;
    for(int i=0;i<4;i++){
        //printf("%lld\n",box[i]);
        if(max<box[i]){
            
            max=box[i];
        }
    }
    printf("%lld\n",max);
    return 0;
}


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

typedef long long ll;
#define fori(n) for(int i=0;i<n;i++)
#define pb push_back


ll power(ll base,ll e)
{
    ll answer=1;
    //ll e=1000000005;
    while(e)
    {
        if(e%2==1)
        {
            answer*=base;
        }
        base*=base;
       // base%=mod;
        e/=2;
       // answer%=mod;
    }
    return answer;
}


void sieveprimes(ll n)
{
    bool prime[n+1];
    memset(prime,true,sizeof(prime));

    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }

        }

    }

    /*for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";*/
    /*for(ll i=2;i<=n;i++)
    {
        if(prime[i])    ans.insert(i*i);
    }*/
}


int main()
{
    int s;
    cin>>s;
    int count=0;
    while(s>=500)
    {
        s-=500;
        count+=1000;
    }
    while(s>=5)
    {
        s-=5;
        count+=5;
    }
    cout<<count<<"\n";
}


Measured memory_bytes: 256
import java.util.*;
class Drink {
    int cost;
    int amount;
    public Drink(int cost, int amount) {
	this.cost = cost;
	this.amount = amount;
    }

    public int getCost() {
	return this.cost;
    }
}
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = Integer.parseInt(sc.next());
	int M = Integer.parseInt(sc.next());
	Drink[] drinks = new Drink[N];
	long yen = 0;
	for(int i = 0; i<N; i++) {
	    drinks[i] = new Drink(Integer.parseInt(sc.next()),Integer.parseInt(sc.next()));
	}
	Arrays.sort(drinks, Comparator.comparing(Drink::getCost));
	for(int i = 0; i<N; i++) {
	    if(drinks[i].amount<=M) {
		yen += (long)drinks[i].cost*(long)drinks[i].amount;
		M = M-drinks[i].amount;
	    }else{
		yen += (long)drinks[i].cost*(long)M;
		M = 0;
	    }
	    if(M<=0)break;
	}
	System.out.println(yen);
    }
}

Measured memory_bytes: 65888
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _020_A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nab = ReadInts();
            if (nab[0] == 2)
            {
                Console.WriteLine("Borys");
            }
            else if ((nab[2] - nab[1]) % 2 == 0)
            {
                Console.WriteLine("Alice");
            }
            else
            {
                Console.WriteLine("Borys");
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

struct	QS {
	long L=0;
	long R=0;
};

int     main() {
	int N;
	cin >>N;
	long a;
	long A=0;
	for (int i=0; i<N; i++) {
		cin >>a;
		A += a-1;
	}
	cout << A << endl;
	return 0;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int h, w; cin >> h >> w;
    vector<string> s(h); cin >> s;
    auto dis = defvec<int>(INF, h, w);
    if (s[0][0] == '.')dis[0][0] = 0;
    else dis[0][0] = 1;
    queue<pair<int, int>> bfs;
    bfs.emplace(0, 0);
    int dy[] = { 0,1 }, dx[] = { 1,0 };
    while (!bfs.empty()) {
        int y, x;
        tie(y, x) = bfs.front();
        bfs.pop();
        FOR(i, 0, 2) {
            int ny = y + dy[i], nx = x + dx[i];
            if (out(ny, nx))continue;
            int cost;
            if (s[y][x] == '.' && s[ny][nx] == '#')cost = 1;
            else cost = 0;
            if (!chmin(dis[ny][nx], dis[y][x] + cost))continue;
            bfs.emplace(ny, nx);
        }
    }

    cout << dis[h - 1][w - 1] << "\n";
}

Measured memory_bytes: 892
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

type key struct {
	price int
	box   int
}

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func main() {
	INF := int(math.Pow10(9))
	sc.Split(bufio.ScanWords)

	N, M := uint(scanInt()), scanInt()
	K := make([]key, M)
	for i := 0; i < M; i++ {
		a, b := scanInt(), scanInt()

		K[i].price = a
		K[i].box = 0
		for j := 0; j < b; j++ {
			K[i].box += 1 << (uint(scanInt() - 1))
		}
	}

	// DP[i]...ビットマスクiの箱の鍵が開けられる最安値
	DP := make([]int, 1<<N)
	DP[0] = 0
	for i := 1; i < (1 << N); i++ {
		DP[i] = INF
	}

	for _, key := range K {
		for i := 0; i < (1 << N); i++ {
			DP[i|key.box] = intMin(DP[i|key.box], DP[i]+key.price)
		}
	}

	if ans := DP[(1<<N)-1]; ans == INF {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

  static final int MOD = 1000000007;

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] arr = new int[N];
    for (int i = 0; i < N; i++) {
      arr[i] = scanner.nextInt();
    }
    System.out.println(solve(arr, N, K));
  }

  private static int add_self(int a, int b) {
    a += b;
    if (a >= MOD) {
      a -= MOD;
    }
    return a;
  }

  private static int sub_self(int a, int b) {
    a -= b;
    if (a < 0) {
      a += MOD;
    }
    return a;
  }

  private static long solve(int[] arr, int n, int k) {

    int[] dp = new int[k + 1];
    dp[0] = 1; // the number of ways such that we used i candies so far
    for (int child = 0; child < n; ++child) {
      int up_to = arr[child];
      int[] fake = new int[k + 1];
      for (int used = k; used >= 0; --used) {
        int tmp = dp[used];
        int L = used + 1;
        int R = used + Math.min(up_to, k - used);
        if (L <= R) {
          fake[L] = add_self(fake[L], tmp);
          if (R + 1 <= k) {
            fake[R + 1] = sub_self(fake[R + 1], tmp);
          }
        }
      }
      int prefix_sum = 0;
      for (int i = 0; i <= k; ++i) {
        prefix_sum = add_self(prefix_sum, fake[i]);
        dp[i] = add_self(dp[i], prefix_sum);
      }
    }
    return dp[k];
  }
}


Measured memory_bytes: 44884
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

int main()
{
    int n,temp,con = 0;
    scanf("%d",&n);
    map<int,int> spare;
    for(int i = 1; i != n+1; ++i)
    {
        scanf("%d",&temp);
        if(spare[temp] == 0){
            spare[temp] = 1;
            con++;
        }
        else{
            spare[temp] = 0;
            con--;
        }
    }
    printf("%d",con);
    return 0;
}


Measured memory_bytes: 4864
import java.util.Random;
import java.util.Scanner;

public class Main {
	private static final int K = 26;
	private static final int SEARCH = 100;
	private static final int CHECK = 1000000;
	private static Random rand = new Random(System.currentTimeMillis());

	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var d = sc.nextInt();
		var c = new int[K];
		var s = new int[d][K];
		for (var i = 0; i < K; i++) {
			c[i] = sc.nextInt();
		}
		for (var i = 0; i < d; i++) {
			for (var j = 0; j < K; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		sc.close();

		var time = System.currentTimeMillis();
		var t = new int[d];
		var max = Integer.MIN_VALUE;
		for (var i = 0; i < SEARCH; i++) {
			if (System.currentTimeMillis() - time > 1000) {
				break;
			}
			var t2 = search(c, s, d);
			var score = score(c, s, t2, d);
			if (score > max) {
				t = t2;
				max = score;
			}
		}

		for (var i = 0; i < d; i++) {
			System.out.println(t[i]);
		}
	}

	private static int[] search(int[] c, int[][] s, int d) {
		var count = 0;
		var t = create(c, s, d);
		var mdi = 0;
		while (count < CHECK) {
			count++;
			mdi = (mdi + rand.nextInt(d) + 1) % d;
			var mti = (t[mdi] + rand.nextInt(K)) % K;
			var check = check(c, s, t, d, mdi, mti);
			if (check > 0) {
				t[mdi] = mti + 1;
			}
		}

		return t;
	}

	private static int check(int[] c, int[][] s, int[] t, int d, int mdi, int mti) {
		var sum = 0;
		var ti = t[mdi] - 1;
		sum += s[mdi][mti] - s[mdi][ti];

		var last1 = 0;
		var last2 = 0;
		for (var i = mdi - 1; i >= 0; i--) {
			if (t[i] == ti + 1) {
				last1 = i + 1;
				break;
			}
		}
		for (var i = mdi - 1; i >= 0; i--) {
			if (t[i] == mti + 1) {
				last2 = i + 1;
				break;
			}
		}

		var count1 = 1;
		var count2 = 1;
		for (var i = mdi + 1; i < d; i++) {
			if (t[i] == ti + 1) {
				break;
			}
			count1++;
		}
		for (var i = mdi + 1; i < d; i++) {
			if (t[i] == mti + 1) {
				break;
			}
			count2++;
		}
		sum += (mdi - last2 + 1) * c[mti] * count2 - (mdi - last1 + 1) * c[ti] * count1;

		return sum;
	}

	private static int score(int[] c, int[][] s, int[] t, int d) {
		var sum = 0;
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var ti = t[i] - 1;
			sum += s[i][ti];
			last[ti] = i + 1;
			for (var j = 0; j < K; j++) {
				sum -= ((i + 1) - last[j]) * c[j];
			}
		}

		return sum;
	}

	private static int[] create(int[] c, int[][] s, int d) {
		var t = new int[d];
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var v = new int[K];
			for (var j = 0; j < K; j++) {
				v[j] = s[i][j] + (((i + 1) - last[j]) * c[j]);
			}
			t[i] = rand(v) + 1;
			last[t[i] - 1] = i + 1;
		}
		return t;
	}

	private static int rand(int[] v) {
		var sum = 0;
		for (var i = 0; i < v.length; i++) {
			sum += v[i];
		}
		var value = rand.nextInt(sum);
		var index = 0;
		sum = 0;
		for (var i = 0; i < v.length; i++) {
			sum += v[i];
			if (value < sum) {
				break;
			}
			index++;
		}
		return index;
	}
}

Measured memory_bytes: 47840
#include<stdio.h>
#include<algorithm>
using namespace std;
double dp[1020][520];
int n;
double solve(int a,int b){
	if(dp[a][b]>-0.5)return dp[a][b];
	if(a==0)return 0;
	double ret=0;
	if(b>0&&a-b>0)ret+=solve(a-2,b-1)*b/(a-b);
	
	if(a-2*b>0&&a-b>0&&b>0&&a-b-1>0)ret+=(solve(a-2,b)+1)*(a-2*b)/(a-b)*(b)/(a-b-1);
	if(a-2*b>0&&a-b>0&&a-b-1>0&&a-2*b-1>0)ret+=solve(a,b+2)*(a-2*b)/(a-b)*(a-2*b-2)/(a-b-1);
	if(a-2*b>0&&a-b>0&&a-b-1>0)ret+=solve(a-2,b)*(a-2*b)/(a-b)/(a-b-1);
	//printf("%d %d: %f\n",a,b,ret);
	return dp[a][b]=ret+1;
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		a/=2;
		n=a;
		for(int i=0;i<=a*2;i++)for(int j=0;j<=a;j++)
			dp[i][j]=-1;
		printf("%.12f\n",solve(a*2,0)-a);
	}
}

Measured memory_bytes: 5264
n,k = map(int,input().split())
p = list(map(int,input().split()))
kitaichi = []
for i in range(n):
    P = p[i]
    kitai = 1+P
    kitaichi.append(kitai)
m = [0,]
a = 0
for j in range(n):
    a += kitaichi[j]
    m.append(a)
ans = 0
for l in range(n-k+1):
    temp = m[l+k]-m[l]
    if temp> ans:
      ans = temp
print(ans/2)


Measured memory_bytes: 30012
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n;
  scanf("%d", &n);
  int64 ret = 1LL * (n + 2) * (n + 1) * n / 6;
  // trace(n, ret);
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    --x; --y;
    ret -= 1LL * (x + 1) * (n - y);
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <cstdio>
#include <string>
#include <cassert>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int ans;
string n,a;
int main() {
  ans = 0;
  cin >> n;
  a = "CODEFESTIVAL2016";
  rep(i,16)
  if(n[i]!=a[i]) ans++;


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



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

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    vector<int> rank(n);
    rep(i,n){
        rank[vec[i]-1] = i+1;
    }
    rep(i,n){
        cout << rank[i] << " ";
    }
    cout << endl;
}


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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    if (a[n - 1] - a[0] > 1) {
        cout << "No";
        return 0;
    }
    if (a[0] == a[n - 1]) {
        if (a[0] * 2 <= n || a[0] == n - 1) {
            cout << "Yes";
        } else {
            cout << "No";
        }
        return 0;
    }
    int t = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == a[0]) {
            ++t;
        }
    }
    if (t < a[n - 1] && (a[n - 1] - t) * 2 <= n - t) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue> 
#include<cstdio>
using namespace std; 
 
const int MAXN = 3E5 + 100; 
typedef long long ll; 
int n, m, a[MAXN]; 
ll p[MAXN]; 
 
int main() 
{ 
    ll all = 0; 
    scanf("%d%d", &n, &m); 
    for(int i=0; i<n; ++i) scanf("%d", a+i); 
    for(int i=1; i<n; ++i) 
    { 
        int l = a[i-1], r = a[i]; 
        if(l>r) r += m; 
        all += r-l; 
        if(r-l>1) 
        { 
            p[l+2] += 1; 
            p[r+1] -= (r-(l+2)+1) + 1; 
            p[r+2] += (r-(l+2)+1); 
        } 
    } 
    for(int i=1; i<=2*m; ++i) p[i] += p[i-1]; 
    for(int i=1; i<=2*m; ++i) p[i] += p[i-1]; 
 
    ll ans = -1; 
    for(int i=1; i<=m; ++i) ans = max(ans, p[i]+p[i+m]); 
    cout << all - ans << endl; 
 
    return 0; 
} 

Measured memory_bytes: 2176
a,b=map(int,input().split())
x=[]
y=[]
for i in range(b):
    x.append(str(a))
for i in range(a):
    y.append(str(b))
x=''.join(x)
y=''.join(y)
z=[x,y]
z=sorted(z)
print(z[0])


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>

typedef long long ll;

using namespace std;

ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll Bc = B / C;
  ll Bd = B / D;
  ll Ac = (A - 1) / C;
  ll Ad = (A - 1) / D;
  ll lcm = C * (D / gcd(C, D));
  ll Blcm = B / lcm;
  ll Alcm = (A - 1) / lcm;
  printf("%lld\n", (B - A + 1) - ((Bc - Ac) + (Bd - Ad) - (Blcm - Alcm)));
}

Measured memory_bytes: 3240
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())),dtype='int64')
if np.sum(a<0)%2==0:
    a=abs(a)
else:
    a=abs(a)
    a[a.argmin()]=-a[a.argmin()]
# print(a)
print(int(sum(a)))


Measured memory_bytes: 23288
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a[0]==a[1]&&a[2]==a[3]&&a[0]!=a[2]){
		cout<<"Yes";
		return 0;
	}else if(a[0]==a[2]&&a[1]==a[3]&&a[0]!=a[1]){
		cout<<"Yes";
		return 0;
	}else if(a[0]==a[3]&&a[1]==a[2]&&a[0]!=a[1]){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  
  int resL=0,resR=100000;
  
  for(int i=0;i<M;i++){
    int l,r;
    cin>>l>>r;
    
    resL=max(resL,l);
    resR=min(resR,r);
  }
  
  if(resL>resR)
    cout<<0;
  else
    cout<<resR-resL+1<<endl;
  
  
}



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

int cnt;
vector<int> G;

void insertionSort(int A[], int n, int g) {
  for (int i=g; i<n; i++){
    int v = A[i];
    int j = i-g;
    while (j>=0 && A[j]>v) {
      A[j+g] = A[j];
      j = j-g;
      cnt ++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[], int n){
  int h = 1;
  while (h<=n) {
    G.push_back(h);
    h = 3*h+1;
  }

  for (int i=G.size()-1; i>=0; i--) {
    insertionSort(A, n, G[i]);
  }
}

int main() {
  int n;
  cin >> n;
  int A[n];
  for (int i=0; i<n; i++) {
    scanf("%d", &A[i]);
  }

  cnt = 0;
  shellSort(A, n);

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

  return 0;
}



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

int main()
{
  int N;
  cin >> N;
  int A, B, C, D;
  A = N / 1000;
  N -= A * 1000;
  B = N / 100;
  N -= B * 100;
  C = N / 10;
  D = N % 10;
  if ((A == B && B == C)||(B == C && C == D)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <cstdio>
#define N 303
#define oo 0x7f7f7f7f
using namespace std;

int n, m, a[N][N], vis[N], num[N];

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            scanf("%d", &a[i][j]);
    int res = +oo;
    for (int i = 1; i <= m; ++i) {
        memset(num, 0, sizeof num);
        for (int j = 1; j <= n; ++j) {
            int k = 1;
            while (vis[a[j][k]] && k <= m) ++k;
            if (k > m) continue;
            num[a[j][k]]++;
        }
        int now = 0, id = 0;
        for (int j = 1; j <= m; ++j)
            if (num[j] > now) now = num[j], id = j;
        res = min(res, now);
        vis[id] = 1;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm> 
#include<cstring>
using namespace std;
const int N=2e5+5;
int n,num,p,dp[N],pos[N][30];
char s[N];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=26;i++)pos[n+1][i]=n+1;
	for(int i=n;i>=0;i--)
	{
		for(int j=1;j<=26;j++)pos[i][j]=pos[i+1][j];
		pos[i][s[i+1]-'a'+1]=i+1;
		dp[i]=n+1;
		for(int j=1;j<=26;j++)dp[i]=min(dp[i],dp[pos[i][j]]+1);
	}
	int t=dp[0];
	while(t--)
		for(int i=1;i<=26;i++)
			if(dp[pos[p][i]]<dp[p])
			{
				printf("%c",i+'a'-1);
				p=pos[p][i];
				break;
			}
	return 0;
}

Measured memory_bytes: 24576
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N;
    cin >> N;
    string s;
    
    
    cout << N-1 << endl;;
    cin >> s;
    if ( s == "Vacant" ) { return 0; }
    cout << 0 << endl;;
    cin >> s;
    if ( s == "Vacant" ) { return 0; }    
    
    bool pre_sex = s == "Male";
    int pre_i = 0;
    
    int l = 0, r = N-1;
    while ( true ) {
        
        cout << (l+r)/2 << endl;;
        cin >> s;
        
        if ( s == "Vacant" ) { return 0; }    
        
        bool new_sex = ( ( (l+r)/2 - pre_i )%2 == 0 ) ? pre_sex : !pre_sex;
        if ( new_sex == ( s == "Male" ) ) {            
            pre_i = (l+r)/2;
            pre_sex = new_sex;
            l = (l+r)/2;
        }
        else {            
            r = (l+r)/2;
        }
        
    }
    
    
    return 0;
}

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

LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}


int main(){
    LL n,m;cin >> n >> m;
    vector<LL> t(n,0);
    LL k=n*(n-1)-2*(n-1)-2*(n-2);
    for (int i = 0; i < m; i++) {
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        if(st[{b,a}]){
            if(st[{b,a}]!=c+2){
                if(abs(a-b)>=3){
                    puts("0");
                    return 0;
                }
                else{
                    if((a+b)%2==0){
                        if(t[(a+b)/2]==2){
                            puts("0");
                            return 0;
                        }
                        t[(a+b)/2]=3;
                    }
                }
            }
            else{
                if(abs(a-b)<3&&(a+b)%2==0){
                    if(t[(a+b)/2]==3){
                        puts("0");
                        return 0;
                    }
                    t[(a+b)/2]=2;
                }
            }
        }
        if(a==b){
            if(t[a]!=c+2&&t[a]){
                puts("0");
                return 0;
            }
            t[a]=c+2;
        }
        if(abs(a-b)>2&&st[{a,b}]==0&&st[{b,a}]==0) k-=2;
        st[{a,b}]=c+2;
    }
    LL dp[n][2];
    memset(dp,0,sizeof(dp));
    if(t[0]!=3) dp[0][0]=1;
    if(t[0]!=2) dp[0][1]=1;
    st[{n,n-2}]=1,st[{n-2,n}]=1;
    for (int i = 0; i < n-1; i++) {
        if(st[{i,i+1}]==0&&st[{i+1,i}]==0){
            dp[i+1][0]=(2*dp[i][0]+2*dp[i][1])%mod;
            dp[i+1][1]=(2*dp[i][0]+2*dp[i][1])%mod;
        }
        else if(st[{i,i+1}]==0||st[{i+1,i}]==0){
            dp[i+1][0]=(dp[i][0]+dp[i][1])%mod;
            dp[i+1][1]=(dp[i][0]+dp[i][1])%mod;
        }
        else{
            dp[i+1][0]=dp[i][(st[{i,i+1}]+st[{i+1,i}])%2]%mod;
            dp[i+1][1]=dp[i][(1+st[{i,i+1}]+st[{i+1,i}])%2]%mod;
        }
        if(st[{i,i+2}]==0&&st[{i+2,i}]==0){
            dp[i+1][0]*=2;
            dp[i+1][1]*=2;
        }
        if(t[i+1]==3) dp[i+1][0]=0;
        else if(t[i+1]==2) dp[i+1][1]=0;
    }
    cout << (dp[n-1][0]+dp[n-1][1])%mod*fpow(2,k/2)%mod << endl;
    return 0;
}


Measured memory_bytes: 33792
#include<bits/stdc++.h>
using namespace std;
long long a[1000000];
bool cmp(long long a,long long b)
{
return a>b;
} 
int main()
{
   long long n,k,ans=0;
   cin>>n>>k;
   for(long long i=1;i<=n;i++)
   cin>>a[i];
   if(k>0)
   {
    sort(a+1,a+n+1,cmp);
	for(long long i=k+1;i<=n;i++)
	ans+=a[i];   
	cout<<ans;
	return 0;
   } 
   else
   {
	for(long long i=1;i<=n;i++)
	ans+=a[i];   
	cout<<ans;
	return 0;
   }
   return 0;
}
   

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

#define ll long long

const int N = 1e5+7; 
ll n,a[N],ans,m,minn = 0x7fffffff,minx;

int main(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		if(a[i] < minn){
			minn = a[i];
			minx = i;
		}
	}
	vector <int> vec;
	if(minx != 1)
	vec.push_back(0);
	for(int i = 1; i <= n; i++)
		if(a[i] == minn) 
			vec.push_back(i);
	int len = vec.size();
	for(int i = 1; i < len; i++){
		ans += (vec[i] - vec[i-1] - 3 + m) / (m-1);
		if((vec[i] - vec[i-1] - 1) % (m-1) != 0) vec[i] += (m-1) - ((vec[i] - vec[i-1] - 1) % (m-1));
	}
	if(vec[len-1] != n)
	ans += (n - vec[len-1] - 2 + m) / (m-1);
	cout << ans;
}


Measured memory_bytes: 1024
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,m,i,j,p,lst;
	cin>>n>>m>>p;
	vector<pair<pii,ll>>e;
	for(i=0;i<m;i++){
		ll x,y,w;
		cin>>x>>y>>w;
		e.pb({{x,y},p-w});
	}
	ll dp[n+3];
	for(i=0;i<=n+1;i++)
		dp[i]=1e14;
	dp[1]=0;
	for(i=0;i<2*n;i++){
		for(j=0;j<m;j++){
			ll u=e[j].F.F,v=e[j].F.S,w=e[j].S;
			if(dp[v]>dp[u]+w)
				dp[v]=dp[u]+w;
		}
		if(i==n)lst=dp[n];
	}
//	cout<<lst<<" "<<dp[n]<<"\n";
	if(lst!=dp[n])cout<<"-1";else
	cout<<max(0LL,-dp[n]);
	return 0;
}

Measured memory_bytes: 576
// HEADERS //
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <stack>
#include <unordered_map>
#include <bitset>
 
// MISCELLANEOUS //
#define fast_IO() ios_base::sync_with_stdio(false),cin.tie(NULL)
#define gcd __gcd
#define cnt_1 __buitlin_popcount
#define ll long long
#define endl "\n"
#define scn_I(x) scanf("%d",&x)
#define scn_L(x) scanf("%lld",&x) 
#define test(t) cin>>t; while(t--)
#define mem(v,x) memset(v,x,sizeof(v))
 
// LOOPS //
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define irep(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define srep(i,v) for(decltype(v.begin())i=v.begin();i!=v.end();i++)
 
// CONTAINERS //
// #define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ii pair<int,int>
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define msi map<string,int>
#define mll map<ll,ll>
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define all(v) (v).begin(),(v).end()
#define present(v,x) (v).find(x)!=(v).end()
 
// DEBUGGING //
#define dbg() printf("\n**DEBUG**\n") 
#define chk(a) cerr<<endl<<#a<<":"<<a<<endl
#define chk2(a,b) cerr<<endl<<#a<<":"<<a<<"\t"<<#b<<":"<<b<<endl
 
// CONSTANTS //
#define PI acos(-1)
#define M 1000000007
#define N 100005
 
// MAIN //
// using namespace __gnu_pbds; 
using namespace std;
int main()
{
  fast_IO();
  int n,k; cin>>n>>k; vi v(n);
  rep(i,0,n) cin>>v[i];
  ll dp[n]; mem(dp,0);
  rep(i,1,n) dp[i]=abs(v[i]-v[0]);
  rep(i,2,n)
  {
    dp[i]=abs(v[i]-v[i-1])+dp[i-1];
    for(int j=2;j<=k && j<=i;++j) dp[i]=min(dp[i],abs(v[i]-v[i-j])+dp[i-j]);
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1536
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	string s;
	cin >> s;

	if (s[0] == '9' || s[1] == '9') cout << "Yes";
	else cout << "No";

	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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 c[4005][4005];
void init() {
  c[0][0] = 1;
  rep(i, 4001) rep(j, i+1) {
    c[i+1][j] += c[i][j];
    c[i+1][j+1] += c[i][j];
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, k; std::cin >> n >> k;
  init();
  auto comb = [&](int n, int k) -> mint {
    return c[n][k];
  };
  auto ff = [&](int n, int k) -> mint {
    return comb(n+k-1, k-1);
  };
  auto f = [&](int n, int k) -> mint {
    if (n == 0 && k == 0) return 1;
    if (n < k) return 0;
    if (k < 1) return 0;
    return ff(n-k, k);
  };
  rrep(i, k) {
    mint blue = f(k, i);
    mint red = ff(n-k-(i-1), i+1);
    mint ans = blue * red;
    printf("%lld\n", ans.x);
  }
}


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

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  for (int i=0; i<N; i++) {
    int v=A[i];
    int j=i-1;
    while (j>=0 && A[j]>v) {
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }
    for (int i=0; i<N; i++) {
      cout << (i==0?"":" ") << A[i] << flush;
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>

using namespace std;

int main(){

	int N;
	int L[100];

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	int count = 0;

	for (int i = 0; i < N; i++) {
		for ( int j = i+1; j < N; j++) {
			for (int k = j+1; k < N; k++) {
				// if(i == j || i == k || j == k) continue;
				if (L[i] == L[j] || L[i] == L[k] || L[j] == L[k]) continue;
				if(L[i] + L[j] > L[k] && L[k] + L[j] > L[i] && L[i] + L[k] > L[j]) {
					count++;
					// cout << "L[" << i << "] = " << L[i] << " ";
					// cout << "L[" << j << "] = " << L[j] << " ";
					// cout << "L[" << k << "] = " << L[k] << "\n";
				}	
			}
		}
	}
	cout << count << "\n";

	return 0;
}

Measured memory_bytes: 3632