akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

const int NIL = -1;
const int MAX = 2147483647;
const int NUM = 1000001;
clock_t START, END;
bool debug = false;

ll sumv[500000], setv[500000], sum[500000];
ll x, p, v, _num;

void query(ll o, ll L, ll R)
{
	ll M = L + (R - L) / 2;
	if (sumv[o] <= x) {
		_num += (R - L + 1) * (R - L + 2) / 2;
	}
	else {
		if (L == R)
			return;
		query(o * 2, L, M);
		query(o * 2 + 1, M + 1, R);
		ll left = L, right = M + 1, l_right = M;
		while (left <= M && right <= R) {
			if (sum[right] - sum[left - 1] <= x) {
				_num += (right - l_right) * (M - left + 1);
				l_right = right;
				right++;
			}
			else {
				left++;
			}
		}
		/*for (left = M; left >= L; left--) {
			for (right = M + 1; right <= R; right++) {
				if (sum[right] - sum[left - 1] <= x)
					_num++;
				else
					break;
			}
			if (right == M + 1)
				break;
		}*/
	}
}

void update(ll o, ll L, ll R)
{
	ll M = L + (R - L) / 2;
	if (L == R) {
		sumv[o] = v;
	}
	else {
		if (p <= M)
			update(o * 2, L, M);
		else
			update(o * 2 + 1, M + 1, R);
		sumv[o] = sumv[o * 2] + sumv[o * 2 + 1];
	}
}

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in20.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int N, Q;
	scanf("%d%d", &N, &Q);
	for (int i = 1; i <= N; i++) {
		scanf("%lld", &setv[i]);
		sum[i] = sum[i - 1] + setv[i];
		v = setv[i];
		p = i;
		update(1, 1, N);
	}
	for (int i = 0; i < Q; i++) {
		scanf("%lld", &x);
		_num = 0;
		query(1, 1, N);
		printf("%lld\n", _num);
	}
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 6848
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  
  if ( a[0] == a[1] && a[1] == a[2] ){
    cout << "Yes" << endl;
  }
  else if ( a[1] == a[2] && a[2] == a[3]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

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

    int ans = 700;
    REP(i, 3){
        if(s[i] == 'o'){
            ans += 100;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=505;
int a[MAXN][MAXN];
int main()
{
	int k=read();
	if(k<=500){pr2(k);for(int i=1;i<=k;i++){for(int j=1;j<=k;j++)pr1(j);puts("");}}
	else
	{
		int n=((k+3)/4)*2;
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)
		{
			if(i&1)a[i][j]=(i+j)%n+n;
			else a[i][j]=(i+j)%n;
		}pr2(n);
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)pr1(a[i][j]>=k?a[i][j]-n+1:a[i][j]+1);
			puts("");
		}
	}
	return 0;
}



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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define y1 dhwjdshg

using namespace std;

const int N = 200000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    ll n, n1, a, b;
    cin >> n >> a >> b;
    n1 = n;
    if (a + b - 1 > n)
    {
        cout << -1 << "\n";
        return 0;
    }
    if (a * b < n)
    {
        cout << -1 << "\n";
        return 0;
    }
    int cnt[b]; fill(cnt, cnt + b, 1);
    n -= b;
    repb(i, b - 1, -1)
    {
        int d = min(a - 1, n);
        n -= d;
        cnt[i] += d;
    }
    int cur = n1;
    rep(i, 0, b)
    {
        rep(j, cur - cnt[i] + 1, cur + 1)
            cout << j << " ";
        cur -= cnt[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int main()
{
    int x, y, ans = 0;
    cin >> x >> y;
    if (x * y == 1)
        ans += 400000;
    if (x == 1)
        ans += 300000;
    if (y == 1)
        ans += 300000;
    if (x == 2)
        ans += 200000;
    if (y == 2)
        ans += 200000;
    if (x == 3)
        ans += 100000;
    if (y == 3)
        ans += 100000;

    cout << ans << endl;
}

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

#define INF (INT64_MAX/2)

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

	vector<long long> acc( N );
	vector<long long> racc( N );
	for( int i = 0; i < N; i++ ) {
		if( i == 0 ) acc[i] = A[i];
		else acc[i] = acc[i - 1] + A[i];
	}
	for( int i = N - 1; i >= 0; i-- ) {
		if( i == N - 1 ) racc[i] = A[i];
		else racc[i] = racc[i + 1] + A[i];
	}
	long long ans = INF;
	for( int i = 0; i < N - 1; i++ ) {
		ans = min( ans, abs( acc[i] - racc[i + 1] ) );
	}

	cout << ans << endl;
}


Measured memory_bytes: 4992
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def same(x, y):
    if find(x) == find(y):
        return True
    else:
        return False

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

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

N, M, K = map(int, input().split())
par = [-1 for i in range(N + 1)]
rank = [0] * (N + 1)
frendCnt = [0] * (N + 1)
bloc = [[] for _ in range(N + 1)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    frendCnt[a] += 1
    frendCnt[b] += 1
    unite(a, b)

for i in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    bloc[c].append(d)
    bloc[d].append(c)

for i in range(N):
    ans = uCnt(i) - frendCnt[i] - 1
    for j in bloc[i]:
      if same(i, j):
           ans -= 1
    print(ans, end=' ')


Measured memory_bytes: 27044
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        long max = 0;
        if(X <= 3){
            System.out.println(1);
            return;
        }
        for(int i = 2;i*i <= X;i++){
            long power = i;
            while(true){
                power = power*i;
                if(power > X){
                    power = power / i;
                    break;
                }
            }
            max = Math.max(max,power);
        }
        System.out.println(max);
    }
}


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

int main() {
  ll n;cin>>n;
  int ans;
  for(int i=1;i<=sqrt(n);i++){
    ll x=n%i;
    if(x==0)ans=i;
  }
  cout<<ans-1+n/ans-1<<endl;
}

Measured memory_bytes: 3660
#include<iostream>

using namespace std;

int main(){
  int n;
  long long int a[109];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  long long int mx=0;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      mx = max(mx, abs(a[i]-a[j]));
    }
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N = inputInt()

	if N >= 30:
		print("Yes")
	else:
		print("No")

	#print(N)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 76780
#include<stdio.h>
#include<stdlib.h>


int main(){

  int data[200];
  int x=0;
  char input[5];
  int top = 1;


  while((scanf("%s",input)) != EOF){

    /* x = x + 1;*/

    /* scanf("%s",input);*/

    if(input[0] == '+'){

      data[top - 2] = data[top -2] + data[top -1];
      top = top- 1;

    }

    else if(input[0] == '-'){

      data[top -2] = data[top-2] - data[top -1];
      top = top -1;

    }

    else if(input[0] =='*'){

      data[top-2] = data[top-2] * data[top -1];
      top = top -1;

    }

    else if(input[0] == '/'){

      data[top -2] = data[top -2] * data[top - 1];
      top = top -1;

    }

    else{

      data[top] = atoi(input);

      /*printf("%d\n",data[top]);*/

      top = top + 1;

    }

  }

  printf("%d\n",data[1]);

  return 0;

}

Measured memory_bytes: 548
import std;

auto input()
{
    return readln().chomp();
}

alias sread = () => readln.chomp();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    long a, b;
    scan(a, b);
    if ((a <= 9) && (b <= 9))
    {
        writeln(a * b);

    }
    else
    {
        writeln(-1);
    }
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

auto binary_search(long key, long[] l)
{
    long left = 0; //lの左端
    long right = l.length - 1; //lの右端
    while (right >= left)
    {
        long mid = left + (right - left) / 2; //区間の真ん中
        if (l[mid] == key)
        {
            return mid;
        }
        else if (l[mid] > key)
        {
            right = mid - 1;
        }
        else if (l[mid] < key)
        {
            left = mid + 1;
        }

    }
    return -1;
}

// auto a = [1, 14, 32, 51, 51, 51, 243, 419, 750, 910];
// auto a = aryread();
// writeln(a);
// long len_a = a.length;
// writeln(len_a);
// long ans;
// ans = binary_search(51, a);
// writeln(ans);


Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main()
{
    string ss;
	int out=0,point=0;
	bool base[3];
	int xx=0;
	int n;
	cin >> n;
	base[0]=base[1]=base[2]=false;
	while(xx<n){
		cin >> ss;
		if(ss=="HIT"){
			if(base[2]){
				point++;
			}
			if(base[1]){
				base[2]=true;
			}
			if(base[0]){
				base[1]=true;
			}
			base[0]=true;
		}
		else if(ss=="OUT"){
			out++;
			if(out==3){
				printf("%d\n",point);
				xx++;
				point=out=0;
				for(int i=0;i<3;i++)base[i]=false;
			}
		}
		else{
			point++;
			if(base[2]){
				point++;
				base[2]=false;
			}
			if(base[1]){
				point++;
				base[1]=false;
			}
			if(base[0]){
				point++;
				base[0]=false;
			}
		}
		/*for(int i=0;i<3;i++){
			if(base[i])printf("YES ");
			else printf("NO ");
		}
		printf("\n");
		*/
	}
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int L,R;
    cin >> L >> R;
    long long int ans = 2020;
    for(long long int i = L;i <= min(R,L+4038);i++){
        for(long long int j = i+1;j <= min(R,L+4038);j++){
            long long int a = i*j % 2019;
            ans = min(a,ans);
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long ull;
const double EPS= (1e-9);
using namespace std;
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=0;
vector<int> v;
int main(){

    int n,m;
    cin>>n>>m;
    ll sum=0;
    for(int i=0;i<n;i++){
        int no;
        cin>>no;
        sum+=no;
        v.pb(no);
    }
    sort(allr(v));
    int cnt=0;
    for(int i=0;i<sz(v);i++){
        if(v[i]>=(sum/(4*m))+((sum%(4*m)!=0))) cnt++;
    }
    if(cnt>=m) cout<<"Yes\n";
    else
        cout<<"No\n";
}
































































































































































































































































































































































































































































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

int main(void){
    int a,b;
    cin >> a >> b;
    int A = a+b;
    int B = a-b;
    int C = a*b;
    int c = max(A,B);
    int d = max(c,C);
    cout << d << endl;
}

Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    V<string> vs = {
        "Sunny", 
        "Cloudy", 
        "Rainy",
    };
    string S;
    cin >> S;
    auto ite = find(ALL(vs), S);
    auto idx = distance(vs.begin(), ite);
    idx++;
    idx %= 3;
    cout << vs[idx] << endl;
    return 0;
}


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

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

  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());

  ll left = 0, right = 1000000000005, mid;

  while(left < right){
    mid = (left + right) / 2;
    ll sum = 0;
    rep(i, n){
      sum += max(a[i] - mid / f[i], 0LL);
    }
    if(sum <= k){
      right = mid;
    }
    else{
      left = mid + 1;
    }
  }
  cout << left << endl;


  return 0;
}


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

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

int sx[256];
int sy[256];


int main()
{
	int N,n,d;
	while(cin >> N, N)
	{
		sx[0] = sy[0] = 0;
	
		for(int i=1; i<N; i++)
		{
			cin >> n >> d;
			sx[i] = sx[n]+dx[d];
			sy[i] = sy[n]+dy[d];
		}

		int minx=(1<<20), maxx=-(1<<20);
		int miny=(1<<20), maxy=-(1<<20);
		for(int i=0; i<N; i++)
		{
			minx = min(minx,sx[i]);
			maxx = max(maxx,sx[i]);
			miny = min(miny,sy[i]);
			maxy = max(maxy,sy[i]);
		}
		cout << maxx-minx+1 << " " << maxy-miny+1 << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

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

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

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

  long long a[110000][3];
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> a[i][j];
    }
  }
  
  long long dp[110000][3];
  
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        if (j == k) continue;
        chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
      }
    }
  }
  
  long long ans = 0;
  for (int j = 0; j < 3; ++j) {
    chmax(ans, dp[N][j]);
  }
  cout << ans << endl;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream&
operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream&
operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream&
operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

vector<ll> generate_primes(ll N) {
    vector<int> is_prime(N, 1);
    vector<ll> primes;
    repeat(i, 2, N) {
        if(not is_prime[i]) continue;
        primes.push_back(i);
        for(ll j = i * 2; j < is_prime.size(); j += i) is_prime[j] = 0;        
    }
    return primes;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    auto primes = generate_primes(pow(1e10, 1.0/3.0)+10);
    set<ll> primes2;    
    for(ll p : generate_primes(sqrt(1e10) + 10)) primes2.insert(p*p);
    
    int N; cin >> N;
    vector<ll> S(N); cin >> S;

    map<ll, int> normalized_s;

    auto normalize = [&] (ll s) {
        for(ll p : primes) {
            ll ppp = p * p * p;
            while(s % ppp == 0) s /= ppp;            
            if(s == 1) break;
        }
        return s;
    };
    
    for(ll s : S) {
        normalized_s[normalize(s)]++;
    }
    
    int ans = 0;
    set<ll> used;
    for(auto s_ : normalized_s) {
        ll s = s_.first;
        int cnt = s_.second;
        assert(cnt > 0);
        if(used.count(s)) continue;
        ll t = normalize(s * s);
        used.insert(s);
        used.insert(t);
        
        int s_cnt = cnt;
        int t_cnt = normalized_s.count(t) ? normalized_s[t] : 0;
        
        ans += s == t ? 1 : max(s_cnt, t_cnt);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 17068
#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;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	ll n, W;
	cin >> n >> W;
	
	vll w(n), val(n);
	for(int i=0 ; i<n ; ++i){
		cin >> w[i] >> val[i];
	}
	
	vvll dp(n+1, vll(1e5+1, 1e18));
	dp[1][0] = 0;
	dp[1][val[0]] = w[0];
	for(int i=2 ; i<=n ; ++i){
		dp[i][0] = 0;
		for(int j=1 ; j<1e5+1 ; ++j){
			dp[i][j] = dp[i-1][j];
			if(j >= val[i-1]){
				dp[i][j] = min(dp[i][j], dp[i-1][j-val[i-1]] + w[i-1]);
			}
		}
	}
	
	for(int i=1e5 ; i>=0 ; --i){
		if(dp[n][i] <= W){
			cout << i;
			return;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 83192
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
using namespace std;
int dp[1001][1001];
int w[1001],c[1001];
int sumw[1001];
int main(){
	int n;
	cin>>n;
	cin>>c[0]>>w[0];
	sumw[0]=w[0];
	REP(i,1,n) {
		cin>>c[i]>>w[i];
		sumw[i]=sumw[i-1]+w[i];
	}
	REP(i,0,n) REP(j,i,n) dp[i][j]=j-i+1;
	REP(i,0,n-1)  if(c[i]>=w[i+1]||c[i+1]>=w[i]) dp[i][i+1]=1;

	for(int k=2;k<n;k++){
		for(int i=0;i+k<n;i++){
			if((dp[i+1][i+k]==1&&c[i]>=sumw[i+k]-sumw[i])||(dp[i][i+k-1]==1&&c[i+k]>=sumw[i+k-1]-(i?sumw[i-1]:0)))
				dp[i][i+k]=1;
			for(int j=i+1;j<i+k;j++)
				dp[i][i+k]=min(dp[i][i+k],dp[i][j]+dp[j+1][i+k]);
		}
	}
	p(dp[0][n-1]);
	return 0;
}

Measured memory_bytes: 6996
#include <stdio.h>
#define NIL -1
#define MAX 25

typedef struct{
  int parent,left,right;
} Node;
Node Tree[MAX];
int kazu,Depth[MAX],Height[MAX];

int setHeight(int u){
  int h1,h2;
  h1=h2=0;
  if(Tree[u].right!=NIL) h1=setHeight(Tree[u].right)+1;
  if(Tree[u].left!=NIL) h2=setHeight(Tree[u].left)+1;
  if(h1>h2) return Height[u]=h1;
  else return Height[u]=h2;
}
void setDepth(int u,int depth){
  if(u==NIL) return;
  Depth[u]=depth;
  if(Tree[u].right!=NIL) setDepth(Tree[u].right,depth+1);
  if(Tree[u].left!=NIL) setDepth(Tree[u].left,depth+1);
}
int getSibling(int u){
  if(Tree[u].parent==NIL) return NIL;
  else if(Tree[Tree[u].parent].left==NIL || Tree[Tree[u].parent].right==NIL)
    return NIL;
  else if(Tree[Tree[u].parent].left==u) return Tree[Tree[u].parent].right;
  else return Tree[Tree[u].parent].left;
}


int main(){
  int root,id,i,r,l,degree[MAX];
  char typ[MAX][15];
  scanf("%d",&kazu);
  for(i=0;i<kazu;i++)Tree[i].parent=Tree[i].left=Tree[i].right=NIL;
  for(i=0;i<kazu;i++){
    scanf("%d%d%d",&id,&r,&l);
    if(r==-1&&l==-1) degree[id]=0;
    else if(r==-1 || l==-1) degree[id]=1;
    else degree[id]=2;
    Tree[r].parent=id;
    Tree[l].parent=id;
    Tree[id].right=r;
    Tree[id].left=l;
  }
  for(i=0;i<kazu;i++) if(Tree[i].parent==NIL) root=i;
  setDepth(root,0);
  setHeight(root);
  for(i=0;i<kazu;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,",i,Tree[i].parent,getSibling(i),degree[i],Depth[i],Height[i]);
    if (Depth[i]==0) printf(" root\n");
    else if(Height[i]==0) printf(" leaf\n");
    else printf(" internal node\n");
  }
  return 0;
}



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

int main() {
  vector<int> ns(4 + 1, 0);
  int a, b;
  for(int i = 0; i < 3; ++i) {
    cin >> a >> b;
    ns[a]++;
    ns[b]++;
  }
  for(int i = 1; i <= 4; ++i) {
    if(ns[i] >= 3) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#define For(N) for (int i = 0; i < N; i++)

using namespace std;
using ll = long long int;

void say(string);

int main() {
	int N;
	int A, B;
	int ans = 0;
	cin >> N >> A >> B;
	For(N + 1) {
		int sum = 0;
		for (int j = 0; j < 5; j++) {
			int s = (int)pow(10, j);
			sum += (i / s) % 10;
		}
		if (A <= sum&&sum <= B)ans += i;
	}
	say(to_string(ans));
	return 0;
}

void say(string s) {
	cout << s << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <complex>
#include <iomanip>
#include <random>

using namespace std;

typedef long long ll;
#define int long long

int M = (int)1e9 + 7;
#define msum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define msub(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define mmult(a, b) (((a) * (b)) % M)

typedef long double ld;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vlll;
typedef vector<double> vd;
typedef vector<vd> vdd;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpi;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SZ(a) ((int)(a).size())
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);
const int oo = 1e18 + 100;
const string DIGITS = "0123456789", alph = "abcdefghijklmnopqrstuvwxyz", ALPH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

//THE END OF TEMPLATE////////////////////////////////////////////////////////////////////////////////

#define N 3100

double dp[N][N];


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

	int n;
	cin >> n;
	double p, q;
	dp[0][0] = 1.0;
	for (int i = 1; i <= n; i++)
	{
		cin >> p;
		q = 1.0 - p;
		dp[i][0] = dp[i - 1][0] * q;
		for (int j = 1; j <= i; j++)
		{
			dp[i][j] = dp[i - 1][j] * q;
			dp[i][j] += dp[i - 1][j - 1] * p;
		}
	}


	double sum = 0.0;
	for (int i = n / 2 + 1; i <= n; i++)
	{
		sum += dp[n][i];
	}

	cout << setprecision(12) << sum;
}

//m1.codeforces.com, m2.codeforces.com или m3.codeforces.com

Measured memory_bytes: 72320
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


// ----------------------------------------------------------------------------
int main(){
  string s,q;
  cin >> s >> q;
  s += s;
  for(int i=0; i<s.size()-q.size(); i++){
    if(q == s.substr(i,q.size())){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}



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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int a[110000];
signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(A: int, B: int, C: int):
    a, b, c = sorted([A, B, C])
    return a + b + 10 * c


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    result = solve(A, B, C)
    print(result)

if __name__ == '__main__':
    main()


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

int main() {
	int N,R;
	cin >> N >> R;
	int naibu;
	if(N>=10){
		cout << R << endl;
	} else {
		cout << R + 100* (10-N) << endl;
	}
}

Measured memory_bytes: 256
import math
anslist = []

while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break

    diagonal = h * h + w * w
    i = h + 1
    #print(diagonal)
    while True:
        #print(i, diagonal - i * i, diagonal)
        if i * i >= diagonal - i * i:
            i = 0
            diagonal += 1
        elif math.sqrt(diagonal - i * i) == int(math.sqrt(diagonal - i * i)):
            anslist.append([i, int(math.sqrt(diagonal - i * i))])
            break
        i += 1

for i, j in anslist:
    print(i, j)


Measured memory_bytes: 5684
#include <bits/stdc++.h>
#define F first
#define S second
#define int long long
using namespace std;
typedef long long ll;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<ll> pos(n + 1);
    for (int i = 0; i < n; ++ i) {
        int a;
        cin >> a;
        pos[a] = i;
    }
    multiset<ll> ms;
    ms.insert(-1); ms.insert(-1);
    ms.insert(n); ms.insert(n);
    ll ans = 0;
    for (int i = n; i >= 1; -- i) {
        ms.insert(pos[i]);
        auto it = ms.find(pos[i]);
        it --;
        int a = *it;
        it --;
        int b = *it;
        ++ it, ++ it;
        ++ it;
        int x = *it;
        ++ it;
        int y = *it;
        ans += i * (a - b) * (x - pos[i]);
        ans += i * (pos[i] - a) * (y  - x);
    }
    cout << ans;
}

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

bool isPalindrome(string s) {
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

int main() {
    string s;
    cin >> s;
    bool ans = true;
    if (!isPalindrome(s)) {
        ans = false;
    }
    if (!isPalindrome(s.substr(0, s.size()/2))) {
        ans = false;
    }

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

    return 0;
}

Measured memory_bytes: 256
list1=[int(i) for i in input().split()]
A = list1[0]
B = list1[1]
C = list1[2]
#print(A)

tobe = int(A)- int(B)
if tobe < 0:
  tobe = int(0)

#print(tobe)

answer = int(C) - int(tobe)
if answer < 0:
  answer = int(0)
print(int(answer))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;
const ll mod=9982453;

int main(){
    int x;cin>>x;
    if(x==1)cout<<0<<endl;
    else cout<<1<<endl;
}

Measured memory_bytes: 3616
//Don't give up too easy bhai
#pragma GCC optimize("-O3")
 
#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define double long double
#define inf 1e18

typedef pair<int,int> pii;
 
#define forall(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define vi vector<int>
#define vd vector<double>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007
#define br cout<<"\n"
#define whatis(x) cerr << "var "<<#x << " ==> " << x<<"\n"
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define T int __t;cin>>__t;while(__t--)

void solve()
{
    int n,k;cin>>n>>k;
    vi a(n);inputv(a);

    // int cur = 0;
    for(int i=k;i<n;i++)
    {
        if(a[i] <= a[i-k]) cout<<"No";
        else cout<<"Yes";
        br;
    }

}

signed main()
{
    fast;

    solve();
    return 0;
}

Measured memory_bytes: 4780
#pragma GCC optimize ("O3")

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

using QWORD = unsigned long long;
using SQWORD = long long;
using DWORD = unsigned int;
using SDWORD = int;
using WORD = unsigned short;
using SWORD = short;
using DOUBLE = double;
using FLOAT = float;

#define MIN_SDWORD (-2147483648)
#define MAX_SDWORD (2147483647)
#define ArrayLength(a)  (sizeof(a) / sizeof(a[0]))

static inline QWORD MAX(QWORD a, QWORD b) { return a > b ? a : b; }
static inline DWORD MAX(DWORD a, DWORD b) { return a > b ? a : b; }
static inline SDWORD MAX(SDWORD a, SDWORD b) { return a > b ? a : b; }
static inline QWORD MIN(QWORD a, QWORD b) { return a < b ? a : b; }
static inline DWORD MIN(DWORD a, DWORD b) { return a < b ? a : b; }
static inline SDWORD MIN(SDWORD a, SDWORD b) { return a < b ? a : b; }

#define BYTE_BITS   (8)
#define WORD_BITS   (16)
#define DWORD_BITS  (32)
#define QWORD_BITS  (64)

using M_BOOL = bool;
#define M_TRUE (true)
#define M_FALSE (false)

static void printMatrix(DWORD **p, DWORD dwSize)
{
    printf("---\n");
    for (DWORD i = 0; i < dwSize; i++) {
        for(DWORD j = 0; j < dwSize; j++) {
            printf("%5d", p[i*dwSize + j]);
        }
        cout << endl;
    }
    printf("---\n");
}

static inline SDWORD inputSDWORD(void)
{
    SDWORD lNumber = 0;
    M_BOOL bRead = M_FALSE;
    for (;;) {
        char c = getchar();
        if (('0' <= c) && (c <= '9')) {
            lNumber *= 10;
            lNumber += (c - '0');
            bRead = M_TRUE;
        } else {
            if (bRead) {
                return lNumber;
            }
        }
    }
}

#define MAX_STR_LEN (100)

int main()
{
    DWORD dwInput_N, dwInput_M, dwInput_Q;
 
    static char str[MAX_STR_LEN + 1];

    /* string input */
    fgets(str, ArrayLength(str), stdin);

    dwInput_N = inputSDWORD();
    DWORD dwIdx = 0;
    while(1) {
        if (dwInput_N - 1 <= dwIdx) {
            break;
        }
        if (str[dwIdx] != '1') {
            break;
        }
        dwIdx++;
    }
    printf("%c\n", str[dwIdx]);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long i,ans=1;

int main(){
	int n;
	cin>>n;
	for(i=1;i<=n;i++)
		ans=ans*i%mod;
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 3612
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

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

}

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

fn main(){
    let n: usize = read_as_vec()[0];
    let mut h: Vec<i32> = read_as_vec();

    if n == 1{
        println!("Yes");
        return;
    }

    if h[0] > 1{
        h[0] -= 1;
    }
    //println!("{:?}", h);
    //decrease each height by 1
    for i in 0..n-1{
        if h[i] < h[i+1]{
            h[i+1] -= 1;
        }
    }

    //println!("{:?}", h);
    
    //judge
    for i in 0..n-1{
        if h[i] > h[i+1]{
            println!("No");
            return;
        }
    }
    println!("Yes");    
}


Measured memory_bytes: 6396
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 

const int MAX_V = 10000;


int main(){
	int n,m;
	while(cin>>n>>m){
		if(n==0 && m==0) break;
		vi s(m,0);
		rep(i,m) cin>>s[i];
		int t;
		rep(i,n){
			rep(j,m){
				cin>>t;
				s[j]-=t;
			}
		}
		sort(all(s));
		cout<<(s[0]<0?"No":"Yes")<<endl;
	}
}

Measured memory_bytes: 1208
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0] * (n+1)
B = [0] * (m+1)
for i in range(n):
    A[i+1] = A[i] + a[i]
for i in range(m):
    B[i+1] = B[i] + b[i]

ans = 0
j = m
for i in range(n+1):
    if A[i] > k:
        break
    while B[j] > k - A[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47424
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(void){

    char c[2][3];
    for(int  i = 0; i < 2; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }

    if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int main() {
  int a,b,c;
  cin >> a >> b >> c;
  swap(a,b);swap(a,c);
  cout << a << " "<< b << " "<< c << endl;
  
  
  return 0;
}



Measured memory_bytes: 256
import sys
from collections import *
import copy
input=lambda :sys.stdin.readline().rstrip()
N,W=map(int,input().split())
WV=[list(map(int,input().split())) for i in range(N)]

lst=deque([])
for w,v in WV:
    nlst=deque([[w,v]])
    for i in range(len(lst)):
        w1,v1=lst[i]
        if w1+w<=W:
            if w1:
                nlst.append([w1+w,v1+v])
    if not lst:
        lst=copy.copy(nlst)
        continue
    Xlst=lst
    lst=deque()

    if Xlst or nlst:
        w1,v1=nlst[0]
        w2,v2=Xlst[0]
        if w1<w2:
            lst.append(nlst.popleft())
        else:
            lst.append(Xlst.popleft())
    while Xlst or nlst:
        w,v=lst[-1]
        if Xlst and nlst:
            w1,v1=nlst[0]
            w2,v2=Xlst[0]

            if w==w1:
                if v>=v1:
                    nlst.popleft()
                else:
                    lst.pop()
                    lst.append(nlst.popleft())
            elif w==w2:
                if v>=v2:
                    Xlst.popleft()
                else:
                    lst.pop()
                    lst.append(Xlst.popleft())
            else:
                if w1<w2:
                    if v>=v1:
                        nlst.popleft()
                    else:
                        lst.append(nlst.popleft())
                else:
                    if v>=v2:
                        Xlst.popleft()
                    else:
                        lst.append(Xlst.popleft())
        elif nlst:
            w1,v1=nlst[0]
            if w==w1:
                if v>=v1:
                    nlst.popleft()
                else:
                    lst.pop()
                    lst.append(nlst.popleft())
            else:
                if v>=v1:
                    nlst.popleft()
                else:
                    lst.append(nlst.popleft())
        elif Xlst:
            nlst=Xlst
            Xlst=deque()



lst.append([0,0])
print(max([v for w,v in lst if w<=W]))


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
  int n,m; cin>>n>>m;
  vector<int>Ans(n+1,0); //Ans[0]は使わない
  rep(i,m){
    int a,b; cin>>a>>b;
    for (int j=1; j<=n; j++){
      if (a==j) Ans[j]++;
      if (b==j) Ans[j]++;
    }
  }
  for (int i=1; i<=n; i++) cout << Ans[i] << endl;
}

Measured memory_bytes: 3568
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();

        long ans = 0;
        long c = 1;
        while (c*c <= N) {
            if (N%c == 0) {
                if (c-1 > 0 && N/(c-1) == N%(c-1)) {
                    ans += c-1;
                }
                long d = N/c;
                if (d-1 > 0 && N/(d-1) == N%(d-1)) {
                    ans += d-1;
                }
            }
            c++;
        }

        System.out.println(ans);
    }
}



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

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

  int n, mxCar, s, t; cin >> n >> mxCar >> s >> t;
  vec<int, 1> a(n);
  for (auto& i : a) {
    cin >> i;
  }

  vec<bool, 1> del(18);
  for (int i = 0; i < 18; ++i) {
    del[i] = (s >> i & 1) || !(t >> i & 1);
  }
  int const mxBit = static_cast<int>(count(all(del), false));

  vec<int, 1> b;
  for (auto& i : a) {
    int ret = 0;
    for (int k = 0, j = 0; k < 18; ++k) {
      if (del[k]) {
        if (((s >> k & 1) && !(i >> k & 1)) || (!(t >> k & 1) && (i >> k & 1))) {
          ret = -1;
          break ;
        }
      } else {
        if (i >> k & 1) {
          ret |= 1 << j;
        }
        ++j;
      }
    }
    if (~ret) {
      b.emplace_back(ret);
    }
  }
  a = b;
  s = 0;
  t = (1 << mxBit) - 1;

  vec<LL, 2> binom(sz(a) + 1), pref(sz(a) + 1);
  for (int i = 0; i < sz(binom); ++i) {
    binom[i] = pref[i] = vec<LL, 1>(i + 1);
    binom[i][0] = binom[i][i] = 1;
    for (int j = 1; j < i; ++j) {
      binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
    }
    for (int j = 1; j <= i; ++j) {
      pref[i][j] = pref[i][j - 1] + binom[i][j];
    }
  }

  LL ans = 0;

  vec<int, 1> cnt(1 << mxBit), vis(1 << mxBit);
  for (int mask = 0; mask < 1 << mxBit; ++mask) {
    LL ret = 0;
    for (auto& i : a) {
      ++cnt[i & mask];
    }
    for (auto& i : a) {
      if (!vis[i & mask]) {
        int tmp = cnt[i & mask];
        ret += (tmp < mxCar ? pref[tmp][tmp] : pref[tmp][mxCar]);
        vis[i & mask] = true;
      }
    }
    for (auto& i : a) {
      --cnt[i & mask];
      vis[i & mask] = false;
    }

    ans += (__builtin_popcount(mask) & 1 ? -ret : ret);
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 5284
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
int n, m, q;
int a[51], b[51], c[51], d[51];
int v[11];
int ans = 0;
 
 
int main() {
    int N, M;
    cin >> N >> M;
    
    vector<long long> H;
    set<long long> st;
    for (int i= 0;i<N;i++){
        long long HM = 0;
        cin >> HM;
        H.push_back(HM);
        st.insert(i+1);
    }

    for (int i= 0;i<M;i++){
        long long n1 ,n2;
        cin >> n1 >> n2;
        if (H[n1-1] <= H[n2-1]){
            st.erase(n1);
        }
        if(H[n1-1] >= H[n2-1]) {
            st.erase(n2);
        }
    }
   
    
    cout << st.size() <<endl;
    return 0;
}


Measured memory_bytes: 8832