akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
//#include<chrono>
#include<random>
using namespace std;
typedef long long int llint;
const int big=1e9+100000;
const int mod=1e9+7;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define res resize
#define ins insert
#define era erase
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	int i,n,m;
	cin>>n>>m;
	vector<string>word(n);
	vector<string>drow(n);
	for(i=0;i<n;i++){cin>>word[i];drow[i]=word[i];reverse(drow[i].begin(),drow[i].end());}
	sort(word.begin(),word.end());
	sort(drow.begin(),drow.end());
	for(i=0;i<m;i++){
		string sla;cin>>sla;
		int ans=0,bas=-1,rec=0,kak=0;
		if(sla[0]=='*'){reverse(sla.begin(),sla.end());rec=1;}
		if(sla.back()=='*'){kak++;sla.pob();}
		for(int j=0;j<sla.size();j++){
			if(sla[j]=='?'){bas=j;break;}
		}
		string slap=sla;
		for(char c='a';c<='z';c++){
			if(bas!=-1){sla[bas]=c;slap[bas]=c;}
			slap.back()++;
			if(kak==1){
				if(rec==0){ans+=lower_bound(word.begin(),word.end(),slap)-lower_bound(word.begin(),word.end(),sla);}
				else{ans+=lower_bound(drow.begin(),drow.end(),slap)-lower_bound(drow.begin(),drow.end(),sla);}
			}else{
				auto it=lower_bound(word.begin(),word.end(),sla);
				if(it!=word.end()&&(*it)==sla){ans++;}
			}
			slap.back()--;
		}
		if(bas==-1){ans/=26;}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 11820
a, b = map(str,input(). split())

if a == 'H' and b == 'H':
    print('H')
elif a == 'H' and b == 'D':
    print('D')
elif a == 'D' and b == 'H':
    print('D')
elif a == 'D' and b == 'D':
    print('H')

Measured memory_bytes: 9084
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<lint> A(N),abs_A(A);
	for (int i = 0; i < N; i++) cin >> A[i];

	lint ans = 0;
	int micnt = 0, zerocnt = 0;
	for (int i = 0; i < N; i++) {
		abs_A[i] = abs(A[i]);
		ans += abs(A[i]);
		if (A[i] == 0) zerocnt++;
		if (A[i] < 0) micnt++;
	}

	if (zerocnt > 0 || micnt % 2 == 0) {
	
		cout << ans;
		return 0;
	}
	else {
		
		cout << ans - 2 * *min_element(abs_A.begin(), abs_A.end());
		return 0;
	}
}

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

int main() {
	int n; cin >> n;
	vector<int> a(n + 1); rep(i, 1, n + 1) cin >> a[i];

	int m;
	vector<int> b(n + 1, 0);
	rem(i, n, 1) {
		if (i > n / 2) b[i] = a[i];
		else {
			int idx = i, sum = 0;
			while (idx <= n) {
				sum += b[idx];
				idx += i;
			}
			b[i] = abs((sum % 2) - a[i]);
		}
		m += b[i];
	}
	vector<int> c;
	rep(i, 1, n + 1) if(b[i]) c.pb(i);

	cout << m << endl;
	rep(i, 0, m) {
		if (i > 0) cout << " ";
		cout << c[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();

    HashMap<Integer, Integer> evenMap = new HashMap<>();
    HashMap<Integer, Integer> oddMap = new HashMap<>();

    for (int i = 0; i < N; i++) {
      int v = scn.nextInt();
      if (i % 2 == 0) {
        if (!evenMap.containsKey(v)) {
          evenMap.put(v, 1);
        } else {
          evenMap.put(v, evenMap.get(v) + 1);
        }
      } else {
        if (!oddMap.containsKey(v)) {
          oddMap.put(v, 1);
        } else {
          oddMap.put(v, oddMap.get(v) + 1);
        }
      }
    }

    List<Map.Entry<Integer, Integer>> evenList = new ArrayList<>(evenMap.entrySet());
    List<Map.Entry<Integer, Integer>> oddList = new ArrayList<>(oddMap.entrySet());
    Collections.sort(evenList, (e1, e2) -> -e1.getValue().compareTo(e2.getValue()));
    Collections.sort(oddList, (e1, e2) -> -e1.getValue().compareTo(e2.getValue()));

    int evenMostFreq = evenList.get(0).getKey();
    int oddMostFreq = oddList.get(0).getKey();

    int ans = 0;
    if (evenMostFreq != oddMostFreq) {

      evenList.get(0).setValue(0);
      oddList.get(0).setValue(0);
      for (Map.Entry<Integer, Integer> entry : evenList) {
        ans += entry.getValue();
      }
      for (Map.Entry<Integer, Integer> entry : oddList) {
        ans += entry.getValue();
      }

    } else {

      int ans1 = 0;
      int ans2 = 0;

      if (evenList.size() == 1 && oddList.size() == 1) {
        ans = N / 2;

      } else if (evenList.size() == 1) {
        oddList.get(1).setValue(0);
        for (Map.Entry<Integer, Integer> entry : oddList) {
          ans += entry.getValue();
        }
      } else if (oddList.size() == 1) {
        evenList.get(1).setValue(0);
        for (Map.Entry<Integer, Integer> entry : evenList) {
          ans += entry.getValue();
        }
      } else {
        int tmp1 = oddList.get(1).getValue();
        int tmp2 = evenList.get(0).getValue();
        oddList.get(1).setValue(0);
        evenList.get(0).setValue(0);
        for (Map.Entry<Integer, Integer> entry : evenList) {
          ans1 += entry.getValue();
        }
        for (Map.Entry<Integer, Integer> entry : oddList) {
          ans1 += entry.getValue();
        }

        oddList.get(1).setValue(tmp1);
        evenList.get(0).setValue(tmp2);

        evenList.get(1).setValue(0);
        oddList.get(0).setValue(0);
        for (Map.Entry<Integer, Integer> entry : evenList) {
          ans2 += entry.getValue();
        }
        for (Map.Entry<Integer, Integer> entry : oddList) {
          ans2 += entry.getValue();
        }

        ans = Math.min(ans1, ans2);

      }
    }

    System.out.println(ans);

  }

}


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

const int INF = 1e9;

long long g(long long x) {
  long long ans = 0;
  ++x;
  if (x % 4 == 2 || x % 4 == 3) {
    ++ans;
  }
  for (int i=1; i<50; i++) {
    long long d = (long long)pow(2, i);
    long long m = x % (2 * d);
    if (m > d && m % 2 == 1) {
      ans += d;
    }
  }
  return ans;
}
int main() {
  long long a,b;
  cin>>a>>b;
  long long y1 = g(a-1);
  long long y2 = g(b);

  cout<<(y1^y2)<<endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

int N, K;
vector<int> A;

signed main()
{
    int one = 0;
    cin >> N >> K;
    REP(i, N) {
        int a;
        cin >> a;
        if(a == 1) { one = i; }
        A.push_back(a);
    }
    int ans = LLINF;
    for(int i = 0; i < K; ++i) {
        int left = one - K + 1 + i;
        int right = N - (one + i + 1);
        int cand = 1;
        if(left > 0) {
            cand += left / (K-1);
            if(left % (K-1) != 0) { cand++; }
        }
        if(right > 0) {
            cand += right / (K-1);
            if(right % (K-1) != 0) { cand++; }
        }
        ans = min(ans, cand);
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1400
import sys

n = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)

if a_list[-1] == 0:
  print(0)
  sys.exit()

if a_list[0] > 1000000000000000000:
  print(-1)
  sys.exit()

ans = 1
for a in a_list:
  ans *= a

  if ans > 1000000000000000000:
    print(-1)
    sys.exit()

print(ans)


Measured memory_bytes: 84672
#include <stdio.h>
#define MAX 100000

int parent(int i){ return i/2;}
int left(int i){ return i*2;}
int right(int i){ return i*2 + 1;}

int main(){
  int H,i,A[MAX + 1];

  scanf("%d",&H);
  for(i = 1;i <= H;i++) scanf("%d",&A[i]);
  for(i = 1;i <= H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <= H) printf("left key = %d, ",A[left(i)]);
    if(right(i) <= H) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 608
program abc133d
   implicit none

   integer :: N, r1, i
   integer, allocatable :: a(:), r(:)

   read(*,*) N
   allocate( a(0:N), r(n))
   read(*,*) a(1:N)

   a(0) = a(N)
   r = 0
   r1 = 0
   do i = 1, n-2, 2
      r1 = r1 + a(i) - a(i+1)
   enddo
   r1 = r1 + a(n)

   r(1) = r1

   do i = n, 2, -1
      if (i == n) then
         r(n) = 2*a(n) - r(1)
         cycle
      else
         r(i) = 2*a(i) - r(i+1)
      end if
   enddo

   print *, r(:)
end program abc133d


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

int main(){
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='+'){
      ans++;
    }
    if(s.at(i)=='-'){
      ans--;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3544
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

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

int n;
int m;
ll K;
ll T[3][1005];
ll A[1005];

ll solve(ll x,ll y,ll z){
	for(int i=0;i<n;i++){
		A[i] = T[0][i]*x + T[1][i]*y + T[2][i]*z;
	}
	sort(A,A+n);
	reverse(A,A+n);
	ll ans=0;
	for(int i=0;i<m;i++){
		ans += A[i];
	}
	return ans;
}

int main()
{
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%lld %lld %lld",&T[0][i],&T[1][i],&T[2][i]);
	}
	ll k[] = {1,-1};
	ll ans = solve(1,1,1);
	for(int a=0;a<2;a++){
		for(int b=0;b<2;b++){
			for(int c=0;c<2;c++){
				ans = max(ans,solve(k[a],k[b],k[c]));
			}
		}
	}

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


Measured memory_bytes: 128
S = input()
S = S[::-1]
mod = 10 ** 9 + 7
table = [[0] * 13 for _ in range(len(S) + 1)]
table[0][0] = 1

dd = 1

for i in range(len(S)):
    if S[i] == '?':
        for j in range(13):
            for k in range(10):
                table[i+1][(j + dd * k)  % 13] += table[i][j]
                table[i+1][(j + dd * k)  % 13] %= mod
    else:
        num = int(S[i])
        for j in range(13):
            table[i+1][(j + dd * num)  % 13] += table[i][j]
            table[i+1][(j + dd * num)  % 13] %= mod

    dd = (dd * 10) % 13

print(table[i+1][5])


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

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

    vector<int>cnt(n,0);

    rep(i,0,m*2){
        int m;
        cin>>m;
        cnt[m-1]++;
    }

    rep(i,0,n){
        cout<<cnt[i]<<endl;
    }

}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    string S; cin >> S;
    string kouho[5];
    kouho[0] = "hi";
    rep(i, 4){
        kouho[i+1] = kouho[i] + "hi";
    }
    rep(i, 5){
        if(kouho[i] == S){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> x(N);
	for (auto& x_i : x) {
		cin >> x_i;
	}

	int ans = numeric_limits<int>::max();

	for (int i = 0; i + K <= N; ++i) {
		int d = x[i + K - 1] - x[i];
		int tmp = d + min(abs(x[i]), abs(x[i + K - 1]));
		ans = min(ans, tmp);
	}

	cout << ans << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<limits.h>
int A[500005],N,c=0,i,tmp[2][250005];
void marge(int l,int m,int r)
{
	int i,j,c1=m-l,c2=r-m;
	for(i=0;i<c1;i++)tmp[0][i]=A[l+i];
	for(i=0;i<c2;i++)tmp[1][i]=A[m+i];
	tmp[0][c1]=tmp[1][c2]=INT_MAX;
	for(i=j=0;i<c1||j<c2;c++)
	{
		if(tmp[0][i]<tmp[1][j])
		{
			A[l+i+j]=tmp[0][i];
			i++;
		}
		else
		{
			A[l+i+j]=tmp[1][j];
			j++;
		}
	}
}

void margeSort(int l,int r)
{
	int m;
	if(l+1<r)
	{
		m=(l+r)/2;
		margeSort(l,m);
		margeSort(m,r);
		marge(l,m,r);
	}
}

int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
		scanf("%d",A+i);
	margeSort(0,N);
	for(i=0;i<N;i++)
		printf("%d%c",A[i],i==N-1?'\n':' ');
	printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 5644
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for(auto i=0; i<(n); i++)
#define repd(i,n) for(auto i=(n)-1; i>=0; i--)
#define repf(i,a,b) for(auto i=(a); i<=(b); i++)
#define repe(i,l) for(auto i: l)
#define mem(x,val) memset((x),(val),sizeof(x));
#define rite(x) freopen(x,"w+",stdout);
#define read(x) freopen(x,"rt",stdin);
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define pb push_back
#define clr clear()
#define INF ((int)0x3f3f3f3f)
#define ins insert
#define xx first
#define yy second
#define eps 1e-9
#define endl '\n'
#define _ ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.precision(10);cout<<fixed;
template<class T> T abs(T x) { return x > 0 ? x : -x; }
template<class T> T mini(T x, T y) { return x <  y? x : y; }
template<class T> T maxi(T x, T y) { return x <  y? y : x; }
template<class T> T gcd(T a, T b) { return a%b? gcd(b, a%b) : b; }
typedef long long i64;
typedef unsigned long long ui64;
typedef string st;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<st> vs;
typedef map<int,int> mii;
typedef map<st,int> msi;
typedef set<int> si;
typedef set<st> ss;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef long long ll;
typedef unsigned long long ull;

#define MOD ((int)1e9 + 7)
#define MAX 1000007


vi arr;

void pre(){
	repf(i, 1, 100){
		if(i == 1){
			arr.pb(1);
		}else{
			int j = 2;
			double p = pow(i, j);
			while(p <= 1000){
				arr.pb((int)p);
				p = pow(i, ++j);
			}
		}
		
	}
	sort(all(arr));
}
int main() {_
	//Solution
	#ifdef LOCAL
		// read("abc097_b.in");
		// rite("abc097_b.out");
	#endif
	pre();
	int x;
	cin >> x;
        int ans = 0;
	rep(i, sz(arr)){
            if(arr[i] > x){
            break;
}else ans = arr[i];
         }

cout << ans << endl;
	
	
	
	
	
	
	
	
	
	#ifdef LOCAL
		//cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << endl;
	#endif
   	
	return 0;
}


/*

	g++-6 -std=c++11 abc097_b.cpp -o abc097_b -DLOCAL && ./abc097_b


*/






Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, A, B = [int(x) for x in input().split()]

    q, r = divmod(N, (A + B))
    ans = 0
    ans += q * A
    ans += min(r, A)

    print(ans)





if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

AB, BC, CA = get_ints


puts (AB * BC) / 2


Measured memory_bytes: 14440
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)


const int MAX_N = 2 * (int) 1e5;
ll N, A[MAX_N], A1[MAX_N];
ll sum = 0;

void solve() {
    ll ans = 0, ans1 = 0;
    sort(A1, A1 + N);
    ll b = A1[N / 2];
    REP(i, N) {
        ans += abs(A[i] - (i + 1) - b);
        if (b >= 0) {
            ans1 += abs(A[i] - (i + 1) - (b + 1));
        } else {
            ans1 += abs(A[i] - (i + 1) - (b - 1));
        }

    }
    cout << min(ans, ans1) << endl;
}

int main() {
    cin >> N;
    REP(i, N) {
        cin >> A[i];
        A1[i] = A[i] - (i + 1);
    }
    solve();
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
const int N = 2000;

#define PI acos(-1)
typedef long long ll;
#define INF 0x3f3f3f3f
int mod = 1000000007;
typedef pair<int, int> pii;
int rec[1301];
int main()
{
	//freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	 // freopen("output.txt", "w", stdout);
	int a, b;
	while (cin >> a >> b)
	{
		if (a > b)
			printf("%d\n", a-1);
		else
			printf("%d\n", a);
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	typedef	long long ll;
	#define all(v) ((v).begin()),((v).end())
	#define clr(v,val) memset(v,val,sizeof v)
	#define watch(x) cout << (#x) << " is " << (x) << endl
	#define endl "\n"
	void fast(){
		std::ios_base::sync_with_stdio(0); cin.tie(NULL);
	}
	const int N = 1e5 + 20;
	/***You***Can***Do***It***/
	int main()
	{
		fast();

		int d;
		cin >> d;

		map<int, string>mp;
		mp[25] = "Christmas";
		mp[24] = "Christmas Eve";
		mp[23] = "Christmas Eve Eve";
		mp[22] = "Christmas Eve Eve Eve";
		cout << mp[d] << endl;
	}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i=0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    ll n, ans=-1, a, x, y; cin>>n;
    vector<set<pair<ll,ll>>> v(n);
    rep(i,n){
        cin>>a;
        rep(j,a){
            cin>>x>>y;
            v[i].insert(make_pair(x-1,y));
        }
    }
    for(ll bit=0;bit<(1<<n);bit++){
        bool ok=1;
        ll cnt=0;
        rep(i,n){
            if(bit&(1<<i)){
                cnt++;
                for(auto p: v[i]){
                    if(p.second && !(bit&(1<<p.first))){
                        ok=0; break;
                    }
                    else if(!p.second && (bit&(1<<p.first))){
                        ok=0; break;
                    }
                }
            }
            if(!ok) break;
        }
        if(ok) ans=max(ans, cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a;
	int b;
	cin>>a>>b;
	if (a < b){
		cout << "a < b\n";
	}else if (a > b){
		cout << "a > b\n";
		}else{
		cout << "a == b\n";
		}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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

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

map<ll, int>  prime_factorization_map(ll x) {
  map<ll, int> res;
  for(ll i = 2; i*i <= x; ++i) {
    while(x % i == 0) {
      if(res.find(i) == res.end()) res[i] = 0;
      ++res[i];
      x /= i;
    }
  }
  if(x != 1) res[x] = 1;

  return res;
}
int main()
{
  string s; cin >> s;
  int n = s.size();
  map<char, int> mp;
  mp['a'] = mp['b'] = mp['c'] = 0;
  for(auto c : s) ++mp[c];
  
  if(abs(mp['a']-mp['b']) <= 1 && abs(mp['b']-mp['c']) <= 1 && abs(mp['c']-mp['a']) <= 1) cout << "YES" << endl;
  else cout << "NO" << endl;

}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int a, b, c;
    int k;
    int n;
 
    scanf("%d%d%d", &a, &b, &c);
    n = 0;
    for (k = a; k <= b; k++) {
        if (c % k == 0) n++;
    }
    printf("%d\n", n);
    return 0;
}


Measured memory_bytes: 2136
n,m = map(int,input().split())
# m の約数を求めるのです
i = 1
#import collections
#dic = collections.defaultdict(int)
li = []
while i*i <= m:
    if m % i == 0:
        if m//i != i:
            li.append(i)
            li.append(m//i)
        else:
            li.append(i)
    i += 1
#print(li)
# 最大の最大公倍数 N*d <= M
ans = 1
for v in li:
    if n*v <= m:
        ans = max(ans,v)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main()
{   int a,b;
    scanf("%d %d",&a,&b);
   if(a>=b)
   {  for(int i=0;i<a;i++)printf("%d",b);
   }
   else for(int i=0;i<b;i++)printf("%d",a);

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
lmax = 1
rmin = n
for i in range(m):
  l, r = map(int, input().split())
  lmax = max(l, lmax)
  rmin = min(r, rmin)
print(rmin - lmax + 1 if rmin - lmax + 1 >= 0 else 0)

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(true){
  	c -= b;
  	if(c <= 0){
  		cout << "Yes" << endl;
  		break;
  	}
  	a -= d;
  	if(a <= 0){
  		cout << "No" << endl;
  		break;
  	}
  }
  return 0;
}


Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int N = cin.nextInt();

        WriteLine((N-2)*180);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
from heapq import heappush, heappop, heapify
N = int(input())
M = 3 * N
A = list(map(int, input().split()))
B = A[::-1]

L = [0] * (N + 1)
que = A[:N]
heapify(que)
S = sum(que)
L[0] = S
for i, a in enumerate(A[N: 2 * N], start=1):
    S += a
    heappush(que, a)
    S -= heappop(que)
    L[i] = S

R = [0] * (N + 1)
que = [-a for a in B[:N]]
heapify(que)
S = sum(que)
R[0] = S
for i, b in enumerate(B[N: 2 * N], start=1):
    b = -b
    S += b
    heappush(que, b)
    S -= heappop(que)
    R[i] = S
R = R[::-1]

ans = -10**18
for l, r in zip(L, R):
    ans = max(ans, l + r)
print(ans)


Measured memory_bytes: 37212
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    int N, K;
    cin >> N >> K;

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

    sort(begin(h), end(h));

    int ans = h[K-1] - h[0];
    for (int i = 1; i < N-K+1; ++i) {
        ans = min(ans, h[i+K-1] - h[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

N,M = I()
A = [I() for _ in range(M)]
links = [[] for _ in range(N)]
ans = [-1]*(N)
ans[0] = 0
for a,b in A:
    links[a-1].append(b-1)
    links[b-1].append(a-1)
que = deque([0])
while que:
    i = que.pop()
    for j in links[i]:
        if ans[j] == -1:
            ans[j] = i+1
            que.appendleft(j)
print('Yes')
for i in range(1,N):
    print(ans[i])

Measured memory_bytes: 155524
N, C = map(int, input().split())

db = [0 for i in range(100001)]
mem = [set() for i in range(C + 1)]

for i in range(N):
    s, t, c = map(int, input().split())
    if s not in mem[c]:
        db[s - 1] += 1
        mem[c].add(s)
    else:
        db[s] += 1
    
    if t not in mem[c]:
        db[t] -= 1
        mem[c].add(t)
    else:
        db[t - 1] -= 1

ans = 1
cnt = 0
for d in db:
    cnt += d
    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 26224
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; i--)
#define REP(i, k, n) for(int i=(int)(k); i<(int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const int INF = INT_MAX;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

int main(){
	int N; cin >> N;
	int a[N], f = 0;
	rep(i, N){
		char c; cin >> c;
		a[i] = c - '0';
		f += a[i]*(((N-1)&i)==i);
	}
	if(f%2) cout << 1 << endl;
	else{
		rep(i, N-1){
			if(a[i]%2 != a[i+1]%2){
				cout << 0 << endl;
				return 0;
			}
			f += abs(a[i+1]-a[i])/2*(((N-2)&i)==i);
		}
		if(f%2) cout << 2 << endl;
		else cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 4224
//	Author : amnptl 
//	   Godbless
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define NeedForSpeed() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD (1000000007); // 1e9+7
int main()
{
	NeedForSpeed();
	ll k,a,b; cin>>k>>a>>b; ll q = b/k; 		
	(q*k >=a && q*k <= b) ? cout<<"OK" : cout<<"NG";
	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n;
    cin >> n;
    int ans = 0;
    if(n<=3){
        ans = 0;
    }else{
        ans = (n-1)/2;
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
int factorial(int n) {
  if (n == 0) return 0;
  if (n == 1) return 1;
  return factorial(n-1)*n;
}

int combination(int n, int r) {
  if (n < r) return 0;
  if (n == r || r == 0) return 1;
  return factorial(n)/(factorial(r)*factorial(n-r));
}

int comb[2020][2020];
signed main() {
  comb[0][0] = 1;
  for (int i = 1; i < 2020; i++) {
    for (int j = 0; j < i+1; j++) {
      comb[i][j] = comb[i-1][j];
      if (j - 1 >= 0) comb[i][j] += comb[i-1][j-1];
      comb[i][j] %= MOD;
    }
  }

  int N, K;
  cin >> N >> K;
  for (int i = 0; i < K; i++) {
    cout << (comb[K-1][i] * comb[N-K+1][i+1]) % MOD << endl; 
  }
}



Measured memory_bytes: 30720
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
multiset<pair<int,int> > xCover,yCover;

bool isCover(const multiset<pair<int, int> > cover, int width){
  if(cover.begin()->first>0||cover.rbegin()->first<width)
    return false;
  int counter=0;
  for(auto iter=cover.begin();iter!=cover.end();++iter){
    counter+=iter->second;
    if(counter==0&&next(iter)!=cover.end()){
      return false;
    }
  }
  return true;
}

int main(){ _;
  int N,W,H;cin>>N>>W>>H;
  int x,y,w;
  REP(i,N){
    cin>>x>>y>>w;
    xCover.insert(make_pair(x-w,-1));
    xCover.insert(make_pair(x+w,1));
    yCover.insert(make_pair(y-w,-1));
    yCover.insert(make_pair(y+w,1));
  }
  if(isCover(xCover,W)||isCover(yCover,H))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 40640
n = int(input())
a = list(map(int, input().split()))
b = [0] * (n + 1)
for i in range(n):
    b[i + 1] = b[i] + a[i]
b.sort()
c, s = 0, b[0]
ans = 0
for i in b:
    if i == s:
        c += 1
    else:
        ans += c * (c - 1) // 2
        s = i
        c = 1
ans += c * (c - 1) // 2
print(ans)

Measured memory_bytes: 26720
#import sys
#input = sys.stdin.readline
def main():
    H, W, A, B = map( int, input().split())
    ANS = [ ['0']*W for _ in range(H)]
    now = 0
    A2 = 2*A
    B2 = 2*B
    if A == 0:
        for _ in range(B):
            print('1'*W)
        for _ in range(H-B):
            print('0'*W)
        return
    if B == 0:
        ans = '1'*A + '0'*(W-A)
        for _ in range(H):
            print(ans)
        return
            
    for i in range(H):
        if i >= B2:
            now = 0
        elif i % B2 >= B:
            now = A
        else:
            now = 0
        for j in range(W):
            if j >= A2:
               if now == 0:
                   ANS[i][j] = '1'
            elif (j+now)%A2 < A:
                ANS[i][j] = '1'
    for i in range(H):
        print( ''.join(ANS[i]))
if __name__ == '__main__':
    main()


Measured memory_bytes: 11892
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}
int main(){
  int n,X;cin>>n>>X;
  int x[n]={};
  fol(i,n){cin>>x[i];x[i] = abs(x[i]-X);}
  int d = x[0];
  fol(i,n){
    d = gcd(d,x[i]);
  }
  cout << d << endl;
  return 0;
}


Measured memory_bytes: 640
#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 all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a)                          \
    for (int i = 0; i < (a).size(); i++) \
        cin >> (a)[i];

int main()
{
    int N, K;
    cin >> N >> K;
    vll a(N), s(N+1);
    rep(i, N)
    {
        cin >> a[i];
    }
    partial_sum(a.begin(),a.end(), s.begin()+1);
    unordered_map<ll, int> sums;
    vll sumsInt;
    for (size_t i = 0; i < N+1; i++)
    {
        for (size_t j = i + 1; j < N+1; j++)
        {
            sums[(s[j] - s[i])]++;
            sumsInt.push_back(s[j]-s[i]);
        }
//        sums[s[i]]++;
//        sumsInt.push_back(s[i]);
    }
//    sumsInt.push_back(s.back());
//    sums[(s.back())]++;
    sort(all(sumsInt));
    bitset<60> ans = 0;
    for (int digit = 60; digit >= 0; digit--)
    {
        int cnt = 0;
        for (auto &&i : sums)
        {
            if ((i.first & (1LL<<digit)))
                cnt += i.second;
        }
        if (cnt >= K)
        {
            for (auto &&i : sums)
            {
                if (!(i.first & (1LL<<digit)))
                {
                    i.second=0;
                }
            }

            ans[digit] = 1;
        }
    }
    cout << ans.to_ullong() << endl;
    return 0;
}

Measured memory_bytes: 26928
a = [list(map(int,input().split())) for _ in range(3)]

flag = False
#print(a)
for a1 in range(101):
    for a2 in range(101):
        for a3 in range(101):
            if (a[0][0]-a1 == a[1][0]-a2 == a[2][0]-a3) and (a[0][1]-a1 == a[1][1]-a2 == a[2][1]-a3) and (a[0][2]-a1 == a[1][2]-a2 == a[2][2]-a3):
                flag = True
                break
if flag:
    print('Yes')
else:
    print('No')

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

int main()
{
	int n,m; cin>>n>>m;
	vector <int> g[n+1]; int indegree[n+1]={0}; queue <int> q; int LP[n+1];
	for (int i=0; i<m; i++)
	{
		int x,y; cin>>x>>y;
		g[x].push_back(y);
		indegree[y]++;
	}
	for (int i=1; i<=n; i++)
	{
		LP[i]=INT_MIN;
		if (indegree[i]==0)
		{
			q.push(i);
			LP[i]=0;
		}
	}
	while (q.size()!=0)
	{
		int cur = q.front(); q.pop();
		for (auto nxt : g[cur])
		{
			LP[nxt] = max( (LP[cur] + 1) , LP[nxt] );
			indegree[nxt]--;
			if (indegree[nxt]==0)
				q.push(nxt);
		}
	}
	int ans=0;
	for (int i=1; i<=n; i++)
		ans = max(ans,LP[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;
     
int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b, m;
  cin >> a >> b >> m;
  vector <int> a_i(a);
  for (int& elem: a_i) cin >> elem;
  vector <int> b_i(b);
  for (int& elem: b_i) cin >> elem;
  vector <int> x(m);
  vector <int> y(m);
  vector <int> c(m);
  int ans = *min_element(all(a_i)) + *min_element(all(b_i));
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i] >> c[i];
    x[i]--;
    y[i]--;
    int get = a_i[x[i]] + b_i[y[i]] - c[i];
    ans = min(ans, get);
  }
  cout << ans << '\n';
  return (0);
}


Measured memory_bytes: 2176
import java.util.*

fun main(args: Array<String>) {
    multipleOf2AndN()
}

private const val TWO = 2L

fun multipleOf2AndN() {
    val n = Scanner(System.`in`).nextLong()
    val result = n * TWO / gcd(n, TWO)

    println(result)
}

private tailrec fun gcd(m: Long, n: Long): Long {
    if (m < n) return gcd(n, m)
    if (n.toInt() == 0) return m
    return gcd(n, m % n)
}


Measured memory_bytes: 31400
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x,y,q;
    cin>>x>>y>>q;
    int x1,y1,d;
    int c=0,l=0;
    while (q--)
    {
        cin>>x1>>y1>>d;
        if (d==2)
        {
            if (x>x1)
                x=x1;
        }
        else if (d==4)
        {
            if (y>y1)
                y=y1;
        }
        else if (d==1)
        {
            if (x1>c)
                c=x1;
        }
        else
        {
            if (y1>l)
                l=y1;
        }
    }
    if (x>c &&y>l)
        cout<<(x-c)*(y-l)<<endl;
    else
        cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
import math
N, K = list(map(int,input().split()))
if K % 2:  ans = (N // K) ** 3
else:
    ans = (N // K) ** 3
    cnt = 0
    temp = K // 2
    while(1):
        if temp > N:  break
        cnt += 1
        temp += K
    ans += cnt ** 3
print(ans)

Measured memory_bytes: 62848
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	const int nmMax=50;
	char a[nmMax][nmMax],b[nmMax][nmMax];
	for(int y=0;y<n;++y){
		for(int x=0;x<n;++x){
			cin>>a[y][x];
		}
	}
	for(int y=0;y<m;++y){
		for(int x=0;x<m;++x){
			cin>>b[y][x];
		}
	}
	bool exist=false;
	for(int ly=0;ly<n;++ly){
		for(int lx=0;lx<n;++lx){
			if(ly+m-1>=n||lx+m-1>=n)continue;
			bool match=true;
			for(int y=0;y<m;++y){
				for(int x=0;x<m;++x){
					if(a[ly+y][lx+x]!=b[y][x])match=false;
				}
			}
			if(match)exist=true;
		}
	}
	if(exist) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ld pi=3.14159265358979323846;
 
int main() {
    string s;
    cin>>s;
    ll a=0,b=0;
    rep(i,s.size()){
        if ((i%2==0 and s[i]=='1') or (i%2==1 and s[i]=='0')){
            a++;
        }
    }
    rep(i,s.size()){
        if ((i%2==1 and s[i]=='1') or (i%2==0 and s[i]=='0')){
            b++;
        }
    }
    cout<<min(a,b)<<endl;
}

Measured memory_bytes: 3756
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std; 
typedef long long ll;
int a,b,c;
inline void read(int &x)
{
	int f;char c;
	for (f=1,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for (x=0;c<='9'&&c>='0';c=getchar()) x=x*10+(c&15);x*=f;
}
inline int mn(int _x,int _y)
{
	return _x<_y?_x:_y;
}
inline int mx(int _x,int _y)
{
	return _x>_y?_x:_y;
}
inline int ab(int _x)
{
	if(_x<0) return -_x;
	else return _x;
}
int main()
{
	read(a);read(b);read(c);
	printf("%d %d %d\n",c,a,b); 
	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int sx, sy, tx, ty;
    scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
    int i;
    int dx, dy;
    dx = tx - sx;
    dy = ty - sy;
    for (i = 0; i < dx; i++)
        printf("R");
    for (i = 0; i < dy; i++)
        printf("U");
    for (i = 0; i < dx; i++)
        printf("L");
    for (i = 0; i < dy + 1; i++)
        printf("D");
    for (i = 0; i < dx + 1; i++)
        printf("R");
    for (i = 0; i < dy + 1; i++)
        printf("U");
    printf("LU");
    for (i = 0; i < dx + 1; i++)
        printf("L");
    for (i = 0; i < dy + 1; i++)
        printf("D");
    printf("R\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int a,b; cin>>a>>b;
  for(int i=0;i<=a;i++){
    if(i*2+(a-i)*4==b){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=35;
const ll INF=1LL<<60;

ll dp[MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,T;cin>>N>>T;
    T++;
    vector<ll> A;
    vector<pair<ll,ll>> B;
    
    for(int i=0;i<N;i++){
        ll a,b;cin>>a>>b;
        if(a==0) A.push_back(b);
        else B.push_back({a,b});
    }
    
    sort(all(A));
    
    sort(all(B),[](pair<ll,ll> a,pair<ll,ll> b){
        return (1+a.second)*b.first<(1+b.second)*a.first;
    });
    
    for(int i=0;i<MAX;i++) dp[i]=INF;
    
    dp[0]=1;
    
    for(auto p:B){
        for(int i=33;i>=0;i--){
            if(dp[i]>T) continue;
            
            dp[i+1]=min(dp[i+1],dp[i]+dp[i]*p.first+p.second+1);
        }
    }
    
    int ans=0;
    
    for(int i=0;i<=33;i++){
        if(dp[i]>T) continue;
        ans=max(ans,i);
        for(int j=0;j<A.size();j++){
            dp[i]+=A[j]+1;
            if(dp[i]<=T) ans=max(ans,i+j+1);
            else break;
        }
    }
    
    cout<<ans<<endl;
}




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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int n; cin >> n; cout << n * n * n;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define int long long int
#define ull unsigned long long
#define PI 3.14159265
#define SIZE 200010
#define MOD 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define tc int tcs;cin>>tcs;while(tcs--)
#define set_bit __builtin_popcount
#define MSET(table,i) memset(table, i, sizeof(table))
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ){stringstream ss; ss<< number; return ss.str();}
int power(int x,int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}



int32_t main()
{
    fast;
    int n,k;
    cin>>n>>k;

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

    map<int,int> m;

    vector<int> v;

    int i=1;
    v.pb(1);
    m[1]=1;
    int l=k;
    int answer=-1;
    int x;
    while(1)
    {
        x=a[i];
        l--;
        if(m.find(x) == m.end())
        {
            m[x]=1;
            v.pb(x);
        }
        else
        {
            
            break;
        }
        if(l==0)
            {
                answer=x;
            }
        i=x;
    }

    

    if(answer==-1)
    {
        int j;
        int cnt=0;
        for(j=0;j<v.size();j++)
        {
            if(v[j] == x)
            {
                break;
            }
            cnt++;
        }

        int ind= (k-cnt)%(v.size()-cnt);
        
        cout<<v[ind + cnt]; 
    }
    else
    cout<<answer;

    return 0;
}

Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int A, B;
    cin >> A >> B;
    if (A > B)
        cout << "safe" << endl;
    else
        cout << "unsafe" << endl;
    return 0;
}

Measured memory_bytes: 3632
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n-1);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        a[i]--;
    }
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
    }
    for (int i = 0; i < n-1; i++) {
        std::cin >> c[i];
    }
    ll res = 0;
    for (int i = 0; i < n; i++) {
        res += b[a[i]];
        if(i>0){
            if(a[i] == a[i-1]+1){
                res+=c[a[i-1]];
            }
        }
    }
    std::cout << res << std::endl;
}


Measured memory_bytes: 256