akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N,Ss,Sf,Gs,Gf;
  cin >> N >> Ss >> Sf >> Gs >> Gf;
  vector<bool>a(N);
  char s;
  Ss--,Sf--,Gs--,Gf--;
  for(int i=0;i<N;i++){
    cin >> s;
    a.at(i)=(s=='#');
  }
  bool ans=true;
  for(int i=Ss;i<Gs-1;i++)
    if(a.at(i)&&a.at(i+1))
      ans=false;
  for(int i=Sf;i<Gf-1;i++)
    if(a.at(i)&&a.at(i+1))
      ans=false;
  if(Gs>Sf&&Gf<Gs){
    bool ok=false;
    for(int i=Sf;i<=Gf;i++)
      if(!(a.at(i-1)||a.at(i)||a.at(i+1)))
        ok=true;
    if(!ok)
      ans=false;
  }
  cout << (ans?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <numeric>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

void solve(long long a, long long b){
    char A = a + '0';
    char B = b + '0';
    string strA, strB;
    REP(i, b) strA += A;
    REP(i, a) strB += B;
    print(min(strA, strB));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


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

using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;

const int MAXN = 200010;

int n, k, c;

int dpPrefix[MAXN];
int dpSuffix[MAXN];
int mxDpPrefix[MAXN];
int mxDpSuffix[MAXN];

string s;

multiset< int > q;

int getMax()
{
	auto it = q.end();
	it--;

	return *it;
}

int main()
{
	cin >> n >> k >> c >> s;

	for(int i = 1 ; i <= n ; i++)
	{
		int val = 0;
		if( i - c >= 1 ) val = mxDpPrefix[i - c - 1];

		dpPrefix[i] = val + 1;
		if( s[i - 1] == 'x' ) dpPrefix[i]--;

		mxDpPrefix[i] = max( mxDpPrefix[i - 1] , dpPrefix[i] );
	}

	for(int i = n ; i > 0 ; i--)
	{
		int val = 0;
		if( i + c <= n ) val = mxDpSuffix[i + c + 1];

		dpSuffix[i] = val + 1;
		if( s[i - 1] == 'x' ) dpSuffix[i]--;

		mxDpSuffix[i] = max( mxDpSuffix[i + 1] , dpSuffix[i] );
	}

	vector< int > ans;

	c = max( c , 1 );
	//c = min( c , n - 1 );

	for(int i = 2 ; i <= c + 1 ; i++)
		q.insert( mxDpSuffix[i] );

	for(int i = 1 ; i <= s.size() ; i++)
	{
		if( getMax() < k && s[i - 1] == 'o' ) ans.push_back( i );

		int r = 0;
		if( i - c >= 1 ) r += mxDpPrefix[i - c];
		if( i + 1 <= n ) r += mxDpSuffix[i + 1];

		q.erase( q.find( r ) );

		r = mxDpPrefix[i];
		if( i + c + 1 <= n ) r += mxDpSuffix[i + c + 1];

		q.insert( r );
	}

	for(int i = 0 ; i < ans.size() ; i++)
		printf("%d\n",ans[i]);
}

Measured memory_bytes: 5752
X=int(input())
Ni=0
while (Ni+1) ** 5 - Ni** 5 <= X:
    Ni+=1
    
for i in range(1,Ni+1):
    for ii in range(-i,i):
        if i**5 - ii**5==X:
            break
    else:
        continue
    break

print(i,ii)

Measured memory_bytes: 63868
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e) int i; for(int i=s;i<=e;i++)
#define repd(i,s,e) int i; for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())

const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
 


signed main()
{
 
    fast;
    read2(a,b);
    cout<<6-a-b<<endl;
    return 0;
}

/* Pooja Yadav */

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

int main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  if(S.at(K - 1) == 'A'){
    S.at(K - 1) = 'a';
  }
  else if (S.at(K - 1) == 'B') {
    S.at(K - 1) = 'b';
  }
  else{
    S.at(K - 1) = 'c';
  }
  cout << S << endl;
}

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

int main()
{
    int N, ans = 1;
    string s;

    cin >> N >> s;
    for(int i = 0; i < N-1; i++){
        if(s[i] != s[i+1]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
def indexes(s,c)
    result = []
    offset = 0
    while i = s.index(c, offset)
        result << i
        offset = i + 1
    end
    return result
end

s = gets.chomp
t = gets.chomp

s_uniq = s.chars.uniq
t_uniq = t.chars.uniq

s_indexes = []
s_uniq.each do |c|
    current = indexes(s, c)
    s_indexes << current if current != []
end

t_indexes = []
t_uniq.each do |c|
    current = indexes(t, c)
    t_indexes << current if current != []
end

if s_indexes.sort == t_indexes.sort
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 27968
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, a, b) = readLongList()
    val c = a + b
    var count = (n / c) * a + min(n % c, a)
    out.println(count)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 36488
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	bool operator<(const struct Info &arg) const{
		return height < arg.height;
	};
	int height,pile[101];
};

int N,loc[101];

Info* info;


void func(){

	for(int i = 0; i < N; i++){
		info[i].height = 1;
		info[i].pile[0] = i;
		loc[i] = i;
	}

	int put_cube,to_put_cube,index,tmp,tmp2,limit;

	while(true){
		scanf("%d %d",&put_cube,&to_put_cube);
		if(put_cube == 0 && to_put_cube == 0)break;

		if(put_cube == to_put_cube)continue;

		put_cube--;
		to_put_cube--;
		if(to_put_cube == -1){
			tmp = loc[put_cube];
			for(index = 0; info[tmp].pile[index] != put_cube; index++);

			if(index == 0)continue;

			limit = info[tmp].height;
			for(int i = index; i < limit;i++){

				loc[info[tmp].pile[i]] = info[tmp].pile[i];
				info[info[tmp].pile[i]].height = 1;
				info[info[tmp].pile[i]].pile[0] = info[tmp].pile[i];
			}
			info[tmp].height = index;
		}else{

			tmp = loc[to_put_cube];
			tmp2 = -1;
			for(index = 0; info[tmp].pile[index] != to_put_cube; index++){
				if(info[tmp].pile[index] == put_cube){
					tmp2 = index;
					break;
				}
			}

			if(tmp2 != -1){

				limit = info[tmp].height;

				for(int i = tmp2; i < limit; i++){

					loc[info[tmp].pile[i]] = info[tmp].pile[i];
					info[info[tmp].pile[i]].height = 1;
					info[info[tmp].pile[i]].pile[0] = info[tmp].pile[i];
				}
				info[to_put_cube].pile[1] = put_cube;
				info[to_put_cube].height++;
				info[put_cube].height = 0;
				loc[put_cube] = to_put_cube;

				info[tmp].height = tmp2;
				continue;
			}

			tmp2 = -1;
			for(int i = index; i < info[tmp].height; i++){
				if(info[tmp].pile[i] == put_cube){
					tmp2 = 1;
					break;
				}
			}

			if(tmp2 == 1)continue;

			tmp = loc[put_cube];
			for(index = 0; info[tmp].pile[index] != put_cube; index++);

			limit = info[tmp].height;

			for(int i = index;i < limit; i++){

				loc[info[tmp].pile[i]] = info[tmp].pile[i];
				info[info[tmp].pile[i]].height = 1;
				info[info[tmp].pile[i]].pile[0] = info[tmp].pile[i];
			}
			info[tmp].height = index;
			tmp2 = loc[to_put_cube];
			info[put_cube].height = 0;
			loc[put_cube] = tmp2;
			info[tmp2].pile[info[tmp2].height] = put_cube;
			info[tmp2].height++;
		}
	}

	sort(info,info+N);

	for(int i = 0; i < N; i++){
		if(info[i].height == 0)continue;
		printf("%d\n",info[i].height);
	}

	printf("end\n");
}


int main(){

	info = (Info*)malloc(sizeof(Info)*101);

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

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

class Solve {
private:
	using vi = std::vector<int>;
	using vvi = std::vector<vi>;

	int n, m;
	vvi mat;
	vi win, lose;

	int rc(int index)
	{
		if (index == n) return 1;
		if (n / 2 < lose[index] || n / 2 < win[index]) return 0;
		vi undefined;
		for (int i{}; i < n; i++)
			if (i != index && mat[index][i] < 0)
				undefined.push_back(i);
		std::vector<int> result;
		for (int i{}; i < n / 2 - lose[index]; i++)
			result.push_back(0);
		for (int i{}; i < n / 2 - win[index]; i++)
			result.push_back(1);
		int ret{};
		do
		{
			for (int i{}; i < (int)undefined.size(); i++)
			{
				mat[index][undefined[i]] = result[i];
				mat[undefined[i]][index] = 1 - result[i];
				if (result[i]) lose[undefined[i]]++;
				else win[undefined[i]]++;
			}
			ret += rc(index + 1);
			for (int i{}; i < (int)undefined.size(); i++)
				if (result[i]) lose[undefined[i]]--;
				else win[undefined[i]]--;
		} while (std::next_permutation(result.begin(), result.end()));
		for (auto& e: undefined)
			mat[index][e] = mat[e][index] = -1;
		return ret;
	}

public:
	bool is_last_query{};
	Solve()
	{
		scanf("%d", &n);
		if (n == 0)
		{
			is_last_query = true;
			return;
		}
		scanf("%d", &m);
		mat.resize(n, vi(n, -1));
		win.resize(n);
		lose.resize(n);
		for (int i{}; i < m; i++)
		{
			int x, y;
			scanf("%d%d", &x, &y);
			x--; y--;
			mat[x][y] = 1;
			win[x]++;
			mat[y][x] = 0;
			lose[y]++;
		}
		printf("%d\n", rc(0));
	}
};

int main()
{
	while (!Solve().is_last_query);

	return 0;
}


Measured memory_bytes: 3256
n = int(input())

res = "Yes"
s = input()
box = [s]
for i in range(n-1):
    post_s = input()
    if s[-1] != post_s[0]:
        res = "No"
    elif post_s in box:
        res = "No"
    s = post_s
    box.append(s)

print(res)

Measured memory_bytes: 3060
# include <iostream>
# include <algorithm>
# include <queue>
using namespace std;
const int N=200006;
struct node
{
	int l,r;
}a[N];
priority_queue < int,vector <int>,greater <int> > b;
int n,m,s;
int comp (node p,node q)
{
	if (p.l<q.l)
	return 1;
else if (p.l==q.l)
    if (p.r>q.r)
    return 1;
else return 0;
else return 0;
}
void work (void)
{
	int i,j,t;
	i=1;
	t=0;
	while (a[i].l==0&&i<=n)
	i++;
	for (j=1;j<i;j++)
	b.push (a[1].r);
	for (j=1;j<=m;j++)
	{
		while (a[i].l<j&&i<=n)
		{
			b.push (a[i].r);
			i++;
		}
		if (i<=n)
		{
			i++;
			t++;
			if (t==n)
			break;
		}
   else if (b.top ()<=j&&b.empty ()==0)
        {
        	b.pop ();
        	t++;
			if (t==n)
			break;
		}
	}
	s=n-t;
	cout<<s;
}
int main (void)
{
	int i;
	cin>>n>>m;
	for (i=1;i<=n;i++)
	cin>>a[i].l>>a[i].r;
	sort (a+1,a+n+1,comp);
	work ();
	return 0;
}


Measured memory_bytes: 2936
#include<iostream>
#include<queue>

using namespace std;

int main(){
  int n, m, k;
  cin >> n >> m;

  priority_queue<int> a;
  for(int i=0;i<m;i++){
    cin >> k;
 	a.push(k);
  }
  

  
  priority_queue<int> b;
  int dum;
  while(-1){
    dum = a.top();
    a.pop();

    if(a.empty()){
      break;
    }
    
    b.push(dum- a.top());    
  }
  
  while(n > 1 && !b.empty()){
    b.pop();
    n--;
  }
  
  int result = 0;
  while(-1){
    if(b.empty()){
      break;
    }
    result += b.top();
    b.pop();
  }
    
  cout << result << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll H, N;
    cin >> H >> N;
    vl A(N);
    rep(i, N) cin >> A[i];
    ll sum = 0;
    rep(i, N) sum += A[i];
    cout << ((H <= sum) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1024
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        long A = scan.nextLong();
        long B = scan.nextLong();

        if(A > B) {
            long tmp = A;
            A = B;
            B = tmp;
        }
        long gcd = gcd(A, B);
        if(gcd == 1) {
            os.println("1");
        } else {
            long x = gcd;
            long previ = 0;
            long answer = 1;

            if(x%2 == 0)
                answer++;

            while(x%2 == 0) {
                x /= 2;
            }

            for (long i = 3 ; i <= Math.sqrt(x); i += 2) {
                if (x % i == 0)
                    answer++;
                while(x%i == 0) {
                    x /= i;
                }
            }

            if(x > 2)
                answer++;

            os.println(answer);

        }

    }



    static public long gcd(long a, long b) {
        while(a > 0) {
            long tmpa = a;
            a = b % a;
            b = tmpa;
        }
        return b;
    }

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define F first
#define S second
#define nl cout<<"\n"
//cout<<fixed<<setprecision(11);
const ll MOD=1e9+7;
const ll ARR_MAX = 23;
const ll VAL_MAX = 1e5+1;
const ll INF=1e14;

string s[ARR_MAX];
int h,w;

bool ck(int x,int y){
    if(x>=0 && x<h && y>=0 && y<w && s[x][y]=='.'){
        return true;
    }
    return false;
}

void solve(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    int mx=0;
    int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    int n=h*w;
    for(int i=0;i<n;i++){
        if(s[i/w][i%w]=='#') continue;
        priority_queue<pii> pq;
        pq.push({0,i});
        int vis[n]={};
        memset(vis,0,sizeof(vis));
        int dist[n];
        while(!pq.empty()){
            int d=-pq.top().F;
            int node=pq.top().S;
            pq.pop();
            if(vis[node]){
                continue;
            }
            else{
                dist[node]=d;
            }
            vis[node]=1;
            int x=node/w,y=node%w;
            for(int j=0;j<4;j++){
                int xx=x+dx[j],yy=y+dy[j];
                int nxt=xx*w+yy;
                if(ck(xx,yy) && !vis[nxt]){
                    pq.push({-1*(d+1),nxt});
                }   
            }
            // cout<<node<<" "<<d,nl;
        }
        for(int i=0;i<n;i++){
            // cout<<i/w<<" "<<i%w<<" "<<dist[i]<<" "<<vis[i],nl;
            if(vis[i])
                mx=max(mx,dist[i]);
        }
        // return;
    }
    cout<<mx,nl;
}

int main(){
    fastio();
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int ans;
int main()
{
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
	for(int j=0;j<=b;j++)
	for(int k=0;k<=c;k++)
	{
		if(500*i+100*j+50*k==x)
		ans++;
	}
	cout<<ans;
	return 0;
}

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

    
int main(){
    string s;
    cin >> s ;
    bool a=false;
    int sia=s.size();

    for(int i=0;i<sia;i++)
    {
        for(int l=0;l<sia;l++)
        {
            if(i==l){break;}
            if(s.at(i)==s.at(l)){
                a=true;
                break;
            }
        }
    }
    if(a==true){cout << "no" << endl;}
    else{cout << "yes" << endl;}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	scanf("%d",&n);
	int arr[n];
	for(int i=0;i<n;i++)
		scanf("%d",&arr[i]);
	int ans[n];int j=1;
	for(int i=0;i<n;i++)
	{
		arr[i]=arr[i]%4;
		if(arr[i]==0)
		{
			if(j<=n-1)
				ans[j]=arr[i];
			else
			{
				printf("Yes\n");
				return 0;
			}
			j+=2;
		}
			
	}
	j--;
	int flag=0;
	for(int i=0;i<n;i++)
	{
		if(arr[i]==2)
		{
			flag=1;
			if(j<=n-1)
				ans[j]=arr[i];
			j++;
		}
	}
	if(flag==0)
		j++;
	if(j>=n)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cctype>
inline int getint() {
	register char ch;
	while(!isdigit(ch=getchar()));
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
	return x;
}
int main() {
	char ch;
	scanf("%c",&ch);
	if(ch=='A') putchar('T');
	if(ch=='T') putchar('A');
	if(ch=='C') putchar('G');
	if(ch=='G') putchar('C');
	return 0;
}

Measured memory_bytes: 128
N = int(input())
B = list(map(int, input().split()))

sousa = []

for i in range(N,0,-1):
  for j in range(i,0,-1):
    if B[j-1] == j:
      sousa.append(j)
      del B[j-1]
      break
      
  if j <= 0:
    break
    
if len(B) > 0:
  print(-1)
  exit(0)
#print(sousa)

for i in range(N-1,-1,-1):
  print(sousa[i])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <bitset>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  ll tmp, ans;
  string S, T;
  cin >> S >> T;
  ll sl = S.length();
  ll tl = T.length();
  
  ans = -1;
  rep(i, sl-tl+1){
    tmp = 0;
    rep(j, tl){
      if(S[j+i]==T[j]){
        tmp++;
      }
    }
    ans=max(ans,tmp);
  }
 

  cout << tl-ans << endl;

  
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long M = sc.nextLong();
    long ans = Math.abs(N - 2) * Math.abs(M - 2);
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

vector<vector<int>> cs;
int H, W, K;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

int update(vector<vector<int>>& vv) {
  vector<vector<int>> vv2(H, vector<int>(W, 0));
  vector<int> pos(W, H-1);
  int score = 0;
  for (int r = H-1; r >= 0; --r) {
    vector<bool> b(W, true);
    for (int c = 0; c + K - 1 < W; ++c) {
      int i = c;
      while (vv[r][i] == vv[r][i + 1] && i + 1 < W) {
        ++i;
      }
      if (i - c>= K - 1) {
        for (int j = c; j <= i; ++j) b[j] = false;
        c = i;
      }
    }
    for (int c = 0; c < W; ++c) {
      if (b[c]) {
        vv2[pos[c]][c] = vv[r][c];
        --pos[c];
      } else {
        score += vv[r][c];
      }
    }
  }
  vv = vv2;
  return score;
}

int solve(int r, int c) {
  vector<vector<int>> tmp(H, vector<int>(W, 0));
  for (int i = 0; i < W; ++i) {
    if (i != c) {
      for (int j = H-1; j >= 0; --j) {
          tmp[j][i] = cs[j][i];
      }
    } else {
      int pos = H-1;
      for (int j = H-1; j >= 0; --j) {
        if (j == r) continue;
        tmp[pos][i] = cs[j][i];
        --pos;
      }
    }
  }

  int total = 0, score = 0, k = 1;
  do {
    score = update(tmp);
    total += k * score;
    k *= 2;
  } while (score > 0);
  return total;
}

int main() {
  cin >> H >> W >> K;
  cs.resize(H, vector<int>(W));
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      char c; cin >> c;
      cs[i][j] = c - '0';
    }
  }

  int vmax = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      vmax = max(vmax, solve(i, j));
    }
  }
  cout << vmax << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char* argv) {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a > 12) {
    printf("%d\n", b);
  } else if (a > 5 && a < 13) {
    printf("%d\n", b >> 1);
  } else {
    printf("0\n");
  }
}

Measured memory_bytes: 128
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let a = read_as_vec::<u64>()[0];
    let b = read_as_vec::<u64>()[0];
    let c = read_as_vec::<u64>()[0];
    let x = read_as_vec::<u64>()[0];


    let mut ans = 0;
    for ai in 0..a+1{
        if ai*500 > x{
            continue;
        }
        for bi in 0..b+1{
            if ai*500 + bi*100 > x{
                continue;
            }
            let rest = x - ai*500 - bi*100;
            if rest%50 == 0 && rest/50 <= c{
                ans += 1;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
import heapq
N, M = map(int, input().split())
W = [tuple(map(int, input().split())) for i in range(N)]
W.sort()
h = []

j = 0
ans = 0
for i in range(M+1):
    while j < N and W[j][0] < i+1:
        heapq.heappush(h, (-W[j][1], W[j][1]))
        j += 1
    if h:
        p = heapq.heappop(h)
        ans += p[1]

print(ans)

Measured memory_bytes: 27076
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
       // System.out.println("0".compareTo("1"));
		Deque<Integer> stack = new ArrayDeque<Integer>();

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line=br.readLine();
            String[] str=line.split(" ");
            
            for(int i=0;i<str.length;i++){
            	if(str[i].equals("+")){
            		int a=stack.pop()+stack.pop();
            		stack.push(a);
            	}else if(str[i].equals("-")){
            		int aa=stack.pop();
            		int bb=stack.pop();
            		int a=bb-aa;
            		stack.push(a);
            	}else if(str[i].equals("*")){
            		int aa=stack.pop();
            		int bb=stack.pop();
            		int a=aa*bb;
            		stack.push(a);
            	}else{
            		stack.push(Integer.parseInt(str[i]));
            	}
            }
            System.out.println(stack.pop());
        }
	}

}

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

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    for(int i = 0; i < N; i++){
        cin >> D[i];
    }
    sort(D.begin(),D.end());
    int delta = D[N/2] - D[N/2 - 1];
    // if(delta == 0){
    // }
    cout << delta << endl;
    
    // cout << delta << endl;

    return 0;
}

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    int S, W;
    cin >> S >> W;
    if (W>=S) cout << "unsafe" << "\n";
    else cout << "safe" << "\n";

    return 0;
}

Measured memory_bytes: 3676
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc087/tasks/arc090_b

"""
import sys
from sys import stdin
from heapq import heappush, heappop
input = stdin.readline




def solve(data, N):
    scores = [-1] * (N+1)
    graphs = [[] for _ in range(N+1)]
    in_degs = [0] * (N+1)

    for l, r, d in data:
        in_degs[r] += 1
        graphs[l].append((r, d))

    pq = []

    for pos in range(1, N+1):
        if in_degs[pos] == 0:
            heappush(pq, pos)

    cs = 1
    while pq:
        pos = heappop(pq)
        if scores[pos] < 0:
            scores[pos] = cs
        for r, d in graphs[pos]:
            if scores[r] < 0:
                scores[r] = scores[pos] + d
            else:
                if scores[r] != scores[pos] + d:
                    return 'No'
            in_degs[r] -= 1
            if in_degs[r] == 0:
                heappush(pq, r)

    for d in in_degs[1:]:
        if d > 0:
            return 'No'
    return 'Yes'


def main(args):
    N, M = map(int, input().split())
    data = []
    for _ in range(M):
        l, r, d = map(int, input().split())
        data.append((l, r, d))
    ans = solve(data, N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

int main(){

    char b;
    cin >> b;

    if(b == 'A') cout << "T" << endl;
    else if(b == 'T') cout << "A" << endl;
    else if(b == 'C') cout << "G" << endl;
    else if(b == 'G') cout << "C" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrep1(i, s, n) for (int i = (s); i >= (n); i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

int H;
int A[500001];

void maxHeapify(int i)
{
	int left = i * 2;
	int right = i * 2 + 1;
	int largest = i;
	int tmp;

	if (left <= H && A[largest] < A[left]) largest = left;
	if (right <= H && A[largest] < A[right]) largest = right;

	if (largest != i) {
		tmp = A[i];
		A[i] = A[largest];
		A[largest] = tmp;
		maxHeapify(largest);
	}
}

void buildMaxHeap()
{
	rrep1(i, H / 2, 1) maxHeapify(i);
}

int main()
{
	cin >> H;
	rep1(i, 1, H) cin >> A[i];
	buildMaxHeap();
	rep1(i, 1, H) cout << ' ' << A[i];
	cout << endl;

	return 0;
}


Measured memory_bytes: 5032
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var a = ab[0];
        var b = ab[1];

        if (a + b == 15)
        {
            Console.WriteLine("+");
        }
        else if (a * b == 15)
        {
            Console.WriteLine("*");
        }
        else
        {
            Console.WriteLine("x");
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>

using namespace std;
int main()
{
  int n;
  uint64_t h[100100];
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  int ans = 0, curans = 0;
  for (int i = n - 2; i >= 0; --i) {
    if (h[i + 1] <= h[i])
      curans++;
    else {
      ans = max(curans, ans);
      curans = 0;
    }
  }
  std::cout << max(curans, ans) << std::endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define sf1(x)      scanf("%d",&x)
#define pf1(x)      printf("%d\n",x)
#define pf1s(x)     printf("%d ",x)
#define FOR(i,x)    for(int i=0;i<x;i++)
using namespace std;
int main()
{
    int n,a[102];
    sf1(n);
    FOR(i,n) sf1(a[i]);
    int cnt=0;
    FOR(i,n-1){
       for(int j=n-1; j>=i+1; j--){
          if(a[j]<a[j-1]){
            swap(a[j],a[j-1]);
             cnt++;
          }
       }
    }
    FOR(i,n-1)  pf1s(a[i]);
    pf1(a[n-1]);
    pf1(cnt);
    return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string s, result; cin >> s;
    int si = atoi(s.c_str());
    if (si / 100 >= 1 && si /100 <= 12)
    {
        if (si % 100 >= 1 && si % 100 <= 12)
        {
            result = "AMBIGUOUS";
        }
        else
        {
            result = "MMYY";
        }
    }
    else
    {
        if (si % 100 >= 1 && si % 100 <= 12)
        {
            result = "YYMM";
        }
        else
        {
            result = "NA";
        }
    }
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.Objects;

public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();

        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();

        long[][] a = new long[n][m];
        long[][] b = new long[m][l];
        long[][] ans = new long[n][l];

        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++)a[i][j] = sc.nextLong();
        }
        for(int i=0;i<m;i++){
            for(int j=0;j<l;j++)b[i][j] = sc.nextLong();
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<l;j++){
                for(int k=0;k<m;k++)ans[i][j] += a[i][k]*b[k][j];
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<l-1;j++){
                System.out.print(ans[i][j]+" ");
            }
            System.out.println(ans[i][l-1]);
        }
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}



Measured memory_bytes: 36720
program bbb
implicit none

integer :: i, m, res
integer, dimension(5) :: meal, one
integer, dimension(1) :: mloc
read*, meal

res=0

do i=1,5
one(i)=meal(i)-(meal(i)/10)*10
if(one(i)==0) one(i)=10
end do

m=minval(one)
mloc=minloc(one)

do i=1, 5
 if(one(i)==10) then
 res=res+meal(i)
 else
 res=res+(meal(i)/10)*10+10
 end if
end do

res=res-10+one(mloc(1))

write(*,'(i0)') res

end program

Measured memory_bytes: 256
def solve(string):
    n, k = map(int, string.split())
    c = (n - 1) * (n - 2) // 2 - k
    if c < 0:
        return "-1"
    ans = [str(n - 1 + c)]
    for i in range(1, n):
        ans.append("{} {}".format(i, n))
    for i in range(1, n):
        for j in range(i + 1, n):
            if c == 0:
                break
            c -= 1
            ans.append("{} {}".format(i, j))
    return "\n".join(ans)


if __name__ == '__main__':
    print(solve(input()))


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



int main() {
	int A, B;
	cin >> A >> B;
	for (int i = 1; i < 4; i++) {
		if (A != i && B != i) {
			cout << i << endl;;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb emplace_back
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define deb(x) cout << #x << " - " << x << endl;

using namespace std;

int main()
{	IOS;
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	long double n, k; cin >> n >> k;
	double sum = 0.0000000000, temp , x;
	for (double i = 1; i <= n; i++) {
		double b1 = (double)1.0 / n;
		int cnt = 0;
		int t = i;
		while (t < k) {
			t *= 2;
			cnt++;
		}
		while (cnt--) {
			b1 = (double)b1 / 2.0;
		}
		sum += b1;
	}
	// deb(sum);
	// deb(n);
	 cout << fixed << setprecision(12) << sum;
	return 0;

}

Measured memory_bytes: 256
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

x = int(input())

while True:
    if is_prime(x):
        print(x)
        break
    x += 1

Measured memory_bytes: 38384
#include<map>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAX = 2160;
const int MAXN = 100000;
int prm[MAX + 5], pcnt = 0;
bool is_prm[MAX + 5];
void init() {
	for(int i=2;i<=MAX;i++) {
		if( !is_prm[i] )
			prm[++pcnt] = i;
		for(int j=1;i*prm[j]<=MAX;j++) {
			is_prm[i*prm[j]] = true;
			if( i % prm[j] == 0 ) break;
		}
	}
}
ll s[MAXN + 5], a[MAXN + 5], b[MAXN + 5];
ll IsSqr(ll x) {
	ll le = 1, ri = 100000;
	while( le < ri ) {
		ll mid = (le + ri) >> 1;
		if( mid * mid >= x ) ri = mid;
		else le = mid + 1;
	}
	return (ri * ri == x) ? ri : 0;
}
map<ll, int>mp;
int siz[2*MAXN + 5];
int main() {
	init(); int N;
	scanf("%d", &N);
	int ans = 0, flag = false;
	for(int i=1;i<=N;i++) {
		a[i] = b[i] = 1;
		scanf("%lld", &s[i]);
		for(int j=1;j<=pcnt;j++) {
			int cnt = 0;
			while( s[i] % prm[j] == 0 ) {
				cnt++;
				s[i] /= prm[j];
			}
			cnt %= 3;
			if( cnt == 1 ) {
				a[i] *= prm[j];
				b[i] *= prm[j] * prm[j];
			}
			else if( cnt == 2 ) {
				a[i] *= prm[j] * prm[j];
				b[i] *= prm[j];
			}
		}
		if( IsSqr(s[i]) ) {
			a[i] *= s[i];
			b[i] *= IsSqr(s[i]);
		}
		else {
			a[i] *= s[i];
			b[i] *= s[i] * s[i];
		}
		if( !flag && a[i] == 1 && b[i] == 1 )
			flag = true;
	}
	for(int i=1;i<=N;i++) {
		if( a[i] == 1 && b[i] == 1 ) continue;
		if( mp.count(a[i]) )
			siz[mp[a[i]]]++;
		else {
			mp[a[i]] = i;
			mp[b[i]] = i+N;
			siz[i]++;
		}
	}
	for(int i=1;i<=N;i++) {
		if( mp[a[i]] == i )
			ans += max(siz[i], siz[i+N]);
	}
	if( flag ) ans++;
	printf("%d\n", ans);
}

Measured memory_bytes: 15488
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void){
    char tmp[1000];
    fgets(tmp,sizeof(tmp),stdin);
    int num[3];
    num[0]=atoi(strtok(tmp," "));
    num[1]=atoi(strtok(NULL," "));
    num[2]=atoi(strtok(NULL," "));

    if(num[0]<num[1]&&num[1]<num[2]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector <int> v(n), c(n);
    for (int tsumugi = 0; tsumugi < n; tsumugi++){
        cin >> v[tsumugi];
    }
    for (int matsuri = 0; matsuri < n; matsuri++){
        cin >> c[matsuri];
    }

    int ans = 0;
    for (int karen = 0; karen < n; karen++){
        if (v[karen] > c[karen]){
            ans += v[karen] - c[karen];
        }
    }

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

Measured memory_bytes: 256
/*
*/

//#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 1000;

int n, ar[N];

long long eval(int x)
{
	long long res = 0;
	for (int i = 0; i < n; i++)
	{
		int dif = abs(ar[i] - x);
		res += dif*dif;
	}
	return res;
}

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> ar[i];
	}

	long long ans = 1e18;
	for (int res = -100; res <= 100; res++)
	{
		long long pen = eval(res);
		ans = min(ans, pen);
	}
	cout << ans << endl;

	cin.get(); cin.get();
	return 0;
}

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

void Possible() {
    cout << "Possible";
}

void Impossible() {
    cout << "Impossible";
}

int N;
int mx = 0;
int a[101];

int main(void) {
    cin >> N;
    for(int i = 1; i <= N; i++) {
        int t;
        cin >> t;
        ++a[t];
        mx = max(t, mx);
    }
    int mn = (mx % 2 == 0 ? mx / 2 : (mx + 1) / 2);
    for(int i = 1; i < mn; i++) {
        if(a[i] != 0) {
            Impossible();
            return 0;
        }
    }
    if(((mx & 1) && a[mn] != 2) || (!(mx & 1) && a[mn] != 1)) {
        Impossible();
        return 0;
    }
    for(int i = mn + 1; i <= mx; i++) {
        if(a[i] < 2) {
            Impossible();
            return 0;
        }
    }
    Possible();
    return 0;
}

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

#define MOD 1000000007
long long dp[110][5][5][5];

int main()
{
    long long n;
    cin >> n;
    for(long long i = 0; i < 4; ++i){
        for(long long j = 0; j < 4; ++j){
            for(long long k = 0; k < 4; ++k){
                if(i == 0 && j == 2 && k == 1)continue;
                if(i == 0 && j == 1 && k == 2)continue;
                if(i == 2 && j == 0 && k == 1)continue;
                dp[3][i][j][k] = 1;
            }
        }
    }
    for(long long ln = 4; ln <= n; ++ln){
        for(long long k = 0; k < 4; ++k){
            for(long long j = 0; j < 4; ++j){
                for(long long i = 0; i < 4; ++i){
                    for(long long nw = 0; nw < 4; ++nw){
                        if(nw == 0 && i == 2 && j == 1)continue;
                        if(nw == 0 && i == 1 && j == 2)continue;
                        if(nw == 2 && i == 0 && j == 1)continue;
                        if(nw == 0 && i == 2 && k == 1)continue;
                        if(nw == 0 && j == 2 && k == 1)continue;
                        dp[ln][nw][i][j] += dp[ln - 1][i][j][k] % MOD;
                    }
                }
            }
        }
    }

    long long res = 0;
    for(long long i = 0; i < 4; ++i){
        for(long long j = 0; j < 4; ++j){
            for(long long k = 0; k < 4; ++k){
                res = (res + dp[n][i][j][k]) % MOD;
            }
        }
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
	
	int n, l, left, right, sum=0; cin>>n>>l;
	
	left=l+1-1; right=l+n-1;
	for(int i=1;i<=n;i++) sum+=l+i-1;
	
	if(left*right<=0) cout<<sum;
	else{
		if(l>0) cout<<sum-l;
		else if(l<0) cout<<sum-(l+n-1);
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;
bool isprime(int n){
  if(n<2)return false;
  if(n==2)return true;
  if(n%2==0)return false;
  for(int i=3;i<=(int)sqrt(n);i+=2){
    if(n%i==0)return false;
  }
  return true;
}
int main(){
  int p[50000];
  p[0]=0;
  FOR(i,1,50000){
    p[i]=p[i-1]+(isprime(2*i+1) and isprime(i+1));
  }
  // REP(i,10)cerr<<p[i]<<endl;
  int Q;
  cin>>Q;
  int l[Q],r[Q];
  REP(i,Q)cin>>l[i]>>r[i];
  REP(i,Q)cout<<p[(r[i]-1)/2]-p[max(0,(l[i]-3)/2)]<<endl;
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1<< 30;
int main(){
    int l,r;
    cin >> l >> r;
    int fi,la;
    if(r-l+1>=2019){
        fi = 0;
        la = 2018;
    }else{
        fi = l % 2019;
        la = r % 2019;
        if(la<fi) la+=2019;
    }
    int ans = INF;
    for(int i=fi;i<la;i++){
        for(int j=i+1;j<=la;j++){
            chmin(ans,i*j%2019);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    long X,A,B;

    cin >> X >> A >> B;

    if( B-A <=0 ){
        cout << "delicious" << endl;
    }else if( B-A <= X ){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,d,i,j,n;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(b<=c||d<=a)
	printf("0\n");
	else{
		if(c<a&&b<=d)
		printf("%d\n",b-a);
		else if(b>d&&a<=c)
		printf("%d\n",d-c);
		else{
			if(b-c<d-a)
		    printf("%d\n",b-c);
		    else
		    printf("%d\n",d-a);
		}
	}
	return 0;
}

Measured memory_bytes: 128
//2020.1.9
//s1270188 xxxmk2
//alds1_08d

#include<stdio.h>
#include<stdlib.h>

//struct
struct node{
  int k, p;
  struct node *l, *r;
};
typedef struct node *Node;

//global
Node root=NULL;

//prototype
Node mk_Node(int, int);
Node r_rotate(Node);
Node l_rotate(Node);
Node insert(Node,int, int);
Node find(int,Node);
void pr_pre(Node);
void pr_in(Node);
void del_all(Node);
Node del(Node,int);
Node ddel(Node,int);

//main
int main(){
  int num, i, a, b;
  char com[10];
  
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%s",com);

    if(com[0]=='i'){
      scanf("%d %d",&a,&b);
      insert(root,a,b);
    }

    else if(com[0]=='p') {
      pr_in(root);
      printf("\n");
      pr_pre(root);
      printf("\n");
    }

    else if(com[0]=='f'){
      scanf("%d",&a);
      if(find(a,root)==NULL) printf("no\n");
      else printf("yes\n");
    }

    else if(com[0]=='d'){
      scanf("%d",&a);
      del(root,a);
    }
  }

  
  del_all(root);
  return 0;
}


//function
Node mk_Node(int k, int p){
  Node d;
  d=malloc(sizeof(struct node));
  d->k=k;
  d->p=p;
  return d;
}

Node r_rotate(Node t){
  Node s=t->l;
  t->l=s->r;
  s->r=t;
  if(root==t) root=s;
  return s;
}

Node l_rotate(Node t){
  Node s=t->r;
  t->r=s->l;
  s->l=t;
  if(root==t) root=s;
  return s;
}

Node insert(Node t,int k, int p){
  if(t==NULL){
    t=mk_Node(k,p);
    if(root==NULL) root=t;
    return t;
  } 
  if(k==t->k) return t;

  if(k < t->k){
    t->l=insert(t->l,k,p);
    if(t->p < t->l->p) t=r_rotate(t);
  }
  else{
    t->r=insert(t->r,k,p);
    if(t->p < t->r->p) t=l_rotate(t);
  }

  return t;
}

Node find(int n,Node d){
  if(d->k==n) return d;
  if(d->k>n){
    if(d->l==NULL) return NULL;
    else return find(n,d->l);
  }
  else {
    if(d->r==NULL) return NULL;
    else return find(n,d->r);
  }
}

void pr_pre(Node data){
  printf(" %d",data->k);
  if(data->l!=NULL) pr_pre(data->l);
  if(data->r!=NULL) pr_pre(data->r);
}

void pr_in(Node data){
  if(data->l!=NULL) pr_in(data->l);
  printf(" %d",data->k);
  if(data->r!=NULL) pr_in(data->r);
}

void del_all(Node data){
  if(data->l!=NULL) del_all(data->l);
  if(data->r!=NULL) del_all(data->r);
  free(data);
}

Node del(Node t,int n){
  if(t==NULL) return NULL;
  if(n<t->k) t->l=del(t->l,n);
  else if(n>t->k) t->r=del(t->r,n);
  else return ddel(t,n);
  return t;
}

Node ddel(Node t,int n){
  if(t->l==NULL && t->r==NULL) return NULL;
  else if(t->l==NULL) t=l_rotate(t);
  else if(t->r==NULL) t=r_rotate(t);
  else {
    if(t->l->p > t->r->p) t=r_rotate(t);
    else t=l_rotate(t);
  }
  return del(t,n);
}




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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		double Ad=(double)A;
		int B=sc.nextInt();
		double Bd=(double)B;
		int H=sc.nextInt();
		int M=sc.nextInt();
		sc.close();
		double arg, C;
		arg=(double)H*30.0+(double)M*0.5-(double)M*6.0;
		C=Math.sqrt(Ad*Ad+Bd*Bd-2.0*Ad*Bd*Math.cos(Math.toRadians(arg)));
		System.out.println(C);
	}
}


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    string s;
    getline(cin, s);

    for(int i = 0;s[i] != '\0';i++){
        if('a' <= s[i] && s[i] <= 'z') cout << char(s[i]-('a'-'A'));
        else if('A' <= s[i] && s[i] <= 'Z') cout << char(s[i]+('a'-'A'));
        else cout << s[i];
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3132