akhauriyash/Code-Regression huggingface dataset:
a,b,k=map(int,input().split())

if b-a>200:
    for i in range(k):
        print(a+i)
    for i in range(k):
        print(b-k+1+i)
    
else:
    arr=[]
    for i in range(a,b+1):
        if i<a+k or i>b-k:
            arr.append(i)
    for i in range(len(arr)):
        print(arr[i])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[4][4];
int main() {
	for(int i=1; i<=3; ++i)
		for(int j=1; j<=3; ++j) scanf("%d",&a[i][j]);
	if(a[1][2]+a[2][3]+a[3][1]+a[1][3]+a[2][1]+a[3][2]==2*(a[1][1]+a[2][2]+a[3][3])) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int x, int y)
{
  if (y == 0)
    return x;
  return gcd(y, x%y);
}

int main(void)
{
  int x, y;
  
  scanf("%d%d", &x, &y);
  
  printf("%d\n", gcd(x, y));
  
  return 0;
}



Measured memory_bytes: 2148
import heapq

def main():

    w,h = 0,0
    grid = []
    c = []
    inf = 1000000007
    y = [0,1,0,-1]
    x = [1,0,-1,0]

    def inside(i,j):
        return 0<=i and i<h and 0<=j and j<w

    def solve():
        d = [[[inf]*4 for _ in range(w)] for _ in range(h)]
        d[0][0][0] = 0
        pq = [[0,0,0,0]]
        heapq.heapify(pq)
        while pq:
            ccost,cy,cx,cd = heapq.heappop(pq)
            if d[cy][cx][cd] < ccost: continue
            if cy==h-1 and cx==w-1:return ccost
            for i in range(4):
                nd = (cd+i)%4
                ny = cy+y[nd]
                nx = cx+x[nd]
                if not inside(ny,nx):continue 
                if i == grid[cy][cx]:ncost = ccost
                else                :ncost = ccost+c[i]
                if ncost<d[ny][nx][nd]:
                    d[ny][nx][nd] = ncost
                    heapq.heappush(pq,[ncost,ny,nx,nd])
        return inf

    while True:
        w,h = map(int,input().split())
        if w == 0:break
        grid = []
        for i in range(h):
            grid.append(list(map(int,input().split())))
        c = list(map(int,input().split()))
        print (solve())

if __name__ == '__main__':
    main()




Measured memory_bytes: 5936
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(){
    string s;
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int A, B, D;

struct Elem {
    int x, y;
    bool operator<(const Elem &e) const {
        if(x + y != e.x + e.y) return x + y < e.x + e.y;
        return A*x+B*y < A*e.x+B*e.y;
    }
};

signed main() {
    while(cin >> A >> B >> D, A) {
        Elem ans{51000, 51000};
        repq(x,0,50000) {
            // right
            int diff = D + x * A;
            if(diff % B == 0) {
                int y = diff / B;
                chmin(ans, Elem{x, y});
            }

            // left
            diff = abs(D - x * A);
            if(diff % B == 0) {
                int y = diff / B;
                chmin(ans, Elem{x, y});
            }
        }
        printf("%lld %lld\n", ans.x, ans.y);
    }
    return 0;
}

Measured memory_bytes: 3216
#include<stdio.h>
#include<string.h>
    
int LCS(char *X, char *Y){
  int i,j,m,n,c[1001][1001];
  m = strlen(X);
  n = strlen(Y);
      
  for(i=0; i<m; i++){
    c[i][0] = 0;
  }
  for(j=0; j<n; j++){
    c[0][j] = 0;
  }
    
  for(i=1;i<m+1;i++){
    for(j=1;j<n+1;j++){
      if (X[i-1]==Y[j-1]) c[i][j]=c[i-1][j-1]+1;
      else if (c[i-1][j]>=c[i][j-1]) c[i][j]=c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }
  return c[i-1][j-1];
}
    
int main(){
  int i, q;
  char X[1001], Y[1001];
      
  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%s", X);
    scanf("%s", Y);
    printf("%d\n", LCS(X, Y));
    
  }
  return 0;
}

Measured memory_bytes: 6492
#include <bits/stdc++.h>
#define ll long long
int main()
{
    ll x;
    ll k;
    ll d;
    ll ans;
    std::cin >> x >> k >> d;
    x = std::abs(x);
    ll n = x / d;
    if (n - k > 0) {
        ans = x - k * d;
    } else {

        if ((k - n) % 2 == 0) {
            ans = x - n * d;
        } else {
            ans = x - n * d - d;
        }
    }
    std::cout << std::abs(ans) << std::endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a>b) {
			System.out.println(a+(a-1));
		}
		else if(b>a) {
			System.out.println(b+(b-1));
		}
		else {
			System.out.println(a+b);
		}

	}

}

Measured memory_bytes: 35676
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=n;i>=s;i--)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 21;

ll coin[20] = {};
ll m[13][100001] = {};
int main() {
	ll p = 0;
	coin[p++] = 1;
	ll t = 1;
	rep(i, 1, 7) {
		t *= 6;
		coin[p++] = t;
	}
	t = 1;
	rep(i, 1, 6) {
		t *= 9;
		coin[p++] = t;
	}
	sort(coin, coin + p);

	rep(i, 0, 100001)m[0][i] = MAX_L;

	repe(i, 1, 12) {
		repe(j, 1, 100000) {
			if (j - coin[i - 1] >= 0) {
				m[i][j] = min(m[i - 1][j], m[i][j - coin[i - 1]] + 1);
			}
			else {
				m[i][j] = m[i - 1][j];
			}
		}
	}
	ll n; cin >> n;
	cout << m[12][n] << endl;
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    string s; cin >> s;
    string o[4] = {"WWS","SWW","SSS","WSW"};
    string x[4] = {"WSS","SSW","SWS","WWW"};
    char t[4][n+2];
    rep(i,4){
        rep(j,3){
            if(s[0]=='o') t[i][j] = o[i][j];
            else t[i][j] = x[i][j];
        }
        REP(j,1,n){
            if(s[j]=='o'){
                rep(k,4){
                    if(t[i][j]==o[k][0] && t[i][j+1]==o[k][1]){
                        t[i][j+2] = o[k][2];
                    }
                }
            }else{
                rep(k,4){
                    if(t[i][j]==x[k][0] && t[i][j+1]==x[k][1]){
                        t[i][j+2] = x[k][2];
                    }
                }
            }
        }
        if(t[i][0]==t[i][n] && t[i][1]==t[i][n+1]){
            REP(j,1,n+1){
                cout << t[i][j];
            }
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<stack>
#include<string>
#include<stdlib.h>
#include<stdio.h>
#include<cmath>
#include<cstdlib>
#include<typeinfo>
#include<sstream>
#include<list>
#include<set>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fori(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
int in()
{
	int x;cin>>x;
	return x;
}
int stringInt(string a)
{
	return atoi(a.c_str());
}
string intString(int a)
{
	stringstream ss;
	ss<<a;
	return ss.str();
}
vector<int> SieveOfEratosthenes(int x)
{
	vector<int> a;
	vector<int> b(x+1,0);
	for(int i=2;i<=x;i++)
	{
		if(b[i]==0)
		{
			a.push_back(i);
			for(int l=i;l<=x;l+=i)
			{
				b[l]=1;
			}
		}
	}
	return a;
}

int main ()
{
	int n,m;
	while(cin>>n>>m&&n&&m)
	{
		vector<long long > a,b;
		b.push_back(0);
		rep(i,n)
		{
			b.push_back(in());
		}
		rep(i,n+1)
		{
			rep(l,n+1)
			{
				a.push_back(b[i]+b[l]);
			}
		}
		long long ans = 0;
		sort(a.begin(),a.end());
		rep(i,a.size())
		{
			vector<long long>::iterator t=upper_bound(a.begin(),a.end(),m-a[i]);
			if(t==a.begin())continue;
			t--;
			ans=max(ans,*t+a[i]);
		}
		cout<<ans<<endl;


	}

}

Measured memory_bytes: 17184
#coding: utf-8
include Math

class Point

	def initialize(args)
		@x,@y = args[0],args[1]
	end

	def x 
		return @x
	end

	def y
		return @y
	end
end



n = 0

n = gets.chomp.to_i

n.times{|i|
	str = gets.chomp.split(' ').map(&:to_f)
	
	a = Point.new(str[0,2])
	b = Point.new(str[2,2])
	c = Point.new(str[4,2])

	#外心
	x = 0.5 * (((c.y-b.y)*(b.x**2-a.x**2+b.y**2-a.y**2)-(b.y-a.y)*(c.x**2-b.x**2+c.y**2-b.y**2))/((b.x-a.x)*(c.y-b.y)-(b.y-a.y)*(c.x-b.x))).to_f
	y = 0.5 *( (-(c.x-b.x)*(b.x**2-a.x**2+b.y**2-a.y**2)+(b.x-a.x)*(c.x**2+c.y**2-b.x**2-b.y**2))/((b.x-a.x)*(c.y-b.y)-(b.y-a.y)*(c.x-b.x))).to_f

	#外接円の半径
	ab = sqrt((b.x-a.x)**2 + (b.y-a.y)**2)
	bc = sqrt((b.x-c.x)**2 + (b.y-c.y)**2)
	ac = sqrt((c.x-a.x)**2 + (c.y-a.y)**2)
	s = (ab+bc+ac)/2
	ss = sqrt(s*(s-ab)*(s-bc)*(s-ac))
	r = ab*bc*ac/(4*ss)
	
	puts sprintf("%.3f %.3f %.3f", x,y,r)
}

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

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

    vector<uint64_t> a(n);
    uint64_t all_xor = 0;
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
        all_xor = all_xor xor a[i];
    }

    for (auto i = 0; i < n; i++) {
        cout << (all_xor xor a[i]) << " ";
    }

    cout << endl;
    return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 n,m,d;
    cin >> n >> m >> d;

    if(d==0){
        cout << (long double)(m-1)/n << endl;
        return;
    }

    i64 two=max((i64)0,(n-d)-(1+d)+1),one=max((i64)0,min(n-d,d))+max((i64)0,n-max(1+d,n-d+1)+1);
    print(two);
    print(one);
    cout << (long double)(m-1)*(two*2+one)/n/n << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cstdio>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e6+5;
int n, ans, d = 1, q[N], l, r;
char s[N], t[N];
int main()
{  
    n = read(); scanf("%s%s", s+1, t+1);
    for(int i = n, p = n, l = 1, r = 0; i; --i)
    {
        d &= (s[i] == t[i]);
        if(t[i] == t[i-1]) continue;
        p = min(p, i);
        while(p&&s[p] != t[i]) --p;
        if(!p) return puts("-1"), 0;
        while(l <= r&&q[l]-(r-l+1)+1 > i) ++l; 
        q[++r] = p, ans = max(ans, (i != p)*(r-l+1));
    }
    printf("%d\n", ans+(d == 0));
    return 0;
}
/* 
4
bcad
*/

Measured memory_bytes: 6016
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll x = 0;
    int n;
    cin >> n;
    string op;
    cin >> op;
    ll ans = 0;

    for(int i = 0 ; i < op.size(); i++)
    {
        if(op[i] == 'I') x++;
        else x--;
        ans = max(ans, x);
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
import math
N = int(input())
ans_list = [0 for i in range(N)]
index = int(math.sqrt(N))

for x in range(1,index):
  for y in range(1,index):
    for z in range(1,index):
      n = x**2 + y**2 + z**2 + x*y + y*z + z*x 
      if (n <= N):
        ans_list[n-1] += 1
for i in range(N):
  print(ans_list[i])

Measured memory_bytes: 9208
n,A,B,C = map(int,input().split())
l = [int(input()) for i in range(n)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == n:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF
    
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c) + 10
    ret2 = dfs(cur+1,a,b+l[cur],c) + 10
    ret3 = dfs(cur+1,a,b,c+l[cur]) + 10

    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))


Measured memory_bytes: 3064
def main():

    n,m = map(int,input().split())
    ary = []
    for i in range(m):
        aa, bb = map(int,input().split())

        ary.append((aa-1,bb-1))
    ary_s = list(set(ary))
    a = []
    # b = []
    # Union-Find作る
    uf = UnionFind(n)

    for i in range(len(ary_s)):
        a.append(ary_s[i][0])
        a.append(ary_s[i][1])
        uf.union(ary_s[i][0], ary_s[i][1])
    ans = 1
    for i in a:
        ans = max(ans, uf.size(i))
    print(ans)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

if __name__=='__main__':
    main()


Measured memory_bytes: 48388
using System;
using System.Linq;
class abc
{
    static void Main()
    {
        string[] L = Console.ReadLine().Split(' ');
        int N = int.Parse(L[0]);
        int M = int.Parse(L[1]);

        string[] S = Console.ReadLine().Split(' ');
        int[] I = Array.ConvertAll(S, int.Parse);
        double sum = 0;
        for (int i = 0; i < I.Length; i++)
        {
            sum += I[i];
        }
        if (N >= sum) Console.WriteLine(N - sum);
        else Console.WriteLine("-1");
    }
}


Measured memory_bytes: 28300
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


const int MAX = 2020202;
const int MOD = 1e9 + 7;
ll fac[MAX], finv[MAX], inv[MAX];

void combinit() {
	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;
	}
}
ll comb(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;
}


ll modpow(ll a, ll n) {
	ll res = 1;
	a %= MOD;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

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


	int K;
	string S;
	cin >> K >> S;
	int N = S.size();
	int L = K + N;
	combinit();

	ll ans = 0;

	for (int i = N-1; i < L; i++) {
		ll tmp = modpow(26, L - (i + 1))*modpow(25,i+1-N);
		tmp %= MOD;
		tmp *= comb(i,N-1);
		tmp %= MOD;
		ans += tmp;
		ans %= MOD;
	}
	puts(ans);

	
	return 0;
}

Measured memory_bytes: 51752
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
using namespace std;

typedef long long ll;

#define rep(i,a) for(int i=0;i<(a);++i)
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

const int MAX = 1000000000;
int n;
string table[] = {"0", "1", "2", "3", "5", "7", "8", "9"};

string rec(int c)
{
    int a, b;
    a = c / 8; b =c % 8;

    if(a  == 0) 
        return table[b];
    else 
        return rec(a) + table[b];
}

int main()
{
    while(cin >> n && n) 
        cout << rec(n) << endl;
}

Measured memory_bytes: 904
#include <stdio.h>
int n, k, l, r, m, x;
int a[200000];
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	r = 1000000000;
	while (l + 1 < r) {
		m = (l + r) / 2;
		x = 0;
		for (int i = 0; i < n; i++) {
			x += (a[i] - 1) / m;
		}
		if (x <= k)r = m;
		else l = m;
	}
	printf("%d\n", r);
}

Measured memory_bytes: 2440
n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(q)]

A = []


def dfs(num):
    if len(num) == n:
        A.append(num)
    else:
        now = num[-1]
        for i in range(now, m + 1):
            dfs(num + [i])


for i in range(1, 10):
    dfs([i])

ans = 0
for now in A:
    point = 0
    for a, b, c, d in abcd:
        if now[b-1] - now[a-1] == c:
            point += d

    ans = max(ans, point)

print(ans)


Measured memory_bytes: 23032
N=int(input())

import sys
input = sys.stdin.readline

s=[list(input()) for i in range(N)]

for i in range(N):
    s[i].sort()

out=0

d={}

for i in range(N):
    if str(s[i]) in d:
        out+=d[str(s[i])]
        d[str(s[i])]+=1
    else:
        d[str(s[i])]=1

print(out)


Measured memory_bytes: 44752
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    cin >> s;
    string dst = "AKIHABARA";
    if (s == dst) {
        cout << "YES" << endl;
        return 0;
    }
    int idx = 0;
    unordered_map<char, int> used;
    for(char c: dst) {
        if (idx < s.size() && c == s[idx]) {
            idx += 1;
        } else {
            used[c] += 1;
        }
    }
    
    if (idx == s.size() && used.size() == 1 && 
        used.count('A') > 0 && 
        used['A'] + s.size() == dst.size()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


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

using namespace std;

int main () {
  string oo, ee;
  cin >> oo >> ee;
  int l = oo.length() + ee.length();
  char arr[l + 1];
  int p = 0, q = 0;
  for (int i = 1; i < l + 1; ++i) {
    if (i % 2 == 1) {
      cout << oo[p];
      ++p;
    }
    else {
      cout << ee[q];
      ++q;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<string>
#define lli long long int
#define f(i,n) for(i=0;i<n;i++)
#define f(j,n) for(j=0;j<n;j++)
using namespace std;
lli bin(lli n,lli m){
    lli dp[n+1][m+1];
    for(lli i=0;i<=n;i++){
        for(lli j=0;j<=m;j++){
            dp[i][j] = 0;
        }
    }
    for(lli i=0;i<=n;i++){
        for(lli j=0;j<=min(i,m);j++){
            if(j==0||i==j) dp[i][j] = 1;
            else dp[i][j] = dp[i-1][j-1]+dp[i-1][j];
        }
    }
    return dp[n][m];
}
int main(){
    lli ans=0,in=0;
    string s;
    cin>>s;
    map<string,lli> mp;
    for(lli i=0;i<s.length();i++){
        if(i==0){
            ans++;
            mp[s.substr(i,i+1)]=0;
            mp[s.substr(i,i+1)]++;
            in=1;
        }
        else if(mp[s.substr(in,i+1-in)]==0){
            mp.clear();
            mp[s.substr(in,i+1-in)]=0;
            mp[s.substr(in,i+1-in)]++;
            in=i+1;
            ans++;
        }
        else continue;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            Console.WriteLine(ab[0] * ab[1]);
        }
    }
}

Measured memory_bytes: 28148
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int table[][3] = {
    {  0,  0,  0},
    {  0,  0,255},
    {  0,255,  0},
    {  0,255,255},
    {255,  0,  0},
    {255,  0,255},
    {255,255,  0},
    {255,255,255}
  };

  const char *name[] = {
    "black",
    "blue",
    "lime",
    "aqua",
    "red",
    "fuchsia",
    "yellow",
    "white",
  };

  const int n = sizeof(table) / sizeof(table[0]);

  char buff[256];
  while(fgets(buff,sizeof(buff),stdin), buff[0] != '0'){
    char col[3] = { 0 };
    int rgb[3];
    int diff = INT_MAX;
    int ans;
    REP(i,3){
      col[0] = buff[1 + i*2];
      col[1] = buff[1 + i*2 + 1];

      sscanf(col, "%x", rgb + i);
    }

#define DBL(x) ((x)*(x))
    REP(i,n){
      int tmp = 0;
      REP(j,3)
        tmp += DBL(rgb[j] - table[i][j]);
      if(tmp < diff){
        diff = tmp;
        ans = i;
      }
    }
    puts(name[ans]);
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;

int main()
{
    ld n,x,t;
    cin>>n>>x>>t;
    cout<<int(ceil(n/x)*t);
}


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

int GCD(int x,int y) {
    if (x<y) {
        swap(x,y);
    }
    if (y==0) {
        return x;
    }
    return GCD(y,x%y);
}
int LCM(int x,int y) {
    return x/GCD(x,y)*y;
}
int main() {
    int a, b;
    while (cin >> a >> b) {
        printf("%d %d\n",GCD(a,b),LCM(a,b));
    }
    return 0;
}

Measured memory_bytes: 3116
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>
using namespace std;
using ll = long long;
 
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
 
mint ncr(ll n, ll k) {
  mint a = 1, b = 1;
  for (int i = 0; i < k; i++) a *= n - i;
  for (int i = 1; i <= k; i++) b *= i;
  return a / b;
}
 
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  auto ans = mint(2).pow(n) - ncr(n, a) - ncr(n, b) - 1;
  cout << ans.x << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define MOD 1000000007
string S;
ll dp[101001][13];//dp[i桁まで見たとき][そこまでの数の１３で割ったあまり]

int main(){
    cin >> S;
    dp[0][0] = 1;
    for(int i=0;i<S.length();i++){
        for(int k=0;k<13;k++){
            int t;
            if(S[i]!='?'){
                t = S[i]-'0';
                dp[i+1][(k*10+t)%13] += dp[i][k]%=MOD;
            }else{
                for(int j=0;j<10;j++){
                    dp[i+1][(k*10+j)%13] += dp[i][k]%=MOD;
                }
            }
        }
    }
    cout << dp[S.length()][5]%MOD << endl;
    return 0;
}

Measured memory_bytes: 10688
/** Author: Dwai
 *  Omae wa mou shindeiru!
**/

#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for (i = a; i <= b; i++)
#define frr(i,a,b) for (i = a; i >= b; i--)
#define rep(i,n) for (i = 0 ; i < n; i++)
#define repr(i,n) for (i = n - 1; i >= 0; i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define flushinput   cin.ignore(numeric_limits<streamsize>::max(),'\n');

void debug_out() { cerr << endl; }

void clock_out(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}

void fileio(){
  freopen("/home/dwai/Desktop/cp/input.txt","r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}

void ofileio(){
  freopen("input.txt","r", stdin);
  freopen("output.txt", "w", stdout); 
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define fio() fileio()
#define ofio() fileio()
#define clock() clock_out()
#else
#define debug(...) 42
#define fio() 42
#define ofio() ofileio()
#define clock() 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef map<ll,ll> mll;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;



void solve()
{
	ll n;cin>>n;
	ll a,b;cin>>a>>b;

	ll ans;
	if((b-a)%2==0)ans=(b-a)/2;
	else
	{
		if(a-1<=n-b)
		{
			ans=a+((b-a)-1)/2;
		}
		else
		{
			ans=n-b+1+(n-(a+(n-b+1)))/2;
		}
	}
	cout<<ans;
}

int main()
{
//	fio();
	fast
	ll t=1;
	//cin>>t;

	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int64)n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}


int main(){
	//in_o();
	int64 n,x;
	cin>>n;
	MPII hsh;int64 ans=0;
	FOR(i,0,n){
		cin>>x;
		hsh[x]++;
	}
	FOREACH(it,hsh){
		if(it->second>=4){
			ans=max(ans,(int64)it->first*it->first);
		}
	}
	VI v;
	FOREACH(it,hsh){
		if(it->second>=2)
			v.PB(it->first);
	}
	sort(v.begin(),v.end(),greater<int>());
	if(v.size()>=2)
		ans=max(ans,(int64)v[0]*v[1]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4992
'use strict';
(function(stdin) {
    var inputs = stdin.toString();
    var S = parseInt(inputs.split('\n')[0], 10);
    var h = Math.floor(S / 3600);
    var m = Math.floor(S % 3600 / 60);
    var s = S % 60;
    console.log([h,m,s].join(':'));
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define BOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

ll solve(ll l, ll s){
    if(l%s==0)return 3*l;
    return 3*s*(l/s)+solve(s,l%s);
}

int main(){
    
    ll N,X;
    cin>>N>>X;
    cout<<solve(max(N-X,X),min(N-X,X))<<endl;
    return 0;
}

Measured memory_bytes: 256
A,B,K = map(int,input().split())
ans = []
for i in range(K):
  ans.append(A + i)
  if A + i >= B:
    break
for i in range(K):
  ans.append(B - i)
  if B - i <= A:
    break
ans = sorted(set(ans))
for a in ans:
  print(a)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
using namespace std;
int T,N,K,M,X[100000+10], A[100000+10];
int main()
{
  cin >> T;
  for(int t=0;t<T;++t){
    cin >> N;
    cin >> K;
    for(int i=0;i<N;++i)
      cin >> X[i];
    for(int i=0;i+1<N;++i)
      A[i]=X[i+1]-X[i];
    sort(A,A+N-1);
    reverse(A,A+N-1);
    M=X[N-1]-X[0];
    for(int i=0;i<K-1;i++)
      M-=A[i];
    if(N<K)
      M=0;
    cout << M << endl;
  }
}

Measured memory_bytes: 3932
package main

import "fmt"

func main() {
	var a, b, c, d, e, k int
	fmt.Scan(&a, &b, &c, &d, &e, &k)
	if e-d > k || e-c > k || e-b > k || e-a > k {
		fmt.Println(":(")
		return
	}
	fmt.Println("Yay!")
}


Measured memory_bytes: 512
// GRL_1_A
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int inf=pow(10,9);
int max_n=pow(10,5);
struct edge{int to,cost;};
vector<int> setu(max_n,0); 
vector<vector<edge>> G(max_n);
vector<int> min_dis(max_n,inf);
vector<bool> seen(max_n,false);
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n,m,s;
    cin>>n>>m>>s;
    rep(i,m){
        int ss,tt,d;
        cin>>ss>>tt>>d;
        edge e;
        e.to=tt,e.cost=d;
        G[ss].emplace_back(e);
        setu[ss]++;
    }
    priority_queue<ipair,vector<ipair>,greater<ipair>> que; //1:現在地の暫定最短距離 2:現在地
    min_dis[s]=0; //スタート地点の最短距離は確定
    que.push(ipair(min_dis[s],s)); 

    while(!que.empty()){
        ipair q=que.top(); que.pop(); //暫定の最短距離集合の中で最短距離のnodeのmin_disが決定
        int now=q.second;
        if(seen[now]) continue;
        else seen[now]=true;
        for(int i=0;i<setu[now];i++){ //いま起点としてる頂点から行ける頂点を見る
            edge e=G[now][i];
            if(min_dis[e.to]>min_dis[now]+e.cost){
                min_dis[e.to]=min_dis[now]+e.cost;
                que.push(ipair(min_dis[e.to],e.to));
            }
        }
    }
    rep(i,n){
        if(min_dis[i]!=inf) cout<<min_dis[i]<<endl;
        else cout<<"INF"<<endl;
    }
    return 0;
}


Measured memory_bytes: 13592
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int INF=1e15;
 
signed main(){
    vector<set<int>>vec(26);
  	REP(i,26)vec[i].insert(INF);
    int N,Q;string S;cin>>N>>S>>Q;
    REP(i,N){
        vec[S[i]-'a'].insert(i);
    }
    REP(i,Q){
        int a;cin>>a;
        if(a==1){
            int b;char c;cin>>b>>c;--b;
            char d=S[b];
            S[b]=c;
            vec[d-'a'].erase(b);
            vec[c-'a'].insert(b);
        }
        if(a==2){
            int e,f;cin>>e>>f;e--;
            int ans=0;
            for(int z=0;z<26;z++){
                if(vec[z].empty()) continue;
                int eid=*vec[z].lower_bound(e);
                int fid=*vec[z].lower_bound(f);
                if(fid>eid)ans++;
            }
            cout<<ans<<endl;
        }
    }
}

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

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ll;
typedef pair<uint, uint> Pos;

static const ll mod = 1'000'000'007;

// const char m[4] = { 'T', 'A', 'G', 'C' };

uint dpA[4][4][4];
uint dpB[4][4][4];

int main(int, char**)
{
	uint n;
	cin >> n;

	uint (*dpp)[4][4];
	uint (*dp)[4][4];

	dpA[0][0][0] = 1;

	for (uint i = 0; i < n; ++i) {
		dpp = (i%2==0) ? dpA : dpB;
		dp =  (i%2!=0) ? dpA : dpB;
		for (uint c1 = 0; c1 < 4; ++c1) {
			for (uint c2 = 0; c2 < 4; ++c2) {
				for (uint c3 = 0; c3 < 4; ++c3) {
					if (dpp[c1][c2][c3] == 0) continue;
					for (uint a = 0; a < 4; ++a) {
						// NG: AGC 123
						// ACG     132
						// GAC     213
						// A?GC    1?23
						// AG?C    12?3
						if ((a==3)&&(c1==2)&&(c2==1)) continue;
						if ((a==2)&&(c1==3)&&(c2==1)) continue;
						if ((a==3)&&(c1==1)&&(c2==2)) continue;
						if ((a==3)&&(c1==2)&&(c3==1)) continue;
						if ((a==3)&&(c2==2)&&(c3==1)) continue;
						dp[a][c1][c2] += dpp[c1][c2][c3];
						dp[a][c1][c2] %= mod;
					}
				}
			}
		}
		for (uint i = 0; i < 4; ++i) {
			for (uint j = 0; j < 4; ++j) {
				for (uint k = 0; k < 4; ++k) {
					dpp[i][j][k] = 0;
				}
			}
		}
	}

	ll ans = 0;
	for (uint i = 0; i < 4; ++i) {
		for (uint j = 0; j < 4; ++j) {
			for (uint k = 0; k < 4; ++k) {
				ans += dp[i][j][k];
				ans %= mod;
			}
		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
n=int(input())
a=[[s for s in input().split()]for _ in range(n)]
def f():
 for i in range(n-1):
  d=a[i][:];d[3],d[4]=d[4],d[3]
  for j in range(i+1,n):
   e=a[j][:];e[3],e[4]=e[4],e[3]
   for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
    f=[d[k]for k in p]
    if f[0]==e[0]and f[5]==e[5]:
     f=f[1:5]*2
     for k in range(4):
      if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print(f())


Measured memory_bytes: 5616
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
 
int main(){
  //入力
  int a,b,c,d,e;
  int N = 5;
  cin >> a >> b >> c >> d >> e;
  vector<int> Time = { a,b,c,d,e };
  //注文してから次に届くまでの時間
  vector<int> nextTime(N);
  
  for (int i = 0; i < N; i++ )
  {
    if (Time[i] % 10 == 0) nextTime[i] = Time[i];
    else nextTime[i] = Time[i] - Time[i]%10 + 10;
    
    //nextTime[i] = (Time[i] + 9) / 10 * 10;
  }
  
  int BestTime = 99999999;
  //最後に注文するものを全通り計算
  for (int i = 0; i < N; i++)
  {
    int SumTime = 0;
    for (int j = 0; j < N; j++)
    {
      if(i == j){
        //最後の処理
        SumTime += Time[j];
      }else{
        //最後以外の処理
        SumTime += nextTime[j];
      }
    }
    BestTime = min(BestTime, SumTime);
  }

  cout << BestTime << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <sstream>
#include <algorithm>

const int N = 100000 + 10;

char string[N][20];
int rank[N], order[N], dp[N];
int MOD, s;

bool cmp(int a, int b) {
	return strcmp(string[a], string[b]) < 0;
}

int sum[N];

int lowbit(int x) {
	return x & -x;
}

int get_sum(int x) {
	int result = 0;
	while (x) {
		(result += sum[x]) %= MOD;
		x -= lowbit(x);
	}
	return result;
}

void insert(int x, int v) {
	while (x <= s) {
		(sum[x] += v) %= MOD;
		x += lowbit(x);
	}
}

int main() {
	int a, b;
	while (scanf("%d%d%d", &a, &b, &MOD) != EOF) {
		if (a + b + MOD == 0) {
			break;
		}
		memset(sum, 0, sizeof(sum));
		for (int i = a; i <= b; ++ i) {
			std::stringstream buffer;
			buffer << i;
			buffer >> string[i - a + 1];
		}
		s = b - a + 1;
		for (int i = 1; i <= s; ++ i) {
			order[i] = i;
		}
		std::sort(order + 1, order + s + 1, cmp);
		for (int i = 1; i <= s; ++ i) {
			rank[order[i]] = i;
		}
		
		memset(dp, 0, sizeof(dp));
		for (int i = 1; i <= s; ++ i) {
			dp[i] = (get_sum(rank[i] - 1) + 1) % MOD;
			insert(rank[i], dp[i]);
		}
		int answer = 0;
		for (int i = 1; i <= s; ++ i) {
			(answer += dp[i]) %= MOD;
		}
		printf("%d\n", answer);
	}
	return 0;
}

Measured memory_bytes: 4776
H, N  = map(int, input().split())
# hitpoint H
# waza N
As = [] # damage
Bs = [] # MP comsumptions
for i in range(N):
    a,b = map(int, input().split())
    As.append(a)
    Bs.append(b)

INF = 10**10
M = H + max(As) + 1
dp = [INF]*M
dp[0] = 0
for i,(a,b) in enumerate(zip(As,Bs)):
    # update
    for j in range(H):
        # 何回でも使っていい⇛dp[i+1][j]+b
        dp[j+a] = min(dp[j+a], dp[j]+b) 
print(min(dp[H:]))



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

using namespace std;

#define int long long

signed main () {
  string s, t;
  cin >> s >> t;
  for(int i=0;i<s.size();i++) {
    rotate(s.begin(), s.begin() + 1, s.end());
    if(s == t) {
      cout << "Yes" << endl;
      break;
    }
    if(i == s.size() - 1) {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 256
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    VS s(3);
    REP(i,3){
        cin >> s[i];
    }

    VVI vvi(3);
    REP(i,3){
        REP(j,s[i].length()){
            vvi[i].PB(s[i][j]-'a');
        }
    }

    int t=0;
    while(true){
        if(vvi[t].size()==0){
            break;
        }else{
            int ot=t;
            t = vvi[t][0];
            vvi[ot].erase(vvi[ot].begin());
        }
    }
    char ans = t+'A';

    cout << ans << ENDL;
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

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

    vector<double> A(N);

    rep(i, N) cin >> A[i];



    double h = 0;
    rep(i,N) h+= 1 / A[i];

    cout << fixed << setprecision(15) << 1 / h << endl;

}

Measured memory_bytes: 256
import math
def main():
    x1, y1, x2, y2 = map(float, input().split())
    b = abs(x2 - x1)
    h = abs(y2 - y1)
    d = math.sqrt(b ** 2 + h ** 2)
    print("{0:.8f}".format(d))


if __name__ == "__main__":
    main()

Measured memory_bytes: 7708
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}



void solve(long long a, long long b, long long c, long long d, long long e, long long k){
    a = min({a,b,c,d,e});
    b = max({a,b,c,d,e});
    if(b - a > k){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    long long d;
    scanf("%lld",&d);
    long long e;
    scanf("%lld",&e);
    long long k;
    scanf("%lld",&k);
    solve(a, b, c, d, e, k);
    return 0;
}


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

int main () {
    int a,b;
    cin >> a >> b;
    char s[100] = {47};
    for (int i=0; i < a+b+1; i++) cin >> s[i];
    
    int i = 0;
    for (; i < a; i++) {
        if (s[i] == '-') {
            cout << "No" << endl;
            return 0;
        }
    }
    if (!(s[i] == '-')) {
            cout << "No" << endl;
            return 0;
    }
    i++;
    for (; i < a+b+1; i++) {
        if (s[i] == '-') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

using namespace std;

int n,p[8],q[8],a,b,cnta,cntb;

int main()
{
    cin>>n;
    for (int i=0; i<=n-1; i++) cin>>p[i];
    for (int i=0; i<=n-1; i++) cin>>q[i];
    do { cnta++; } while  (prev_permutation(p,p+n));
    do { cntb++; } while  (prev_permutation(q,q+n));
    cout<<abs(cnta-cntb);
    return 0;
}


Measured memory_bytes: 256
s = input()
target = s[:(len(s)-1)//2]
target2 = s[(len(s)+3)//2-1:]
if target == target2:
    l, r = 0, len(s)-1
    flag = True
    while l <= r:
        if s[l] == s[r]:
            l += 1
            r -= 1
        else:
            print('No')
            exit(0)

    print("Yes")


else:
    print('No')


Measured memory_bytes: 9032
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int N;
	cin >> N;
	VL a(N);
	REP(i, N) cin >> a[i];

	if (N == 1) {
		cout << a[0] << endl;
		return 0;
	}

	deque<ll> b;
	if (N % 2 == 0) {
		b.push_back(a[0]);
		FOR(i, 1, N) {
			if (i % 2 == 1) b.push_front(a[i]);
			if (i % 2 == 0) b.push_back(a[i]);
		}
	}

	if (N % 2 == 1) {
		b.push_back(a[0]);
		FOR(i, 1, N) {
			if (i % 2 == 1) b.push_back(a[i]);
			if (i % 2 == 0) b.push_front(a[i]);
		}
	}

	REP(i, N) cout << b[i] << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 5504