akhauriyash/Code-Regression huggingface dataset:
'use strict'

const INF = 900719925474099;

function numofbits5(bits)
{
    bits = bits & 0xffffffff
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    bits = (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);

    //console.log('bits:',bits);
    return bits;
}

function Main(input){
    let temp = input.trim().split('\n');
    let temp2 = temp[0].split(' ').map((v)=>parseInt(v));
    let n = temp2.shift();
    let m = temp2.shift();
    
    let k;
    let sum;
    let ksw = [];
    for(let i=1;i<=m;i++){
        temp2 = temp[i].split(' ').map((v)=>parseInt(v));
        k = temp2[0];
        sum = 0;
        for(let j=1;j<=k;j++){
            sum += 1 << (temp2[j]-1);
        }
        ksw.push(sum);
    }
    let p = temp[m+1].split(' ').map((v)=>parseInt(v));

    //console.log('-------------------------');
    //console.log(ksw,p);
    let ans = 0;
    let f;
    let maxi = Math.pow(2,n)
    for(let i=0;i<maxi;i++){
        f = true;
        for(let j=0;j<m;j++){
            //console.log('ksw:',ksw[j],'i:',i,'ksw&i:',ksw[j]&i,'bits:',numofbits5(ksw[j]&i),'p:',p[j],'if:',numofbits5(ksw[j]&i)%2 != p[j]);
            if(numofbits5(ksw[j]&i)%2 != p[j]){
                f = false;
                //console.log('break;');
                break;
            }
        }
        if(f == true) ans++;
        //console.log('cnt:',ans);
    }
    console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11596
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

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

    int maxCnt = 0;
    for (int i = 0; i < s.size(); i++) {
        int cnt = 0;
        string now = s.substr(i, 1);
        int j = i+1;
        while (now == "A" || now == "C" || now == "G" || now == "T") {
            cnt++;
            now = s.substr(j, 1);
            j++;
        }
        if (cnt > maxCnt) maxCnt = cnt;
    }

    cout << maxCnt << endl;
}

Measured memory_bytes: 384
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h>>w;
    rep(i,h){
        string temp;
        cin>>temp;
        cout<<temp<<"\n";
        cout<<temp<<"\n";
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}
int main(void){
    int n;
    int s[100+5];
    scanf("%d", &n);
    for(int i=0; i<n; i++)scanf("%d", &s[i]);
    
    int ans=0;
    for(int i=0; i<n; i++)ans+=s[i];
    
    if(ans%10==0){
        qsort(s, n, sizeof(int), cmpfunc);
        for(int i=0; i<n; i++){
            if(s[i]%10!=0){
                printf("%d\n", ans-s[i]);
                return 0;
            }
        }
        printf("0\n");
    }else{
        printf("%d\n", ans);
    }
    return 0;
}


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


int main(){
    int N;
    cin >> N;
    vector<string> W(N);
    for(int i=0;i<N;++i) cin >> W[i];
    bool flag = true;
    for(int i=1;i<N;++i){
        if(W[i-1].back() != W[i].front()){
            cout << "No" << endl;
            flag = false;
            break;
        }
    }
    if(flag){
        for(int i=0;i<N-1;++i){
            for(int j=i+1;j<N;++j){
                if(W[i]==W[j]){
                    cout << "No" << endl;
                    flag = false;
                }
            }
        }
    }
    if(flag) cout << "Yes" << endl;
    return 0;
}




Measured memory_bytes: 256
using System;

class B
{
	static void Main()
	{
		var a = int.Parse(Console.ReadLine());
		int c = 0, w = 0, t = 0, r = 0;
		for (int i = 0; i < a; i++)
		{
			var b = Console.ReadLine();
			if (b == "AC") c++;
			if (b == "WA") w++;
			if (b == "TLE") t++;
			if (b == "RE") r++;
		}
		Console.WriteLine("AC x " + c + "\n" + "WA x " + w + "\n" + "TLE x " + t + "\n" + "RE x " + r);
	}
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

int Cnt[3];
int main() {
	string S[3];
	for(int k=0; k<3; k++) cin >> S[k];
	int now = 0;
	while(Cnt[now] < SZ(S[now])) {
		Cnt[now]++;
		now = S[now][Cnt[now]-1] - 'a';
	}
	cout << (char)('A' + now) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
//#define N (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

template<typename T>
struct BIT{
    private:
    vector<T> array;
    int length;
    
    public:

    BIT(int _n=0) : array(_n+1),length(_n){}

    T sum(int i){
        T s=0;
        while(i>0){
            s+=array[i];
            i -= i&(-i);
        }
        return s;
    }

    T sum(int i,int j){
        T ret1 = sum(i-1);
        T ret2 = sum(j);
        return ret2-ret1;
    }

    void add(int i,T x){
        while(i<=length){
            array[i]+=x;
            i += i&(-i);
        }
    }
};

int main(void){
    int n,q;
    cin>>n>>q;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<int>pi(n+1,-1);
    vector<vector<int>>ps(n+1);
    for(int i=0;i<n;i++){
        int l = pi[a[i]];
        if(l!=-1)ps[l].push_back(i+1);
        pi[a[i]]=i+1;
    }
    vector<vector<P>>qs(n+1);
    for(int qi=0;qi<q;qi++){
        int l,r;
        cin>>l>>r;
        qs[l].emplace_back(r,qi);
    }
    BIT<int> d(n+1);
    vector<int>ans(q);
    for(int x = n;x>=1;x--){
        for(int y:ps[x]){
            d.add(y,1);
        }
        for(P query:qs[x]){
            int r = query.first,i = query.second;
            ans[i] = r-x+1-d.sum(r);
        }
    }
    for(int i=0;i<q;i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 59804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> field(h, vector<char>(w));
    int x, y;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            cin >> field[i][j];
            if(field[i][j] == 'S')
            {
                x = i;
                y = j;
            }
        }
    }
    vector<int> dx = {1, 0, -1, 0};
    vector<int> dy = {0, 1, 0, -1};
    vector<vector<bool>> d(h, vector<bool>(w));
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            d[i][j] = false;
        }
    }
    function<int(int, int, int)> bfs = [&](int x, int y, int count)
    {
        queue<P> que;
        que.push(P(x, y));
        d[x][y] = true;
        int tmp = min(min(x, h-x-1), min(y, w-y-1));
        while(count--)
        {
            queue<P> nque;
            while(que.size())
            {
                P p = que.front();
                que.pop();
                int mi = min(min(p.first, h-p.first-1), min(p.second, w-p.second-1));
                tmp = min(tmp, mi);
                for(int i = 0; i < 4; i++)
                {
                    int nx = p.first+dx[i];
                    int ny = p.second+dy[i];
                    if(0 <= nx && nx < h && 0 <= ny && ny < w && field[nx][ny] == '.' && d[nx][ny] == false)
                    {
                        d[nx][ny] = true;
                        nque.push(P(nx, ny));
                    }
                }
            }
            que = nque;
        }
        return tmp;
    };
    int mi = bfs(x, y, k+1);
    if(mi == 0) cout << 1 << endl;
    else
    {
        cout << (mi-1) / k + 2 << endl;
    }
}




Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 0x7fffffff
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
const int MAX=1e5+10;
const double eps=1e-6;

char s[MAX];

int main(){
    #ifdef ONLINE_JUDGE
    #else
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    #endif

    int len,juge,ans=0;
    scanf("%s",s+1);
    s[0]=' ';
    len=strlen(s);
    len--;
    juge=1;
    int l=1,r=len;
    while(l<r){
    	if(s[l]=='x'||s[r]=='x'){
    		if(s[l]=='x'&&s[r]=='x'){
    			l++;r--;
    			continue;
    		}
    		if(s[l]=='x'){
    			l++;
    			ans++;
    			continue;
    		}
    		if(s[r]=='x'){
    			r--;
    			ans++;
    			continue;
    		}
    	}
    	if(s[l]!=s[r]){
    		juge=0;
    		break;
    	}
    	l++;r--;    	
    }
    if(juge)
    	cout<<ans<<endl;
    else
    	cout<<-1<<endl;

    return 0;	
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[100050];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	int k=-1;
	int num=0;
	int p=0,q=0;
	for(int i=n-1;i>=0;i--){
		if(a[i]==k)num++;
		if(num==2){
			num=0;
			if(p==0)p=k;
			else if(q==0){
				q=k;
				break;
			}
			k=0;
		}
		else{
			num=1;
			k=a[i];
		}
	}
	long long ans=((long long)p)*(long long)q;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long ans=-2000000000000000000;
    ans=max(ans,a*c);
    ans=max(ans,b*c);
    ans=max(ans,a*d);
    ans=max(ans,b*d);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <algorithm>
static const int MAXN = 5004;
static const int MAXK = 5004;

int n, k, a[MAXN];
bool f[MAXN][MAXK] = {{ false }}, g[MAXN][MAXK] = {{ false }};
int f_lte_max[MAXN][MAXK];

int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);

    f[0][0] = true;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= k; ++j)
            f[i][j] = (f[i - 1][j] || (j >= a[i] && f[i - 1][j - a[i]]));
    }
    g[n + 1][0] = true;
    for (int i = n; i >= 1; --i) {
        for (int j = 0; j <= k; ++j)
            g[i][j] = (g[i + 1][j] || (j >= a[i] && g[i + 1][j - a[i]]));
    }

    for (int i = 0; i <= n; ++i) {
        f_lte_max[i][0] = 0;
        for (int j = 1; j <= k; ++j)
            f_lte_max[i][j] = (f[i][j] ? j : f_lte_max[i][j - 1]);
    }

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (a[i] >= k) continue;
        int max = -1;
        for (int j = 0; j <= k - 1; ++j) if (g[i + 1][j])
            max = std::max(max, j + f_lte_max[i - 1][k - 1 - j]);
        if (max < k - a[i]) ++ans;
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 146944
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define mp(a, b) make_pair(a, b)

template<typename T, typename Compare = greater<T> >
inline void chmax(T& t, T f, Compare comp){if(!comp(t, f))t = f;}

int h, w;

string solve(vector<string>& patterns){
    string res = "0";
    set<string> spells;
    rep(x, h)rep(y, w){
        for(int dx=-1; dx<=1; ++dx){
            for(int dy=-1; dy<=1; ++dy){
                string spell = "";  spell += patterns[x][y];
                for(int nx=(x+dx+h)%h, ny=(y+dy+w)%w; nx!=x || ny!=y; (nx+=(dx+h))%=h, (ny+=(dy+w))%=w){
                    spell += patterns[nx][ny];
                    if(!spells.insert(spell).second){
                        for(auto itr=spells.begin(); itr!=spells.end();){
                            if((*itr).size() < res.size())spells.erase(itr++); else itr++;
                        }
                        chmax(res, spell, [](string& s, string& t){return mp(t.size(), s) < mp(s.size(), t);});
                    }
                }
            }
        }
    }
    return res;
}

int main(){
    while(cin >> h >> w, h|w){
        vector<string> patterns(h);
        rep(i, h)cin >> patterns[i];
        cout << solve(patterns) << '\n';
    }
    return 0;
}

Measured memory_bytes: 32080
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAX 101

int main()
{
	int data[MAX];
	int n, finish=0, start=MAX;
	int sum, min=-1, t;

	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &data[i]);
		if (data[i] > finish)
			finish = data[i];
		if (data[i] < start)
			start = data[i];
	}

	for (int i = start; i <= finish; i++) {
		sum = 0;
		for (int j = 0; j < n; j++) {
			t = abs(data[j] - i);
			sum += pow(t, 2);
		}
		if (min == -1 || min>sum)
			min = sum;
	}

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

	return 0;
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define sz(x) (int)(x.size())
#define bit(n, k) (((n) >> (k)) & 1)

using namespace std;

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

const int maxn = 1e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();
	int n, k;
	cin >> n >> k;
	int arr[n];
	for (int i = 0; i < n; i++) cin >> arr[i];
	sort(arr, arr + n);
	ll ans = 0;
	for (int i = 0; i < k; i++) ans += (ll)arr[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
using System;

public class AIZU0652
{
	public static void Main(string[] args)
	{
        string[] line = Console.ReadLine().Trim().Split(' ');
        int a = int.Parse(line[0]);
        int b = int.Parse(line[1]);
        int c = int.Parse(line[2]);
        getAns(a, b, c);
	}

    public static void getAns(int a,int b,int c)
    {
        var ans=0;
        var oneweek=a*7+b;//1週間にもらえるコイン
        var nonweek=0;//6日以内で何日必要か
        var cnt=0;//何週間必要か

        //本来ならこちらも0除算対策をしなければならない
        if(c>oneweek){//1週間以上必要なとき
            cnt=c/oneweek;
            nonweek=c%oneweek/a;

            //残りのコインが6日間でもらえるコインを上回ったとき
                //nonweekが大きくなってしまうことがあるため
                //そのような場合nonweekを7日に固定
            if(a*6<c%oneweek){
                nonweek=7;   
                ans=7*cnt+nonweek;
            }
            else{
                //cがログインボーナスで割り切れるときはそのまま
                if(c%(cnt*oneweek+nonweek*a)==0){
                    ans=7*cnt+nonweek;
                }
                //cがログインボーナスで割り切れないときはもう1日必要
                else{
                    ans=7*cnt+nonweek+1;
                }
            }      
        }
        else{//7日以内で済むとき
            nonweek=c/a;
            //cを0で割らないように場合分け
            if(nonweek!=0){                
                //残りのコインが6日間でもらえるコインを上回ったとき
                //nonweekが大きくなってしまうことがあるため
                //そのような場合nonweekを7日に固定
                if(a*6<c%oneweek){
                    //Console.WriteLine("ok");
                    nonweek=7;
                    ans=nonweek;
                }
                else{
                        //cがログインボーナスで割り切れるときはそのまま
                    if(c%(nonweek*a)==0){
                        ans=nonweek;
                    }
                    //cがログインボーナスで割り切れないときはもう1日必要
                    else{
                        ans=nonweek+1;
                    }
                }
            }
            else{
                if(c%a==0){
                    ans=nonweek;
                }
                else{
                    ans=nonweek+1;
                }
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 15992
///AOJ0515
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#define rep(i,a) for( int i = 0; i != (a); ++i )
#define repd(i,a) for( int i = (a); i >= 0; --i )
#define repi(i,a,b) for( int i = (a); i != (b); ++i )
using namespace std;
typedef unsigned long long ull;

int road[17][17];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	while (std::cin >> a >> b, a, b){
		memset(road, 0, sizeof(road));
		road[0][0] = 1;
		int n;
		std::cin >> n;
		for (int i = 0; i < n; ++i){
			int x, y;
			std::cin >> x >> y;
			road[x - 1][y - 1] = -1;
		}

		for (int i = 0; i < a; ++i){
			for (int j = 0; j < b; ++j){
				if (road[i][j] >= 0){
					if (road[i][j - 1] >= 0 && j-1>=0)road[i][j] += road[i][j - 1];
					if (road[i - 1][j] >= 0 && i-1>=0)road[i][j] += road[i - 1][j];
				}
			}
		}
		/*for (int i = 0; i < a; ++i){
			for (int j = 0; j < b; ++j){
				std::cout << road[i][j] << " ";
			}
			std::cout << endl;
		}*/
		std::cout << road[a - 1][b - 1] << '\n';
	}
	//system("pause");
	return 0;

}

//1000000000000000000

Measured memory_bytes: 1196
#include <iostream>
using namespace std;
int main(void){
    int i=0;
    double x;
    int out[8]={0};
    while(cin >> x) {
        if(i%2==0) {
            if(x >= 1.1) 
                out[0]++;
            else if(x>=0.6)
                out[2]++;
            else if(x>=0.2)
                out[4]++;
            else 
                out[6]++;
        }
        else {
            if(x >= 1.1) 
                out[1]++;
            else if(x>=0.6)
                out[3]++;
            else if(x>=0.2)
                out[5]++;
            else 
                out[7]++;
        }
        i++;
    }
    for(int i=0;i<8;i+=2) {
        cout << out[i] << " " << out[i+1] << endl; 
    }
    return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

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

signed main(){
  Int t;
  cin>>t;
  while(t--){
    Int n,d;
    cin>>n>>d;
    Int x=0;
    for(Int i=0;i<128;i++)
      chmax(x,i+(i^d));
    if(n&1) x=d;
    cout<<(n-1)/2*254+x<<endl;
  }
  return 0;
}


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

int main () {
    double s; cin >> s;
    double length = s / 3; 
  
    s -= length; 

    double breadth = s / 2; 
 
    double height = s - breadth; 
  
    std::cout << std::fixed << std::setprecision(12) << length * breadth * height << endl; 
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
G = [[] for _ in range(n)]
for _ in range(n):
    u, k, *v = map(int, input().split())
    u -= 1
    G[u].extend(v)
seen = [False] * n
d = [-1] * n
f = [-1] * n
t = 1

def dfs(v):
    global t
#     print(v+1, t)
    d[v] = t
    t += 1
    seen[v] = True
    for next_v in G[v]:
        next_v -= 1
        if not seen[next_v]:
            t = dfs(next_v)
    f[v] = t
    t += 1
    return t

def main():
#     todo = []
#     seen[0] = True
    for i in range(n):
        if not seen[i]:
            dfs(i)
    for i in range(n):
        print(i+1, d[i], f[i])
#     print(G)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5652
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b;
  string s;
  long long ans = 0;
  
  cin >> a >> s >> b;

  if(s == "+") ans = a + b;
  else ans = a - b;
  
  cout << ans << endl;

}

Measured memory_bytes: 256
def gcd(x,y):
    if x%y==0:
        return y
    while x%y>0:
        x,y=y,x%y
    return y
a,b,c,d=map(int,input().split())
x,y=abs(a-c),abs(b-d)
g=gcd(x,y)
print(g*(x//g+y//g-1))

Measured memory_bytes: 38256
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, _ := sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(N)
	maxNums := make([]int, N)
	mx := 0
	for i := N - 1; i >= 0; i-- {
		mx = max(mx, A[i])
		maxNums[i] = mx
	}
	mxDiff := 0
	diffCount := make(map[int]int)
	for i := 0; i < N-1; i++ {
		diff := maxNums[i+1] - A[i]
		if diff >= 0 {
			mxDiff = max(mxDiff, diff)
			diffCount[diff]++
		}
	}

	fmt.Fprintln(wtr, diffCount[mxDiff])
}


Measured memory_bytes: 8704
def main():
    N, K = [int(n) for n in input().split()]
    S = input()
    S = [int(s) for s in S]
    cnt = 0
    suc = 1
    zeros = []
    ones = []
    
    for i in S:
        if i == suc:
            cnt += 1
        else:
            if suc == 0:
                zeros.append(cnt)
                cnt = 1
            elif suc == 1:
                ones.append(cnt)
                cnt = 1
            suc ^= 1
    if suc == 0:
        zeros.append(cnt)
    elif suc == 1:
        ones.append(cnt)
    
    if suc != 1:
        ones.append(0)
    
    if len(zeros) <= K:
        print(len(S))
        return
    # print(zeros)
    # print(ones)
    s = sum(zeros[:K])+sum(ones[:K+1])
    # print(s)
    m = s
    left = 0
    right = K-1
    while True:
        if right == len(zeros)-1:
            break
        s -= zeros[left] + ones[left]
        s += zeros[right+1] + ones[right+2]
        if s > m:
            m = s
        # print(left, right, s)
        
        left += 1
        right += 1
    print(m)


if __name__ == "__main__":
    main()

Measured memory_bytes: 47196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

int solve(int N)
{
  vector<long long> daruma(N);
  rep(i, N)
  {
    cin >> daruma[i];
  }
  vector<vector<long long>> dp(N, vector<long long>(N, 0));
  for(int step = 1; step < N; step++)
  {
    rep(l, N)
    {
      int r = l + step;
      if(r > N - 1)
        continue;

      if(dp[l + 1][r - 1] == r - l - 1 && abs(daruma[l] - daruma[r]) < 2)
        dp[l][r] = r - l + 1;

      for(int k = l; k < r; k++)
      {
        dp[l][r] = max(dp[l][r], dp[l][k] + dp[k + 1][r]);
      }
    }
  }
  
  long long dst = 0;
  rep(l, N) rep(r, N)
  {
    dst = max(dst, dp[l][r]);
  }
  return dst;
}

int main()
{
  while(true)
  {
    int N;
    cin >> N;
    if(N != 0)
      cout << solve(N) << endl;
    else
      break;
  }
  return 0;
}


Measured memory_bytes: 3688
#include<iostream>
using namespace std;
int main()
{
	int i=1,k,a,b,flag=1;
	cin>>k;
	cin>>a;
	cin>>b;
	while(k*i<=b)
	{
		if( (k*i >= a) && (k*i <= b) )
		{
			cout<<"OK";
			flag=0;
			break;
		}
		else
		{
			flag=1;
		}
		i++;
	}
	if(flag==1)
		cout<<"NG";
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
vector<long long> a(51), p(51);

// Problem Specific Parameter:
long long f(long long N, long long X) {
  if(N==0LL) {
    if(X <= 0) return 0LL;
    else return 1LL;
  } else if(X <= 1 + a[N-1]) {
    return f(N-1, X-1);
  } else {
    return p[N-1] + 1 + f(N-1, X-2-a[N-1]);
  }
}

int main() {
  long long N, X; cin >> N >> X;
  a[0] = 1, p[0] = 1;
  for(int i = 1; i < N; ++i) {
    a[i] = a[i-1]*2 + 3;
    p[i] = p[i-1]*2 + 1;
  }

  cout << f(N, X) << endl;
  return 0;
}


Measured memory_bytes: 256
s=input()
a=len(s)
if s[0]=='k' and s[1]=='e' and s[2]=='y' and s[3]=='e' and s[4]=='n' and s[5]=='c' and s[6]=='e':
    print('YES')
elif s[0]=='k' and s[1]=='e' and s[2]=='y' and  s[3]=='e' and s[4]=='n' and s[5]=='c' and s[a-1]=='e':
    print('YES')
elif s[0]=='k' and s[1]=='e' and s[2]=='y' and s[3]=='e' and s[4]=='n' and s[a-2]=='c' and s[a-1]=='e':
    print('YES')
elif s[0]=='k' and s[1]=='e' and s[2]=='y' and s[3]=='e' and s[a-3]=='n' and s[a-2]=='c' and s[a-1]=='e':
    print('YES')
elif s[0]=='k' and s[1]=='e' and s[2]=='y' and s[a-4]=='e' and s[a-3]=='n' and s[a-2]=='c' and s[a-1]=='e':
    print('YES')
elif s[0]=='k' and s[1]=='e' and s[a-5]=='y' and s[a-4]=='e' and s[a-3]=='n' and s[a-2]=='c' and s[a-1]=='e':
    print('YES')
elif s[0]=='k' and s[a-6]=='e' and s[a-5]=='y' and s[a-4]=='e' and s[a-3]=='n' and s[a-2]=='c' and s[a-1]=='e':
    print('YES')
elif s[a-7]=='k' and s[a-6]=='e' and s[a-5]=='y' and s[a-4]=='e' and s[a-3]=='n' and s[a-2]=='c' and s[a-1]=='e':
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define crap ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define assign(x,val) memset(x,val,sizeof(x))
void solve(){
    int n;cin>>n;
    vector<ll>a(n);
    bool flag=false;
    for(int i=0;i<n;i++) {cin>>a[i];if(a[i]==0) flag=true;}
    if(flag) {cout<<0;return;}
    ll prod=1;
    for(int i=0;i<n;i++){
        if(a[i]<=1000000000000000000/prod)
        prod*=a[i];
        else
        {
            cout<<-1;return;
        }
    }
    cout<<prod;
}
int main() {
    crap;
	int t=1;
	//cin>>t;
	while(t--){
	    solve();
	}
	return 0;
}

Measured memory_bytes: 3984
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
int main(){
    long long n,a,b;
    cin >> n >> a >> b;
    if(b>a){
        if(n<2){
            cout << 0 << endl;
        }
        else{
            cout << (b-a)*(n-2) + 1 << endl;
        }
    }else if(b<a){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
 
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
 
public class Main {
 
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
		int val=n*(n+1);
		System.out.print(val/2);
        
 
	}
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define  mem(a,x) memset(a,x,sizeof(a));
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;
int main()
{
    ft
    int t,i,j,n,m,l,r;
    string s;
    cin>>s;
    s+="/";
    n=s.size();
    l=r=m=0;
    for(i=0; i<n; i++)
    {
        if(s[i]=='/')
        {
            if(r==0)
            {
                if(l<2019)
                {
                    m=1;
                    break;
                }
                else if(l>2019)
                {
                    m=0;
                    break;
                }
                r++;
            }
            else if(r==1)
            {
                if(l<4)
                {
                    m=1;
                    break;
                }
                else if(l>4)
                {
                    m=0;
                    break;
                }
                r++;
            }
            else
            {
                if(l<=30)
                {
                    m=1;
                    break;
                }
                else if(l>30)
                {
                    m=0;
                    break;
                }
            }
            l=0;
        }
        else
        {
            l=(l*10)+s[i]-48;
        }
    }
    (m==1)? cout<<"Heisei\n": cout<<"TBD\n";
    return 0;
}



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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;
signed main() {
  int64_t n,x,y;
  cin >> n >> x >> y;
  vector<vector<int>> graph(n);
  for(int i=0;i<n-1;i++){
    graph[i].push_back(i+1);
    graph[i+1].push_back(i);
  }
  graph[x-1].push_back(y-1);
  graph[y-1].push_back(x-1);

  vector<int> distCount(n,0);

  for(int i=0;i<n;i++){
    queue<int> q;
    q.push(i);
    
    vector<int> dist(n,-1);
    dist[i]=0;
    while(!q.empty()){
      int node = q.front();
      q.pop();
      int d = dist[node]+1;
      for(auto n:graph[node]){
        if(dist[n]>=0) continue;
        distCount[d]++;
        dist[n] = d;
        q.push(n);
     }
    }
  }
  for(int i=1;i<n;i++){
    cout << distCount[i]/2 << endl;
  }

  return 0;
}




Measured memory_bytes: 3736
// Problem : D - Friends
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Delete the dynamically allocated memory

#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
// #define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)

void print(vr* edges,ll n,ll s,vr &ans,bool* visited){
	visited[s]=true;
	ans.pb(s);
	for(ll i=0;i<edges[s].size();i++){
		if(!visited[edges[s][i]]){
			print(edges,n,edges[s][i],ans,visited);
		}
	}
	return;
}

void DFS(vr* edges,ll n){
	mk(visited,n,bool)
	for(ll i=0;i<n;i++){
		visited[i]=false;
	}
	ll mx=-inf;
	for(ll i=0;i<n;i++){
		if(!visited[i]){
			vr ans;
			print(edges,n,i,ans,visited);
			ll v=ans.size();
			mx=max(mx,v);
		}
	}
	cout<<mx<<"\n";
	delete[] visited;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m;
	cin>>n>>m;
	mk(edges,n,vr)
	for(ll i=0;i<m;i++){
		ll f,s;
		cin>>f>>s;
		edges[f-1].pb(s-1);
		edges[s-1].pb(f-1);
	}
	DFS(edges,n);
	delete[] edges;
	return 0;
	}

Measured memory_bytes: 28436
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    char s[n];
    bool check=false;

    for(int i = 0; i < n; i++) {
        cin >> s[i];
        if(s[i]=='Y'){
            check=true;
        }
    }
    
    
	
    cout << (check?"Four":"Three") << endl;

	return 0;
}

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

import sys

sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')

N,M=MAP()
C=LIST()

dp=[INF]*(N+1)
dp[0]=0
for i in range(N):
    for j in range(M):
        if i+C[j]<=N:
            dp[i+C[j]]=min(dp[i+C[j]], dp[i]+1)
print(dp[N])



Measured memory_bytes: 7272
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,k = map(int,ipt().split())
#    n = 5000
#    k = 1
    p = [int(i)-1 for i in ipt().split()]
#    p = [(i-1)%n for i in range(n)]
#    c = [10**9 for i in range(n)]
    c = [int(i) for i in ipt().split()]
    ma = -10**18
    al = [False]*n
    for i in range(n):
        if al[i]:
            continue
        pts = []
        nap = i
        for j in range(n):
            nap = p[nap]
            pts.append(c[nap])
            al[nap] = True
            if nap == i:
                break
        ln = len(pts)
        jt = (k-1)%ln
        jt += 1+ln
        sma = 0
        for jp in pts:
            sma += jp
        if sma > 0:
            nm = ((k-1)//ln-1)*sma
        else:
            nm = 0
        pts *= 2
        ma1 = -10**18
#        print(pts,al)
        for ji in range(ln):
            sm = 0
            for jj in range(jt):
                sm += pts[ji-jj]
#                print(i,j,j-jj,sm)
                if ma1 < sm:
                    ma1 = sm
        ma1 += nm
        if ma < ma1:
            ma = ma1
#        print(ma)

    print(ma)




    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 71044
#include<bits/stdc++.h>
#define ll long long
using namespace std;
string a;
int main(){
	cin>>a;
	ll cnt=0,num=a.length();
	for(ll i=0;i<=num/2-1;i++)
	if(a[i]!=a[num-1-i]) cnt++;
	cout<<cnt;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/


int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b(n, 0);
    int count = 0;
    vector<int> c;

    for(int i = n; i >= 1; i--){
        int sum = 0;
        for(int j = i; j <= n; j += i){
            if(j % i == 0)sum += b[j - 1];
        }
        if(sum % 2 != a[i - 1]){
            c.push_back(i);
            count++;
            b[i - 1]++;
        }
    }
    if(count != 0){
        cout << count << endl;
        for(auto it : c)cout << it << endl; 
    }else if(count == 0){
        if(*max_element(a.begin(), a.end()) == 0)cout << 0 << endl;
        else cout << -1 << endl;
    }
}

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

inline int64_t ceiling_div(int64_t a, int64_t b){ // ceiling(a/b)= floor((a+b-1)/b)
  return (a+b-1)/b;
}

int main(){
  int HPa,ATa,HPb,ATb;
  cin >> HPa >> ATa >> HPb >> ATb;

  string ans= (ceiling_div(HPa, ATb) >= ceiling_div(HPb, ATa)) ? "Yes"
                                                               : "No";

  cout << ans << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N,M;
  cin >> N >> M;

  vector<vector<char> >A(N,vector<char>(N));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cin >> A[i][j];
    }
  }

  vector<vector<char> >B(M,vector<char>(M));
  for(int i=0;i<M;i++){
    for(int j=0;j<M;j++){
      cin >> B[i][j];
    }
  }

  bool match;

  for(int i=0;i<=N-M;i++){
    for(int j=0;j<=N-M;j++){
      match = true;
      for(int k=0;k<M;k++){
        for(int l=0;l<M;l++){
          if(B[k][l] != A[i + k][j + l])
            match = false;
        }
      }
      if(match)
        break;
    }
    if(match)
      break;
  }

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

  return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

f [pp,qq,rr,cc] [_,p,q,r] = let c = 4*(p+r)+9*q in p<=pp && q<=qq && r<=rr && c<=cc
flt s l = let r = filter (f l) s in cond ["NA"] (map (show . head) r) $ null r

main = do
    n <- getInt
    unless (n==0) $ do
        flt <$> replicateM n getInts <*> getInts >>= mapM_ putStrLn >> main


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

int tate[2005][2005];
int yoko[2005][2005];

int main(){
	int H,W;
    cin >> H >> W;
	char c[H][W];
    int i,j,k,l;
    int ans=0;
    int tmp;
    for(j=0;j<H;j++)for(i=0;i<W;i++)cin >> c[j][i];
    for(i=0;i<H;i++){
        tmp=0;
        for(j=0;j<W;j++){
            if(c[i][j]=='.')tmp++;
            else tmp=0;
            yoko[i][j]=tmp;
            }
        }
    for(i=0;i<H;i++){
        j=W-1;
        while(j>0){
            if(yoko[i][j]>yoko[i][j-1]){
                k=yoko[i][j];
                for(l=j-k+1;l<j;l++)yoko[i][l]=k;
                j-=k;
            }
            else j--;
            }
        }
    for(i=0;i<W;i++){
        tmp=0;
        for(j=0;j<H;j++){
            if(c[j][i]=='.')tmp++;
            else tmp=0;
            tate[j][i]=tmp;
            }
        }
	for(i=0;i<W;i++){
        j=H-1;
        while(j>0){
            if(tate[j][i]>tate[j-1][i]){
                k=tate[j][i];
                for(l=j-k+1;l<j;l++)tate[l][i]=k;
                j-=k;
            }
            else j--;
            }
        }
    for(i=0;i<H;i++)for(j=0;j<W;j++)ans=max(ans,yoko[i][j]+tate[i][j]-1);
    cout << ans << endl;
}

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


int main(){


    string s;


    cin >> s;


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


    if( s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(0) != s.at(2) ){

        cout << "Yes" << endl;

        }

    else cout << "No" << endl;

    
    return 0;


    }


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n,k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];

	vector<ll> ary;
	rep(i,n){
		ll val = 0LL;
		rep(j,i,n){
			val += a[j];
			ary.push_back(val);
		}	
	}

	ll ans = 0LL;
	rrep(bit,40){
		const ll cur = ans | (1LL << bit);
		ll cnt = 0;
		for(auto &elem:ary){
			if((elem & cur) == cur){
				cnt++;
			}
		}
		if(cnt >= k) ans = cur;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6516
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string.h>
#include<string>
#include<set>
#include<limits.h>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<functional>
#include<stack>
#include<deque>
#include<queue>
#define int long long
using namespace std;

signed main() {
	string a, b;
	cin >> a >> b;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end(), greater<char>());
	if (a < b)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<int> C(N);
  for (int i=0;i<N;i++){
    cin >> C.at(i);
  }
  int A=0, B=0;
  // sort
  sort(C.begin(), C.end());
  reverse(C.begin(), C.end());
  for (int i=0;i<N;i++){
    if (i%2==0){
      A += C.at(i);
    } else {
      B += C.at(i);
    }
  }
  cout << A - B << endl;
}

Measured memory_bytes: 3644