akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,x;cin>>n>>m>>x;
    vector<ll> c(n);
    vector<vector<ll>> a(n);
    rep(i,n){
        cin>>c[i];
        a[i]=vector<ll>(m);
        rep(j,m)cin>>a[i][j];
    }
    ll ans = INF;
    rep(i,1<<n){
        vector<ll> rikai(m,0);
        ll okane = 0;
        rep(j,n){
            if(i>>j&1){
                rep(k,m){
                    rikai[k]+=a[j][k];
                }
                
                    okane += c[j];
            }
        }
        bool abovex = true;
        for(ll rika:rikai)if(rika<x)abovex=false;
        if(abovex){
            ans=min(ans,okane);
        }
    }
    if(ans==INF)cout<<-1;
    else cout<<ans;
    return 0;
}

Measured memory_bytes: 3664
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    if(a <= b){
        cout << a << endl;
    }else{
        cout << a - 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
#define int             long long
#define ld              long double
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int, int>
#define mk(arr,n,type)  type *arr=new type[n];
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int, int>
#define umii            unordered_map<int, int>
#define pqmax           priority_queue<int>
#define pqmin           priority_queue<int, vi, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define trailzrobits(x) __builtin_ctzll(x)
#define leadzrobits(x)  __builtin_clzll(x)
#define paritybits(x)   __builtin_parityll(x)
#define gcd             __gcd
#define lcm(x, y)       (x * y) / gcd(x, y)
#define mod             1000000007
#define endl            '\n'
#define PI              3.14159265358979323846
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x

void __print(int x) {cout<<x;}
void __print(float x){cout<<x;}
void __print(double x){cout<<x;}
void __print(ld x) {cout<<x;}
void __print(char x){cout <<'\''<<x<<'\'';}
void __print(const char *x){cout <<'\"' <<x<<'\"';}
void __print(const string &x) {cout<<'\"'<<x<<'\"';}
void __print(bool x) {cout<<(x?"true":"false");}
template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}
template<typename T>                void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}void _print() {cout << "]\n";}
template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)
#else 
#define dbg(x...)
#endif

int power(int x, int y, int p = mod){
    int res = 1;
    x %= p;
    while(y > 0){
        if(y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res; 
}

int inv(int x, int p = mod){
    return power(x, p - 2) % p;
}

const int N = 1e6 + 6;
 
int32_t main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1;
    // cin >> t;
    while(t--){
        
        int n; cin>>n;
        mk(a, n+1, int);
        for(int i=1; i<=n; i++)
            cin>>a[i];
        
        mk(dp, n+1, int);
        dp[1] = 0;

        for(int i=2; i<=n; i++){
            int q1 = abs(a[i]-a[i-1]) + dp[i-1];
            int q2 = (i==2) ? inf : abs(a[i] - a[i-2]) + dp[i-2];
            dp[i] = min(q1, q2);
        }

        cout<<dp[n];
    }

    return 0;

}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
using namespace std;

int main(void){
    while(true){
        int n;
        double sum = 0, sum2 = 0 ;
        scanf("%d", &n);
        if(n == 0) break;
        for(int i = 0; i < n; i++){
            int x;
            scanf("%d", &x);
            sum += x;
            sum2 += x * x;
        }
        printf("%lf\n", sqrt((sum2 - sum * sum / n) / n));
    }

    return 0;
}




Measured memory_bytes: 2740
#include <bits/stdc++.h>
            #define REP(i, n) for(int i = 0;i < n;i++)
            #define REPR(i, n) for(int i = n;i >= 0;i--)
            #define FOR(i, m, n) for(int i = m;i < n;i++)
            #define FORR(i, m, n) for(int i = m;i >= n;i--)
            #define SORT(v, n) sort(v, v+n);
            #define VSORT(v) sort(v.begin(), v.end());
            #define llong long long
            #define pb(a) push_back(a)
            #define INF 1000000000000000000LL
            #define MOD 1000000007
            using namespace std;
            typedef pair<int, int> P;
            typedef pair<llong, llong> LP;
            typedef pair<int, P> PP;
            typedef pair<llong, LP> LPP;
            //vector<tuple<long long, long long, long long>>vec;

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

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


            int main() {
                int n;
                cin>>n;
                vector<int> v(n,0);
                vector<int> c(n,0);
                vector<int> x(n,0);
                REP(i,n)
                {
                    cin>>v[i];
                }
                REP(i,n)
                {
                    cin>>c[i];
                    x[i]=v[i]-c[i];
                }
                int ans=0;
                for(int i=0; i<n; i++)
                {
                    if(x[i]>=0) ans+=x[i];
                }
                cout<<ans<<endl;

            }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	ll ans = linf;
	for (int i = 0; i <= n - k; ++i) {
		if (a[i + k - 1] <= 0) {
			ll tmp = 0 - a[i];
			mins(ans, tmp);
		}
		else if (a[i] >= 0) {
			ll tmp = a[i + k - 1] - 0;
			mins(ans, tmp);
		}
		else {
			ll tmp = a[i + k - 1] - a[i] + min(a[i + k - 1] - 0, 0 - a[i]);
			mins(ans, tmp);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}

int main(){
    int N, M; cin >> N >> M;
    vector<int> cnt(N,1);
    vector<bool> red(N,false); red[0] = true;
    REP(i,M) {
        int x, y; cin >> x >> y; x--, y--;
        cnt[x]--, cnt[y]++;
        if(red[x] && cnt[x]<1) {
            red[x] = false;
            red[y] = true;
        }
        else if(red[x] && cnt[x]>=1) {
            red[y] = true;
        }
    }
    int ans = 0;
    REP(i,N) if(red[i]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,w,q;
  int a,b;
  cin >>s>>w;
  cin >>a>>b;
  cin >>q;
  if(s==q) cout <<a-1<<' '<<b<<'\n';
  else cout <<a<<' '<<b-1<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Keep_calmYou_are_still_learning ios_base::sync_with_stdio(false);cin.tie(NULL);//freopen("out.txt","w",stdout);
typedef long long ll;
typedef long double ld;
using namespace std;



int main()
{
    Keep_calmYou_are_still_learning;

    ll n,ans=0;
    cin>>n;
    ll a[n+2],b,prev=0;
    for (ll i=0;i<=n;i++)
        cin>>a[i];
    for (ll i=0;i<n;i++)
    {
        cin>>b;

        ans+=min(prev,a[i]);
        if (prev>=a[i])
           a[i]=0;
        else
            a[i]-=prev;

        if (a[i]>b)
            ans+=b,a[i]-=b,b=0;
        else
            ans+=a[i],b-=a[i],a[i]=0;


        prev=b;
    }
    ans+=min(prev,a[n]);

    cout<<ans<<'\n';


    return 0;
}


Measured memory_bytes: 1024
// 動的計画法
#include <bits/stdc++.h>
using namespace std;

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

  vector<bool> vec(100000, false);
  vector<string> vec2 = { "dream", "dreamer", "eraser", "erase" };

  vec.at(0) = true;

  for (int i = 0; i < S.size(); i++) {
    if (!vec.at(i)) continue;

    for(int j = 0; j < vec2.size(); j++) {
      if (S.substr(i, vec2.at(j).size()) == vec2.at(j)) {
        vec.at(i + vec2.at(j).size()) = true;
      }
    }
  }

  cout << (vec.at(S.size()) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
N, W = map(int, input().split())
L = sorted([list(map(int,input().split())) for i in range(N)])

dp = [0] * (W + 1)
con = 0

for w, v in L:
  con += w
  for i in range(min(con, W), w - 1, -1):
    if dp[i] < dp[i - w] + v:
      dp[i] = dp[i - w] + v

print(max(dp))

Measured memory_bytes: 9656
N = int(input())
S = input()
MOD = 10 ** 9 + 7
from collections import defaultdict
dic = defaultdict(int)

for s in S:
  dic[s] += 1
  
ans = 1
for value in dic.values():
  ans *= (value + 1)
  ans %= MOD
  
print((ans - 1) % MOD)

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 1000000;
ll mod = INF;


int main(){

    int d,t,s;
    cin >> d>>t>>s;

    if(s*t>=d)cout << "Yes"<<endl;
    else cout << "No"<<endl;
    
    return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

ll N;
ll ans;

void dfs(ll cur, int use) {
	if (cur > N){
		return;
	}
	if ( use == 0b111 ){
		ans++;
	}

	dfs(cur * 10 + 3, use | 0b001);
	dfs(cur * 10 + 5, use | 0b010);
	dfs(cur * 10 + 7, use | 0b100);
}

int main() {
	cin >> N;
	ans = 0;

	dfs(0, 0);
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nm = IO.RSInt;
            var s = new List<int[]>();
            for (int i = 0; i < nm[1]; i++)
            {
                var ks = IO.RSInt;
                var tmp = new int[ks.Length - 1];
                Array.Copy(ks, 1, tmp, 0, ks.Length - 1);
                s.Add(tmp);
            }
            var p = IO.RSInt;

            int cnt = 0;
            for (int i = 0; i < 1 << nm[0]; i++)
            {
                bool allRight = true;
                for (int j = 0; j < nm[1]; j++)
                {
                    int pushedCnt = 0;
                    foreach (var sw in s[j])
                    {
                        if ((i & 1 << sw - 1) >> sw - 1 == 1)
                        {
                            pushedCnt++;
                        }
                    }
                    if (pushedCnt % 2 != p[j])
                        allRight = false;
                }
                if (allRight) cnt++;
            }
            WriteLine(cnt);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N,M;
    Scd2(N,M);
    int k;
    int a;
    int c[66] = {};
    Rep(i,N){
        Scd(k);
        Rep(i,k){
            Scd(a);
            c[a]++;
        }
    }

    int ans = 0;
    Rep(i,M+1){
        if( c[i] == N ) ans++;
    }
    printf ("%d\n", ans);

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main() {
	int x;
	string str;
	cin >> x >> str;
	x %= 26;
	for (auto &c : str) {
		c += x;
		if (c > 'Z') c -= 26;
	}
	cout << str << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
#include <cmath>
int main() {
    static const double pi = acos(-1);
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double th = 2 * pi * (H * 60 + M) / 720;
    double tm = 2 * pi * M / 60;
    double theta  = th - tm;
    double ans;
    ans = sqrt(A * A + B * B - 2.0 * A * B * cos(theta));

    printf("%.10f\n",ans);
      
    return 0;
}

Measured memory_bytes: 4124
N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = -1
b = -1
total = 0
ans = 0
while a<len(A)-1:
    if total+A[a+1] > K:
        break
    a+=1
    total+=A[a]
    
while b<len(B)-1:
    if total+B[b+1] > K:
        break
    b+=1
    total+=B[b]
    
ans = a+b+2
subs = K - total
while a>=0:
    subs+=A[a]
    a-=1
    for i in range(b+1, len(B)):
        if subs < B[i]:
            break
        subs-=B[i]
        b = i
    ans = max(ans,a+b+2)
print(ans)

Measured memory_bytes: 110980
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	vi a(4);
	rep(i, 4) cin>>a[i];
	sort(all(a));
	cout << (a[0] == a[1] && a[2] == a[3] ? "yes" :"no") <<endl;
}

Measured memory_bytes: 3156
def f(n) -> list:
	if n==1:
		return [1]
	ret = []
	i = 2
	while i*i<=n:
		while n%i==0:
			n //= i
			ret.append(i)
		i += 1
	if n!=1:
		ret.append(n)
	return ret
n=int(input())
print("{}:".format(n),*f(n))


Measured memory_bytes: 5596
package main

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

func main() {
	var n float64
	fmt.Scan(&n)
	fmt.Println((n * 2) * math.Pi)
}

// =================================
// I/O util
// =================================

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

// =================================

Measured memory_bytes: 1756
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int N;
	cin >> N;
	if(N < 1000){
		cout << "ABC" << endl;
	}
	else{
		cout << "ABD" << endl;
	}
	return 0;
}

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

typedef long long ll;

int N;
ll X;
ll A[2010];
ll dp[2010][2010];
ll ans = 1001001001001001;

int main()
{
    scanf("%d%lld",&N,&X);
    for(int i = 0; i < N; i++)scanf("%lld",A + i);

    for(int i = 0; i < N; i++)dp[i][0] = A[i];
    for(int j = 1; j <= N; j++)
    {
        for(int i = 0; i < N; i++)
        {
            dp[i][j] = min(dp[i][j - 1],dp[(i - 1 + N) % N][j - 1]);
        }
    }

    for(int i = 0; i < N; i++)
    {
        ll res = X * i;
        for(int j = 0; j < N; j++)
        {
            res += dp[j][i];
        }
        ans = min(ans,res);
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<pair<int,int>> a(n);
  for(int i=0;i<n;++i){
    int temp;
    cin >> temp;
    a[i] = make_pair(temp, i+1);
  }
  sort(a.begin(), a.end());
  for(int i=0;i<(n-1);++i) cout << a[i].second << " ";
  cout << a[n-1].second << endl;
  return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
typedef struct { char suit, value; } Card;

void bubble(Card A[], int N){
    int i,j;
    Card t;
    for(i=0;i<N;i++){
        for(j=N-1;j>=i;j--){
             if(A[j].value < A[j-1].value){
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
       }
      }
   }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


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

using namespace std;

typedef long long ll;

int N;
ll a[100001], b[100001];

int main() {
  cin >> N;

  for(int i = 0; i < N; i++) cin >> a[i] >> b[i];

  ll ans = 0;
  ll k = 0;

  for(int i = N-1; i >= 0; i--) {
    ll tmp = a[i] + k, tmp2 = 0;
    if(tmp % b[i] != 0) {
      tmp2 = tmp / b[i] + 1;
      ans += tmp2 * b[i] - tmp;
      k += tmp2 * b[i] - tmp;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $c);
$array = [$a, $b, $c];
$seven = 0;
$five = 0;
for($i = 0; $i < 3; $i++){
    if( $array[$i] == 7){
      $seven ++;
    }elseif( $array[$i] == 5){
      $five ++;
    }
  }
  if($seven === 1 && $five === 2){
    echo 'YES';
  }else{
    echo 'NO';
  }
?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

int main() {
  int H, W, D;
  cin >> H >> W >> D;

  // mp[a] = aが入っているマスの座標(i, j)
  map<int, vector<int>> mp;
  REP(i, H){
    REP(j, W){
      int a;
      cin >> a;
      mp[a] = {i, j};
    }
  }

  mp[0] = mp[D];

  // REP(i, H*W+1){
  //   DUMP(i);
  //   DUMP(mp[i][0]);
  //   DUMP(mp[i][1]);
  // }

  //cost[i][j] = i,i+D,...,i+jDと移動するコスト
  // i = 0,1,...,D-1; i+jD <= HW
  vector<vector<int>> cost(D, vector<int>(H*W/D + 5, 0));
  FOR(i, 0, D){
    for(int j =0; i + (j+1)*D <= H*W; j++){
      cost[i][j+1] = cost[i][j] + abs(mp[i+(j+1)*D][0] - mp[i+j*D][0])
                    + abs(mp[i+(j+1)*D][1] - mp[i+j*D][1] );
    }
  }

  int Q;
  cin >> Q;

  REP(i, Q){
    int L, R;
    cin >> L >> R;
    // L = y*D + x, 0<=x<=D-1
    int x = L%D;
    int y = L/D;
    // R = yy * D + x, y < yy
    int yy = R/D;
    cout << cost[x][yy] - cost[x][y] << endl; 
  }
}


Measured memory_bytes: 15232
//Name: Middle-Square Method
//Level: 1
//Category: やるだけ
//Note: 

/**
 * 8桁の数の中央4桁は、100で割ってから10000で剰余を取れば求められる。
 */
#include <iostream>
#include <algorithm>

using namespace std;

void solve(int CASE) {
    int N;
    cin >> N;
    cout << "Case " << CASE << ":" << endl;
    for(int i = 0; i < 10; ++i) {
        N *= N;
        N = N / 100 % 10000;
        cout << N << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    int N;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        solve(i+1);
    }
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,k;cin>>a>>b>>c>>k;
    if(a+b>=k){
        cout<<min(k,a);
    }else{
        cout<<a-(k-a-b);
    }
    return 0;
}

Measured memory_bytes: 3648
public class Main {

	/**
	 * ????????????????????????
	 *
	 * @param args
	 */
	public static void main(String[] args) {
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				System.out.println(i + "x" + j + "=" + i * j);
			}
		}
	}
}

Measured memory_bytes: 24196
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int a,b,c;cin >> a >> b >> c;
  int k;cin >> k;

  if(k <= a) {
    cout << k << "\n";
    return 0;
  }
  else {
    k -= a;
  }

  if(k <= b) {
    cout << a << "\n";
    return 0;
  }
  else {
    k -= b;
  }

  cout << a - k << "\n";
  
  return 0;
}


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

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)round(x))<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

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

  int n, a, b;
  
  while (cin >> n >> a >> b) {
    int ans = n;
    
    for (int i = 0; i < n; i++) {
      int t;
      cin >> t;

      if (a <= t && t < b) {
        ans--;
      }
    }

    cout << ans << endl;
  }
}


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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 1; i < s.size()/2; ++i)
    {
        if(s.substr(0, i) == s.substr(i, i))
        {
            ans = i;
        }
    }
    cout << 2*ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
int main(void){
    int n;cin>>n;
    double x[n],y[n];
    double sum=0.0;
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    rep(i, n-1){
        for(int j=i+1;j<n;j++)
        sum+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
    printf("%12.8f\n", 2*sum/n);
}



Measured memory_bytes: 256
import numpy as np
from fractions import gcd

N=int(input())
A=list(map(int, input().split()))

p=10**9+7
n = 10 ** 6  # N は必要分だけ用意する
#fact = [1, 1]  # fact[n] = (n! mod p)
#factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用 逆元
"""
for i in range(2, n + 1):
    #fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    #factinv.append((factinv[-1] * inv[-1]) % p)
#a//gcd(a,b)*b
"""
def lcm(a,b):
    g=gcd(a,b)
    #return ((a*b)*pow(g,p-2,p))%p
    return a//gcd(a,b)*b

LCM=1
for x in A:
    LCM=lcm(LCM,x)



#print(LCM)
ans=0
LCM%=p
for i in range(N):
    #ans+=(LCM*inv[A[i]])%p
    ans+=(LCM*pow(A[i],p-2,p))%p
    ans%=p
print(ans)

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

int main(){
    long long x,k,d;
    cin>>x>>k>>d;
    x = abs(x);
    long long a ,b;
    if(x%d==0) a = x/d-1;
    else a = x/d;
    b = a+1;
    //cout<<a<<" "<<b<<"\n";
    if(k<a){
        cout<<x-k*d<<"\n";
        return 0;
    }
    long long x1=x-a*d, x2 = x-b*d;
    //cout<<x1<<" "<<x2<<"\n";
    if((k-a)%2 == 0) cout<<x1<<"\n";
    else cout<<abs(x2)<<"\n"; 
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int D;
  cin >> D;
  vector<ll> C(26);
  rep(i, 26) cin >> C[i];
  vector<vector<ll>> S(D, vector<ll>(26));
  rep(i, D) rep(j, 26) cin >> S[i][j];
  rep(i, D) {
    cout << max_element(all(S[i]))-begin(S[i])+1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 3756
n,w=map(int,raw_input().split())
vw=[map(int,raw_input().split()) for _ in xrange(n)]
dp=[[0]*(w+1) for _ in xrange(n+1)]
for i in xrange(n):
    for j in xrange(w+1):
        if j<vw[i][1]:
            dp[i+1][j]=dp[i][j]
        else:
            dp[i+1][j]=max(dp[i][j],dp[i][j-vw[i][1]]+vw[i][0])
print(dp[n][w])

Measured memory_bytes: 23112
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();

    int n, k;
    cin >> n >> k;

    for(int i = 1; i <= k; i++){
        cout << COM(k-1, i-1) * COM(n-k+1, i) % MOD << endl;
    }
}




Measured memory_bytes: 12160
package main

import (
	"fmt"
	"math"
)

func main() {
	N, T := scanInt2()
	Cs, Ts := scanInts2(N)

	c := 1001
	for i := 0; i < N; i++ {
		if Ts[i] <= T {
			c, _ = getMin(c, Cs[i])
		}
	}
	if c == 1001 {
		fmt.Println("TLE")
	} else {
		fmt.Println(c)
	}
}

/*
	Snippets
*/
func scanInt() (a int) {
	fmt.Scan(&a)
	return
}
func scanInt2() (a, b int) {
	fmt.Scan(&a, &b)
	return
}
func scanInt3() (a, b, c int) {
	fmt.Scan(&a, &b, &c)
	return
}
func scanInts(n int) []int {
	A := make([]int, n)
	for i := 0; i < n; i++ {
		A[i] = scanInt()
	}
	return A
}
func scanInts2(n int) ([]int, []int) {
	A, B := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		A[i], B[i] = scanInt2()
	}
	return A, B
}
func scanInts3(n int) ([]int, []int, []int) {
	A, B, C := make([]int, n), make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		A[i], B[i], C[i] = scanInt3()
	}
	return A, B, C
}
func scanMatrix(n, m int) [][]int {
	A := make([][]int, n)
	for i := 0; i < n; i++ {
		A[i] = scanInts(m)
	}
	return A
}
func scanStr() (s string) {
	fmt.Scan(&s)
	return
}
func scanStrs(n int) []string {
	S := make([]string, n)
	for i := 0; i < n; i++ {
		S[i] = scanStr()
	}
	return S
}
func getAbs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func getPow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}
func getMin(nums ...int) (int, int) {
	if len(nums) == 0 {
		panic("funciton getMin() requires at least one argument.")
	}
	min := nums[0]
	pos := 0
	for i := 1; i < len(nums); i++ {
		if min > nums[i] {
			min = nums[i]
			pos = i
		}
	}
	return min, pos
}
func getMax(nums ...int) (int, int) {
	if len(nums) == 0 {
		panic("funciton getMax() requires at least one argument.")
	}
	max := nums[0]
	pos := 0
	for i := 1; i < len(nums); i++ {
		if max < nums[i] {
			max = nums[i]
			pos = i
		}
	}
	return max, pos
}
func getGcd(a, b int) int {
	if b == 0 {
		return a
	}
	return getGcd(b, a%b)
}
func getLcm(a, b int) int {
	return a * b / getGcd(a, b)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
string s,w;
 
int main(){
	cin >> s >> w;
	if(s.size()==w.size()){
		REP(i,0,s.size()){
			if(s[i]<w[i]){cout << "LESS" << endl; return 0;}
			else if(s[i]>w[i]){cout << "GREATER" << endl; return 0;}
			else continue;
		}
		cout << "EQUAL" << endl;
	}else if(s.size()<w.size()){
		cout << "LESS" << endl;
	}else{
		cout << "GREATER" << endl;
	}
	
	return 0;
}

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

int main(){
	int N, X;
	cin >> N >> X;
	vector<int> L(N);
	for( int i = 0; i < N; i++ ){
		cin >> L.at(i);
	}
	
	int  count = 0;
	int D = 0;//座標
	for( int i = 0; i <= N; i++ ){
		if( D <= X ){
			if( i != N ){
				D += L.at(i);
				count++;
			}
			else{
				count++;
			}
		}
		else{
			break;
		}
	}
	
	cout << count << endl;
}

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

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

int main(void){
    int X, Y;
    int Turu,Kame;
    string answer;
    cin >> X >> Y;
    if((Y - X * 2) % 2 != 0){
        answer = "No";
    } else {
        Kame = (Y - X * 2) / 2;
        Turu = X - Kame;
    }

    if(Turu >= 0 && Kame >= 0 && Turu + Kame == X && Turu * 2 + Kame * 4 == Y){
        answer = "Yes";
    } else {
        answer = "No";
    }
    cout << answer;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    int s=S.size();
    int64_t ans=0, r_2=pow(2,s-1), r_10=1;
    for(int i=s-1;i>=0;i--){
        ans+=(S[i]-'0')*r_2*r_10;
        r_2/=2;
        for(int j=i-1;j>=0;j--) ans+=(S[j]-'0')*r_2*r_10;
        r_10*=10;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
a, b, c = [int(i) for i in input("").split(" ")]
ispoor = False
if (a == b and b != c):
  ispoor = True
if (b == c and c != a):
  ispoor = True
if (c == a and a != b):
  ispoor = True
if(ispoor):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9156
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
    string s,trg;
    long long k;
    cin >> s >> k;
    for(int i=0;i<s.size();i++){
        trg = s.substr(i,1);
        if(i==s.size()-1){
            if(trg == "1"){
            cout << "1" << endl;
            return 0; 
            }
        }
        if(trg != "1"){
            if(k<=i){
            cout << "1" << endl;
            return 0;
            }else{
            cout << trg << endl;
            return 0;
            }
        }
    }
}

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


int A[100100];
int main(){
	int n,a;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a;
		A[a-1]=i;
	}
	
	for(int i=0;i<n;i++){
		if(i>0) cout << " ";
		cout << A[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

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

        long happypoint = 0;

        // 500円玉のhappypoint
        happypoint = happypoint + (price/500) * 1000;

        price = price % 500;

        // 5円玉のhappypoint
        happypoint = happypoint + (price/5) * 5;

        // 出力
        System.out.println(happypoint);

        sc.close();
    }

}

Measured memory_bytes: 23636
const Main = (input) {
  const [m, d] = input.split(" ").map(n => Number(n));
  let count = 0;
  for (let i = 1; i <= m; i++) {
    for (let p = 2; p <= (d / 10); p++) {
      if (Number.isInteger(i / p)
          && i / p < 10
          && i / p >= 2
          && (i / p) + (p * 10) <= d ) {
        count++;
      }
    }
  }
  console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
n,m=map(int,input().split())
tosi=[0]*(n+1)
ab=[ list(map(int,input().split())) for i in range(m)]

for i in range(m):
  tosi[ab[i][0]]+=1
  tosi[ab[i][1]]+=1
tosi.pop(0)
for i in tosi:
  print(i)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

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

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	

	if (s == "zyxwvutsrqponmlkjihgfedcba")
	{
		println(-1);
		return 0;
	}

	vector<bool> a(26);
	for (char it : s)
	{
		a[it - 'a'] = true;
	}

	for (ll i = 0; i < 26; i++)
	{
		if (!a[i])
		{
			println((s + (char)('a' + i)));
			return 0;
		}
	}

	string t = s;
	string res;
	next_permutation(all(t));
	for (ll i = 0; i < s.length(); i++)
	{
		res = res + t[i];
		if (s[i] != t[i])
		{
			break;
		}
	}

	println(res);
}




Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int dist(int a, int b, int w){
  int ax = a % w;
  int ay = a / w;
  int bx = b % w;
  int by = b / w;

  return abs(ax - bx) + abs(ay - by);
}

int main(){
  int n;

  while(cin >> n){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;

    int ans = INT_MAX;
    for(int w = 1; w <= n; w++){
      ans = min(ans, dist(a, b, w) + dist(c, d, w));
    }
    cout << ans << endl;
  }
}

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

int main() {
  vector<string> S = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string s;
  cin >> s;

  for (int i = 0; i < 7; ++i) {
    if (s == S.at(i)) cout << 7-i << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
int main() {
	int n[26] = { 0 };
	char c;
	while (scanf("%c", &c) != EOF)
		n[(int)tolower(c) - 97]++;
	for (int i = 0; i < 26; i++)
		printf("%c : %d\n", i + 97, n[i]);
}

Measured memory_bytes: 976
#include <iostream>
#include <vector>

using namespace std;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int ans = 11;
vector<vector<int>> mp;
void dfs(int i, int j, int direction, int num, vector<vector<int>> mp){
	while(mp[i+dx[direction]][j+dy[direction]] == 0){
		i += dx[direction];
		j += dy[direction];
	}
	if(mp[i+dx[direction]][j+dy[direction]] == 3){
		ans = min(num,ans);
		return;
	}
	if(mp[i+dx[direction]][j+dy[direction]] == 1 && num < 10){
		mp[i+dx[direction]][j+dy[direction]] = 0;
		for(int k = 0;k<4;k++){
			if(mp[i+dx[k]][j+dy[k]] == 1)continue;
			if(mp[i+dx[k]][j+dy[k]] == -1)continue;
			dfs(i,j,k,num+1,mp);
		}
	}
}


int main(){
	int w,h;
	while(cin>>w>>h,w){
		mp.resize(h+2,vector<int>(w+2,-1));
		int def_i,def_j;
		for(int i = 1;i < h+1;i++){
			for(int j = 1;j < w+1;j++){
				cin >> mp[i][j];
				if(mp[i][j] == 2){
					def_i = i;
					def_j = j;
				}
			}
		}
		mp[def_i][def_j] = 0;
		for(int i = 0;i < 4;i++){
			if(mp[def_i+dx[i]][def_j+dy[i]] != 0 && mp[def_i+dx[i]][def_j+dy[i]] != 3)continue;
			dfs(def_i,def_j,i,1,mp);
		}
		if(ans == 11)cout << -1 << endl;
		else cout << ans << endl;
		ans = 11;
		mp.clear();
	}
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll N;
  cin>>N;
  vector<int>ans(35);
  bool chk=true;
  if(N==1){
    cout<<1<<endl;
    chk=false;
  }
  if(N==0){
    cout<<0<<endl;
    chk=false;
  }
  
  
  ll sum=N;
  ll num=0;
  while(sum!=1&&sum!=0){
    if(sum<0){
      if(abs(sum)%2==0){
        sum=abs(sum)/2;
        ans[num]=0;
        num++;
        
      }
      else{
        sum=abs(sum)/2+1;
        ans[num]=1;
        num++;
      }
    }
    
    else{
      if(abs(sum)%2==0){
        sum=(-1)*abs(sum)/2;
        ans[num]=0;
        num++;
      }
      else{
        sum=(-1)*abs(sum)/2;
          ans[num]=1;
        num++;
          
      }
    }
    
    if(sum==1){
      ans[num]=1;
      break;
  }
  }
  bool flag=false;
  
  for(int i=35;i>=0;i--){
    if(flag){
      cout<<ans[i];
    }
    
    if(flag==false&&ans[i]!=0){
      cout<<ans[i];
      flag=true;
    }
  }

  cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	set<char> found;

	for(auto& chr: fetch<string>()) {
		found.insert(chr);
	}

	cout << (found.count('W') != found.count('E') || found.count('S') != found.count('N') ? "No\n" : "Yes\n");
}

int main() {
	fast_io();
	solve();

	return 0;
}


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

int main() {
  int N; cin >> N;
  vector<int> a(N);
  rep(i, 0, N) cin >> a[i];
  int mxp = max_element(a.begin(), a.end()) - a.begin();
  int mnp = min_element(a.begin(), a.end()) - a.begin();
  vector<pair<int, int>> ans;
  if(abs(a[mxp]) >= abs(a[mnp])) {
    rep(i, 0, 2) ans.push_back({mxp + 1, 1});
    rep(i, 1, N) rep(j, 0, 2) ans.push_back({i, i + 1});
  } else {
    rep(i, 0, 2) ans.push_back({mnp + 1, N});
    rem(i, N, 1) rep(j, 0, 2) ans.push_back({i, i - 1});
  }
  cout << ans.size() << endl;
  for(auto p : ans) cout << p.first << " " << p.second << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

int main() {
	int n, w;
	struct { int v, w; } item[101];
	cin >> n >> w;
	for (int i = 0; i <= n; i++)
		cin >> item[i].v >> item[i].w;
	int dp[101][10001] = {};
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= w; j++)
			if (item[i].w <= j)
				dp[i+1][j] = max(dp[i][j], dp[i+1][j - item[i].w] + item[i].v);
			else
				dp[i+1][j] = dp[i][j];
	cout << dp[n][w] << endl;
	return 0;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  rep(i,10000){
    int c =i*0.08;
    int d =i*0.10;
    if(c==A && d==B){
      cout << i; 
      return 0;
    }
  }
  
  cout << -1;
}



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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  ll h, w;
  cin >> h >> w;

  ll ans = 1000000000;
  if (h % 3 == 0 || w % 3 == 0) {
    ans = 0;
    cout << ans << endl;
    return 0;
  }

  for (int hi = 1; hi < h; hi++) {
    int rest = h - hi;

    ll a, b, c;
    a = hi * w;

    if (rest % 2 == 0) {
      b = rest / 2 * w;
      c = rest / 2 * w;
    } else {
      b = rest / 2 * w;
      c = (rest - rest / 2) * w;
    }

    ll maxx = max(a, max(b, c));
    ll minn = min(a, min(b, c));
    ll diff = maxx - minn;

    ans = min(ans, diff);

    if (w % 2 == 0) {
      b = w / 2 * rest;
      c = w / 2 * rest;
    } else {
      b = w / 2 * rest;
      c = (w - w / 2) * rest;
    }

    maxx = max(a, max(b, c));
    minn = min(a, min(b, c));
    diff = maxx - minn;

    ans = min(ans, diff);
  }

  swap(h, w);
  for (int hi = 1; hi < h; hi++) {
    int rest = h - hi;

    ll a, b, c;
    a = hi * w;

    if (rest % 2 == 0) {
      b = rest / 2 * w;
      c = rest / 2 * w;
    } else {
      b = rest / 2 * w;
      c = (rest - rest / 2) * w;
    }

    ll maxx = max(a, max(b, c));
    ll minn = min(a, min(b, c));
    ll diff = maxx - minn;

    ans = min(ans, diff);

    if (w % 2 == 0) {
      b = w / 2 * rest;
      c = w / 2 * rest;
    } else {
      b = w / 2 * rest;
      c = (w - w / 2) * rest;
    }

    maxx = max(a, max(b, c));
    minn = min(a, min(b, c));
    diff = maxx - minn;

    ans = min(ans, diff);
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main()
{
    long long n,m,x,y,z,i,j,k=0;
    cin>>n;

    for(i=n;i>=1;i--)
    {
        m=i;
        j=0;
        while(m>0)
        {
            m=m/10;
            j++;
        }
        if(j%2!=0)
        {
            k++;
        }
    }
    cout<<k;
}



Measured memory_bytes: 256
x,y=map(int,input().split())
if x==0 or y==0:
    if y>=x:
        print(abs(y-x))
    else:
        print(abs(y-x)+1)
else:
    if x>0 and y>0:
        if y>=x:
            print(abs(y-x))
        else:
            print(abs(y-x)+2)
    if x<0 and y<0:
        if y>=x:
            print(abs(y-x))
        else:
            print(abs(y-x)+2)
    elif x>0 and y<0:
        print(abs(-y-x)+1)
    elif x<0 and y>0:
        print(abs(y+x)+1)

Measured memory_bytes: 61976