akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string.h>
#include<tuple>
#define all(c) c.begin(),c.end()
#define pb push_back
#define em emplace_back
#define ll long long int
#define mp make_pair
#define isro ios_base::sync_with_stdio(false);
#define debug(c) cout<<c<<endl;
#define find(v,x) find(all(v),x)!=v.end()
using namespace std;

typedef vector<ll>vi;
typedef vector<vi>vii;
typedef pair<ll,ll>pi;
typedef tuple<ll,ll,ll>ti;

int MAXN=100;
int MAXW=100;


int main(){
  isro; 
  ll n,k;
  cin>>n>>k;
  vi v(n),cost(n,+1e9);

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

  cost[0]=0;
  for(auto i=0;i<n;i++){
    for(auto j=i+1;j<=i+k and j<n;j++)
      cost[j]=min(cost[j],abs(v[i]-v[j])+cost[i]);                            
  }

  cout<<cost[n-1]<<endl;

}


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

#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()
#define VI         vector<int>
#define MOD 1000000007

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

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 ll INF=(ll)1e19;
//const int INF=(1<<30);

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

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


mint mpow(int x, int n){
  if(n==0)return 1;

  mint y = mpow(x, n/2);
  y *= y;

  if(n%2==1) y *=x;
  return y;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);

mint dp[101][8];

int nn[] = {1,2,3,5,8,13,21,34};


int main(){
  int h,w,k;
  cin >> h >> w >> k;

  if(w==1){
    cout << 1 << endl;
    return 0;
  }

  REP(i,h+1)REP(j,w)dp[i][j]=0;
  dp[0][0]=1;

  FOR(i,1,h+1)REP(j,w){
    if(j==0 || j==w-1){
      dp[i][j] += dp[i-1][j] * nn[w-2];
    }else{
      dp[i][j] += dp[i-1][j] * (nn[j-1] * nn[w-j-2]);
    }
    if(j>0){

      dp[i][j] += dp[i-1][j-1] * (nn[max(0,j-2)] * nn[max(0,w-j-2)]);
    }
    if(j<w-1){
      dp[i][j] += dp[i-1][j+1] * (nn[max(0,j-1)] * nn[max(0,w-j-3)]);
    }
  }

  cout << dp[h][k-1].x << endl;
}



Measured memory_bytes: 3328
#include <iostream>
#include <utility>
#include <set>
#include <algorithm>

typedef long long ll;
typedef std::pair<ll, ll> ii;

ll a[100100];
ll sum[100100];

int ans=0;

int main()
{
	int n;
	std::cin >> n;
	for(int i=1;i<=n;i++)
		std::cin >> a[i];
	std::sort(a+1, a+1+n);
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	for(int i=n;i>0;i--)
	{
		ll cur=sum[i];
		if(2*sum[i]>=a[i+1])
			ans++;
		else
			break;
	}
	std::cout << ans << '\n';
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

    if(B-1 >= N){
        cout << (A*N)/B - (N/B)*A << endl;
    }else{
        ll ans = (N/B) * B + (B-1);
        if (ans > N){
            ans -= B;
        }
        cout << (A*ans)/B - (ans/B)*A << endl;
    }
    return 0;
}

Measured memory_bytes: 3568
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second 
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const int MAX = INT_MAX;

int main() {
	
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> b(n);
	map<int, int>cnt;
	for (int i = 0;i < n;++i) {
		cin>>a[i];
		cnt[a[i]] += 1;
	}

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

	sort(all(b), greater<int>());

	int cntr = 0;
	int l = -1;
	int match = -1;
	vector<ll> mismatches;
	for (int i = 0;i < n;++i) {
		if (a[i] == b[i]) {
			match = a[i];
			if (cnt[a[i]] > n) {
				cout<<"No"<<endl;
				return 0;
			}

			l = i;
			break;
		}
	}


	if (l != -1) {
		for (int i = 0;i < n;++i) {
			if (a[i] != match && b[i] != match) {
				mismatches.pb(i);
			}
		}

		for (int i = l, k = 0;i < n && k < mismatches.size();++i, ++k) {
			if (a[i] == b[i])
				swap(b[i], b[mismatches[k]]);
			else break;
		}
	}

	cout<<"Yes"<<endl;
	for (int i = 0;i < n;++i) cout<<b[i]<<" ";

	return 0;
}


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

#define int long long

int dist[305][305];
int ans[305][305];
const int mex = 1e16 + 5;

signed main(){
    int n, m , full, x, y, z;
    cin >> n >> m >> full;
    
    for(int i = 0; i <= 300; i++){
        for(int j = 0; j <= 300; j++){
            if(i!=j){
                dist[i][j] = mex;
                ans[i][j] = mex;
            }
        }
    }
    
    while(m--){
        cin >> x >> y >> z;
        dist[x][y] = z;
        dist[y][x] = z;
    }
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                    if(dist[j][k] > dist[j][i] + dist[i][k]){
                        dist[j][k] = dist[j][i] + dist[i][k];
                    }
            }
        }
    }
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(dist[i][j] <= full){
                dist[i][j] = 1;
            }
            else{
                dist[i][j] = mex;
            }
        }
    }
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                    if(dist[j][k] > dist[j][i] + dist[i][k]){
                        dist[j][k] = dist[j][i] + dist[i][k];
                    }
            }
        }
    }
    
    
    int q; cin >> q;
    
    while(q--){
        cin >> x >> y;
        if(dist[x][y] == mex){
            cout << "-1\n"; continue;
        }
        
        cout << dist[x][y]-1LL << '\n';
    }
    
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int x, k, d;

signed main() {
	cin >> x >> k >> d;
	x = abs(x);
	int n = min(x / d, k);
	x -= n * d;
	k -= n;
	if (k % 2 == 0) cout << x;
	else cout << -(x - d);
}

Measured memory_bytes: 3672
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

const MOD: usize = 1e9 as usize + 7;

macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        x: i32,
        l: [i32; n],
    }
    let mut dist: i32 = 0;
    let mut ans: i32 = 1;
    for i in l.into_iter(){
        dist = dist + i;
        if dist > x {break;}
        ans += 1;
    }
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<stdio.h>
int main(void)
{
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0){
			break;
		}
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				if(i==1||j==1||i==H||j==W){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int[][] a = new int[n][n];
			for (int i = 0; i < n; i++) {
				int m = sc.nextInt();
				for (int j = 0; j < m; j++) {
					a[i][sc.nextInt() - 1] = 1;
				}
			}

			int[] l = new int[n];
			int k = sc.nextInt();
			for (int i = 0; i < k; i++) {
				l[sc.nextInt() - 1] = 1;
			}

			int ans = -1;
			L: for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (a[i][j] < l[j]) {
						continue L;
					}
				}

				if (ans == -1) {
					ans = i + 1;
				} else {
					ans = -1;
					break;
				}
			}

			System.out.println(ans);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 64776
/* 
 * File:   main.c
 * Author: s1252006
 *
 * Created on June 15, 2018, 11:19 AM
 */

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

void insertionSort(int array[], int length) {
    int key, i;
    for (int j = 1; j < length; j++) {
        key = array[j];
        i = j-1;
        while (i >= 0 && array[i] > key) {
            array[i+1] = array[i];
            i = i-1;
        }
        array[i+1] = key;
        
        
        printf("\n");
        for (int ixArray = 0; ixArray < length; ixArray++) {
            if (ixArray != 0) printf(" ");
            printf("%d", array[ixArray]);
        }
        
    }
}


int main(int argc, char** argv) {
    int length;
    scanf("%d", &length);
    
    const int nxArray = length;
    int array[nxArray];
    for (int ixArray = 0; ixArray < nxArray; ixArray++)
        scanf("%d", &array[ixArray]);

    for (int ixArray = 0; ixArray < nxArray; ixArray++) {
        if (ixArray != 0) printf(" ");
        printf("%d", array[ixArray]);
    }
    
    insertionSort(array, nxArray);
    printf("\n");
    
//    for (int ixArray = 0; ixArray < nxArray; ixArray++) {
//        printf("%d ", array[ixArray]);
//    }
    
    

    return (EXIT_SUCCESS);
}





Measured memory_bytes: 2140
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;


//----------------------------------------------------------------
signed main(){

	string a,b;
	cin >> a >> b;
	ll ans = 0;
	rep(i,3)if(a[i] == b[i])ans++;
	cout << ans << endl;

	
	
	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://abc139.contest.atcoder.jp/tasks/abc139_b

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
size = int(input())
nums = [int(s) for s in input().split()]

count = 0
checked = False

while True:
  for i in range(size):
    t = nums[i]
    if t % 2 == 1:
      checked = True
      break;
    nums[i] = t/2
  if checked:
    break
  count = count + 1

print(count)


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



public class Test
{
	public static void Main( )
	{
		var n = int.Parse( Console.ReadLine().Trim() );
		
		LinkedList<string> dll = new LinkedList<string>();
		
		for( var i=0; i<n; i++ ) {
			string[] s = Console.ReadLine().Trim().Split();
			if( s[0].Equals( "insert" ) ) {
				dll.AddFirst( s[1] );
			} else if( s[0].Equals( "delete" ) ) {
				dll.Remove( s[1] );
			} else if( s[0].Equals( "deleteFirst" ) ) {
				dll.RemoveFirst();
			} else if( s[0].Equals( "deleteLast" ) ) {
				dll.RemoveLast();
			}
		}
		Console.WriteLine( string.Join( " ", dll.ToArray() ) );
		
		return;
	}
}



Measured memory_bytes: 118160
#include <stdio.h>

int main(void);

int main(void)
{
  int a, b;
  
  scanf("%x", &a);
  scanf("%x", &b);
  
  if(a < b){
  	printf("<");
  }
  else if(a > b){
  	printf(">");
  }
  else{
  	printf("=");
  }
  
  return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static List<int> a = new List<int>();

        static void Main(string[] args)
        {
            //[summary]A - ABCxxx
            int n = int.Parse(Console.ReadLine());

            Console.WriteLine("ABC" + n);
        }
    }
}

Measured memory_bytes: 11092
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n =  Integer.parseInt(sc.next());
		List l = new ArrayList<Integer>(n);

		for(int i = 0 ; i < n ; i++) {
			l.add(Integer.parseInt(sc.next()));
		}
		l.sort(Comparator.reverseOrder());
		int ans = 0;
		for (int i = 0 ; i < n ; i++ ) {	
			for (int j = i +1 ; j < n ; j++ ) {	
				for (int k = j +1 ; k < n ; k++ ) {
					int a = (int) l.get(i);
					int b = (int) l.get(j);
					int c = (int) l.get(k);
					if(a < b + c ) {
						ans++;
					}else {
						break;
					}
				}





			}
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 24424
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vl b(n+1, LINF); rep(i,n-1)cin>>b[i+1]; 
    ll ans=0;
    rep(i,n){
        ans += min(b[i],b[i+1]);
    }
    puta(ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    char S[10];
    scanf("%s", &S);
    if(S[0] != S[1]) {
        printf("Yes");
    }
    else if (S[1] != S[2]) {
    	printf("Yes");
	}
    else {
    	printf("No");
	}
    return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

#define ll long long

using namespace std;

int main(){
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC" << endl;
        return 0;
    }
    cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#define int long long
using namespace std;

int mod = 998244353;
int a, b, c, d;
int dp[3001][3001];

int dfs(int h, int w) {
	if (h == a && w == b) return 1;
	if (dp[h][w] != -1) return dp[h][w];
	if (h == a) {
		return dp[h][w] = dfs(h, w - 1) * h % mod;
	}
	if (w == b) {
		return dp[h][w] = dfs(h - 1, w) * w % mod;
	}
	
	int res1 = dfs(h - 1, w) * w + dfs(h, w - 1) * h;
	res1 %= mod;
	int res2 = dfs(h - 1, w - 1) * (w - 1) % mod * (h - 1) % mod;
	return dp[h][w] = (res1 + mod - res2) % mod;
}

signed main() {
	int i, j;
	
	cin >> a >> b >> c >> d;
	for (i = 0; i <= c; i++) for (j = 0; j <= d; j++) dp[i][j] = -1;
	cout << dfs(c, d) << endl;
	return 0;
}

Measured memory_bytes: 74324
#include<bits/stdc++.h>
#define N 200050
#define M 200
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define clr(a) a.clear()
#define ll long long
#define SIZE N
#define MOD mod
using namespace std;
int mod = 1e9 + 7;
int n,k,ar[N];
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>ar[i];
        if(i>=k){
            if(ar[i]>ar[i-k])cout<<"Yes\n";
            else cout<<"No\n";
        }
    }
  	return 0;
}



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



int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	int res=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			res+=(v[i]*v[j]);
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
def find(x):
  if par[x] < 0:
    return x
  else:
    tank = []
    while par[x] >= 0:
      tank.append(x)
      x = par[x]
    for elt in tank:
      par[elt] = x
    return x

def unite(x,y):
  x = find(x)
  y = find(y)
    
  if x == y:
    return False
  else:
    if par[x] > par[y]:
      x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True

def same(x,y):
  return find(x) == find(y)

def size(x):
  return -par[find(x)]

N,M=map(int,input().split())
par = [-1]*N
for _ in range(M):
  a,b=map(int,input().split())
  unite(a-1,b-1)
print(-min(par))

Measured memory_bytes: 14668
#include <iostream>

using namespace std;

template<class T>
bool binary_search(T* xs, int st, int ed, T v){
    //cout << "v = " << v << " ," << st << ' ' << ed << '\n';
    if(ed-st <= 1){
        return xs[st] == v;
    }
    int mid = (st+ed)/2;
    if(xs[mid] > v){
        return binary_search(xs, st, mid, v);
    } else if(xs[mid] < v){
        return binary_search(xs, mid, ed, v);
    } else {
        return true;
    }
}

int main(){
    int n;
    cin >> n;
    int xs[n];
    for(int i = 0; i < n; ++i){
        scanf("%d", &xs[i]);
    }
    int q;
    cin >> q;
    int v = 0;
    int cnt = 0;
    for(int i = 0; i < q; ++i){
        scanf("%d", &v);
        if(binary_search(xs, 0, n, v)){
            ++cnt;
        }
    }
    cout << cnt << '\n';
}

Measured memory_bytes: 1624
#include<stdio.h>
#include<math.h>
#define pi acos(-1)
int main()
{
	double r;
	scanf("%lf",&r);
	double a,b;
	a=2*r*pi;
	b=r*r*pi;
	printf("%lf %lf",b,a);
	printf("\n");
	return 0;
} 


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

const int N = 1e6;
vector<ll> a;
queue<ll> q;
set<ll> s;

void init()
{
    for(ll i = 1; i <= 9; i++) {
        q.push(i);
        a.push_back(i);
    }
    while(!q.empty()) {
        ll u = q.front(); q.pop();
        int itm = u % 10;
        for(int i = max(0, itm - 1); i <= min(9, itm + 1); i++) {
            ll num = u * 10 + i;
            if(num <= 3234566667) {
                a.push_back(num);
                q.push(num);
            }
        }
    }
    sort(a.begin(), a.end());
    //printf("size = %d\n", a.size());
}

void solve()
{
    int k;
    scanf("%d", &k);
    printf("%lld\n", a[k - 1]);
}

int main()
{
    init();
    solve();
    return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <int r>
struct Decimal{
    std::vector<int> digits;
    
    Decimal(int n) : digits(r + 1, 0) { // 1/n
        int rem = 1;
        for(int i=1;i<=r;++i){
            rem *= 10;
            digits[i] = rem / n;
            rem %= n;
        }
    }

    Decimal<r>& operator+=(Decimal<r> &rhs){
        for(int i=r;i>0;--i){
            digits[i] += rhs.digits[i];
            if(digits[i] >= 10){
                digits[i] -= 10;
                digits[i - 1] += 1;
            }
        }

        return *this;
    }
};

constexpr int r = 10100;

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    while(true){
        int N, K, M, R;
        std::cin >> N >> K >> M >> R;

        if(N == 0){
            break;
        }

        Decimal<r> p(N);

        if(M == 1){
            for(int k=1;k<=N-1;++k){
                Decimal<r> d(k * N);
                p += d;
            }
        }

        std::cout << p.digits[0] << ".";
        for(int i=1;i<=R;++i){
            std::cout << p.digits[i];
        }
        std::cout << std::endl;
    }
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define ll long long
#define INF LLONG_MAX 
#define dd double 
#define fi first
#define se second
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define dll deque<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define vvll vector<vector<ll>>
#define vpll vector<pair<long long,long long>>
#define vpcl vector<pair<char,long long>>
#define vpsl vector<pair<string,long long>>
#define stll stack<long long>
#define stc stack<char>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define psl pair<string,long long>
#define mcl map<char,long long>
#define msl map<string,long long>
#define pcl pair<char,long long>
#define mmll multimap<long long,long long> 
#define mmcl multimap<char,long long>
#define mmsl multimap<string,long long>
#define sll set<long long>
#define sc  set<char>
#define ss  set<string>
#define msll multiset<long long>
#define msc  multiset<char>
#define mss  multiset<string>
#define lb lower_bound
#define up upper_bound
#define lt length
#define clr clear
#define ap append
#define sz size
#define sub substr
#define ull unsigned long long int
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int; 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

ll modexp(ll x,ll n,ll p){    //modular exponential function
  if(n==0){return 1;}
  ll u = modexp(x,n/2,p);
  u = u*u%p;
  if(n%2==1){u=(u*x)%p;}
  return u;
}

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

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll t; 
    //cin>>t;
    t=1;
    while(t--){
        ll n,w; cin>>n>>w;
        ll wt[n],v[n];
        ll dp[w+1][n]= {0};
        rep(i,0,n-1){
            cin>>wt[i]>>v[i];
        }
        // cout<<n<<" "<<w<<"\n";
        // rep(i,0,n-1){cout<<wt[i]<<" ";}cout<<"\n";
        // rep(i,0,n-1){cout<<v[i]<<" ";}cout<<"\n";
        rep(i,0,w){
            rep(j,0,n-1){
                if(i==0){dp[i][j]=0;}
                else if(j==0){
                    if(i>=wt[j]){
                        dp[i][j] = v[j];
                    }
                    else{dp[i][j]=0;}
                }
                else{
                    if(i>=wt[j]){
                        dp[i][j] = max(dp[i][j-1],v[j]+dp[i-wt[j]][j-1]);
                    }
                    else{dp[i][j] = dp[i][j-1];}
                }
            }
        }
        cout<<dp[w][n-1];
    }
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
const int mod = 998244353; 
const int N = 3005;
/*The problem can be paraphrased as follows:
How many pairs of sets (T, U) such that both are non-empty subsets of {1, 2, . . . , N} and also satisfies
the conditions below?
1. U is a subset of T
2. Let U = {x1, x2, . . . , xk
}, then ax1 + ax2 + · · · + axk = S
Then, for each i (1 ≤ i ≤ n), there are three options:
1. put to both U and T
2. put to T, but do not put to U
3. do not put to both U and T
and the sum increases by ai only if the first option was chosen.
By the observation above, it can be seen that performing Dynamic Programming with the following
recurrence relations will do:
d p[i][j] = When the choices for the first i options is already determined, the number of combination
such that the sum of ak for each k that the first option was chosen is equal to j
The desired answer is d p[N][S ], and the total time complexity is O(NS ).
Sample Code: https://atcoder.jp/contests/abc169/submissions/13772481
*/
#define int long long

int pow(int a , int b , int m){
	int ans = 1;
	while(b){
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int cache[N][N];
int n , s;
int store[N],a[N];

int dp(int idx , int p){
	if(p<0)
		return 0;
	if(p==0)
		return store[idx];
	if(idx > n)
		return 0;
	int &ans = cache[idx][p];
	if(ans != -1)
		return ans;
	ans = 2 * dp(idx+1,p) + dp(idx+1,p-a[idx]);
	ans%=mod;
	return ans;
}


void test_case(){
	memset(cache,-1,sizeof(cache));
	cin >> n >> s;
	for(int i = 0 ; i <= n + 2;i++)
		store[i] = pow(2,n+1-i,mod);
	for(int i = 1 ; i <= n ; i++)
		cin >> a[i];
	int ans = dp(1,s);
	cout<<ans;
}
 
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 74428
use std::io::stdin;


fn solve(S: &str, prefix: i64) -> i64 {


    if S.len() == 1 {
        let n: i64 = S.parse().unwrap();
        return n +  prefix
    }
    let mut res= 0;
    for i in 1..(S.len()) {
        let nextPrefix: i64 = S[..i].parse().unwrap();
        res += solve(&S[i..], nextPrefix + prefix)
    }
    let ns: i64 = S.parse().unwrap();
    res += ns + prefix;
    return res
}

fn main() {
    let s = {
        let mut s = String::new();
        stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };

    let ans = solve(&s, 0);
    println!("{}", ans)

}


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

int main() {
  string S;
  cin >> S;
  
  for (int i = 0; i < S.size(); i++) {
    if (i%2 == 0){
      if (S.at(i) == 'L'){
        cout << "No" << endl;
        return 0;
      }
    }
    else {
      if (S.at(i) == 'R'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}




Measured memory_bytes: 3600
#include <iostream>
#include <string>
using namespace std;
 
int main() {
	string S;
	cin >> S;

	int cnt = 0;
	char c = S[0];
	for(int i = 1; i < S.size(); i++)
	{
		if(S[i] != c) cnt++;
		c = S[i];
	}

	cout << cnt << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include<bits/stdc++.h>
using ll= long long;
using namespace std;

int main()
{
    int n;
    cin>>n;
    string s = "APPROVED";
    for(int i=0;i<n;i++){
        int temp;
        cin>>temp;
        if(temp%2==0&&temp%3!=0&&temp%5!=0){
            s = "DENIED";
            break;
        }
    }

    cout<<s;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int A, B, C;
  cin >> A >> B >> C;
  
  if(A == B) //AとBが等しければCが異なる．
    cout << C << endl;
  else if(B == C) //BとCが等しければAが異なる．
    cout << A << endl;
  else if (C == A) //CとAが等しければBが異なる
    cout << B << endl;
    
  return 0;
}


Measured memory_bytes: 256
import itertools
h,w,k=map(int,input().split())
li=[]
ans=0
for i in range(h):
    c=input()
    li.append(c)
for n in itertools.product([0,1],repeat=h):
    for m in itertools.product([0,1],repeat=w):
        sharp=0
        for i in range(h):
            if n[i]==1:
                continue
            else:
                for j in range(w):
                    if m[j]==1:
                        continue
                    else:
                        if li[i][j]=="#":
                            sharp+=1
        if sharp==k:
            ans+=1
print(ans)

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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  if(a%3 == 0 || b%3 == 0 || (a+b) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n;
long long l, t;
long long x[maxn];
int dir[maxn];

int read() {
  if (scanf("%d%lld%lld", &n, &l, &t) < 3) {
    return false;
  }
  l *= 2;
  t *= 2;
  for (int i = 0; i < n; i++) {
    scanf("%lld%d", &x[i], &dir[i]);
    x[i] *= 2;
    dir[i] %= 2;
  }
  return true;
}

long long nx[maxn];
long long res[maxn];

void solve() {
  int id = 0;
  for (int i = 1; i < n; i++) {
    if (dir[i] == dir[0]) {
      continue;
    }
    long long t0;
    if (dir[0]) {
      t0 = ((x[i] - x[0] + l) % l) / 2;
    } else {
      t0 = ((x[0] - x[i] + l) % l) / 2;
    }
    if (t0 > t) {
      continue;
    }
    int cnt = (1 + (t - t0) / (l / 2)) % n;
    if (!dir[0]) {
      cnt = (n - cnt) % n;
    }
    id = (id + cnt) % n;
  }
  for (int i = 0; i < n; i++) {
    nx[i] = ((x[i] + t * (2 * dir[i] - 1)) % l + l) % l;
  }
  long long x0 = nx[0];
  sort(nx, nx + n);
  int pos = (dir[0] ? -inf : inf);
  for (int i = 0; i < n; i++) {
    if (nx[i] == x0) {
      if (dir[0]) {
        pos = max(pos, i);
      } else {
        pos = min(pos, i);
      }
    }
  }
  for (int it = 0; it < n; it++) {
    res[id] = nx[pos];
    pos = (pos + 1) % n;
    id = (id + 1) % n;
  }
  for (int i = 0; i < n; i++) {
    printf("%lld\n", res[i] / 2);
  }
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 3968
n,m = map(int,input().split())
key = [i+1 for i in range(n)]
lmax = 0
rmin = 10**5
for i in range(m):
  l,r = map(int,input().split())
  lmax = max(l,lmax)
  rmin = min(r,rmin)

num = rmin-lmax+1
print(num if num>0 else 0)

Measured memory_bytes: 7088
n = gets.to_i
points = gets.split.map(&:to_i)

while true
  points.sort!
  min = points.first
  points = points.map.with_index { |point, i| i.zero? ? min : point % min }
  points = points.select { |point| !point.zero? }
  break if points.uniq.size == 1
end

puts points.first


Measured memory_bytes: 23144
import java.util.*;

public class Main {
	private static int w, h;
	private static char[][] grid;
	private static int count;
	private static boolean valid;

	private static void dfs(int x, int y, int len) {
		if (x == w-1 && y == h-1) {
			if (len == count) valid = true;
			return;
		}
		if (x < w-1 && grid[y][x+1] == '#') {
			dfs(x+1, y, len + 1);
		}
		if (y < h-1 && grid[y+1][x] == '#') {
			dfs(x, y+1, len + 1);
		}
	}

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		h = input.nextInt();
		w = input.nextInt();
		input.nextLine();
		grid = new char[h][];
		for (int y = 0; y < h; y++) {
			grid[y] = input.nextLine().toCharArray();
			for (int x = 0; x < w; x++) {
				if (grid[y][x] == '#') count++;
			}
		}
		if (grid[0][0] != '#') {
			System.out.println("Impossible");
			return;
		}
		valid = false;
		dfs(0, 0, 1);
		System.out.println(valid ? "Possible" : "Impossible");
	}
}


Measured memory_bytes: 10060
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    x, y, a, b, c = map(int, input().split())
    P = sorted(list(map(int, input().split())), reverse=True)
    Q = sorted(list(map(int, input().split())), reverse=True)
    R = sorted(list(map(int, input().split())), reverse=True)
    Apples = sorted(P[:x] + Q[:y] + R, reverse=True)
    print(sum(Apples[: x + y]))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 29124
M, D = map(int, input().split())

ans = 0
for m in range(1, M + 1):
    for d in range(10, D + 1):
        d1 = int(str(d)[0])
        d2 = int(str(d)[1])
        if m == d1 * d2 and d1 > 1 and d2 > 1:
            ans += 1

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

#define MAX 200

int main(void)
{
    int i, j;

    char in[MAX], out[MAX];
    while (1) {
        scanf("%s", in);
        int in_len = (int)strlen(in);

        if (strcmp(in, "-") == 0) {
            break;
        } else {
            int shuffle_num;
            scanf("%d", &shuffle_num);

            for (i = 1; i <= shuffle_num; i++) {
                int cards_num;
                scanf("%d", &cards_num);

                for (j = 0; j < in_len - cards_num; j++) {
                    out[j] = in[cards_num + j];
                }
                for (j = in_len - cards_num; j < in_len ; j++) {
                    out[j] = in[j - in_len + cards_num];
                }

                for (j = 0; j < in_len; j++) {
                    in[j] = out[j];
                }
            }
            out[in_len] = '\0';

            printf("%s\n", out);
        }
    }

    return 0;
}

Measured memory_bytes: 584
H,W = map(int,input().split())
while not (H == 0 and W == 0):
    for i in range(H):
        if i%2 == 0:
            if W%2 == 0:
                print('#.'*(W//2))
            else:
                print('#.'*(W//2)+'#')
        else:
            if W%2 == 0:
                print('.#'*(W//2))
            else:
                print('.#'*(W//2)+'.')
    print('')
    H,W = map(int,input().split())



Measured memory_bytes: 5608
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

typedef struct {
	int t;
	int x;
	int y;
} datum;

bool cmp_t(const datum &left, const datum &right) {
	return left.t < right.t;
}

int main()
{
	string s;
	cin >> s;
	int count = 0;
	int length = s.size();
	if (length % 2 == 0) {
		for (int i = 0; i < length/2 ; i++) {
			if (s[i] != s[length - 1 - i]) count++;
		}
	}
	else {
		for (int i = 0; i < (length-1) / 2; i++) {
			if (s[i] != s[length - 1 - i]) count++;
		}
	}
	cout << count << endl;
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
string k[] = {"dream","dreamer","erase","eraser"};
int mem[100005];
bool works(int id){
    if (id == s.size()) return true;
    else if (mem[id] != -1) return mem[id];
    else{
        for (int i = 0; i < 4; i++){
            bool matches = true;
            for (int j = 0; j < k[i].size(); j++){
                if (id+j >= s.size() || s[id+j] != k[i][j]) {matches = false; break;}
            }
            if (matches && works(id+k[i].size())) return mem[id] =true;
        }
        return mem[id] = false;
    }
}
int main(){
    memset(mem,-1,sizeof(mem));
    cin >> s;
    printf("%s",works(0)?"YES":"NO");
}


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

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

  int cnt = 0;
  bool flag = true;
  for (char c : w) {
    for (int i = 0; i < w.length(); i++) {
      if (c == w[i]) cnt++;
    }

    if (cnt % 2 != 0) {
      flag = false;
      break;
    }
  }

  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
from collections import defaultdict

d = defaultdict(int)

n = int(input())
a = [int(i) for i in input().split(" ")]
q = int(input())

operations = []

for i in range(q):
    temp = input().split(" ")
    operations.append((int(temp[0]), int(temp[1])))

for hoge in a:
    d[hoge] += 1

initial_sum = 0
for key, value in d.items():
    initial_sum += key * value

for op in operations:
    target, goto = op

    before = goto * d[goto] + target * d[target]
    d[goto] += d[target]
    d[target] = 0

    after = goto * d[goto]
    diff = after - before
    
    initial_sum += diff
    print(initial_sum)
    


Measured memory_bytes: 35564
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 1e3;

int main()
{
	int a,b,c,p,vis;
	while(~scanf("%d %d %d",&a,&b,&c))
	{
		if(c==0) 
		{
			printf("YES\n");
			continue;
		}
		if(b==1) 
		{
			printf("NO\n");
			continue;
		}
		if(a==1)
		{
			printf("YES\n");
			continue;
		}
		p = a;
		vis = 0;
		while(p)
		{
			if(p==c) vis = 1;
			p %= b;
			if(p==c) vis = 1;
			p += a%b;
			p %= b;
			if(p==c) vis = 1;
		}
		if(vis == 1) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

int main() {
  char c;
  cin >> c;
  
  string vowel = "aeiou";
    
  if(vowel.find(c) < 5){
    cout << "vowel" << endl;
  }
    
  else{
  	cout << "consonant" << endl;
  }
    
}


Measured memory_bytes: 256
def solve(string):
    *nkrsp, t = string.split()
    t = list(t)
    n, k, *rsp = map(int, nkrsp)
    b = {k: v for k, v in zip("spr", rsp)}
    ans = sum([b[k] for k in t[:k]])
    for i, _t in enumerate(t[k:]):
        if _t == t[i]:
            t[i + k] = "x"
        else:
            ans += b[_t]
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 5492
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int x; cin >> x;
	const int bound = 262143; // (4^9-1)
	int cnt = 0;
	for( int i = 0; i <= bound; ++i ){
		ll res = 0;
		int flag = 1;
		int itmp = i;
		int gs[4] = {0, 0, 0, 0};
		for( int j = 0; j < 9; ++j ){
			int k = itmp % 4;
			++gs[k];
			itmp -= k; itmp /= 4;
			// 右から見ていったときに 0 の次にさらに一度でも 0 以外が出ていたら候補から外すようにする
			if( k == 0 && flag == 1 ){
				flag = 2;
			}
			if( k != 0 && flag == 2 ){
				flag = 0;
				break;
			}
			if( k == 1 ) k = 3;
			else if ( k == 2 ) k = 5;
			else if( k == 3 ) k = 7;
			res += k * pow(10, j);
		}
		if( flag && gs[1] != 0 && gs[2] != 0 && gs[3] != 0 && res <= x ){
			++cnt;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	string S;
	cin >> S;
	for (int B = 0; B < 16; ++B) {
		string T;
		if (B & 1) {
			T.push_back('A');
		}
		T.append("KIH");

		if (B & 2) {
			T.push_back('A');
		}
		T.append("B");

		if (B & 4) {
			T.push_back('A');
		}
		T.append("R");

		if (B & 8) {
			T.push_back('A');
		}

		if (S == T) {
			cout << "YES\n";
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main() {
	int n, sum;
	cin >> n >> sum;
	for (int x = 0; x <= n; x++) {
		for (int y = 0; y <= n; y++) {
			int z = n - x - y;
			if(z < 0) continue;
			if(x + y + z == n && 10000 * x + 5000 * y + 1000 * z == sum) {
				cout << x << " " << y << " " << z << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll S;
    cin >> S;
    ll n = sqrt(S);
    if(n*n<S) ++n;
    ll xy = n*n - S;
    ll m = 1;
    for(ll d=sqrt(xy); d>=1; --d){
        if(xy%d==0){
            m = d;
            break;
        }
    }
    ll x = m;
    ll y = xy / m;
    cout << "0 0 " << x << " " << n << " " << n << " " << y << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rap(i,a,b) for(int i=b;i>=a;i--)
using namespace std;
typedef long long ll;
int main()
{    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
     ll x,y;
     cin>>x>>y;
     if(x%y==0)
     {  cout<<"-1"<<endl;
	 }
	 else
	 {  cout<<x<<endl;
	 }
	 return 0;
}


Measured memory_bytes: 256
import Data.List
import Control.Monad

type Card = (String,Int)

main = do
  n <- readLn
  ss <- replicateM n getLine
  mapM_ (putStrLn . toString) . solve . map (toCards . words) $ ss

toString :: Card -> String
toString (t,n) = t ++ " " ++ show n

toCards :: [String] -> Card
toCards [t,n] = (t,read n) 

thirteenS :: String -> [String]
thirteenS = replicate 13

pattern :: [String]
pattern = (concat [thirteenS "S",thirteenS "H",thirteenS "C",thirteenS "D"])

numbers :: [Int]
numbers = (concat . replicate 4 $ [1..13])

makeCards :: [(String,Int)]
makeCards = zip pattern numbers

solve :: [Card] -> [Card]
solve cards = makeCards \\ cards

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

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

    int n, y;
    cin >> n >> y;

    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= n - i; ++j) {
            int k = n - (i + j);
            if(y == i*10000+j*5000+k*1000) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 3664
import functools

n = int(input())
while(n):
    bottom_record = [0]*(n+1)

    for i in range(0, n):
        l = list(map(int, input().split()))
        l.append(functools.reduce(lambda x, y: x + y, l))
        bottom_record = [x + y for(x,y) in zip(bottom_record, l)]
        print(''.join(map('{0:5d}'.format, l))) 
    print(''.join(map('{0:5d}'.format, bottom_record)))
    n = int(input())

Measured memory_bytes: 8120