akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

string s;
int use;

string ReplaceAll(string s,string a, string b){
  int p = s.find(a);
  while(p!=string::npos){
    s.replace(p,a.size(),b);
    p = s.find(a);
  }
  return s;
}

bool parse(int l,int r){
  int p = 0;
  for(int i=l;i<r;i++){
    if(s[i] == '(')p++;
    if(s[i] == ')')p--;
    if(!p){
      if(s[i] == '*')return parse(l,i) && parse(i+1,r);
      if(s[i] == '+')return parse(l,i) || parse(i+1,r);
      if(s[i] == '-' && s[i+1] == '>')return !parse(l,i) || parse(i+2,r);
    }
  }

  if(s[l] == '-')return !parse(l+1,r);
  if(s[l] == '(' && s[r-1] == ')')return parse(l+1,r-1);
  if(s[l] == 'T')return true;
  if(s[l] == 'F')return false;
  return ( ( use >> (s[l]-'a') ) & 1);
}

int main(){
  while(cin >> s,s!="#"){
    s = ReplaceAll(s,"--","");
    int x = s.find("=");
    bool f = true;
    for(use=0;use<(1<<11);use++){
      f &= parse(0,x) == parse(x+1,s.size());
      if(!f)break;
    }
    cout << (f?"YES\n":"NO\n");
  }
}

Measured memory_bytes: 900
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    N = int(input())
    xy = [list(map(int, input().split())) for _ in range(N)]

    ans = [0]
    p = 1
    for i in range(N):
        p *= i+1
    def dfs(d, perm):
        if d==N:
            dist = 0
            for i in range(N-1):
                dist += ((xy[perm[i+1]][0]-xy[perm[i]][0])**2+(xy[perm[i+1]][1]-xy[perm[i]][1])**2)**0.5
            ans[0] += dist
        else:
            for i in range(N):
                if i not in perm:
                    dfs(d+1, perm+[i])

    dfs(0, [])
    print(ans[0]/p)

if __name__ == '__main__':
    resolve()


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

int main()
{
    string a,b;
    int e;
    cin>>a>>b;
    int c = stoi(a+b);
    e=sqrt(c);
    if (e * e == c)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, x, j, s, c;
	for(;;) {
		scanf("%d %d", &n, &x);
		if (n+x==0) exit(0);
		for (c=0; n>2; n--) {
			for (s=x-n-(j=1); (s>j)&(j<n); s--,j++) {
				if ((s>0)&(s<n)) {
					c++;
				}
			}
		}
		printf("%d\n", c);
	}
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';
ll const mod = 1e9+7;

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

int main() {
    int n,k;
    cin >> n >> k;
    bool f = true;
    vector<pair<ll,bool>> a(n);
    for (int i = 0;i < n;++i) {
        cin >> a[i].first;
        a[i].second = (a[i].first >= 0);
        if (a[i].second) f = false;
        a[i].first = abs(a[i].first);
    }
    sort(a.begin(),a.end());
    ll ans;
    if (f && k%2) {
        ans = -1;
        for (int i = 0;i < k;++i) (ans *= a[i].first) %= mod;
    } else {
        reverse(a.begin(),a.end());
        ans = 1;
        bool s = true;
        for (int i = 0;i < k;++i) {
            (ans *= a[i].first) %= mod;
            if (!a[i].second) s = !s;
        }
        if (!s) {
            ll w = -1,x = -1,y = -1,z = -1;
            for (int i = k;i < n;++i) if (a[i].second) {
                w = a[i].first;
                break;
            }
            for (int i = k-1;i >= 0;--i) if (!a[i].second) {
                x = a[i].first;
                break;
            }
            for (int i = k;i < n;++i) if (!a[i].second) {
                y = a[i].first;
                break;
            }
            for (int i = k-1;i >= 0;--i) if (a[i].second) {
                z = a[i].first;
                break;
            }
            if ((w < 0 || x < 0) && (y < 0 || z < 0)) ans *= -1;
            else if (w < 0 || x < 0) (ans *= y*pow_mod(z,-1)%mod) %= mod;
            else if (y < 0 || z < 0) (ans *= w*pow_mod(x,-1)%mod) %= mod;
            else if (y*x > w*z) (ans *= y*pow_mod(z,-1)%mod) %= mod;
            else (ans *= w*pow_mod(x,-1)%mod) %= mod;
        }
    }
    cout << (ans+mod)%mod << endl;
    // p_ary(a,0,n);
}


Measured memory_bytes: 6424
N,M = map(int,input().split())
all_favourite = list(range(1,M+1))
for i in range(N):
  asking_people = list(map(int, input().split()))
  for j in range(M):
    if all_favourite[j] not in asking_people[1:]:
      all_favourite[j] = 0
count = 0
for k in range(M):
  if all_favourite[k] != 0:
    count += 1
    
print(count)

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)


int main() {
    i64 n,d;
    cin >> n >> d;

    vector<i64> x(n);
    vector<i64> y(n);

    rep(i, n){
        cin >> x[i] >> y[i];
    }

    u64 ans=0;

    rep(i,n){
        if(x[i]*x[i]+y[i]*y[i] <= d*d){
            ans++;
        }
    }

    cout << ans;

  return 0;
}


Measured memory_bytes: 6416
arrays = []
3.times { |i| arrays << gets.chomp.split(' ').map(&:to_i) }
a = Array.new(3, nil)
b = Array.new(3, nil)

101.times do |i|
  a[0] = i
  b[0] = arrays[0][0] - a[0]
  b[1] = arrays[0][1] - a[0]
  b[2] = arrays[0][2] - a[0]
  a[1] = arrays[1][1] - b[1]
  a[2] = arrays[2][2] - b[2]
  
  next if a.any? { |t| t < 0 } || b.any? { |t| t < 0 }
  corrects = []
  3.times do |j|
    3.times do |k|
      corrects << (arrays[j][k] == (a[j] + b[k]))
    end
  end

  if corrects.all?
    puts 'Yes'
    exit
  end
end
puts 'No'

Measured memory_bytes: 1788
#include <iostream>

int main()
{
    long long N, K;
    std::cin >> N >> K;

    if (N > K) {
        N = N % K;
    }

    if (K - N > N) {
        std::cout << N;
    } else {
        std::cout << (K - N) << std::endl;
    }

    return 0;
}

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

int main(){
        int N;
        int d[100];

        cin >> N;
        for (size_t i = 0; i < N; i++) {
                cin >> d[i];
        }


        set<int> values;
        for (size_t i = 0; i < N; i++) {
                values.insert(d[i]);
        }

        cout << values.size() << endl;

        return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

bool isOnSegment(Vec2 p, Vec2 a, Vec2 b) {
    auto ab = b - a;
    auto ap = p - a;

    if (ab.cross(ap) != 0)
        return false;

    // ab ??¨ ap ????????????
    if (ab.dot(ap) < 0)
        return false;

    // p ??? ab ?????????????????????
    if (ab.magSq() >= ap.magSq())
        return true;

    return false;
}

bool isIntersectLineSegments(Vec2 a, Vec2 b, Vec2 c, Vec2 d) {
    auto s = (b - a).cross(c - a) * (b - a).cross(d - a);
    auto t = (d - c).cross(a - c) * (d - c).cross(b - c);

    if (s < 0 && t < 0)
        return true;

    // ???????????????????????????
    if (isOnSegment(c, a, b) || isOnSegment(d, a, b) || isOnSegment(a, c, d) || isOnSegment(b, c, d)) {
        return true;
    }
    return false;
}

void main() {
    int q = readint();
    for (int i = 0; i < q; i++) {
        auto xs = readints();
        auto a = Vec2(xs[0], xs[1]);
        auto b = Vec2(xs[2], xs[3]);
        auto c = Vec2(xs[4], xs[5]);
        auto d = Vec2(xs[6], xs[7]);

        if (isIntersectLineSegments(a, b, c, d))
            writeln(1);
        else
            writeln(0);
    }
}

struct Vec2 {
    immutable double x;
    immutable double y;

    this(double x, double y) {
        this.x = x;
        this.y = y;
    }

    Vec2 opAdd(Vec2 other) {
        return Vec2(this.x + other.x, this.y + other.y);
    }

    Vec2 opSub(Vec2 other) {
        return Vec2(this.x - other.x, this.y - other.y);
    }

    Vec2 opMul(double d) {
        return Vec2(this.x * d, this.y * d);
    }

    double dot(Vec2 other) {
        return this.x * other.x + this.y * other.y;
    }

    double cross(Vec2 other) {
        return this.x * other.y - other.x * this.y;
    }

    double mag() {
        return sqrt(magSq());
    }

    double magSq() {
        return this.x * this.x + this.y * this.y;
    }

    Vec2 normalize() {
        auto m = mag();
        if (m != 0 && m != 1)
            return Vec2(this.x / m, this.y / m);
        return this;
    }

    static double distance(Vec2 a, Vec2 b) {
        return (a - b).mag();
    }
}

Measured memory_bytes: 2924
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll h, n, a[100010];
  cin >> h >> n;
  for (ll i = 0; i < n; ++i)
  {
    cin >> a[i];
  }

  for (ll i = 0; i < n; ++i)
  {
    h -= a[i];
  }

  cout << (h > 0 ? "No" : "Yes") << endl;
}


Measured memory_bytes: 1024
#define ANSWER
#include <algorithm>
#include <vector>
#include <iostream>


template <typename T> 
class mylist {
    public:
        std::vector<T> list;
        void sort(); 
        std::vector<T> sorted();
        std::vector<int> argsort();
        int find(T key){
            typename std::vector<T>::iterator iter = std::find(list.begin(), list.end(), key);
            return std::distance(list.begin(), iter);
        };
};

#include <iostream>
#include <vector>
#include <cstdarg>

class mystd
{
public:
    template<typename T>
    static bool Input(int number,...);
    static bool InputArray(std::vector<long long> array);
    static bool InputArrays(long long number,...);
    static bool InputMatrix(std::vector<std::vector<long long>> array);
    static long long min(std::vector<long long> array);
    static long long max(std::vector<long long> array);
    template<typename T>
    static void Print(int number,...);
};

template<typename T>
bool mystd::Input(int number,...){
    va_list args;
    va_start(args, number);
    for (long long i = 0; i < number; i++)
    {
        std::cin >> *(va_arg(args, T*));
    }
    return true;
}

template<typename T>
void mystd::Print(int number,...){
    va_list args;
    va_start(args, number);
    for (long long i = 0; i < number; i++)
    {
        if(i!=0){
            std::cout << " ";
        }
        std::cout << *(va_arg(args, T*));
    }
    std::cout << std::endl;;
}

bool mystd::InputArray(std::vector<long long> array){
    for (long long &i : array)
    {
        std::cin >> i;
    }
    return true;
}

bool mystd::InputArrays(long long number,...){
    va_list args;
    va_start(args, number);
    std::vector<std::vector<long long>*> arrays(number);
    for (auto &i : arrays)
    {
        i = va_arg(args, std::vector<long long>*);
    }
    long long length = arrays[0]->size();

    for (long long j=0;j<length;j++)
    {
        for (auto &&i : arrays)
        {
            std::cin >> (*i)[j];
        }
    }
    return true;
}


long long mystd::min(std::vector<long long> array){
    long long ans = array[0];
    for (long long &i : array)
    {
        if(i < ans){
            ans = i;
        }
    }
    return ans;
}


long long mystd::max(std::vector<long long> array){
    long long ans = array[0];
    for (long long &i : array)
    {
        if(i > ans){
            ans = i;
        }
    }
    return ans;
}

#ifndef ANSWER
#include "../../library/mystd.hpp"
#include "../../library/mylist.hpp"
#endif

#include <algorithm>
typedef long long ll;

void Main(){
    ll N;
    mylist<std::string> weekdays;
    weekdays.list = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    std::string input;
    mystd::Input<std::string>(1,&input);
    int answer = weekdays.list.size() - weekdays.find(input);
    
    mystd::Print<int>(1,&answer);
}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ac_abc177_a
{
    class Program
    {
        static void Main()
        {
            var input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            var D = input[0];
            var T = input[1];
            var S = input[2];

            Console.WriteLine( D > T * S ? "No" : "Yes" );
        }
    }
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<int> sum_count(n, 0);
    for (int i = 1; i < n; ++i) {
        if (s[i] == 'C' && s[i-1] == 'A') {
            sum_count[i] = sum_count[i-1] + 1;
        } else {
            sum_count[i] = sum_count[i-1];
        }
    }
    for (int i = 0; i < q; ++i) {
        int l, r;
        cin >> l >> r;
        --l;
        --r;
        cout << sum_count[r] - sum_count[l] << "\n";
    }
    return 0;
}


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

int main()
{
    int n, a, b, all = 0;
    cin >> n >> a >> b;
    int ans, ans1, ans2, ans3, ans4, ans5;

    for (int i=1; i<=n; i++) { 
        ans1 = i%10;
        ans2 = (i-ans1)%100;
        ans3 = (i-ans1-ans2)%1000;
        ans4 = (i-ans1-ans2-ans3)%10000;
        ans5 = (i-ans1-ans2-ans3-ans4)%100000;
        ans = ans1 + ans2/10 + ans3/100 + ans4/1000 + ans5/10000;
        if (ans >= a && ans <= b) {
            all += i;
        }
    }
    cout << all;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define endl "\n"
using Edge = pair<int,ll>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(void){
  int n; cin >> n;
  int x[n];
  FOR(i,0,n-1) cin >> x[i];
  int ans = 0;
  int anssum = 1001001001;

  FOR(i,1,100){
    int sum = 0;
    FOR(j,0,n-1){
      sum += abs(x[j]-i) * abs(x[j]-i);
    }
    if(anssum>sum){
      anssum = sum;
    }
  }

  cout << anssum << endl;
}




Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)
class P_UnionFind:
    def __init__(self, n):
        self.p=[i for i in range(n)]
        self.r=[0 for i in range(n)]
        self.d=[0 for i in range(n)]

    def root(self,x):
        if self.p[x]==x:
            return x
        else:
            tmp = self.root(self.p[x])
            self.d[x] += self.d[self.p[x]]
            self.p[x] = tmp
            return self.p[x]
    
    def weight(self,x):
        self.root(x)
        return self.d[x]

    def diff(self,x,y):
        return self.weight(y)-self.weight(x)

    def uni(self,x,y,w):
        if self.same(x,y) and self.diff(x,y)!=w:
            return False
        w+=self.weight(x)
        w-=self.weight(y)
        x=self.root(x)
        y=self.root(y)
        if(x==y):
            return
        if self.r[x]<self.r[y]:
            self.p[x]=y
            self.d[x]=-w
        else:
            self.p[y]=x
            self.d[y]=w
            if self.r[x]==self.r[y]:
                self.r[x]+=1
    
    def same(self,x,y):
        return self.root(x)==self.root(y)


n,m=map(int,input().split())
uf=P_UnionFind(n)
d=[-1 for i in range(n)]
d[0]=0
data=[]
for i in range(m):
    a,b,c=map(int,input().split())
    if uf.uni(a-1,b-1,c) == False:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 10832
#include <bits/stdc++.h>
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
#define endl '\n'
using namespace std;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 112345;
int dp[MAXN], h[MAXN];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i<=n; ++i) {
        scanf("%d", h+i);
        dp[i] = INF;
    }
    dp[1] = 0;
    for (int i = 1; i<=n; ++i) {
        dp[i+1] = min(dp[i+1], abs(h[i]-h[i+1])+dp[i]); 
        dp[i+2] = min(dp[i+2], abs(h[i]-h[i+2])+dp[i]); 
    }
    printf("%d\n", dp[n]);
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
  int a, b, n, i, k, x, count = 0;
  scanf("%d", &n);
  char s[n+1];
  scanf("%s", s);
  for(i=0; i<n-2; i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') count++;
  }
  printf("%d", count);
}
  

Measured memory_bytes: 128
<?php
$n = intval(trim(fgets(STDIN)));
$p = array_map('intval', explode(" ", fgets(STDIN)));
$q = array_map('intval', explode(" ", fgets(STDIN)));

$fact[0] = 1;
for($i=1;$i<=$n;$i++){
    $fact[$i] = $fact[$i-1] *$i;
}

$sum_q =0;

$sum_p = order($n,$p,$fact);
$sum_q = order($n,$q,$fact);
if($sum_p >= $sum_q){
    echo $sum_p - $sum_q;
}else{
    echo $sum_q - $sum_p;
}

function fact($i){
    
}

function order($n,$p,$fact){
    $n_array = [0,1,2,3,4,5,6,7,8];
    $sum_p = 1;
    for($i=0;$i<$n-1;$i++){
        $sum_p += (array_search($p[$i], $n_array) -1) * $fact[$n-1-$i];
        $n_array = array_diff($n_array,array($p[$i]));
        $n_array = array_values($n_array);
    }
    return $sum_p;
}
// 0*2 1*1 +1
// 2*2 0*1 +1


?>


Measured memory_bytes: 4728
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

int main(){

    int N;
    cin >> N;

    vector<ll> v1(N);
    vector<ll> v2(N);
    vector<ll> v3(N);
    for(int i = 0; i < N; i++) cin >> v1[i];
    for(int i = 0; i < N; i++) cin >> v2[i];
    for(int i = 0; i < N - 1; i++) cin >> v3[i];

    ll tmp = 0;
    int last = -10;
    for(int i = 0; i < N; i++){
        int a = v1[i] - 1;
        tmp += v2[a];
        if(last + 1 == a) tmp += v3[a-1];
        last = a;
        //if(DEBAG) cout << tmp << endl;
    }
    cout << tmp << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long N, W;
    cin >> N >> W;

    long long v[N], w[N];
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    bool dp[W * 2 + 1][N];
    long long vs[W * 2 + 1];
    for (int i = 0; i < W * 2 + 1; ++i) {
        vs[i] = 0;
    }

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

    for (int i = 0; i < W; ++i) {
        for (int j = 0; j < N; ++j) {
            if (!dp[i][j] and vs[i] + v[j] > vs[i + w[j]]) {
                for (int k = 0; k < N; ++k) {
                    dp[i + w[j]][k] = dp[i][k];
                }
                dp[i + w[j]][j] = true;
                vs[i + w[j]] = vs[i] + v[j];
            }
        }
    }

    long long ans = 0;
    for(int i = 0; i <= W; ++i) {
        ans = max(ans, vs[i]);
    }

    std::cout << ans;

    return 0;
}

Measured memory_bytes: 20736
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <bitset>
using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const double PI=3.14159265358979323846;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REP1(i, n) for(int i = 1; i <= (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define ZERO(a) memset(a, 0, sizeof(a))

#define RAD(d) (PI * (d) / 180)
#define DEG(r) (180.0 * (r) / PI)

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<class T> void dump(const vector<T> &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

template<class T> void dump(int w, int h, const vector<T> &v)
{
	REP(j, h){
		REP(i, w-1){ cout << v[j * w + i] << " "; }
		cout << v[j * w + w-1] << endl;
	}
}

template<class T> T accumulate(const vector<T> &v)
{
	T sum = 0;
	REP(i, SZ(v)){ sum += v[i]; }
	return sum;
}

template<class T> struct Matrix
{
	T w, h;
	vector<T> A;
	Matrix(T w_, T h_) : w(w_), h(h_), A(w * h) {}
	T get(T x, T y) const { return A[y * w + x]; }
};

template<class T> void input(Matrix<T> &m)
{
	REP(j, m.h){
		REP(i, m.w){
			cin >> m.A[j * m.w + i];
		}
	}
}

template<class T> Matrix<T> prod(const Matrix<T> &a, const Matrix<T> &b)
{
	Matrix<T> m(b.w, a.h);

	REP(j, m.h){
		REP(i, m.w){
			ll c = 0;
			REP(k, a.w){
				c += a.A[j * a.w + k] * b.A[k * b.w + i];
			}
			m.A[j * m.w + i] = c;
		}
	}

	return m;
}

void dump(const Matrix<ll> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%lld ", m.A[j * m.w + i]); }
		printf("%lld\n", m.A[j * m.w + m.w-1]);
	}
}

void dump(const Matrix<double> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%f ", m.A[j * m.w + i]); }
		printf("%f\n", m.A[j * m.w + m.w-1]);
	}
}

string &to_upper(string &s)
{
	REP(i, s.length()){
		if('a' <= s[i] && s[i] <= 'z'){
			s[i] -= 32;
		}
	}

	return s;
}

string &to_lower(string &s)
{
	REP(i, s.length()){
		if('A' <= s[i] && s[i] <= 'Z'){
			s[i] += 32;
		}
	}

	return s;
}

// すべての約数を列挙する
template <class T> vector<T> get_divisors(T n)
{
	vector<T> ret;
	for(T i = 1; i * i <= n; i++){
		if(n % i == 0){
			ret.push_back(i);
			if(i * i != n)
				ret.push_back(n / i);
		}
	}
	sort(ALL(ret));
	return ret;
}

// 1-sqrt(N)までの約数を列挙する
template <class T> vector<T> get_divisors2(T n)
{
	vector<T> ret;
	for(T i = 1; i * i <= n; i++){
		if(n % i == 0){
			ret.push_back(i);
		}
	}
	return ret;
}

int F(ll A, ll B)
{
	return LEN(to_string(max(A, B)));
}

int main()
{
	int S, W;
	cin >> S >> W;
	if(S<=W){
		cout << "unsafe" << endl;
	}
	else{
		cout << "safe" << endl;
	}

	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a>=b&&a>=c)
        printf("%d\n",b+c);
    else if(b>=a&&b>=c)
        printf("%d\n",a+c);
    else if(c>=b&&c>=a)
        printf("%d\n",b+a);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
typedef pair<int, int> P;

ll f(ll h) {
  if(h == 1) return 1;
  return 2*f(h/2)+1;
}

int main() {
  ll h; cin >> h;
  cout << f(h) << endl;

  return 0;
}


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

using namespace std;

int main() {
    unordered_set<string> s;
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        string temp; cin >> temp;
        s.insert(temp);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 17632
import sys
K=int(input())
A=[0 for i in range(K)]
a=7
for i in range(K+5):
    if a%K==0:
        print(i+1)
        sys.exit()
    else:
        if A[a%K]>0:
            print(-1)
            sys.exit()
        A[a%K]+=1
        a=(a%K)*10+7

Measured memory_bytes: 17012
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>

using namespace std;

int main(int argc, const char * argv[]) {
    
    string s;
    cin >> s;
    
    string ans = "Yes";
    
    int n = 200;
    
    int size, size2, size3;
    //char tmp;
    
    int j=0;
    
    size = (int)s.length();
    size2 = (size - 1) / 2;
    size3 = (size + 1) - (size + 3) / 2;
    
    //char r[size], p[(size - 1) / 2], pr[(size - 1) / 2], q[size3];
    char r[n], p[n], pr[n], q[n], qr[n];

    //cout << "size3 = " << size3 << endl;
    for(int i=(int)s.length()-1; i>=0; i--)
    {
        //for(int j= size-1; ; j--)
        //{
            //tmp = s[i];
            //cout << j << endl;
            r[j] = s[i];
        //}
        //cout << i << endl;
        j++;
        //cout << s[i] << endl;
        
    }
    
    j=0;
    
    for(int i=0; i<size2; i++)
    {
        pr[i] = s[i];
        p[size2 - i - 1] = s[i];
        //cout << pr << endl;
//        if(pr[i] != p[size2 - i - 1])
//        {
//            ans = "No";
//            break;
//        }
    }
    
    for(int i=0; i<size3; i++)
    {
        qr[i] = s[(size + 3) / 2 + i - 1];
        q[size3 - i - 1] = s[(size + 3) / 2 + i - 1];
//        cout << "q[" << size3-i-1 << "] = " << q[size3-i-1] << endl;
//        cout << qr << endl;
//        if(qr[i] != q[size3 - i - 1])
//        {
//            ans = "No";
//            break;
//        }
    }
    
    //if(s != r) ans = "No";
    
    for(int i=0; i<size; i++)
    {
        //cout << s[i] << " " << r[i] << endl;
        if(s[i] != r[i])
        {
            ans = "No";
            break;
        }
    }
    
    for(int i=0; i<size2; i++)
    {
        //cout << p[i] << " " << pr[i] << endl;
        if(p[i] != pr[i])
        {
            ans = "No";
            break;
        }
    }
    
    for(int i=0; i<size3; i++)
    {
        
        //cout << q[i] << " " << qr[i] << endl;

        if(q[i] != qr[i])
        {
            ans = "No";
            break;
        }
    }
//    if(p != pr) ans = "No";
//    if(q != qr) ans = "No";
    
    if(size2 == 1) ans = "Yes";
    
//    cout << "s = " << s << endl;
//    cout << "r = " << r << endl;
//    cout << "p = " << p << endl;
//    cout << "q = " << q << endl;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
INF = 10000000000


def merge(A, left, mid, right):
    global num
    leftA = A[left:mid]
    rightA = A[mid:right]
    leftA.append(INF)
    rightA.append(INF)
    l = 0
    r = 0
    for i in range(left, right):
        num += 1
        if leftA[l] <= rightA[r]:
            A[i] = leftA[l]
            l += 1
        else:
            A[i] = rightA[r]
            r += 1


def mergeSort(A, left, right):
    if right - left < 2:
        return
    mid = left + (right - left) // 2
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)


if __name__ == "__main__":
    n = int(input())
    S = list(map(int, input().split()))
    num = 0
    mergeSort(S, 0, len(S))
    print(" ".join(map(str, S)))
    print(num)

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

int main(){
    int k;
    ll n; cin >> n >> k;
    vector <ll> p_x(1), m_x;
    rep(i, n){
        ll x; cin >> x;
        if (x < 0){
            m_x.push_back(x * -1);
        }
        else{
            p_x.push_back(x);
        }
    }
    m_x.push_back(0);
    reverse(m_x.begin(), m_x.end());
    
    ll ans = 100000000000000000;
    int left_max, right_max;
    left_max = min(k, int(m_x.size()) - 1);
    right_max = min(k, int(p_x.size()) - 1);
    rep(i, k){
        int l, r;
        l = left_max - i;
        if (l < 0) break;
        r = k - l;
        if (r >right_max) break;
        ans = min(ans, 2 * m_x.at(l) + p_x.at(r));
        ans = min(ans, m_x.at(l) + 2 * p_x.at(r));
    }

    cout << ans << endl;

}

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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

const int mod = 1e9 + 7;

int main()
{
    ll a, b; cin >> a >> b;
    string s; cin >> s;

    ll i;
    for (i = 0; i < a; i++)
        if (!isdigit(s[i])) { cout << "No" << endl; exit(0); }
    if (s[i++] != '-') { cout << "No" << endl; exit(0); }
    for (; i < a + b + 1; i++)
        if (!isdigit(s[i])) { cout << "No" << endl; exit(0); }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
// みなさん私はカーティキー・シャルマです。LNMIITで勉強しています。私は2年目で、コロナパンデミックが発
// 生しています。世界は終わりそうだ。だから私はそれを最大限に生きたいと思っています。それはつまり、コー
// ドを最大限に意味しているのです。私の好きなアニメは「キメツノヤイバ」で、私の一番の男の子はゼニツで、
// 私の一番の女の子はネズコです。私の好きな呼吸スタイルは息吹です。私の最高の悪魔の血の芸術は、
// ククシボによって使用される月の息です。ムーザンは亡くなり、今ではタンジローがポップの新しい魔王です。
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      #ifndef ONLINE_JUDGE
      freopen("inputf.in",  "r",   stdin);
      freopen("outputf.in", "w",  stdout);
      #endif
      FastIO
      string s;
      string t;
      cin >> s;
      cin >> t;
      lld f = 1;
      for(lld i = 0; i < s.length(); i += 1){
      	if (s[i] != t[i]){
      		f = 0;
      		break;
      	}
      }
      if (f == 1){
      	cout << "Yes\n";
      }
      else{
      	cout <<  "No\n";
      }
      return 0;
}

Measured memory_bytes: 3648
from collections import deque
H,W,K= map(int,input().split())
sx,sy,gx,gy = map(int,input().split())
sx-=1;sy-=1;gx-=1;gy-=1 #0index
Pond = []
for i in range(H):
  temp = str(input())
  temp = list(temp)
  Pond.append(temp)
#print(Pond)
INF = float("inf")
reach = [[INF for _ in range(W)] for _ in range(H)]
reach[sx][sy] = 0
dxdy = [(1,0),(-1,0),(0,1),(0,-1)]
Q = deque([(sx,sy)])
while Q:
  x,y = Q.popleft()
  #print(x,y)
  #step = reach[x][y]
  for j in range(4):
    for i in range(1,K+1):
      fac = i
      nx = x+fac*dxdy[j][0]
      ny = y+fac*dxdy[j][1]
      #print(nx,ny)
      if nx<0 or nx>=H or ny<0 or ny>= W or Pond[nx][ny] == "@":
        break
      if reach[x][y]+1 > reach[nx][ny]: #すでに余裕をもって到達済み
        break
      if reach[x][y]+1 < reach[nx][ny]:
        reach[nx][ny] = min(reach[x][y]+1,reach[nx][ny])
        Q.append((nx,ny))
      if nx == gx and ny == gy:
        #print(reach)
        print(reach[nx][ny])
        exit()
print(-1)
                 
  
  

Measured memory_bytes: 204968
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    long A = scanner.nextInt();
    long B = scanner.nextInt();
    long K = scanner.nextInt();

      if (A + K > B - K){
        for (long i = A; i <= B; i++)
          System.out.println(i);
        }
      if (A + K <= B - K){
        for (long i = A; i < A + K; i++)
          System.out.println(i);
        for (long i = B - K + 1; i <= B; i++)
          System.out.println(i);
      }
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<numeric>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

int main()
{
    vector<int> p(100005), l(100005);
    queue<int> q, d;
    d.push(2);

    int x;
    p[1] = 0;
    p[2] = 1;
    for(int i=3; i<100005; i++){
        q = d;
        while(!q.empty()){
            x = q.front();
            q.pop();
            if(i%x == 0){
                p[i] = p[i-1];
                break;
            }
            if(q.empty()){
                p[i] = p[i-1] + 1;
                d.push(i);
            }
        }
    }

    l[0] = 0;
    l[1] = 0;
    l[2] = 0;
    for(int i=3; i<100005; i++){
        if(p[i] > p[i-1] && p[(i+1)/2] > p[(i-1)/2])    l[i] = l[i-1] + 1;
        else    l[i] = l[i-1];
    }

    int Q, a, b;    cin >> Q;
    for(int i=0; i<Q; i++){
        cin >> a >> b;
        cout << l[b] - l[a-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 4048
#include<iostream>
#include<sstream>
#include<list>

using namespace std;

int main(){
	ostringstream out;
	list<char> list;
	int n=0;

	for(string line;cin >> line;){
		list.clear();
		for(int i=0;i<line.length();i++)
			list.push_back(line[i]);
		while(list.size()>1){
			if(list.back()!=list.front())
				break;
			list.pop_front();
			list.pop_back();
		}
		if(list.size()<=1)
			n++;
	}
	out << n << endl;

	cout << out.str();
	return 0;
}

Measured memory_bytes: 1212
package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"fmt"
)

var points [5][5][4]bool

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for i := 0; i < 9; i++ {
		y := i/2
		if i%2 == 0 {
			scanner.Scan()
			info := strings.Split(scanner.Text(), "")
			for k := range info {
				e, _ := strconv.Atoi(info[k])
				if e != 0 {
					points[y][k][1], points[y][k+1][3] = true, true
				}
			}
		} else {
			scanner.Scan()
			info := strings.Split(scanner.Text(), "")
			for k := range info {
				e, _ := strconv.Atoi(info[k])
				if e != 0 {
					points[y][k][2], points[y+1][k][0] = true, true
				}
			}
		}
	}
	x := 1
	y := 0
	dir := 1
	dx := []int{0, 1, 0, -1}
	dy := []int{-1, 0, 1, 0}
	ds := "URDL"
	fmt.Printf("%s", string(ds[dir]))
	for !(x == 0 && y == 0) {
		if points[y][x][(dir+3)%4] {
			dir = (dir+3)%4
		} else if points[y][x][dir] {

		} else if points[y][x][(dir+1)%4] {
			dir = (dir+1)%4
		} else {
			dir = (dir+2)%4
		}
		x += dx[dir]
		y += dy[dir]
		fmt.Printf("%s", string(ds[dir]))
	}
	fmt.Println()
}


Measured memory_bytes: 1080
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long LL;

LL f(LL a,LL b)
{
    LL bit=1,bit2=1,res=0;
    while(bit*2<=b)bit*=2;
    if(a==b)return 1;
    if(bit<=a)return f(a-bit,b-bit);
    if(a==0){
        while(bit2<=b)bit2*=2;
        return bit2;
    }
    res=bit-a;
    b-=bit;
    while(bit2<=b)bit2*=2;
    res+=min(bit,bit2+(bit-a));
    return res;
}

int main()
{
    LL a,b;
    scanf("%lld %lld", &a, &b);
    printf("%lld", f(a,b));
    return 0;
}


Measured memory_bytes: 128
chars = gets.chomp.split('')
result = 'Yes'
chars.each_with_index do |c, i|
  if !(['R','L','U','D'].include?(c)) || (i % 2 == 0 && c == 'L') || (i % 2 == 1 && c == 'R')
    result = 'No'
    break
  end
end

puts result


Measured memory_bytes: 1788
(defun kagami-mochi (n a)
  (let ((res 0)
        (num (make-array '(110) :initial-element 0)))
    (dotimes (i n)
      (incf (aref num (aref a i))))
    (dotimes (i 101)
      (if (> (aref num i) 0)
          (incf res)))
    res))

(defun create-data ()
  (let* ((n (read))
         (a (make-array `(,n))))
    (dotimes (i n)
      (setf (aref a i) (read)))
    (values n a)))

(multiple-value-bind (n a) (create-data)
  (format t "~A~%" (kagami-mochi n a)))

Measured memory_bytes: 8808
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i=0;i<N;i++){
        cin >> L[i];
    }
    sort(L.begin(),L.end());
    ll ans = 0;
    for(ll i=0;i<N-2;i++){
        ll m = i+1;
        for(ll j=i+2;j<N;j++){
            while(m<j && L[i]+L[m]<=L[j]) m++;
            ans += j-m;
        }
    }
    cout << ans << endl;
}

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

int main() {
  
  int n ; cin >> n;
  vector<int> v(n),c(n) ;
  
  for ( int i = 0 ; i < n ; i++ ) cin >> v.at(i) ;
  for ( int i = 0 ; i < n ; i++ ) cin >> c.at(i) ;
  
  int sum ;
  
  for ( int i = 0 ; i < n ; i++ ) 
  	if ( 0 < (v.at(i) - c.at(i)) ) sum += v.at(i) - c.at(i) ;
  
  cout << sum ;


}

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

int ans,w,h,I[55][55];//??????

void dfs(int x,int y){
	I[x][y]=0;
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			if(I[x+i][y+j]==1)dfs(x+i,y+j);
		}
	}
}
int main(){
	while(1){
		cin>>w;
		cin>>h;
		if(w==0&&h==0)break;
		ans=0;
		for(int i=0;i<55;i++){
			for(int j=0;j<55;j++){
				I[i][j]=0;
			}
		}
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				cin>>I[i][j];
			}
		}
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				if(I[i][j]==1){
					dfs(i,j);
					ans++;
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3168
N=int(input())
P=list(map(int,input().split()))
S=["x" if P[i]==i+1 else "o" for i in range(N)]
count=0
for j in range(N-1):
    if S[j]=="x":
        S[j]="o"
        if S[j+1]=="x":
            S[j+1]="o"
        count+=1
if S[N-1]=="x":
    count+=1
print(count)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
#include <fstream>
#include <stdlib.h>
#include <ctime>
typedef long long ll;
typedef long double ld;

using namespace std;
int inf=1e9;
ll p1=1e9+7;
ll p2=1e9+9;
ll q1=34;
ll q2=26;

ll POWER(ll x, ll y){
    if(y==0) return 1;
    ll f=POWER(x,y/2);
    f*=f;
    f%=p1;
    if(y%2==1){
        f*=x;
        f%=p1;
    }
    return f;
}

ll Pow(ll x, ll y){
    ll x1=x%p1;
    x1+=p1;
    x1%=p1;
    ll y1=y%(p1-1);
    y1+=(p1-1);
    y1%=(p1-1);
    return POWER(x1,y1);
}

ll inverse(ll x){
    return Pow(x,p1-2);
}


string s,t;
const int maxn=6e5;
ll shash[maxn];
ll thash[maxn];
ll invq[maxn];
int n,m;



ll ssegm(int i1, int i2){
    ll ret=(shash[i2]-shash[i1]*invq[i2-i1])%p1;
    (ret+=p1)%=p1;
    return ret;
}
ll tsegm(int i1, int i2){
    ll ret=(thash[i2]-thash[i1]*invq[i2-i1])%p1;
    (ret+=p1)%=p1;
    return ret;
}
bool mask[maxn];
int ans=0;
int vis[maxn];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(100);
  //  freopen("input.txt","r",stdin);
    cin>>s>>t;
    n=s.size();
    m=t.size();
    shash[0]=0;
    for(int i=0;i<n;i++){
        shash[i+1]=shash[i]*q1+1LL*(s[i]-'a');
        shash[i+1]%=p1;
  //      cout<<shash[i+1]<<" ";
    }
 //   cout<<endl;
    thash[0]=0;
    for(int i=0;i<m;i++){
        thash[i+1]=thash[i]*q1+1LL*(t[i]-'a');
        thash[i+1]%=p1;
  //      cout<<thash[i+1]<<" ";
    }
   // cout<<endl;

    invq[0]=1;
    ll invq1=q1;
    invq[1]=invq1;
    for(int i=0;i<max(n,m);i++){
        invq[i+1]=invq[i]*invq1;
        invq[i+1]%=p1;
    }

    for(int i=0;i<n;i++){
        int j=0;
        int k=i;
        bool det=1;
        while(j<m){
            int len=min(m-j,n-k);
            if(ssegm(k,k+len)!= tsegm(j,j+len)){
                det=0;
                break;
            }
            k+=len;
            j+=len;
            k%=n;
        }
        mask[i]=det;
    }
 //   for(int i=0;i<n;i++){
 //       cout<<mask[i]<<" ";
 //   }
 //   cout<<endl;
    for(int i=0;i<n;i++){
        if(!mask[i] && !vis[i]){
            int j=i;
            int locans=0;
            while(!vis[j]){
                vis[j]=1;
                if(mask[j]==0) locans=0;
                else{
                    if(ans < locans){
                        ans=locans;
                    }
                }
                j-=m;
                ((j%=n)+=n)%=n;
                locans++;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(!vis[i]){
            cout<<"-1";
            return 0;
        }
    }
    cout<<ans;

 //   cout<<ssegm(3,4)<<" "<<tsegm(0,2);
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<long long> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (vec[i] < vec[i+1]) {
      while (vec[i] <= vec[i+1] && i + 1 < n) {
        i++;
      }
      ans++;
    } else if (vec[i] == vec[i+1] && i + 1 < n) {
      continue;
    } else {
      while (vec[i] >= vec[i+1] && i + 1 < n) {
        i++;
      } 
      ans++;
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#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++)
int INF=1e9+7;

int n=1;
string S;
vvi bit;

void init(int N) {
  while(n<N) n*=2;
  bit=vvi(26,vi(n+1));
}

int sum(int c,int i) {
  int s=0;
  while(i>0) {
    s+=bit[c][i];
    i-=i&-i;
  }
  return s;
}

void add(char c,int i,int x) {
  while(i<=n) {
    bit[c-'a'][i]+=x;
    i+=i&-i;
  }
}

int main() {
  int N,Q;
  cin >> N >> S >> Q;
  
  init(N);
  rep(i,N) add(S[i],i+1,1);
  
  int x;
  rep(q,Q) {
    cin >> x;
    if(x==1) {
      int i;
      char c;
      cin >> i >> c;
      if(S[i-1]!=c) {
        add(S[i-1],i,-1);
        add(c,i,1);
        S[i-1]=c;
      }
    }
    else {
      int l,r;
      cin >> l >> r;
      int ans=0;
      rep(c,26) {
        if(sum(c,r)-sum(c,l-1)) ans++;
      }
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 59168
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    string S;
    cin >> N >> S;
    int l = 0,r = N;
    while (l+1 < r) {
        int mid = (l+r)/2;
        map<string,int>Mp;
        bool ok = false;
        for(int i = 0; i < N-mid+1; i++) {
            if(!Mp.count(S.substr(i,mid))) {
                Mp[S.substr(i,mid)] = i;
            }
            else {
                if(Mp[S.substr(i,mid)]+mid <= i) {
                    ok = true;
                }
            }
        }
        if(ok) {
            l = mid;
        }
        else {
            r = mid;
        }
    }
    cout << l << endl;
}


Measured memory_bytes: 9956
#include <stdio.h>
#include <string.h>
int main ()
{
	int N,i,c;
	scanf("%d",&N);
	
	char s[100000];
	scanf("%s",s);
	
	
	for(i=0;i<strlen(s);i++)
	{
		c=s[i]+N;
		if(c<=90)
		{
			s[i]=c;
		}
		if(c>90)
		{
			s[i]=c-26;
		}
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();

    int ans = 0;
    for(int i=0; i<3; ++i)
      if( s.charAt(i) == t.charAt(i) ) ++ans;
    System.out.println(ans);
  }
}

Measured memory_bytes: 22612
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)


fun main(args: Array<String>) {
    val n = nextLong()
    val arr = primeFact(n)
    var ans = 0
    for(i in 0 until arr.size){
        var ex = 1L
        var now = arr[i].second
        while(now >= ex){
            now -= ex
            ans++
            ex++
        }
    }
    println(ans)
}


fun primeFact(n : Long) : ArrayList<Pair<Long, Long>> {
    var N = n
    val res = arrayListOf<Pair<Long, Long>>()
    for(a in 2 until n/2){
        if(a * a > N) break
        if(N % a != 0L) continue
        var ex = 0L

        while(N % a == 0L) {
            ex++
            N /= a
        }

        res.add(Pair(a, ex))
    }

    if(N != 1L) res.add(Pair(N, 1))
    return res
}

fun abc000a() {
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }

Measured memory_bytes: 36608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;
const long long inf = 100000000000LL;

int main() {
  ll a, b, q;
  cin >> a >> b >> q;
  vll s(a), t(b);
  rep(i,a) cin >> s[i];
  rep(i,b) cin >> t[i];
  s.push_back(-inf);
  s.push_back(inf);
  t.push_back(-inf);
  t.push_back(inf);
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  vll ret;
  rep(i,q) {
    ll x;
    cin >> x;
    ll sl, sr, tl, tr;
    sr = s[upper_bound(s.begin(),s.end(),x)-s.begin()];
    sl = s[upper_bound(s.begin(),s.end(),x)-s.begin()-1];
    tr = t[upper_bound(t.begin(),t.end(),x)-t.begin()];
    tl = t[upper_bound(t.begin(),t.end(),x)-t.begin()-1];
    ll ans = 100000000000LL;
    ans = min(ans,min((x-sl)+(tr-sl),(tr-x)+(tr-sl)));
    ans = min(ans,min((x-tl)+(sr-tl),(sr-x)+(sr-tl)));
    ans = min(ans,max((sr-x),(tr-x)));
    ans = min(ans,max((x-sl),(x-tl)));
    ret.push_back(ans);
  }
  rep(i,ret.size()) cout << ret[i] << endl;
  return 0;
}

Measured memory_bytes: 5968
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
int main(void){
  int n,k;
  cin>>n>>k;
  vi h(n);
  rep(i,n)cin>>h[i];
  int ans=0;
  rep(i,n){
    if(h[i]>=k)ans++;
  }
  cout<<ans;
  return 0;
}

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

void solv() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if(A*B > C*D){
        cout << A * B << endl;
        return;
    }
    cout << C * D << endl;
}

int main() {
    solv();
    return 0;
}

Measured memory_bytes: 256