akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto e : a) cout << e << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);
using namespace std;
int INF = 1e9 + 7;

int main()
{
    ll n, mnj, ans = 0; cin >> n;
    if(n % 2)
    {
        cout << 0;
        return 0;
    }

    ll m = n;
    while(m != 0)
    {
        m = m / 10;
        ans += m;
    }
    ll add = 50;
    while(add <= n)
    {
        mnj = add; m = n;
        while(mnj <= n)
        {
            ans += n / mnj;
            ans -= n / (2 * mnj);
            mnj *= 5;
        }
        add *= 10;
    }
    cout << ans;
    /*while(true)
    {
        ll x; cin >> x;
        n *= x;
        cout << n << endl;
    }*/

    return 0;
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")

#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef pair<int,pll> pip;
typedef pair<pll,int> ppi;
typedef pair<lld,pll> plp;
typedef pair<pll,lld> ppl;
typedef pair<pll,pll> ppp;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define jizz cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
inline void input(int &_x) {
    _x = 0;
    int _tmp = 1; char _tc = getchar();
    while((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
    if(_tc == '-') _tc = getchar(), _tmp = -1;
    while(_tc >= '0' && _tc <= '9') _x = _x*10+(_tc-48), _tc = getchar();
    _x *= _tmp;
}
inline void output(int _x) {
    char _buff[20]; int _f = 0;
    if(_x == 0)putchar('0');
    while(_x > 0)
    {
        _buff[_f++] = _x%10+'0';
        _x /= 10;
    }
    for(_f-=1; _f >= 0; _f--)
        putchar(_buff[_f]);
    putchar('\n');
}
template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<class T1,class T2>
ostream& operator<<(ostream& out, pair<T1,T2> p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) {
     return _out(s,c.begin(),c.end());
 }
#ifdef erd1
    #define pprint(x) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<endl
#else
    #define pprint(x)
#endif

const int mod = 998244353;

inline void M(int& a){
    if(a>=mod)a-=mod;
}

int fpow(int a, int b){
    int ans = 1;
    do if(b&1)ans = (lld)ans*a%mod;
    while(a = (lld)a*a%mod, b>>=1);
    return ans;
}
// code starts here
int dp1[90001]={1}, dp2[90001]={1}, v[300];
signed main(){
    int n, sum = 0;
    lld i2 = fpow(2, mod-2);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> v[i], sum += v[i];
    for(int i = 0; i < n; i++){
        for(int j = sum; j >= 0; --j)
            if(v[i]+j<=sum)
                (dp1[v[i]+j]+=dp1[j])%=mod, (dp2[v[i]+j]+=dp2[j]*i2%mod)%=mod;
    }
    int ans = (fpow(3, n)+(sum%2?0:dp1[sum/2]*3LL))%mod;
    lld p2 = 3LL*fpow(2, n);
    for(int i = sum; 2*i >= sum; --i)
        M(ans += (mod-dp2[i])*p2%mod);
    cout << ans << endl;
}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

ll n, len, w;
pair<ll,ll> a[maxn];
ll ans = 0;
ll p[maxn];

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  cin >> n >> len >> w;
  #define X first
  #define H second
  for (int i = 1; i <= n; ++i) cin >> a[i].X >> a[i].H;
  sort(a + 1, a + n + 1);
  len *= 2;

  for (int i = 1; i <= n; ++i){
    p[i] = p[i] + p[i-1];
    ll del = p[i] * w;
    if (del >= a[i].H) continue;
    a[i].H -= del;
    int nextpos = upper_bound(a+1, a+n+1, mp(a[i].X + len, ll(1e18)) ) - a;
    nextpos--;
    ll num = (a[i].H - 1) / w + 1;
    ans = ans + num;
    p[i] = p[i] + num; p[nextpos+1] -= num;
  }
  cout << ans;
}




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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

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

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

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

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

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

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

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

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

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

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

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  int n,k;
  cin >> n >> k;
  
  int a;
  map<int,int> numCount;
  for(int i=0;i<n;i++){
    cin >> a;
    numCount[a]++;
  }
  
  priority_queue<int, vector<int>, greater<int> > queue;
  for(auto num:numCount){
    queue.push(num.second);
  }

  int ans = 0;
  while(queue.size()>k){
    ans += queue.top(); queue.pop();
  }

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 13556
import Data.List
import Control.Monad

main :: IO()
main = do
  [n, m] <- map read . words <$> getLine :: IO([Int])
  ds <- replicateM n $ map read . words <$> getLine :: IO([[Int]])
  print $ maximum [solve (map (zipWith (*) [i, j, k]) ds ) m | i <- [1, -1], j<-[1, -1], k<- [1,-1]]

solve :: [[Int]] -> Int -> Int
solve ds m = sum . take m . reverse $ sort [sum d | d <- ds]


Measured memory_bytes: 3836
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<map>
#include<cmath>
#include<set>
#define ll long long
#define inf 0x7fffffff;
#define maxn 105
using namespace std;
ll ans;
int x;
int read()
{
    int l=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
        w=-1;
        else
        ch=getchar();
    }
    while(ch<='9'&&ch>='0')
    {
        l*=10;
        l+=ch-'0';
        ch=getchar();
    }
    return l*w;
} 
int main()
{
	x=read();
	ans+=(x/500)*1000;
	x-=x/500*500;
	ans+=(x/5)*5;
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] X = new int[N];
    for (int i = 0; i < N; i++) X[i] = sc.nextInt();
    sc.close();

    int ans = Integer.MAX_VALUE;
    for (int x = 1; x <= 100; x++) {
      int sum = 0;
      for (int i = 0; i < N; i++) {
        sum += (X[i] - x) * (X[i] - x);
      }
      ans = Math.min(ans, sum);
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21972
S = str(input())
S = list(S)

ans = 0

for i in range(1,len(S)+1) :
    if i % 2 == 1:
        if S[i-1] == 'L':
            ans = 1
    else:
        if S[i-1] == 'R':
            ans = 1
            
if ans == 0:
    print('Yes')
    
else:
    print('No')
    

Measured memory_bytes: 3060
#include <stdio.h>
int main(){
        unsigned int m,n,o,gcd,lcm,i,j;
        while(scanf("%d %d",&m,&n) != EOF){
        lcm = m * n;
        if( m < n){
                o = m;
                m = n;
                n = o;
        }
        for(i=1;m%(n/i);)
                for(i++;n%i;i++);
        for(j=1;n/i*j%m||n/i*j%n;j++);
        printf("%d %d\n",n/i,n/i*j);
        }
return 0;
}

Measured memory_bytes: 596
H,W = map(int,input().split())

sx,sy = map(int,input().split())
gx,gy = map(int,input().split())
sx -= 1
sy -= 1
gx -= 1
gy -= 1

a = []
for i in range(H):

    tmp = list(input())
    a.append(tmp)

from collections import deque

q = deque([(sx,sy)])
d = [[float("inf")] * W for i in range(H)]
d[sx][sy] = 0

while len(q) > 0:

    nx,ny = q.popleft()
    if a[nx][ny] == "#":
        continue
    elif nx == gx and ny == gy:
        break

    if nx > 0 and d[nx-1][ny] > d[nx][ny] and a[nx-1][ny] != "#":
        d[nx-1][ny] = d[nx][ny]
        q.appendleft((nx-1,ny))

    if nx != H-1 and d[nx+1][ny] > d[nx][ny] and a[nx+1][ny] != "#":
        d[nx+1][ny] = d[nx][ny]
        q.appendleft((nx+1,ny))

    if ny > 0 and d[nx][ny-1] > d[nx][ny] and a[nx][ny-1] != "#":
        d[nx][ny-1] = d[nx][ny]
        q.appendleft((nx,ny-1))

    if ny != W-1 and d[nx][ny+1] > d[nx][ny] and a[nx][ny+1] != "#":
        d[nx][ny+1] = d[nx][ny]
        q.appendleft((nx,ny+1))

    for xx in range(-2,3):
        for yy in range(-2,3):

            nex = nx + xx
            ney = ny + yy
            if 0 <= nex < H and 0 <= ney < W and d[nex][ney] > d[nx][ny] + 1:
                d[nex][ney] = d[nx][ny] + 1
                q.append((nex,ney))

if d[gx][gy] == float("inf"):
    print (-1)
else:
    print (d[gx][gy])


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

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,ok,ng;
string s;
bool f;

signed main() {
    cin >> n;ng=n;
    cout << 0 << endl;
    cin >> s;
    if (s == "Vacant") return 0;
    while(true) {
        string ss;
        int mid = (ng+ok)/2;
        cout << mid << endl;
        cin >> ss;
        if (ss == "Vacant") return 0;
        if (f) {
            if ((mid-ng-1)%2) {
                if (ss == s) ng = mid;
                else ok = mid,f=false;
            } else {
                if (ss == s) ok = mid,f=false;
                else ng = mid;
            }
        } else {
            if ((mid-ok)%2) {
                if (ss == s) ng = mid,f=true;
                else ok = mid;
            } else {
                if (ss == s) ok = mid;
                else ng = mid,f=true;
            }
        }
        s = ss;
    }
}


Measured memory_bytes: 852
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if (a >= b){
            System.out.println("delicious");
        }else if (X+(a-b) >= 0){
            System.out.println("safe");
        }else {
            System.out.println("dangerous");
        }
    }
}


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

int mx, n;

int main(){	
	while( cin >> mx, mx ){
		int d[300] = {0}, g[300][300] = {0};
		cin >> n;
		for(int i = 1; i <= n; i++) cin >> d[i];
		
		for(int i = 0; i <= n; i++){
			for(int j = 1; j <= mx; j++){
				int v = i + j + d[i + j];
				if( v < 0 ) v = 0;
				if( n+1 < v ) v = n+1;
				g[i][v] = 1;
			}
		}
		for(int k = 0; k < n + 2; k++){
			for(int i = 0; i < n + 2; i++){
				for(int j = 0; j < n + 2; j++){
					if( g[i][k] && g[k][j] ) g[i][j] = 1;
				}
			}
		}
		bool ans = true;
		for(int i = 0; i <= n ; i++){
			if( g[0][i] && !g[i][n+1] ){
				ans = false;
			}
		}
		cout << (ans?"OK":"NG") << endl;
	}
}

Measured memory_bytes: 1516
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s;

int main(){
	cin >> s;
	bool f = false;
	rep(i,s.size()){
		if(s[i] == 'A' && s[i+1] == 'C')f = true;
	}
	if(f)cout << "Yes" << endl;
	else cout << "No" << endl;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dbl;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<long long> vl;
typedef vector< pair<int, int> > vii;
#define mp make_pair
#define pb push_back
#define invec(a, n) for(ll i = 0; i < n; i++) {cin >> a[i];}
#define rep(n) for(ll i = 0; i < n; i++)
#define fr(i,j,k) for(ll i = j; i < k; i++)
#define FR(i,j,k) for(ll i = j; i >= 0; i--)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define INF 1000000
#define xx first
#define yy second
#define pl cout<<endl;
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
		return os<<"("<< p.first << "," << p.second<<")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
os << "{";
typename vector< T > :: const_iterator it;
for( it = v.begin(); it != v.end(); it++ ) {
		if( it != v.begin() ) os << ", ";
		os << *it;
}
return os << "}";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
os << "[";
typename set< T > :: const_iterator it;
for ( it = v.begin(); it != v.end(); it++ ) {
		if( it != v.begin() ) os << ", ";
os << *it;
}
return os << "]";
}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
		os << "[";
		typename map< F , S >::const_iterator it;
for( it = v.begin(); it != v.end(); it++ ) {
if( it != v.begin() ) os << ", ";
os << it -> first << " = " << it -> second ;
}
return os << "]";
}
#define deb(x) cout << #x << " = " << x << endl;
 
#define er(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}
 
void fast()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

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

	int cnt=0;

	for(int i=0;i<3;i++)
	{
		if(s[i]==t[i])
		{
			cnt++;
		}
	}

	cout<<cnt<<endl;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#include<functional>
#include<bits/stdc++.h>
#include<map>
#include<utility>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;
#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define vecl vector<long>
#define vecll vector<long long>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)
#define rep1e(i, n) for(int i=1; i <= (int)(n); i++)
#define rep1ne(i, n) for(int i=1; i < (int)(n); i++)
#define pqi priority_queue<int>
#define pqll priority_queue<ll>
#define pqi_ priority_queue<int, vector<int>, greater<int>>
#define pqll_ priority_queue<ll, vector<ll>, greater<ll>>

#define MAX 100010

using namespace std;

unsigned digit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

bool isPrime(int num) {
  if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0) return false;
    }
    return true;
}

map<ll,int> prime_factor(ll n) {
  map<ll,int> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

ull gdc(ull a, ull b) {
  if(a < b) return gdc(b, a);
  ull r;
  while((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  double N;
  cin >> N;
  double ans = ceil(N/2) / N;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N,M = map(int, input().split())
list_1 = list(map(int, input().split()))
 
i=0
sum=0
 
while i<M:
  sum=sum+list_1[i]
  i=i+1
  
if sum>N:
  print("-1")
  
else:
  print(abs(sum-N))

Measured memory_bytes: 10000
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));
  list($t) = explode(" ", trim(fgets(STDIN)));

  $n=strlen($s);

  $c=[];
  for($i=0;$i<$n;$i++){
    if(isset($c[$s[$i]])){
      if($c[$s[$i]] !== $t[$i]){
        echo "No";
        exit;
      }
    }else{
      $c[$s[$i]] = $t[$i];
    }
  }
  if(max(array_count_values($c)) > 1){
    echo "No";
  }else{
    echo "Yes";
  }



Measured memory_bytes: 16808
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
int p[100005];
map<int, int> cnt;
int find(int x) {
  if (p[x] == x)
    return x;
  return p[x] = find(p[x]);
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    p[i] = i;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    p[find(a)] = find(b);
  }
  for (int i = 1; i <= n; i++)
    p[i] = find(i);
  for (int i = 1; i <= n; i++)
    cnt[find(i)]++;
  cout << cnt.size() << endl;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    double ans = 0;
    for(int i=1;i<=n;i++){
        double count = max(0.0,ceil(log2(k/(double)i)));
        ans += 1/pow(2, count);
    }
    cout << setprecision(15) << (ans/n) << endl;
}

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

int id[200003] , N;

int main(){
	cin >> N;
	for(int i = 1 , x ; i <= N ; ++i){cin >> x; id[x] = i;}
	int mx = 0 , cnt = 0;
	for(int i = 1 ; i <= N ; ++i)
		mx = max(mx , id[i] > id[i - 1] ? ++cnt : (cnt = 1));
	cout << N - mx; return 0;
}


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

int count_days_play(int N, int M,vector<int> &A){
    int outputs = N;

    for(int i = 0; i< M; i++){
        outputs -= A.at(i);

        if(outputs < 0){
            return -1;
        }
    }

    return outputs;

}

int main(){
    int N_days_s=0;
    int M_homeworks = 0;

    cin >> N_days_s >> M_homeworks;

    vector<int> A_days_h(M_homeworks);

    for(int i=0;i<M_homeworks;i++){
        cin >> A_days_h.at(i);
    }

    cout << count_days_play(N_days_s, M_homeworks,A_days_h);


}

Measured memory_bytes: 3644
N = int(input())
left_list = list()
right_list = list()
for _ in range(N):
    center, length = list(map(int, input().split(' ')))
    left_list.append(center - length)
    right_list.append(center + length)
sorted_robot_list = sorted(range(N), key=lambda i: right_list[i])
robot_cnt = 0
before_robot_right = min(left_list)
for robot in sorted_robot_list:
    current_robot_left = left_list[robot]
    if before_robot_right > current_robot_left:
        continue
    robot_cnt += 1
    before_robot_right = right_list[robot]
print(robot_cnt)

Measured memory_bytes: 16672
#include<iostream>
#include<numeric>
#include<vector>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vector<ll> x(n);
    ll sum=accumulate(a.begin(),a.end(),0LL);
    x[0]=sum;
    for(int i=1;i<n;i+=2){
        x[0]-=2*a[i];
    }
    for(int i=0;i<n-1;i++){
        x[i+1]=2*a[i]-x[i];
    }
    for(ll i : x) cout<<i<<endl;
}

Measured memory_bytes: 4808
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> a;
    for (int i = 0; i < N; i++) {
        int b;
        cin >> b;
        a.push_back(b);
    }
    sort(a.begin(), a.end(), greater<int>());

    int alice = 0, bob = 0;
    for (int i = 0; i < N; i++) {
        if (i%2 == 0) {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }

    cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> p(101);
    ll dp[101][101];
    REPP(i,1,n+1) cin >> p[i-1] >> p[i];
    REPP(i,1,n+1) dp[i][i]=0;

    for(int i = 2; i <= n;i++){
        for(int l = 1; l <= n - i + 1;l++){
            int j =  i  +  l - 1;
            dp[l][j] = (1 << 21);
            for(int k = l; k <= j - 1;k++){
            dp[l][j] = min(dp[l][j],dp[l][k] + dp[k+1][j] + p[l-1]*p[k]*p[j]);
            }
        }
    }
    cout << dp[1][n] << endl;
    return 0;
}


Measured memory_bytes: 3232
import java.util.Scanner;

public class Main {

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

		for(int i = 0;i < 3;i++){
			String str = sc.next();
			char initial = str.charAt(0);
			if( 'a' <= initial && initial <= 'z')initial += ('A' - 'a');
			System.out.print(initial);
		}
		System.out.println();

		sc.close();

	}

}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code
int stor[51][28];

int main()
{
  ll
  n, m;
  cin>>n>>m;
  ll x[n];
  ll y[m];
  rep(i, 0, n) cin>>x[i];
  rep(i, 0, m) cin>>y[i];
  ll f = 0;
  ll s = 0;
  rep(i, 1, n)
  {
    s += (x[i] - x[i-1]) * i * (n - i);
    s %= M;
  }
  rep(i, 1, m)
  {
    f += (y[i] - y[i-1]) * i * (m - i);
    f %= M;
  }
  cout<<(f*s)%M<<endl;
  return 0;
}


Measured memory_bytes: 13696
#include<bits/stdc++.h>
#include<vector>
#include<sstream>
#define int long long
#include<string>
#define float long double
using namespace std;
   signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  cout<<((n*n)*n);
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=1000005;
int a[N],n,L;

int main(){
	read(n),read(L);
	rep(i,1,n)read(a[i]);
	rep(i,1,n-1)
		if(a[i]+a[i+1]>=L){
			puts("Possible");
			rep(j,1,i-1)printf("%d\n",j);
			per(j,n-1,i+1)printf("%d\n",j);
			printf("%d\n",i);
			return 0;
		}
	puts("Impossible");
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
long long p = 1000000007;
long long n, m, a, b, c;
long long inv[500001];
long long kai[500001];
long long iai[500001];
void makeinv(void) {
	long long arraynumber = sizeof inv / sizeof inv[0];
	inv[1] = 1;
	for (int invcount = 2; invcount < arraynumber; invcount++) {
		inv[invcount] = p - inv[p % invcount] * (p / invcount) % p;
	}
}
int main() {
	makeinv();
	kai[0] = 1;
	iai[0] = 1;
	for (long long i = 1; i <= 500000; i++) {
		kai[i] = kai[i - 1] * i % p;
		iai[i] = iai[i - 1] * inv[i] % p;
	}
	scanf("%lld%lld", &n, &m);
	a = kai[n] * kai[m] % p;
	a *= iai[m - n];
	a %= p;
	a *= iai[m - n];
	a %= p;
	for (long long i = 0; i <= n; i++) {
		b = 1;
		if (i % 2)b = p - 1;
		b *= kai[m - i];
		b %= p;
		b *= iai[i];
		b %= p;
		b *= iai[n - i];
		b %= p;
		c += b;
		c %= p;
	}
	printf("%lld\n", a * c % p);
}

Measured memory_bytes: 13444
#include<cmath>
#include<cstdio>
#include<algorithm>

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

using namespace std;

const double EPS=1e-8;
const double PI=acos(-1);

struct point{
	double x,y;
	point():x(0),y(0){}
	point(double x,double y):x(x),y(y){}
	point operator-(const point &a)const{ return point(x-a.x,y-a.y); }
};

double cross(const point &a,const point &b){ return a.x*b.y-a.y*b.x; }

point rot(const point &a,double theta){ return point(a.x*cos(theta)-a.y*sin(theta),a.x*sin(theta)+a.y*cos(theta)); }

double area(const point &a,const point &b,const point &c){
	return abs(cross(b-a,c-a))/2;
}

int main(){
	for(int n,m;scanf("%d%d",&n,&m),n;){
		point P[40];
		rep(i,n){
			double t; scanf("%lf",&t);
			P[i]=rot(point(1,0),2*PI*t);
		}

		double ans=0;
		// dp[i][j][k] := ( P[i..j] から k 個選んでできる凸多角形の最大面積. ただし P[i] と P[j] は必ず選ぶ. )
		static double dp[40][40][41];
		rep(i,n) rep(j,n) rep(k,m+1) dp[i][j][k]=0;
		rep(i,n) for(int j=i;j<n;j++) {
			for(int k=3;k<=m;k++){
				for(int l=i+1;l<j;l++){
					dp[i][j][k]=max(dp[i][j][k],dp[i][l][k-1]+area(P[i],P[l],P[j]));
					ans=max(ans,dp[i][j][k]);
				}
			}
		}

		printf("%.6f\n",ans);
	}

	return 0;
}

Measured memory_bytes: 1604
n = int(input())
A = list(map(int, input().split()))

from collections import Counter
c = Counter(A)

num2 = 0
for k, v in c.items():
    if v == 2:
        num2 += 1
    if v >= 3:
        if v % 2 == 0:
            c[k] = 2
            num2 += 1
        else:
            c[k] = 1

if num2 % 2 == 0:
    print(len(c))
else:
    print(len(c) - 1)

Measured memory_bytes: 62124
import sys,collections as cl,bisect as bs,random
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

d = onem()

c = l()

s = []
sel = [0 for i in range(365)]

day = [[0 for i in range(26)] for j in range(365)]
ans = 0
for i in range(d):
	s.append(l())
	ss = [[s[-1][i],i+1] for i in range(26)]

	ak = 0

	for j in range(26):
		if i != 0:
			ak -= c[j] * (i-day[i-1][j]+1)
		else:
			ak -= c[j]

	ma = [-1,-1]
	for j in range(26):
		if i != 0:
			if ma[0] <= c[j] * (i-day[i-1][j]+1) + s[-1][j]:
				ma[0] = c[j] + (i-day[i-1][j]+1) + s[-1][j]
				ma[1] = j
		else:
			if ma[0] <= c[j] + s[-1][j]:
				ma[0] = c[j] + s[-1][j]
				ma[1] = j
	ans += ma[0] + ak
	sel[i] = ma[1]+1

	for j in range(26):
		if j == ma[1]:
			day[i][j] = i
		else:
			day[i][j] = day[i-1][j] if i - 1 >= 0 else 0



for _ in range(140000):
	ima = random.randrange(365)
	po = [[s[ima][i]-c[i],i+1] for i in range(26)]
	po.sort(reverse = True)
	while True:
		data = po[random.randrange(5)][1]
		if sel[ima] != data:
			break
	data = data-1
	ppp = 0
	now = sel[ima]-1
	for i in range(ima+1,365):
		if day[i][data] == i:
			ppp += (i - ima) * c[data]
			break
	else:
		ppp += (364-ima) * c[data]
	ppp += s[ima][data]

	for i in range(ima+1,365):
		if day[i][now] == i:
			ppp -= (i - ima) * c[now]
			break
	else:
		ppp -= (364-ima) * c[now]
	ppp -= s[ima][now]
	if ppp > 0:
		for i in range(ima,365):
			if day[i][data] != i:
				day[i][data] = ima
			else:
				break
		po = ima - 1 if ima != 0 else 0
		for i in range(ima,365):
			if i == ima:
				day[i][now] = po
			elif day[i][now] != i:
				day[i][now] = po
			else:
				break
		sel[ima] = data+1
		ans += ppp

for i in sel:
	print(i)


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

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

    vector<ll> dp(n, INF);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1792
#include <vector>
#include <stdio.h>
#include <queue>
#include <map>
#include <iostream>
using namespace std;

int main(){
    int N, a, b, node, next_node, K=0, i, cur;
    scanf("%d", &N);
    vector<vector <int> > G(N);
    vector<pair <int, int>> edge;
    queue<int> que;
    for(int i=1;i<N;i++){
        scanf("%d %d", &a, &b);
        a --; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        edge.emplace_back(a,b);
    }

    vector<int> used(N,0);
    vector<int> node_c(N,0);
    map<pair<int,int>, int> Ans;

    que.emplace(0);
    used[0] = 1;
    while(! que.empty()){
        node = que.front(); que.pop();
        if(K<(int)G[node].size()) K = G[node].size();
        cur = 1;
        // cout << "---------------" << node << "---------------" << endl;
        for(int next_node:G[node]){
            // next_node = G[node][i];
            // cout << "cur:" << cur << endl;
            if(used[next_node]) continue;
            if(cur == node_c[node]) cur++;
            // cout << "ok"<< endl;

            node_c[next_node] = Ans[make_pair(next_node, node)] = Ans[make_pair(node, next_node)] = cur++;
            used[next_node] = 1;
            que.emplace(next_node);
        }
    }

    printf("%d\n", K);
    for(auto nodes:edge){
        printf("%d\n", Ans[nodes]);
    }

    return 0;

}

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

#define ll long long

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(a*c, a*d), max(b*c, b*d)) << '\n';
	return 0;
}



Measured memory_bytes: 3572
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string S;
  cin >> S;
  bool ans = N % 2 == 0 ? S.substr(0, N / 2) == S.substr(N / 2) : false;
  cout << (ans ? "Yes" : "No") << endl;
}


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

int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  
  ll ans = a * c;
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;

    class Program
    {

        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int s = int.Parse(input[0]);
            int w = int.Parse(input[1]);
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            if (s <= w)
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");

            }
            Console.Out.Flush();
        }
    }

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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"

ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll h,n,num;
	cin>>h>>n;
	while(n--)
	{
		cin>>num;
		h-=num;
	}
	if(h>0)cout<<"No";
	else cout<<"Yes";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

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

    int H, W;
    while (cin >> H >> W, H) {
        vector<string> s(H);
        rep(i, H) cin >> s[i];

        map<string, int> mp;
        rep(i, H) {
            rep(j, W) {
                rep(k, 8) {
                    string t = "";
                    set<P> st;
                    int x = i;
                    int y = j;
                    while (!st.count(P(x, y))) {
                        t += s[x][y];
                        mp[t]++;
                        st.insert(P(x, y));
                        x = (x + dx[k] + H) % H;
                        y = (y + dy[k] + W) % W;
                    }
                }
            }
        }

        string ans = "0";
        for (auto p : mp) {
            if (p.first.size() > ans.size() && p.second >= 2) {
                ans = p.first;
            }
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 38008
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int x, a, b;
  cin >> x >> a >> b;

  if (a >= b){
    cout << "delicious" << endl;
  }else if (b - a <= x){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
}


Measured memory_bytes: 3564
import qualified Data.ByteString.Char8 as BC
import Data.Maybe

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

cdiv :: Int -> Int
cdiv t = if t `mod` 2 /= 0
         then 0
         else 1 + cdiv (t `div` 2)

main :: IO ()
main = do
  getLine
  as <- readIntsLine
  print . sum $ cdiv <$> as

Measured memory_bytes: 1276
#include <stdio.h>

int gcm(int a, int b)
{
    int t;
    int r;

    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    
    return (a);
}

int main(void)
{
    int x, y;
    int t;
    int g;
    int wire;
    int n;
    
    scanf("%d%d", &x, &y);
    if (x < y){
        t = x;
        x = y;
        y = t;
    }
    
    g = gcm(x, y);
    n = (x + 1 + y + 1 - 2) - (x / (x / g) - 1);

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



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

int main(){

    long long int x, k, d, ans = 0;
    cin >> x >> k >> d;
    x = abs(x);

    if (x/d > k){
        ans = abs(x) - k*d;
    }

    else
    {
        k -= x/d;

        if (k%2 == 1){
            ans = abs(abs(x)%d - d);
        }

        else
        {
            ans = abs(x)%d;
        }
        
    }

    cout << ans << endl;
    
    
    return 0; 
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vr vector
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define mod 1000000007



  int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     //ll t;
     //cin>>t;
     //while(t--)
     {
     ll n,h[200001]={0},i,a;
     cin>>n;
     
     for(i=0;i<n-1;i++)
     {cin>>a;h[a]++;}
     
      for(i=1;i<=n;i++)
        cout<<h[i]<<endl;

   // cout<<endl;

     }

 return 0;
  }



Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,M; cin>>N>>M;
  priority_queue<ll> Q;
  for(int i=0; i<N; i++){
    ll a; cin>>a;
    Q.push(a);
  }
  while(M!=0){
    M--;
    ll a=Q.top();
    Q.pop();
    Q.push(a/2);
  }
  ll ans=0;
  while(!Q.empty()){
    ans+=Q.top();
    Q.pop();
  }
  cout<<ans<<endl;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<int> a(N), b(N), c(N), d(N);
  REP(i,N) cin >> a[i] >> b[i];
  REP(i,N) cin >> c[i] >> d[i];

  vector<pair<int,int>> red(N), blue(N);
  REP(i, N) red[i] = make_pair(a[i], b[i]);
  REP(i, N) blue[i] = make_pair(c[i], d[i]);
  sort(ALL(red));
  sort(ALL(blue));

  vector<bool> used(N);
  int ret = 0;
  REP(i, N) {
    int pos, ymax = -INF;
    REP(j, N) {
      if(red[j].first > blue[i].first) break;
      if(used[j] || red[j].second >= blue[i].second) continue;
      if(red[j].second > ymax) {
        ymax = red[j].second;
        pos = j;
      }
    }
    if(ymax != -INF) {
      ++ret;
      used[pos] = true;
    }
  }

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int numS = sc.nextInt();
		int numT = sc.nextInt();
		int numQ = sc.nextInt();
		long shrine[] = new long[numS + 2];
		for(int i = 0; i < numS; i ++) {
			shrine[i] = sc.nextLong();
		}
		shrine[numS] = - (long)Math.pow(10, 12);
		shrine[numS + 1] = (long)Math.pow(10, 12);
		Arrays.sort(shrine);
		long temple[] = new long[numT + 2];
		for(int i = 0; i < numT; i ++) {
			temple[i] = sc.nextLong();
		}
		temple[numT] = - (long)Math.pow(10, 12);
		temple[numT + 1] = (long)Math.pow(10, 12);
		Arrays.sort(temple);
		for(int i = 0; i < numQ; i ++) {
			long ques = sc.nextLong();
			int tmpS = bisect(shrine, ques);
			int tmpT = bisect(temple, ques);
			long min = Long.MAX_VALUE;
			for(int j = 0; j < 4; j ++) {
				long sh = shrine[tmpS - j % 2];
				long tm = temple[tmpT - (j < 2 ? 0 : 1)];
				min = Math.min(min, Math.min(Math.abs(sh - ques), Math.abs(tm - ques))
					+ Math.abs(sh - tm));
			}
			System.out.println(min);
		}
	}

	static int bisect(long array[], long key) {
		int ng = -1;
		int ok = array.length;
		while (Math.abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;
			if(isOK(array, mid, key)) {
				ok = mid;
			}else {
				ng = mid;
			}
		}
		return ok;
	}
	static boolean isOK(long array[], int index, long key) { return array[index] >= key; }
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    queue<pair<string,int>> task;
    int n, q;
    cin >> n >> q;
    for(int i=0;i<n;i++){
        string name;
        int req;
        cin >> name >> req;
        task.push(make_pair(name, req));
    }
    int t=0;
    while(!task.empty()){
        auto c = task.front();
        task.pop();
        if(c.second<=q){
            t+=c.second;
            cout << c.first << ' ' << t << endl;
        }else{
            t+=q;
            task.push(make_pair(c.first, c.second-q));
        }
    }
    
    return 0;
}


Measured memory_bytes: 6172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, k; cin >> n >> k;
    if(n % k) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,h,w,ans=0;
	cin>>n>>h>>w;
	while(n--){
		ll x,y;
		scanf("%lld %lld",&x,&y);
		ans=x>=h&&y>=w?ans+1:ans; 
	} 
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
#import numpy as np
import sys
import math
from collections import defaultdict
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

hp = defaultdict(int)
per = list(itertools.permutations((i for i in range(1,N+1)) , N))
for index , p in enumerate(per) :
    hp[p] = index
print(abs(hp[Q] - hp[P]))



Measured memory_bytes: 11248
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	string A, B, C;
	cin >> N >> A >> B >> C;
	int r = 0;
	for (int i = 0; i < N; ++ i) {
		set<char> s;
		s.insert(A[i]);
		s.insert(B[i]);
		s.insert(C[i]);
		r += s.size() - 1;
	}
	cout << r << endl;
}


Measured memory_bytes: 256