akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(),  s.end());
    vector<int> cnt(2019);
    int x = 1;
    int tot = 0;
    long long ans = 0;
    for(int i=0; i<n; i++){
        cnt[tot]++;
        tot += (s[i] - '0') * x;
        tot %= 2019;
        ans += cnt[tot];
        x = x*10%2019;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
  std::cin >> x>>y;
  std::vector<string> v(x);
  rep(i,x)std::cin >> v[i];
  rep(i,x){
    Rep(j,y){
      if(v[i][j]=='#')continue;
      if(i==0&&j==0){
        if(x>1)if(v[1][0]=='#')n++;
        if(x>1&&y>1)if(v[1][1]=='#')n++;
        if(y>1)if(v[0][1]=='#')n++;
      }else if(i==0&&j==y-1){
        if(y>2)if(v[0][y-2]=='#')n++;
        if(x>1&&y>2)if(v[1][y-2]=='#')n++;
        if(x>1&&y>1)if(v[1][y-1]=='#')n++;
      }else if(i==0){
        if(y>1)if(v[0][j-1]=='#')n++;
        if(y>1)if(v[0][j+1]=='#')n++;
        if(x>1&&y>1)if(v[1][j-1]=='#')n++;
        if(x>1)if(v[1][j]=='#')n++;
        if(x>1&&y>1)if(v[1][j+1]=='#')n++;
      }else if(i==x-1&&j==0){
        if(x>1)if(v[i-1][0]=='#')n++;
        if(x>1&&y>1)if(v[i-1][1]=='#')n++;
        if(y>1)if(v[i][1]=='#')n++;
      }else if(j==0){
        if(y>1)if(v[i][1]=='#')n++;
        if(x>1&&y>1)if(v[i-1][1]=='#')n++;
        if(x>1)if(v[i-1][0]=='#')n++;
        if(x>1&&y>1)if(v[i+1][1]=='#')n++;
        if(x>1)if(v[i+1][0]=='#')n++;
      }else if(i==x-1&&j==y-1){
        if(x>2&&y>1)if(v[x-2][y-1]=='#')n++;
        if(x>2&&y>2)if(v[x-2][y-2]=='#')n++;
        if(x>1&&y>2)if(v[x-1][y-2]=='#')n++;
      }else if(i==x-1){
        if(x>1)if(v[i-1][j]=='#')n++;
        if(x>1&&y>1)if(v[i-1][j-1]=='#')n++;
        if(y>1)if(v[i][j-1]=='#')n++;
        if(x>1&&y>1)if(v[i-1][j+1]=='#')n++;
        if(y>1)if(v[i][j+1]=='#')n++;
      }else if(j==y-1){
        if(y>1)if(v[i][j-1]=='#')n++;
        if(x>1)if(v[i-1][j]=='#')n++;
        if(x>1&&y>1)if(v[i-1][j-1]=='#')n++;
        if(x>1)if(v[i+1][j]=='#')n++;
        if(x>1&&y>1)if(v[i+1][j-1]=='#')n++;
      }else{
        if(v[i-1][j-1]=='#')n++;
        if(v[i-1][j]=='#')n++;
        if(v[i-1][j+1]=='#')n++;
        if(v[i][j-1]=='#')n++;
        if(v[i][j+1]=='#')n++;
        if(v[i+1][j-1]=='#')n++;
        if(v[i+1][j]=='#')n++;
        if(v[i+1][j+1]=='#')n++;
      }
      v[i][j] = char('0'+n);
      n=0;
    }
  }
  rep(i,x)std::cout << v[i] << '\n';
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n):
    k = i + 1
    for j in range(i + 1, n):
        while k + 1 < n and l[k + 1] < l[i] + l[j]:
            k += 1
        cnt += k - j
print(cnt)

Measured memory_bytes: 3188
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
using namespace std;

const int N = 110;
double sum;
int a[N];
int n;

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

	sum = (int)(sum/n+0.5);
	long long res = 0;
	for (int i = 0; i < n; i++) {
		res += (a[i] - sum)*(a[i] - sum);
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
N=int(input())
k=0
tmp=1
ans=0
for n in range(3,N+1,2):
    for i in range(2, n + 1):
        while n % i == 0:
            n //= i
            k += 1
        tmp *= k+1
        k = 0
    if tmp==8:
        ans+=1
    tmp=1
print(ans)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

import sys
import os

A, B, C = map(int, input().split())
last_list = sorted([A, B, C])

swap_num = 0
while True:
    if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        break

    A_temp = B // 2 + C // 2
    B_temp = A // 2 + C // 2
    C_temp = A // 2 + B // 2

    A = A_temp
    B = B_temp
    C = C_temp

    swap_num += 1

    current_list = sorted([A, B, C])
    if last_list == current_list:
        print(-1)
        exit()
print(swap_num)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    vector<vector<ll>> x(n,vector<ll>(3));
    REP(i,n){
        REP(j,3){
            cin >> x[i][j];
        }
    }
    ll ans=0;
    REP(i,1<<3){
        vector<ll> p(n);
        REP(j,n){
            ll res=0;
            REP(k,3){
                res+=x[j][k]*(i&(1<<k)?1:-1);
            }
            p[j]=res;
        }
        sort(ALL(p));
        reverse(ALL(p));
        ll sum=0;
        REP(j,m){
            sum+=p[j];
        }
        chmax(ans,sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3716
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (6006)
ll n, mod, dp[MAXN][MAXN*2], ofs=6000, f=1, inv[MAXN];
int main(){
	auto qexp=[&](ll x,ll e){ll sum=1;for(;e;e>>=1,x*=x,x%=mod)if(e&1)sum*=x,sum%=mod;return sum;};
	FAST
	cin>>n>>mod;
	n *= 3;
	FOR(i,2,n)f*=i,f%=mod;
	FOR(i,0,MAXN-1)inv[i]=qexp(i,mod-2);
	// dp (numbers put, 1s - 2s (-n, to n))
	dp[0][0+ofs]=f;
	FOR(i,1,n)FOR(j,-n,n){
		if(i>=3)dp[i][j+ofs]=dp[i-3][j+ofs]*inv[i]%mod;
		if(i>=2)dp[i][j+ofs]+=dp[i-2][j+1+ofs]*inv[i]%mod;
		if(i>=1)dp[i][j+ofs]+=dp[i-1][j-1+ofs]*inv[i]%mod;
		dp[i][j+ofs]%=mod;
		// cerr<<i<<" "<<j<<": "<<dp[i][j+ofs]<<'\n';
	}
	ll ans = 0;
	FOR(i,0,n){
		ans+=dp[n][i+ofs]%mod,ans%=mod;
	}
	cout<<ans<<'\n';
}


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

int main(){
    int N;
    cin>>N;
    int n = N/100;
    bool flag = false;
    if(N%10==7){
        flag = true;
    }else if(N/100==7){
        flag = true;
    }else if((N-100*n)/10==7){
        flag = true;
    }
    
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3620
N=int(input())
list=list(map(int,input().split()))
sum=sum(list)
cnt=0
for i in range(N):
    cnt+=list[i]
    if cnt >=sum/2:
        sa=sum-cnt
        kotae=cnt-sa
        cnt=cnt-list[i]
        sa=sum-cnt
        kotae2=sa-cnt
        if kotae < kotae2:
            print(kotae)
        else:
            print(kotae2)
        break


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
template<typename T> void print(T t) {cout << t << endl;}

int main() {
	string S; 
	cin >> S;
	ll ans = 0, prev=0;
	for (size_t i = 0; i < S.size(); i++) {
		if (S[i] == 'B') prev++;
		else ans += prev;
	}
	print(ans);
}

Measured memory_bytes: 3752
#include <iostream>
#include <vector>

using namespace std;


int main()
{

    int N, A, B;

    cin>>N;
    cin>>A>>B;

    vector<int>P;
    P.resize(N);
    for(int i=0; i<N; ++i)
        cin>>P[i];

    int num1=0;
    int num2=0;
    int num3=0;
    for(int i=0; i<N; ++i)
    {
        if(P[i]<=A)
            num1++;
        else if(A+1<=P[i] && P[i]<=B)
            num2++;
        else
            num3++;
    }

    cout<<min(min(num1, num2), num3)<<endl;

    return 0;
}


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

int main(){
    int n; cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    sort(v.rbegin(), v.rend());
    stack<double> s;
    for(int i = 0; i < n; i++) s.push(v[i]);
    while(s.size() != 1) {
        double x = s.top(); s.pop();
        double y = s.top(); s.pop();
        s.push((x+y)/2);
    }
    cout << s.top() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  bool flg = false;
  rep(i,S.size()-1){
    if(S[i]=='A' && S[i+1]=='C') flg = true;
  }

  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}



Measured memory_bytes: 764
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s1 = scan.next();
		String s2 = scan.next();
		String s3 = scan.next();
		s1 = s1.toUpperCase();
		s2 = s2.toUpperCase();
		s3 = s3.toUpperCase();
		char[] c = new char[3];
		c[0] = s1.charAt(0);
		c[1] = s2.charAt(0);
		c[2] = s3.charAt(0);
		String s4 = new String(c);
		System.out.println(s4);
	}
}


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

int main() {
long long int n;
cin>>n;
long long int res=n/500;
long long int rem=n-res*500;
long long int ret=rem/5;
long long int ans=res*1000+5*ret;
cout<<ans<<endl;


return 0;
}

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

using namespace std;

int main()
{
  long a, ans = 0;
  cin >> a;
  while(a != 0)
  {
    if (a % 10 == 7)
    {
      cout << "Yes" << endl;
      ans += 1;
      break;
    }
    a /= 10;
  }
  if (ans == 0)
  {
    cout << "No" << endl;
  }
}


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

int main() {
	int a, b, c, k, ans;
	cin >> a >> b >> c >> k;
	if (a >= k) {
		cout << k << endl;
	}
	else if (a + b >= k) {
		cout << a << endl;
	}
	else {
		cout << a - (k - a - b) << endl;
	}

	return 0;
}

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

int main() {
  int x, a, b;
  cin >> x;
  cin >> a;
  cin >> b;
  cout << (x - a) - (x - a) / b * b << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

#define loop(i,first,end) for(int i=(first);i<(end);i++)
#define uint unsigned int
#define ull unsigned long long
#define ll long long
#define vint vector<int>
#define vuint vector<unsigned int>
#define vull vector<ull>
#define vll vector<ll>
#define init(type,var) type var;cin>>var;
#define vinit(vtype,var,n) vtype var(n);loop(i,0,n)cin>>var[i];

const ull MOD = 1000000007ULL;
const ull INF = (ull)(-1LL);

int main(void){
	init(int, k);
	init(int, x);

	loop(i, x - k + 1, x + k)cout << i << ' ';

	return 0;
}

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

int main() {
    int n,m;cin >> n >> m;
    vector<int> a(m);
    vector<long long int> b(n);
    int cnt;cnt = 0;
    if(m!=0){
        for(int i=0;i<m;i++){
        cin >> a[i];
        }
    }
    
    if(m!=0){
        if(a[0] == 1){
            cnt++;
            b[0] = 0;
        }else{
            b[0] = 1;
        }
        if(a[cnt] == 2){
            cnt++;
            b[1] = 0;
        }else{
            if(b[0] == 0){
                b[1] = 1;
            }else{
                b[1] = 2;
            }
        }
    }else{
        b[0] = 1;
        b[1] = 2;
    }

    for(int k=2;k<n;k++){
        if(m!=0){
            if(a[cnt] == k+1){
                cnt++;
                b[k] = 0;
            }else{
                b[k] = (b[k-2] + b[k-1]) % 1000000007;
            }
        }else{
            b[k] = (b[k-2] + b[k-1]) % 1000000007;
        }
    }

    cout << b[n-1] % 1000000007  << endl;
}

Measured memory_bytes: 1408
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;
// 最大公約数求める関数
int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



int main(){
int N;cin >> N;
 vector<tuple<string,int, int>> p(N);
  for (int i = 0; i < N; i++) {
    string a;
	int b;
    cin >> a >> b;
    p.at(i) = make_tuple(a,-b,i+1);  
  }
  sort(p.begin(),p.end());
 rep(i,N){
	  cout << get<2>(p[i]) << endl;
  }
  }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            double T = in.nextInt();
            int X = in.nextInt();
            System.out.format("%.9f", T / X);
            System.out.println();
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod=1e9+7;
const int inf = (1<<30);
string toBin(ll a);
void printMat(int arr[], int n);
void printMat(vector<int> arr, int n);
void printMat(vector<vector<int> > arr, int n, int m);
void printMat(vector<int> arr[], int n);
//void printMat(int arr[][], int n, int m);

void solve(){
	string s;
	cin>>s;
	cout<<(s.substr(0, 3))<<endl;
}

int main()
{
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}
string toBin(ll a){
	string s="";
	while(a>0){
		if(a&1){
			s="1"+s;
		}else{
			s="0"+s;
		}
		a>>=1;
	}
	return s;
}
void printMat(int arr[], int n){
	for(int i=0;i<n;i++){
		cout<<arr[i]<<" ";
	}cout<<endl;
}
void printMat(vector<int> arr, int n){
	for(int i=0;i<n;i++){
		cout<<arr[i]<<" ";
	}cout<<endl;
}
void printMat(vector<int> arr[], int row, int col){
	for(int i=0;i<row;i++){
		for(int j=0;j<col;j++){
			cout<<arr[i][j]<<" ";
		}cout<<endl;
	}cout<<endl;
}
void printMat(vector<vector<int> > arr, int row, int col){
	for(int i=0;i<row;i++){
		for(int j=0;j<col;j++){
			cout<<arr[i][j]<<" ";
		}cout<<endl;
	}cout<<endl;
}

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

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

    if (S == "AAA" || S == "BBB") _PR("No");
    else _PR("Yes");

    return 0;
}

/*



*/

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int a = sc.nextInt();
        if (a == 1) {
            System.out.println("Hello World");
            return;
        }
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(b + c);
    }
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    long long m;
    cin >> n >> m;
    vector<int> a(n);
    int MX = 2e5 + 9;
    vector<int> aCnt(MX);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        aCnt[a[i]]++;
    }
    sort(a.begin(), a.end());
    vector<long long> pref(n+1);
    for (int i = 0; i < n; i++) {
        pref[i+1] = pref[i] + a[i];
    }
    auto getSum = [&] (int l, int r) {
        return pref[r+1] - pref[l];
    };
    auto calc = [&](int mn) -> pair<bool, long long> {
        auto tot = 0ll;
        auto cnt = 0ll;
        auto exact = 0ll;
        int j = n;
        for (int i = 0; i < n; i++) {
            int needExact = mn - a[i];
            if (needExact >= 0) {
                exact += aCnt[needExact];
            }
            while (j > 0 && a[j-1] + a[i] > mn) {
                j--;
            }
            if (j < n) {
                long long c = n-j;
                tot += c*a[i] + getSum(j, n-1);
                cnt += c;
            }
        }
        if (cnt > m) {
            return {false, tot};
        }
        auto take = min(exact, m-cnt);
        tot += take*mn;
        return {true, tot};
    };
    int l = 0, r = MX - 1;
    auto ans = 0ll;
    while (l < r) {
        auto mid = (l+r)/2;
        auto pr = calc(mid);
        if (pr.first) {
            r = mid;
            ans = pr.second;
        } else {
            l = mid+1;
        }
    }
    cout << ans << endl;
}



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

int c[27];
int s[366][27];
int t[366];

int last_day(int d,int type){
    int lday=0;
    for(int i=1;i<=d;i++){
        if(t[i]==type) lday=i;
    }
    
    return lday;
}

int dissatisfied(int d){
    int dis=0;
    for(int j=1;j<=26;j++){
        dis+=c[j]*(d-last_day(d,j));
    }
    return dis;
}


int solve(int d){
    int res=0;
    for(int i=1;i<=d;i++){
        res=res+s[i][t[i]]-dissatisfied(i);
    }
    return res;
}
 
 
int main(void){
    int D;cin>>D;
    
    for(int i=1;i<=26;i++){
        cin>>c[i];
    }
    
    for(int i=1;i<=D;i++){
        for(int j=1;j<=26;j++){
            cin>>s[i][j];
        }
    }
    
    for(int i=1;i<=D;i++){
        cin>>t[i];
    }
    
    for(int i=1;i<=D;i++){
        cout<<solve(i)<<endl;
    }
    
    return 0;
    
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N;
    cin >> N;
    VI V(N);
    REP(i, N) cin >> V[i];
    int idx = 0, b = 0;
    ll ans = 0;
    REP(i, N) {
        while (V[i] & b) {
            b ^= V[idx];
            idx++;
        }
        b ^= V[i];
        ans += i - idx + 1;
    }
    cout << ans << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int>V(N);
    for (int i = 0; i < N; ++i) {
      cin >> V[i];
    }
    vector<int>C(N);
    for (int i = 0; i < N; ++i) {
      cin >> C[i];
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if(V[i] > C[i]){
            ans = ans + V[i] - C[i];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
n,W = map(int, input().split())
w = []
v = []
for i in range(n):
    a,b = map(int, input().split())
    w.append(a)
    v.append(b)

c = [[0 for j in range(W)] for i in range(n)]
for i in range(W):
    if i+1 < w[0]:
        c[0][i] = 0
    else:
        c[0][i] = v[0]

for i in range(1,n):
    for j in range(W):
        if j+1 < w[i]:
            c[i][j] = c[i-1][j]
        else:
            diff = (j+1)-w[i]
            if diff > 0:
                c[i][j] = max(c[i-1][j], v[i]+c[i-1][diff-1])
            else:
                c[i][j] = max(c[i-1][j], v[i])
print(max(c[-1]))


Measured memory_bytes: 171656
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

	ll r, d, x;
	cin>>r>>d>>x;
	for(int i=0;i<10;i++){
		x = r*x - d;
		cout<<x<<"\n";
	}
	return 0;
}


Measured memory_bytes: 256
abck = list(map(int, input().split()))

def picknum(res, num_abc):
    if res < num_abc:
        return res
    else:
        return num_abc

nums = []
res = abck.pop()
for el in abck:
    if res > 0:
        num = picknum(res, el)
    else:
        num = 0
    nums.append(num)
    res = res - num

total = nums[0] - nums[2]
print(total)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
int group(int n){
  if(n==2) return 3;
  if(n==4 || n==6 || n==9 || n==11) return 2;
  else return 1;
}
int main(){
  int x,y;
  cin >> x >> y;
  if(group(x)==group(y)){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}
  
  
  

  



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<double> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}sort(A.begin(), A.end());
	for (int i = 1; i < N; i++) {
		A[i] = (A[i - 1] + A[i]) / 2;
	}
	cout << A[N - 1];
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int inf = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	int A;
	ll count = 0;
	ll ans = 0;
	rep(i, N) {
		cin >> A;
		count += A;
		if (A == 0) {
			ans += count / 2;
			count = 0;
		}
	}
	ans += count / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, ll> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll dp[44][444][444];

int main(void){
	int n,i,ma,mb,a,b,x,y;
	ll c,ans=INFLL;
	fill(dp[0][0],dp[44][0],INFLL);
	dp[0][0][0] = 0ll;
	cin >> n >> ma >> mb;
	for(i=0; i<n; ++i){
		cin >> a >> b >> c;
		for(x=0; x<=400; ++x){
			for(y=0; y<=400; ++y){
				dp[i+1][x][y] = min(dp[i+1][x][y],dp[i][x][y]);
				dp[i+1][x+a][y+b] = min(dp[i+1][x+a][y+b],dp[i][x][y]+c);
			}
		}
	}
	for(x=1; x<=400; ++x){
		for(y=1; y<=400; ++y){
			if(x*mb != y*ma){
				continue;
			}
			ans = min(ans,dp[n][x][y]);
		}
	}
	cout << ((ans==INFLL)?(-1):ans) << endl;
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  int n;
  n = S.size();
  for (int i = 1; i < n; i++) {
    if (S[i] == S[i-1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}

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

int main() {
  int n,m,sum,p;
  p=0;
  sum=0;
  cin >> n >> m;
  vector<int> a(n);
  
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum += a[i];
  }
  
  for(int i=0;i<n;i++){
    if(a[i]*4*m >= sum){
      p ++;
    }
  }
  
  if(p>=m)cout << "Yes" <<endl;
  else cout << "No" <<endl;
       
  
  
  
}


Measured memory_bytes: 256
from collections import deque

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

root = [[] for i in range(n)]
for _ in range(m):
    a, b = (int(x) for x in input().split())
    root[b-1].append(a-1)
    root[a-1].append(b-1) 

stack=deque([0])
check = [-1]*n
check[0] = 0

while len(stack)>0:
    v = stack.popleft()
    for i in root[v]:
        if check[i] == -1:
            check[i]=v+1
            stack.append(i)
if -1 in check:
    print('No')
else:
    print('Yes')
    for i in range(1,n):
        print(check[i])

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

int main(void){
  int n, i, house, max = INT_MIN, min = INT_MAX;
  cin >> n;

  for(i = 0; i < n; i++){
    cin >> house;
    if(house < min) min = house;
    if(house > max) max = house;
  }

  cout << max - min << endl;
  return 0;
}


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

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
typedef long long ll;
inline void Fail(){printf("0");exit(0);}

const int maxn=305;
int n,lim,ans;
char c[maxn];
string s;
int dp[maxn][maxn][maxn];

int main(){
	scanf("%s%d",c,&lim);
	s=c;n=s.size();
	REP(len,n)rep(i,n)rep(k,lim+1){
		int j=i+len-1;
		if(j>=n)break;
		if(s[i]==s[j])dp[i][j][k]=(len>=3?dp[i+1][j-1][k]:0)+(i==j?1:2);
		if(i<n-1)dp[i][j][k]=max(dp[i][j][k],dp[i+1][j][k]);
		if(j-1>0)dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
		if(s[i]!=s[j]&&k)
		dp[i][j][k]=max(dp[i][j][k],(len>=3?dp[i+1][j-1][k-1]:0)+2);
		ans=max(ans,dp[i][j][k]);
	}
	printf("%d",ans);
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 110848
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,d[110],ans = 1;
    cin >> n;
    for(int i = 0;i < n;i++){cin >> d[i];}
    sort(d,d + n);
    for(int i = 0;i < n - 1;i++)
    {
        if(d[i] < d[i + 1]){ans++;}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		myBTree tree=new myBTree();

		int q=in.nextInt();
		for(int i=0;i<q;i++) {
			String odr=in.next();

			switch(odr.charAt(0)) {
			case 'i':
				tree.inset(Integer.parseInt(in.next()));
				break;
				
			case 'd':
				tree.remove(Integer.parseInt(in.next()));
				break;

			case 'f':
				System.out.println((tree.contains(Integer.parseInt(in.next()))? "yes":"no"));
				break;

			case 'p':
				tree.walk('m');
				tree.walk('f');
				break;
			}
		}

		in.close();

	}

}

class BTNode{
	int v;
	BTNode p,lc,rc;

	BTNode(int n){
		v=n;
	}
}

class myBTree{
	private BTNode EDG,ROOT;

	myBTree(){
		EDG=new BTNode(-1);
		ROOT=EDG;
	}
	
	
	/*-----insert-----*/
	void inset(int v) {
		BTNode NEW=new BTNode(v);
		NEW.lc=EDG; NEW.rc=EDG;

		if(ROOT==EDG) {
			ROOT=NEW;
			ROOT.p=EDG;
		}
		else {
			BTNode NOW=ROOT;
			while(true) {
				if(NEW.v<NOW.v) {
					if(NOW.lc==EDG) {
						NOW.lc=NEW;
						NEW.p=NOW;
						break;
					}
					else NOW=NOW.lc;
				}
				else {
					if(NOW.rc==EDG) {
						NOW.rc=NEW;
						NEW.p=NOW;
						break;
					}
					else NOW=NOW.rc;
				}
			}
		}
	}
	
	/*-----search-----*/
	public boolean contains(int key) {
		BTNode NOW=ROOT;

		while(NOW!=EDG) {
			if(key==NOW.v)return true;

			if(key<NOW.v)NOW=NOW.lc;
			else NOW=NOW.rc;
		}

		return false;
	}
	
	public BTNode pointOf(int key) {
		BTNode NOW=ROOT;

		while(NOW!=EDG) {
			if(key==NOW.v)return NOW;

			if(key<NOW.v)NOW=NOW.lc;
			else NOW=NOW.rc;
		}

		return EDG;
	}
	
	/*-----delete-----*/
	public void remove(int key) {
		BTNode RM=pointOf(key);
		delete(RM);
	}
	
	private void delete(BTNode RM) {
		if(RM.lc==EDG && RM.rc==EDG) {
			if(RM.p.lc==RM)RM.p.lc=EDG;
			else RM.p.rc=EDG;
		}
		else if(RM.lc!=EDG && RM.rc==EDG){
			RM.lc.p=RM.p;
			if(RM.p.lc==RM)RM.p.lc=RM.lc;
			else RM.p.rc=RM.lc;
		}
		else if(RM.lc==EDG && RM.rc!=EDG){
			RM.rc.p=RM.p;
			if(RM.p.lc==RM)RM.p.lc=RM.rc;
			else RM.p.rc=RM.rc;
		}
		else {
			BTNode EXC=RM.rc;
			while(EXC.lc!=EDG)EXC=EXC.lc;
			RM.v=EXC.v;
			delete(EXC);
		}
	}

	/*-----walk-----*/
	public void walk(char opt) {
		BTNode NOW=ROOT;

		switch(opt) {
		case 'f':
			preWalk(NOW);
			break;

		case 'm':
			inWalk(NOW);
			break;

		case 'l':
			postWalk(NOW);
			break;
		}

		System.out.println();
	}

	private void preWalk(BTNode NOW) {
		System.out.print(" "+NOW.v);
		if(NOW.lc!=EDG)preWalk(NOW.lc);
		if(NOW.rc!=EDG)preWalk(NOW.rc);
	}

	private void inWalk(BTNode NOW) {
		if(NOW.lc!=EDG)inWalk(NOW.lc);
		System.out.print(" "+NOW.v);
		if(NOW.rc!=EDG)inWalk(NOW.rc);
	}

	private void postWalk(BTNode NOW) {
		if(NOW.lc!=EDG)postWalk(NOW.lc);
		if(NOW.rc!=EDG)postWalk(NOW.rc);
		System.out.print(" "+NOW.v);
	}



}


Measured memory_bytes: 194920
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;


int main(){
    string s; cin>>s;
    bool flag = true;
    for(int i=0;i<s.size();i++){
        if(i % 2 == 0){
            if(s[i] == 'L') flag = false;
        } else {
            if(s[i] == 'R') flag = false;
        }
    }

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


    return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<pii>>;
const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;

    int slen = s.length();
    pii ans = {-1, -1};
    for (int i = 0; i < slen; ++i) {
        if (i + 1 < slen && s[i] == s[i + 1]) {
            ans.first = i + 1;
            ans.second = i + 2;
            break;
        }
        if (i + 2 < slen && s[i] == s[i + 2]) {
            ans.first = i + 1;
            ans.second = i + 3;
            break;
        }
    }

    cout << ans.first << " " << ans.second << endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
typedef std::pair<int,int> P;
    int N;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    cout<<(int)sqrt(N)*(int)sqrt(N);
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

const int MAX_N = 2e5;
ll fac[MAX_N+1], ifac[MAX_N+1], inv[MAX_N+1];

//mpow(x,n)で(x^n)をO(log(n))で計算
ll mpow(ll x, ll n){
    ll res = 1, now = x;
    while(n > 0){
        if(n%2 == 1) res *= now, res %= MOD;
        now *= now, now %= MOD;
        n /= 2;
    }
    return res;
}

//setcomb()でfac,ifac,invを全て計算
void setcomb(){
    rep2(i, 1, MAX_N){
        inv[i] = mpow(i, MOD-2);
    }
    //i!とi!の逆元
    fac[0] = 1, ifac[0] = 1;
    rep2(i, 1, MAX_N){
        fac[i] = (fac[i-1]*i) % MOD;
        ifac[i] = (ifac[i-1]*inv[i]) % MOD;
    }
}

//comb(n, k)でnCk
ll comb(int n, int k){
    ll c = fac[n];
    c *= ifac[n-k], c %= MOD;
    c *= ifac[k], c %= MOD;
    return c;
}

//perm(n, k)でnPk
ll perm(int n, int k){
    return(fac[n]*ifac[n-k])%MOD;
}

int main(){
    int N;
    string S;
    cin >> N >> S;
    vector<int> L, R;
    rep(i, 2*N){
        int A = (S[i] == 'B') + (2*N-i);
        //cout << A << endl;
        if(A%2) L.pb(i);
        else R.pb(i);
    }
    if(L.size() != R.size()){
        cout << 0 << endl;
        return 0;
    }
    setcomb();
    ll ans = fac[N];
    rep(i, N){
        int j = lower_bound(L.begin(), L.end(), R[i]) - L.begin();
        //cout << j << endl;
        if(j <= i){
            cout << 0 << endl;
            return 0;
        }
        else ans *= (j-i), ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6136
#include <stdio.h>

int main()
{
	int a = 0, b = 0, c = 0;
	int sum = 0;
	int i = 0;

	scanf("%d %d %d", &a, &b, &c);

	while (sum < c)
	{
		i++;
		sum += a;
		if ((i % 7) == 0)
			sum += b;
	}

	printf("%d\n", i);

	return 0;
}



Measured memory_bytes: 2088
var lines = [];

var readline = require('readline')
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', (x) => {
    lines.push(x);
});

rl.on('close', () => {
    var n = lines[0].split("");
    var ans = ""

    for (var i = 0; i < 3; i++) {
        switch (n[i]) {
            case "1": ans += "9"; break;
            case "9": ans += "1"; break;
        }
    }

    console.log(Number(ans));
});

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

void saiki(string s, int *ans,int keta,int n) {
	if (s.size() > keta) { return; }

	if (s.find('7') != -1 && s.find('5') != -1 && s.find('3') != -1 && stoi(s) <= n) {
		(*ans)++;
	}

	saiki(s + '3', ans, keta, n);
	saiki(s + '5', ans, keta, n);
	saiki(s + '7', ans, keta, n);

}

int main(void) {
	int n; cin >> n;
	int k = n;
	int keta = 0;
	string s = "";
	int ans = 0;
  
    while(k){
        k/=10;
        keta++;
    }

	saiki(s, &ans, keta, n);
  
    cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, m;
  cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  string a[n], b[m];
  fi(0, n)
    cin >> a[i];
  fi(0, m)
    cin >> b[i];

  fi(0, n - m + 1)
    fj(0, n - m + 1) {
      int ok = 1;
      fk(0, m) {
        if(a[i + k].compare(j, m, b[k]) != 0) {
          ok = 0;
          break;
        }
      }
      if(ok) {
        cout << "Yes\n";
        return 0;
      }
    }

  cout << "No\n";
  // cout << ans << endl;
  return 0;
}



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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int l, r, x;
    cin >> l >> r;
    if (l > r) {
      x = (l - r) + 1;
    }
    else if (l < r) {
      x = (r - l) + 1;
    }
    else {
      x = 1;
    }    
    sum += x;
  }
  cout << sum << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

char s1[15], s2[15], s3[15];
int main()
{
	while(scanf("%s %s %s", s1, s2, s3) != EOF)
	{
		int l1 = strlen(s1);
		int l2 = strlen(s2);
		int l3 = strlen(s3);
		if(s1[l1 - 1] == s2[0] && s2[l2 - 1] == s3[0])
			printf("YES\n");
		else
			printf("NO\n");
		memset(s1, 0, sizeof(s1));
		memset(s2, 0, sizeof(s2));
		memset(s3, 0, sizeof(s3));
	}
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


def solve(W: int, H: int, x: int, y: int):
    ans1 = H*W/2

    if((y == H/2) and (x == W/2)):
        ans2 = 1
    else:
        ans2 = 0

    print(ans1,ans2)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    W = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    y = int(next(tokens))  # type: int
    solve(W, H, x, y)

if __name__ == '__main__':
    main()


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

int main(){
  int a[3], b[3], c[9];
  for(int i = 0; i < 9; i++) cin >> c[i];
  a[0] = (c[0] + c[1] - c[3])/2;
  for(int i = 0; i < 3; i++) b[i] = c[i] - a[0];
  a[1] = c[3] - b[0];
  a[2] = c[6] - b[0];
  if((c[4]==a[1]+b[1])&&(c[5]==a[1]+b[2])&&(c[7]==a[2]+b[1])&&(c[8]==a[2]+b[2])){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}


Measured memory_bytes: 256
#define taskname ""

#include <iostream>
#include <algorithm>

using namespace std;
#define long long long

const int N = 1e3 + 10;
const long INF = 1e16;

int n, a[N];
long sum[N], dp[N][N];

int main()
{
//    freopen(taskname".INP", "r", stdin);
//    freopen(taskname".OUT", "w", stdout);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i], sum[i] = sum[i - 1] + a[i];

    for (int i = 0; i < N; ++i) {
        fill(dp[i], dp[i] + N, INF);
        dp[i][i] = 0;
    }

    for (int r = 2; r <= n; ++r)
        for (int l = r - 1; l > 0; --l)
            for (int mid = l; mid < r; ++mid)
                dp[l][r] = min(dp[l][r], dp[l][mid] + dp[mid + 1][r] + sum[r] - sum[l - 1]);
    cout << dp[1][n];

    return 0;
}


Measured memory_bytes: 8192
A,B,C,X,Y = map(int,input().split())
if A+B <= 2*C:
    ans = A*X + B*Y
else:
    ans = min(X,Y) * 2 * C
    if X > Y:
        ans += (X-Y) * min(A,2*C)
    elif X < Y:
        ans += (Y-X) * min(B,2*C)
print(ans)

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<String> porand = new ArrayList<>(Arrays.asList(sc.nextLine().split(" ")));
		sc.close();
		List<String> stack = new ArrayList<>();
		for(String value: porand) {
			 if(isNumber(value)) {
				 push(stack, value);
			 } else {
				 String operand2 = pop(stack);
				 String operand1 = pop(stack);
				 String calcResult = calcResultGet(operand1, operand2, value);
				 push(stack, calcResult);
			 }
		}
		System.out.println(pop(stack));
	}
	public static void push(List<String> stack, String value) {
		stack.add(value);
	}
	public static String pop(List<String> stack) {
		int popIndex = stack.size() - 1;
		String value = stack.get(popIndex);
		stack.remove(popIndex);
		return value;
	}
	public static boolean isNumber(String value) {
		String numOnlyRegex = "[0-9]+";
		return value.matches(numOnlyRegex);
	}
	public static String calcResultGet(String operand1, String operand2, String enzanshi) {
		int operandNum1 = Integer.parseInt(operand1);
		int operandNum2 = Integer.parseInt(operand2);
		int calcResult = 0;
		switch (enzanshi) {
		case "+":
			calcResult = operandNum1 + operandNum2;
			break;

		case "-":
			calcResult = operandNum1 - operandNum2;
			break;

		case "*":
			calcResult = operandNum1 * operandNum2;
			break;
		}
		return String.valueOf(calcResult);
	}
}

Measured memory_bytes: 26192
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n;
int a[400000],b[400000];
priority_queue<P>que;
int t=0;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[i]>>b[i];
        que.push(make_pair(b[i],a[i]));
        t=max(t,b[i]);
    }
    for(int i=0;i<n*2&&t>=0;i++){
        if(que.empty())break;
        P p=que.top();
        if(p.F>=t&&t>=p.S){
            t-=p.S;
            que.pop();
        }
        else if(t<p.S)break;
        else{
            t=p.F;
        }
    }
    if(t<0)puts("No");
    else if(que.empty())puts("Yes");
    else puts("No");
    return 0;
}



Measured memory_bytes: 11504
#include<bits/stdc++.h>
#define ll long long int
#define fip ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define reptUsual(b) for(i=0; i<b; ++i)
#define reptArIn(i,a,b,ar) for( i=a; i<b; ++i) cin>>ar[i];
#define rept(i,a,b) for(i=a; i<b; ++i)
#define maX(a,b)    ( (a) > (b) ? (a) : (b))
#define miN(a,b)    ( (a) < (b) ? (a) : (b))
#define pb(a) push_back(a)
using namespace std;

int main()
{
    fip;
    int p,q,r,i;
    cin>>p>>q>>r;
    int min = p+q;
    min = miN (min , r+q);
    min = miN (min , p+r);
    cout<<min;
    
    return 0;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n;
  cin >> n;

  int cnt = 0;
  REP(i,n){
    int a;
    cin >> a;
    while(a % 2 == 0){
      a /= 2;
      cnt++;
    }
  }
  
  
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [0]*(n+1)
for i in range(n):
    l[int(input())] = i
l = l[1:]

import sys
if n == 1:
    print(0)
    sys.exit()

m = 0
count = 1
for i in range(n-1):
    if l[i+1]>l[i]:
        count += 1
    else:
        m = max(m,count)
        count = 1
    m = max(m,count)
print(n-m)

Measured memory_bytes: 12924
N = int(input())
A = list(map(int, input().split()))
x = [0] * N
x[0] = 0
for i in range(N):
    if i % 2 == 0:
        x[0] += A[i]
    else:
        x[0] -= A[i]

x[0] //= 2
for i in range(N-1):
    x[i+1] = A[i] - x[i]

x = [i * 2 for i in x]

print(*x)

Measured memory_bytes: 14872