akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long X = nx[1];
        //ちゅーごくじょーよてーり
        //オーダーによってSの終端が決定する
        //まず影響するのは降順のみなことは自明に分かって、
        //で、「次」を選ぶことができる順番は
        //「確率」「期待値」
        //aを取り除いた場合、その後に適用できるのはそれ以前全て。

        List<int> s = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToList();
        ModInt[] dp = new ModInt[X + 1];
        dp[X] = 1;
        ModInt remain = s.Count - 1;
        foreach (var mod in s)
        {
            ModInt[] newDP = new ModInt[X + 1];

            for (int i = 0; i < dp.Length; i++)
            {
                newDP[i % mod] += dp[i];
                newDP[i] += dp[i] * remain;
            }
            remain--;
            dp = newDP;
        }
        ModInt res = 0;
        for (int i = 0; i < dp.Length; i++)
        {
            res += dp[i] * i;
        }
        Console.WriteLine(res);
    }
}


struct ModInt
{
    const int MOD = 1000000007;
    long Data;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public ModInt(long data) { if ((Data = data % MOD) < 0) Data += MOD; }
    public static implicit operator long(ModInt modInt) => modInt.Data;
    public static implicit operator ModInt(long val) => new ModInt(val);
    public static ModInt operator +(ModInt a, ModInt b)
    {
        long res = a.Data + b.Data;
        return new ModInt() { Data = res >= MOD ? res - MOD : res };
    }
    public static ModInt operator -(ModInt a, ModInt b)
    {
        long res = a.Data - b.Data;
        return new ModInt() { Data = res < 0 ? res + MOD : res };
    }
    public static ModInt operator *(ModInt a, ModInt b) => new ModInt(a.Data * b.Data);
    public static ModInt operator /(ModInt a, ModInt b) => a * Power(b, MOD - 2);

    static ModInt Power(ModInt n, long m)
    {
        ModInt res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res *= n;
            n *= n;
            m >>= 1;
        }
        return res;
    }
}


Measured memory_bytes: 32296
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    int res = 0;

    for (int i = 0; i < n; ++i) {
        int l = i;
        while (i + 1 < n && A[i + 1] == A[i]) {
            ++i;
        }
        int r = i;
        int cnt = r - l + 1;
        if (cnt < A[i]) {
            res += cnt;
        } else {
            res += cnt - A[i];
        }
    }
    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i, n){
        if(i==0) continue;
        int cnt = 0;
        for(char c='a'; c<='z'; c++){
            bool left=false, right=false;

            rep(j, i) if(s[j]==c) left=true;
            for(int j=i; j<n; j++){
                if(s[j]==c) right=true;
            }

            if(left and right) cnt++;
        }

        chmax(ans, cnt);
    }

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

Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    d,t,s = map(int,input().split())
    if d>s*t:
        print("No")
    else:
        print("Yes")
    

Measured memory_bytes: 68624
/*
        ঘরে থাকুন , সুস্থ থাকুন ।
    wan-_-s
*/
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define stay_home_stay_safe return 0
#define pb push_back
//const ll N = 200007 ;
void scan(ll &n) { scanf("%lld",&n) ; }
void scan(ll &n, ll &m) { scanf("%lld%lld",&n,&m) ; }
void scan(vector<ll> &v) { ll n = v.size() ; for(ll i=0 ;i<n;i++) scanf("%lld",&v[i]) ; }
//vector<ll> adj[N] ;


void sol () {
    ll n ,i ;
    cin >> n ;
    vector<ll> v(n) ;
    for ( i = 0 ; i <n ;i++) cin >> v[i] ;
    map<ll,ll> mp ;
    ll ans =1 ;
    for ( i = 1 ; i<= n ; i++) {
        ll x = (i + v[i%n]  )%n ;
        x+=n ;
        x%=n ;
        mp[x]++ ;
        if (mp[x]>1) ans = 0 ;
    }
    cout << (ans == 1 ? "YES\n" : "NO\n" ) ;

}


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    ll n , i;
    cin >> n ;
    vector<ll> v(n) ;
    for ( i = n-1 ; i>= 0 ; i--) cin >> v[i] ;
    ll  have=2 , l=2 , r=3 , x = 2 , y= 2  ;
    if (v[0]!=2) {
        cout << -1 << endl ;
        return 0 ;
    }
    for ( i = 1 ; i< n ; i++) {

            ll x = ( ( l+v[i]-1 ) / v[i] ) *v[i] ;
            ll y = (r/v[i]) *v[i] ;
            if (x>r or y<x or y<l) {
                cout << -1 << endl;
                return 0 ;
            }
            l = x ;
            r = y+v[i]-1 ;



    }
    cout << l << ' ' << r << endl ;

    stay_home_stay_safe ;
}






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

int main() {
	int N,ans=0;
	int L[101];

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = i; j < N; j++) {
			for (int k = j; k < N; k++) {
				if (L[i] != L[j] && L[j] != L[k] && L[k] != L[i] && L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

	bool ok = 0;


	for(int i = a; i <= b; i++){
		if(i % n == 0){
			ok = 1;
			break;
		}
	}

	if(ok) cout << "OK" << endl;
	else cout << "NG" << endl;
}





Measured memory_bytes: 3620
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


x,k,d = list(map(int, input().split()))
x = abs(x)
if x>=k*d:
    ans = x-k*d
elif x<=-k*d:
    ans = x+k*d
else:
    v = x//d
    val = x%d
    val2 = abs(val-d)
    if (k-v)%2==0:
        ans = val
    else:
        ans = val2
print(ans)

Measured memory_bytes: 61916
#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int fw[26][N];
int c[N];
void up(int id, int x, int v){
    //printf("update %d %d %d\n",id,x,v);
    while (x < N){
        fw[id][x] += v;
        x += x&(-x);
    }
}
int sum(int id, int x){
    //printf("sum %d %d\n",id,x);
    int res = 0;
    while (x){
        res += fw[id][x];
        x -= x&(-x);
    }
    return res;

}
int main(){
    int n;
    scanf("%d",&n);
    memset(fw,0,sizeof(fw));
    string s;
    cin >> s;
    for (int i = 1; i <= n; i++){
        c[i] = s[i-1]-'a';
        up(c[i],i,1);
    }
    int q;
    scanf("%d",&q);
    for (int i = 0,t; i < q; i++){
        scanf("%d",&t);
        if (t == 1){
            int p;
            char x;
            scanf("%d %c",&p,&x);
            up(c[p],p,-1);
            c[p] = x-'a';
            up(c[p],p,1);
        }
        else{
            int l,r;
            scanf("%d%d",&l,&r);
            int ans = 0;
            for (int j = 0; j < 26; j++){
                if (sum(j,l-1) != sum(j,r)) {
                    //printf("%c is good\n",j+'a');
                    ans++;
                }
            }
            printf("%d\n",ans);
        }
    }
}


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

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  int ans = 99999;
  for (int i = 1; i <= N-1; ++i) {
    int sum = findSumOfDigits(i)+findSumOfDigits(N-i); // i の各桁の和
    ans=min(ans,sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;

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

    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i, m) cin >> b[i];
    int ans = 0;
    rep(i, n)
    {
        int sum = c;
        rep(j, m)
        {
            int a;
            cin >> a;
            sum += a * b[j];
        }
        if (sum > 0)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int ta[100010],nt[200010],to[200010],u[100010];
long long p[100010]={1};
long long q[100010]={1};
long long n,m,M=1e9+7;
long long f(int s){
  long long i,a=1,c=0;
  u[s]=1;
  for(i=ta[s];i+1;i=nt[i]){
    if(u[to[i]])continue;
    a=(a*f(to[i]))%M;
    c++;
  }
  if(c>m)c=m;
  if(s==1)return (a*q[c])%M;
  return (a*p[c])%M;
}
int main(){
  int i,a,b;
  scanf("%lld %lld",&n,&m);
  for(i=0;i<n;i++)ta[i+1]=-1;
  for(i=0;i<=m;i++)p[i+1]=(p[i]*(m-2-i))%M;
  for(i=0;i<=m;i++)q[i+1]=(q[i]*(m-1-i))%M;
  for(i=0;i<n-1;i++){
    scanf("%d %d",&a,&b);
    nt[i    ]=ta[to[i+n-1]=a];
    nt[i+n-1]=ta[to[i    ]=b];
    ta[b]=i+n-1;
    ta[a]=i    ;
  }
  printf("%lld\n",(f(1)*m)%M);
  return 0;
}


Measured memory_bytes: 6016
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n;
	ll k;
	cin>>n>>k;
	
	vector<int> vec;
	
	for(int i = 0;i<n;i++)
	{
		int x;cin>>x;x--;
		vec.push_back(x);
	}
	
	vector<int> pos(n+1 , -1);
	vector<int> path;
	pos[0] = 0;
	path.push_back(0);
	int curr = 0;
	
	while(pos[vec[curr]] == -1)
	{
		pos[vec[curr]] = 1 + pos[curr];
		path.push_back(vec[curr]);
		curr = vec[curr];
	}
	
	int cycle_start = pos[vec[curr]];
	vector<int> cycle;
	for(int i = cycle_start;i<path.size();i++)
	{
		cycle.push_back(path[i]);	
	}
	
	if(k < cycle_start)
	{
		cout<<path[k] + 1<<endl;
		return 0;	
	}
	
	k-=cycle_start;
	ll d = (ll)cycle.size();
	
	cout<<cycle[k%d] + 1<<endl;
	
	return 0;
}

Measured memory_bytes: 7204
N = int(input())
A = list(map(int,input().split()))
C = [0 for _ in range(N+1)]
for i in range(1,N+1):
    C[i] = C[i-1]^A[i-1]
A = [bin(A[i])[2:] for i in range(N)]
A = [A[i] if len(A[i])==20 else "0"*(20-len(A[i]))+A[i] for i in range(N)]
cnt = 0
cur = 0
for i in range(N):
    cnt += cur-i
    b = C[cur]^C[i]
    b = bin(b)[2:]
    if len(b)<20:
        b = "0"*(20-len(b))+b
    B = [int(b[j]) for j in range(20)]
    while cur<N:
        flag = 0
        for j in range(20):
            B[j] += int(A[cur][j])
            if B[j]>=2:
                flag = 1
                break
        if flag==1:break
        cnt += 1
        cur += 1
print(cnt)

Measured memory_bytes: 127400
#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 REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


int main () {

  string S, T;
  ll A, B;
  string U;

  cin >> S;
  cin >> T;
  cin >> A;
  cin >> B;
  cin >> U;

  if (S==U) {
    cout << A - 1 << " " << B << endl;
  }
  else {
    cout << A << " " << B - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void sub_main(istream &cin) {
    ll N;
    cin >> N;
    if(!cin) return;
    vector<int> ip(N);
    for (int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        tmp--;
        ip[tmp] = i+1;
    } // end i
    for (int i = 0; i < N; ++i) {
        // a
        cout << 2*i * N + ip[i] << ' ';
    } // end i
    cout << endl;
    for (int i = 0; i < N; ++i) {
        // b
        cout << 2*(N - i-1) * N + ip[i] << ' ';
    } // end i
    cout << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        sub_main(fs);
    }
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_gcd(_T first, _T second)
{
	_T num1 = first, num2 = second;
	_T remainder = 0, common = 0;

	if (!num1) return num2;
	if (!num2) return num1;

	while (!common) {
		remainder = num1 % num2;

		if (remainder == 0) {
			common = num2;
		}
		else {
			num1 = num2;
			num2 = remainder;
		}
	}
	return(common);
}
template <class _T> static _T tp_lcm(_T first, _T second) {
	_T gcd = tp_gcd<_T>(first, second);
	return first * second / gcd;
}

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static const long long MOD_NUM = 1000000007LL;

static void D_task();

int main()
{
	D_task();
	fflush(stdout);
	return 0;
}

static void D_task()
{
	int N;
	get1int(N);
	std::vector<int> an(N, 0);

	for (int i = 0; i < N; i++) {
		int a;
		get1int(a); a--;
		an[i] = a;
	}

	int now = 0, brk = 0;
	for (int i = 0; i < N; i++) {
		if (now == an[i]) {
			now++;
		}
		else {
			brk++;
		}
	}
	if(brk >= N) {
		brk = -1;
	}
	printf("%d\n", brk);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,a=0,b=0,c=0,ans=0;
    cin >> n;
    string s[n];
    for(int i=0;i<n;i++){
        cin >> s[i];
        int k = s[i].size()-1;
        if(s[i][0]=='B') a++;
        if(s[i][k]=='A') b++;
        if(s[i][0]=='B'&&s[i][k]=='A') c++;
        for(int j=0;j<k;j++){
            if(s[i][j]=='A'&&s[i][j+1]=='B') ans++;
        }
    }
    a-= c;
    b-= c;
    if(c==0) ans += min(a,b);
    else{
        if(a+b>0) ans += c+min(a,b);
        else ans += c-1;
    } 
    cout << ans << endl;
}

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

double convertToDeg(double rad)
{
    return rad * (180 / M_PI);
}

int main()
{
    double a, b, x;
    cin >> a >> b >> x;

    cout << fixed << setprecision(10);

    if (x > a * a * b / 2)
    {
        double degInRad = atan(((2.0 * b) - (2.0 * x / a / a)) / a);
        cout << convertToDeg(degInRad) << endl;
    }
    else
    {
        double degInRad = atan((a * b * b) / (2 * x));
        cout << convertToDeg(degInRad) << endl;
    }
}

Measured memory_bytes: 512
import re
import copy
import numpy as np

def accept_input():
    N,Y = map(int,input().split())
    return N,Y

N,Y = accept_input()

man_result = -1
gosen_result = -1
sen_result = -1
for man in range(N+1):
    if man*10000 > Y:
        break
    for gosen in range(N+1-man):
        if man*10000 + gosen*5000 > Y:
            break
        elif man*10000+gosen*5000+(N-man-gosen)*1000 == Y:
            man_result = man
            gosen_result = gosen
            sen_result = (N-man-gosen)
            break
    if man_result != -1 or gosen_result != -1 or sen_result != -1:
        break
if man_result != -1 or gosen_result != -1 or sen_result != -1:
    print(str(man_result)+" "+str(gosen_result)+" "+str(sen_result)+" ")
else:
    print(str(man_result)+" "+str(gosen_result)+" "+str(sen_result)+" ")


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n, q;
ll r[200000];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> q;
  stack<ll> s;
  s.push(n);
  ll qu;
  for (int i = 0; i < q; i++) {
    cin >> qu;
    while (!s.empty() && qu <= s.top())
      s.pop();
    s.push(qu);
  }
  map<ll, ll> c;
  c[s.top()] = 1;
  s.pop();
  while (!s.empty()) {
    ll l = s.top();
    s.pop();
    ll s = 0;
    auto it = c.lower_bound(l + 1);
    while (it != c.end()) {
      ll cl = it->first;
      ll cs = it->second;
      c.erase(it++);
      s += (cl / l) * cs;
      cl %= l;
      if (cl != 0)
        c[cl] += cs;
    }
    if (s != 0)
      c[l] += s;
  }
  for (auto & p : c)
    r[1] += p.second, r[p.first + 1] -= p.second;
  for (int i = 1; i <= n; i++)
    r[i] += r[i - 1], cout << r[i] << "\n";
}


Measured memory_bytes: 8704
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    long long int h;
    cin >> h;
    long long int count = 0;
    long long int i = 0;
    while(h >= 1) {
        count += pow(2,i);
        h = h/2;
        i++;
        if(h == 0) {
            break;
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool right(string s1,string s2) {
	for(int i = 0;i < s1.size();i++) {
		if(s1[i] != '?' && s1[i] != s2[i]) {
			return false;
		}
	}
	return true;
}
int main() {
	string s,t;
	string best = "~";
	cin >> s >> t;
	int len = s.size(),len1 = t.size();
	for(int i = 0;i <= len-len1;i++) {
		string v = s.substr(i,len1);
		if(right(v,t) == true) {
			string tmp = s;
			for(int j = i;j < i+len1;j++) {
				tmp[j] = t[j-i];
			}
			for(int j = 0;j < i;j++) {
				if(tmp[j] == '?') {
					tmp[j] = 'a';
				}
			}
			for(int j = i+len1;j < len;j++) {
				if(tmp[j] == '?') {
					tmp[j] = 'a';
				}
			}
			best = min(best,tmp);
		}
	}
	if(best == "~") {
		cout << "UNRESTORABLE" << endl;
	} else {
		cout << best << endl;
	}
	return 0;
}

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

Measured memory_bytes: 580
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<sstream>
#include<fstream>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
#include<string>
using namespace std;
/*freopen{"input.txt","r",stdin};
freopen{"output.txt","w",stdout};*/
#define mp make_pair
#define pb push_back
const int INF=1000*1000*1000;
const int maxn=2e5; 
typedef long long ll;
typedef long double ld;
typedef pair<int,int>PII;
//priority_queue <int,vector<int>,greater<int> > q1;  //从小到大 
//priority_queue <int,vector<int>,less<int> >q2;  //从大到小 

int main(){
	//ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
    int n;
    cin>>n;
    map<string,int>m;
    for(int i=0;i<n;i++){
    	string t;
    	cin>>t;
    	m[t]++;
	}
    cout<<m.size();
    
    return 0;
}



Measured memory_bytes: 19176
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPI(i,f,n) for(int i=(f);i<(n);++i)
using namespace std;
typedef long long ll;
typedef tuple<int,int,int> NODE;

const int DINF = 100000;

vector< vector< vector< pair<int,int> > > > G(22, (vector< vector< pair<int,int> > >)(22) );
vector< vector< int > > d(22, (vector<int>)(22, DINF) );

int main() {
  int H,W;
  string sin;
  cin >> H >> W;
  vector< string > S;
  sin = "";
  REP(i, W+2) sin += '#';
  S.push_back(sin);
  REP(i, H) {
    cin >> sin;
    S.push_back( '#' + sin + '#');
  }
  sin = "";
  REP(i, W+2) sin += '#';
  S.push_back(sin);

  // グラフ作成
  REPI(y,1,H+2) REPI(x,1,W+2) {
    if (S[y][x] == '.' ) {
      if (S[y-1][x] == '.' ) G[y][x].emplace_back(y-1, x);
      if (S[y][x-1] == '.' ) G[y][x].emplace_back(y, x-1);
      if (S[y+1][x] == '.' ) G[y][x].emplace_back(y+1, x);
      if (S[y][x+1] == '.' ) G[y][x].emplace_back(y, x+1);
    }
  }
  int dmax = 0;
  // 各開始点からダイクストラ
  REPI(y,1,H+2) REPI(x,1,W+2) {
    if (S[y][x] == '.' ) {
      priority_queue< tuple< int, int, int > > q;
      q.emplace(  0, y, x );
      
      while ( !q.empty() ) {
        int n,ix,iy;
        tie(n,iy,ix) = q.top(); q.pop();
        d[iy][ix] = n;
        for ( auto nv : G[iy][ix] ) {
          int ny = nv.first;
          int nx = nv.second;
          if ( d[ny][nx] > n+1 )
            q.emplace( n+1, ny, nx );
        }
      }
      REPI(iy,1,H+2) REPI(ix,1,W+2) {
        if ( d[iy][ix] != DINF ) dmax = max(dmax, d[iy][ix] );
         d[iy][ix] = DINF;
      }
    }
  }
  cout << dmax << endl;

}


Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void){
    int a, b;
    cin >> a >> b;
    int add = a + b;
    int sub = a - b;
    int mul = a * b;

    int MAX = max({add, sub, mul});

    cout << MAX << endl;
    return 0;
}

Measured memory_bytes: 384
X,Y = map(int,input().split())
def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a = 1
  b = 1
  c = 1
  for i in range(1,n+1):
    a = (a*i)%p
  for i in range(1,k+1):
    b = (b*i)%p
  for i in range(1,n-k+1):
    c = (c*i)%p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return (d**2) %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
if (X+Y)%3 != 0 or X > 2*Y or Y > 2*X:
    print(0)
else:
    ab = (X+Y)//3
    a = X - ab
    b = ab - a
    mod = 10**9+7
    ans = comb(ab,min(a,b),mod)
    print(ans)

Measured memory_bytes: 3064
using static System.Console;
using System.Linq;
class A
{
    static void Main()
    {
        var p = ReadLine().Split().Select(int.Parse).ToArray();
        int N = p[0];int M = p[1];int K = p[2];
        for(var i = 0; i <= N; i++) { for(var j = 0; j <= M; j++) { if (K == (i * M + j * N - 2 * i * j)) { WriteLine("Yes");return; } } }
        WriteLine("No");
    }
}



Measured memory_bytes: 13268
n = int(input())
count = [0 for _ in range(5)]
for i in range(n):
    tmp = input()
    if tmp[0] == 'M':
        count[0] += 1
    elif tmp[0] == 'A':
        count[1] += 1
    elif tmp[0] == 'R':
        count[2] += 1
    elif tmp[0] == 'C':
        count[3] += 1
    elif tmp[0] == 'H':
        count[4] += 1

sum = 0
for i in range(5):
    for j in range(5):
        for k in range(5):
            if i==j or j==k or k==i:
                continue
            elif i < j and j < k:
                sum += count[i]*count[j]*count[k]

print(sum)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

bool search(string s) {
string t;
  while(!s.empty()) {
    t = "-1";
    for(int i=0; i<4; ++i)
    	if(s.find(divide[i]) == 0) t = s.substr(divide[i].size());
    if(t != "-1") s = t;
    else return false;
  }
  return true;
}

int main(){
  string S;
  cin >> S;
  
  reverse(S.begin(), S.end());
  for(int i=0; i<4; ++i) reverse(divide[i].begin(), divide[i].end());
  
  if(search(S)) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		double v,t,y,temp;
		int n;
		while(s.hasNext()){
			v=s.nextDouble();
			t=v/9.8;
			y=4.9*t*t;
			n=(int) ((y+5)/5);
			if((y+5)%5!=0) n++;
			System.out.println(n);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>

int main(void){
    int n,h,m;
    std::cin >> n;
    h=n/3600;
    n=n-h*3600;
    m=n/60;
    n=n-m*60;
    std::cout << h << ":" << m << ":" << n << std::endl;
    return 0;
}


Measured memory_bytes: 3108
n = gets.to_i
count = 0
1.upto(n) do |sum|
  if sum % 3 == 0 && sum % 5 == 0 then
    next
  elsif sum % 3 == 0
    next
  elsif sum % 5 == 0
    next
  else
    count += sum
  end
end

puts count

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

int main() {
  int N;
  cin >> N;
  vector<int> l(N),r(N);
  for (int i = 0; i < N; i++) {
    cin >> l.at(i) >> r.at(i);
  }

  int  ans =  0;
  for (int i = 0; i < N; i++) {
    for (int j = l.at(i); j <= r.at(i); j++) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mod 10000007
#define mp make_pair
#define pi acos(-1)
#define line cout<<"----------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
vector<ll >v;
void convert(string b)
{
    v.clear();
    for(ll  i=b.size()-1;i>=0;i--)
    {
        v.pb(b[i]-'0');
    }

}
ll dp[109][2][109];
ll  k;
ll call(ll ind, bool check,ll sum)
{
    if(ind==-1) return sum==k;
    ll cnt=0;
    ll limit=check? (v[ind]):9;
    ll &ret=dp[ind][check][sum];
    if(ret!=-1 and !check) return ret;
    for(ll i=0;i<=limit;i++)
    {
        bool ck=(i==v[ind])? check:0;
        cnt+=call(ind-1,ck,sum+bool(i));
    }
    if(!check) ret=cnt;
    return cnt;
}
int  main()
{
    string b;
    memset(dp,-1,sizeof dp);
    cin>>b>>k;
    convert(b);
    ll ans1=call(v.size()-1,1,0);
    cout<<ans1<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            {for(ll i=0;i<size;i++) cout<<w[i]<<" ";cout<<"\n";}
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a,ll m=MOD){if(m==1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}

int main()
{
	fastIO
	ll k,x;
	cin>>k>>x;
	if(k*500>=x)
		cout<<"Yes";
	else cout<<"No";	
	return 0;
}




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

int main(){
    string str;
    
    while(true){
        int sum = 0;
        cin >> str;
        if(str=="0") break;
        for(int i = 0 ; i < str.size() ; i++){
            sum += str[i]-'0';
        }
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c;
string s, t;

int main()
{
	cin >> a>>b>>c ;
	s = a + b + c >= 22 ? "bust" : "win";

	
	
	cout << s << endl;
}


Measured memory_bytes: 256
N,W = map(int, input().split())
VW  = [list(map(int, input().split())) for _ in range(N)]
VW  = sorted(VW, key=lambda x:x[1])
# print(VW)
# exit()

# dp = [0] * (W+1) # $B2ACM$N:GBgCM(B
dp = [ [0] * (W+1) for _ in range(N+1)]  # item, omosa

for i in range(N):
    v,w2 = VW[i]
    for w in range(0,W+1):
        if w-w2 >= 0:
            dp[i+1][w] = max(dp[i+1][w],dp[i][w-w2]+v)

        dp[i+1][w] = max(dp[i+1][w] , dp[i][w])


# print( (dp[N]) )
print( max(dp[N]) )



Measured memory_bytes: 41884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef string str;
typedef vector<ll>  vl;
typedef vector< vector<ll> > vvl;
typedef vector<ii> vii;
typedef vector< vector<ii> > vvii;
typedef vector<iii> viii;
typedef vector< vector<iii> > vviii;
typedef vector<str>  vs;
typedef vector< vector<str> > vvs;
typedef long double ld;

//typelower_bounddef priority_queue<long long> pq;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//typedef set<int>::iterator sit;
//typedef map<int,int>::iterator mit;
//typedef vector<int>::iterator vit;


#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repn(i,a,b) for(int i=(a);i<=(b);i++)
#define repin(i,a,b,x) for(int i=(a);i<(b);i+=x)
#define repnin(i,a,b,x) for(int i=(a);i<=(b);i+=x)
#define MAX(a,blower_bound) a=max(a,b)
#define MIN(a,b) a=min(a,b)
//#define fbo find_by_order
//#define ook order_of_key

// if else int i = (number <0) ? 1:0 -  if (number <0) i=1 else 0

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin >> x;
    if (x>= 30) cout << "Yes";
    else cout << "No";
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int n;
  cin >> n;
  vector<pp> a(n);
  rep(i,n) cin >> a[i].first;
  rep(i,n) cin >> a[i].second;
  int ans=inf;
  rep(j,pow(2,n)){
    int q=0;
    int c=j;
    vector<int> b(n),m(n),u(51,0),g(51,0),v(n);
    vector<vector<int>> uu(51,vector<int>(0)),gg(51,vector<int>(0));
    rep(i,n){
      if (c%2==1) b[i]=1;
      c/=2;
    }
    rep(i,n){
      if (b[i]==1){
        m[i]=a[i].second;
        if (i%2==0) {u[m[i]]++;uu[m[i]].push_back(i);}
        else {g[m[i]]++;gg[m[i]].push_back(i);}
      }
      else{
        m[i]=a[i].first;
        if (i%2==1) {u[m[i]]++;uu[m[i]].push_back(i);}
        else {g[m[i]]++;gg[m[i]].push_back(i);}
      }
    }
    sort(all(m));
    bool t=true;
    rep(i,n){
      if (i%2==0){
      if (g[m[i]]==0) {t=false;break;}
      v[i]=gg[m[i]][gg[m[i]].size()-g[m[i]]];
      g[m[i]]--;
      }
      else{
        if (u[m[i]]==0) {t=false;break;}
      v[i]=uu[m[i]][uu[m[i]].size()-u[m[i]]];
      u[m[i]]--;
      }
    }
    rep(i,n){
      for (int k=i+1;k<n;k++){
        if (v[i]>v[k]) q++;
      }
    }
    if (t) ans=min(ans,q);
  }
  if (ans==inf) cout << -1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    for i in b:
        A = [[(a if a != i else 0) for a in l] for l in A]
    return [NO, YES][any([sum(l) == 0 for l in A]) or any([sum([A[i][j] for i in range(3)]) == 0 for j in range(3)]) or (A[0][0]+A[1][1]+A[2][2] == 0) or (A[2][0]+A[1][1]+A[0][2] == 0)]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)]
         for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(f'{solve(A, N, b)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 75144
// D.cpp
// Date: 08:56:18 19 05 2020
// Author: bonelord
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) cerr<<"[("<<__LINE__<<") "<<#x<<" ]: "<<x<<"\n"
#define dbg_arr(x,sz) cerr<<"[("<<__LINE__<<") |"<<sz<<"| "<<#x<<" ]:\n";for(size_t i=0; i<sz; ++i) { cerr<<"["<<i<<"] "<<x[i]<<" "; }cerr<<endl

int N;
int W;
long dp[101][100001];
int w[101];
int v[101];

void solve(){
	cin>>N>>W;
	v[0] = w[0] = 0;
	for (int i = 1; i <= N; ++i){
		cin>>w[i]>>v[i];
	}
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= N; ++i){
		long j = 1;
		for (; j < w[i]; ++j){
			dp[i][j] = dp[i-1][j];
		}
		for (; j <= W; ++j){
			dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
		}
	}
	cout<<dp[N][W]<<"\n";
}

main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.setf(ios::fixed);

//	int t; cin>>t; while (t--)
	solve();
}


Measured memory_bytes: 79232
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <string.h>
#define INF 1000000001

using namespace std;

ifstream in("ssspne.in");

const int MAXV = 10005;
const int MAXE = 2005;

typedef struct edge{
	int x;
	int y;
	int c;
}edge;

int v, e, s, x, y, c;
edge g[MAXV];
int cost[MAXV];

int Bellman_Ford(){
	for(int i = 0; i < v; i++){
		cost[i] = INF;
	}
	cost[s] = 0;
	//relax edges repeatedly
	for(int j = 0; j < v; j++){
		bool update = false;
		for(int i = 0; i < e; i++){
			int u = g[i].x;
			int n = g[i].y;
			int w = g[i].c;
			if(cost[u] != INF && cost[n] > cost[u] + w){
				cost[n] = cost[u] + w;
				update = true;
			}
		}
		if(!update) return true;
	}	
	return false;

	/* checking if negative cycle is present
	for(int i = 0; i < e; i++){
		int u = g[i].x;
		int n = g[i].y;
		int w = g[i].c;
		if(cost[n] > cost[u] + w){
			cout << "NEGATIVE CYCLE" << '\n';
			return;
		}
	}*/
}

int main(){	
	cin >> v >> e >> s;
	for( int i = 0; i < e; ++i){
		cin >> g[i].x >> g[i].y >> g[i].c;
	}

	if(Bellman_Ford()){
		for(int i = 0; i < v; i++){
			if(cost[i] == INF){
				cout << "INF" << '\n';
				continue;
			}
			else 
			cout << cost[i] << '\n';
		}
	}else{
			cout << "NEGATIVE CYCLE" << '\n';
	} 		

  return 0;
}



Measured memory_bytes: 3112
#include <iostream>

using namespace std;

int main(void)
{
  int months;
  int dates;
  
  cin >> months >> dates;
  
  int multi_dates_count = 0;
  for(int month = 4; month <= months; month++){
    for(int date = 12; date <= dates; date++){
      int first_digit = date % 10;
      int second_digit = date / 10;
      if((first_digit >= 2) && (second_digit >= 2) && (first_digit * second_digit == month)){
        multi_dates_count++;
      }
    }
  }
  
  cout << multi_dates_count << endl;
  
  return 0;
}

Measured memory_bytes: 256
# B - Grid Compression

H, W = map(int, input().split())
A = []
for i in range(H):
    A.append(list(str(input())))

h = [0] * H
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            h[i] += 1

w = [0] * W
for j in range(W):
    for i in range(H):
        if A[i][j] == '#':
            w[j] += 1

for i in range(H):
    ans = ''
    if h[i] == 0:
        continue
    for j in range(W):
        if w[j] == 0:
            continue
        else:
            ans += A[i][j]
    print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <istream>
#include <set>
#include <queue>
#define rep0(i,n) for (long long int i = 0; i <= (n); ++i)
#define rep1(i,n) for (long long int i = 1; i <= (n); ++i)
#define REP(a,b) for (long long int i = a; i <= (b); ++i) 
#define ps push_back 
using namespace std;
typedef long long ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int>a(n);
	rep0(i, n - 1)cin >> a[i];
	sort(a.begin(), a.end());
	cout << a[n - 1] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int max;
	int i;
	int j;
	double x[4];
	double y[4];
	scanf("%d",&max);
	for(i=0;i<max;i++) {
		for(j=0;j<4;j++)scanf("%lf %lf",&x[j],&y[j]);
		if(x[0]==x[1]) {
			if(x[2]==x[3])printf("YES\n");
			else printf("NO\n");
		} else if(x[2]==x[3])printf("NO\n");
		else {
			if((y[1]-y[0])/(x[1]-x[0])==(y[3]-y[2])/(x[3]-x[2]))
				printf("YES\n");
			else printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	string str;
	cin>>str;
	if(str[0]=='x'&&str[str.length()-1]==str[0]){
		cout <<str[0]<<endl;
	}else{
		cout <<'o'<<endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()
 

int main(void) {
    int n; cin >> n;
    map<int, int> a;
    rep (i, 0, n) {
        int tmp;
        cin >> tmp;
        a[tmp] = i + 1;
    }

    rep(i, 1, n+1) {
        cout << a[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 5504
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<ll,ll,ll,ll> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
typedef ll Def;
class Bell{
	public:
	struct edge{
		Def to,cost;
	};
	vector<vector<edge> >G;
	Def n;
	vector<Def>d;//distance
	Bell(Def size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(Def a,Def b,Def c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
//		G[b].pb(ee);
	}
	void bel(Def s){
		d=vector<Def>(n,INF);
		d[s]=0;
		Def tmp;
		rep(i,2*n){
			rep(j,n)rep(k,G[j].size()){
				edge e=G[j][k];
				if(d[j]!=INF&&d[e.to]>d[j]+e.cost)
					d[e.to]=d[j]+e.cost;
			}
			if(i==n-1)tmp=d[n-1];
		}
		if(tmp!=d[n-1])cout<<"inf"<<endl;
		else cout<<-d[n-1]<<endl;
	}
};
int main(){
	int n,m;
	cin>>n>>m;
	Bell bel(n);
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		bel.add_edge(a,b,-c);
	}
	bel.bel(0);
}











Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std; 

void swap(int *a, int *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}

int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;

	if(N==2)   return 1;
	if(N%2==0) return 0;

	for(i=3;i<N && N%i!=0;i+=2);

	if(i>=N) return 1;
	
	return 0;
}

int factorial(int N){  //Nの階乗を求める関数
	int ans=1;

	while(N--) ans*=(N+1);
	return ans;
}

void q_sort(int a[], int first, int last){
    int i,j;
    int x,t;

    x = a[(first + last) / 2];
    i = first; j=last;

    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}

int main(){
    int N,root=0;
    double child=0,ans;
    int X[9],Y[9];
    int i,j,k;
    int count=0;

    //input_data
    cin>>N;
    int array[N];
    for(i=0;i<N;i++){
        cin>>X[i]>>Y[i];
    }
    //input_end
    for(i=0;i<N;i++) array[i]=i+1;
    
    do{
        for(i=0;i<N-1;i++){
            root+=pow(X[array[i]-1]-X[array[i+1]-1],2);
            root+=pow(Y[array[i]-1]-Y[array[i+1]-1],2);
            child+=sqrt(root);
            root=0;
        }
        count++;
    }while(next_permutation(array,array+N));

    ans=child/(double)count;
    printf("%3.9f\n",ans);
    return 0;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main()
{
    int n, k;
    scanf("%d", &n);
    scanf("%d", &k);

    vector<int> a(n);

    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end(), greater<int>());

    int sum = 0;
    for(int i=0; i<k; i++){
        sum += a.at(i);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>

using namespace std;

int main()
{
	unsigned int n;
	
	cin >> n;
	
	double a = 100000;
	for (int i = 0; i < n; i++)
	{
		a *= 1.05;
		a /= 1000;
		a = ceil(a);
		a *= 1000;
	}
	cout << (int)a << endl;
	
	return 0;
}

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

int main() {
    int N, C, K; cin >> N >> C >> K;
    vector<int> T(N);
    for (int i = 0; i < N; ++i) cin >> T[i];
    sort(T.begin(), T.end());
    int res = 0;
    for (int i = 0; i < N;) {
        ++res;
        int start = i;
        while (i < N && T[i] - T[start] <= K && i - start < C) ++i;
    }
    cout << res << endl;
}

Measured memory_bytes: 3684
def main():
  IN= open(0).read().split()[2:]
  left,right=-1*float("inf"),float("inf")
  
  for L,R in zip(IN[::2],IN[1::2]):
    L,R=int(L),int(R)
    if right<L or R<left:
      print(0)
      break
    else:
      tmp=sorted([left,right,L,R])
      left,right=tmp[1],tmp[2]
  else:
    print(right-left+1)
  
if __name__=="__main__":
  main()

Measured memory_bytes: 18292