akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n;
    string s;
    cin >> n;
    cin >> s;
    
    int sum = 0;
    REP(i, 10) {
        int i_index = s.find('0'+i, 0);
        if(i_index == -1) continue;
        REP(j, 10) {
            int j_index = s.find('0'+j, i_index+1);
            if(j_index == -1) continue;
            REP(k, 10) {
                int k_index = s.find('0'+k, j_index+1);
                if(k_index == -1) continue;
                sum++;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=500005;

int n,a[MAXN];
char s[MAXN];

int main()
{
	#ifndef ONLINE_JUDGE
    //freopen("code.in","r",stdin);
    //freopen("code.out","w",stdout);
	#endif
	ll ans=0;
	scanf("%s",s+1);
	n=strlen(s+1)+1;
	s[0]='>';s[n]='<';
	for(int i=1;i<=n;++i)
		if(s[i-1]=='>' && s[i]=='<')
		{
			a[i]=0;
			for(int j=i-1;s[j]=='>' && j;--j)chkmax(a[j],a[j+1]+1);
			for(int j=i+1;s[j-1]=='<' && j<=n;++j)chkmax(a[j],a[j-1]+1);
		}
	for(int i=1;i<=n;++i)ans+=a[i];
	printf("%lld\n",ans);
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

int main(){
	int k, a, b; cin >> k >> a >> b;
	for(int i=0; i<=1000; i++){
		int t = i*k;
		if(t>=a && t<=b){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
}

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

using namespace std;

int main(void)
{
    int32_t s;
    cin >> s;
    bool ret = false;
    int32_t digit = 1;
    int32_t dwn = s;

    for (size_t i = 0; i < s / 10; i++)
    {
        if(dwn % 10 == 7)
        {
            ret = true;
        }
        dwn /= 10;
    }
    

    if (ret)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {

	static HashMap<Integer, ArrayList<Integer>> map;
	static boolean[] reached;

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

		int A = sc.nextInt();
		int B = sc.nextInt();

		System.out.println((A >= 6 && A <= 12) ? B/2 : (A<=5 ? 0 : B));
	}

	public static void println(Object o) {
		System.out.println(o);
	}
}

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

using namespace std;

const int N = 100010;

long long x[N];
int v[N];
long long sa[N];
long long fa[N];
long long sb[N];
long long fb[N];

int main() {
  int n;
  long long m;
  scanf("%d %lld", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld %d", x + i, v + i);
  }
  sa[0] = 0;
  fa[0] = 0;
  for (int i = 1; i <= n; ++i) {
    sa[i] = sa[i - 1] + v[i];
    fa[i] = max(fa[i - 1], sa[i] - x[i]);
  }
  sb[n + 1] = 0;
  fb[n + 1] = 0;
  for (int i = n; i >= 1; --i) {
    sb[i] = sb[i + 1] + v[i];
    fb[i] = max(fb[i + 1], sb[i] - m + x[i]);
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, sa[i] - x[i]);
    ans = max(ans, sa[i] - 2 * x[i] + fb[i + 1]);
  }
  for (int i = n; i >= 1; --i) {
    ans = max(ans, sb[i] - m + x[i]);
    ans = max(ans, sb[i] - 2 * m + 2 * x[i] + fa[i - 1]);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 4480
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    chain_inputs = list(map(string_to_int, inputs))

    CHAIN_N = len(inputs)
    NODE_N = CHAIN_N + 1

    # {node: {target: chain_index}}
    node_relation = {i: {} for i in range(NODE_N)}
    # {index: color}
    chain_color = {i: None for i in range(CHAIN_N)}
    # {node : set(color)}
    node_has_color = {i: set() for i in range(NODE_N)}
    passed = set()

    for i, c in enumerate(chain_inputs):
        node = c[0] - 1
        target = c[1] - 1
        node_relation[node][target] = i
        node_relation[target][node] = i

    bfs_queue = collections.deque([0])

    max_branch = 0
    while len(bfs_queue) > 0:
        node = bfs_queue.pop()
        leafs = node_relation[node]
        if max_branch < len(leafs):
            max_branch = len(leafs)

        color = 1
        for leaf, index in leafs.items():
            if leaf in passed:
                continue
            # search color
            # while color in node_has_color[node] or color in node_has_color[leaf]:
            while color in node_has_color[node]:
                color += 1
            node_has_color[node].add(color)
            node_has_color[leaf].add(color)
            chain_color[index] = color

            bfs_queue.appendleft(leaf)
            passed.add(node)

    ret = [max_branch]
    for i in range(CHAIN_N):
        ret.append(chain_color[i])
    return ret


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N-1))
    for r in ret:
        print(r)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<ll,P>  PP;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;
typedef priority_queue<PP, vector<PP>, greater<PP>> PPQueue;

#define fi          first
#define se          second
#define sfi         se.fi
#define sse         se.se
#define pb          push_back
#define INF         INT_MAX
#define MOD         1000000007
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     (upper_bound(all(x),y)-x.begin())
#define lb(x,y)     (lower_bound(all(x),y)-x.begin())
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)

int main() {
  cin.sync_with_stdio(false);
  ll k;
  Vector a(50);
  cin >> k;

  ll times = k / 50;
  ll plus = k % 50;

  rep(i,50)a[i] = i + times;
  reverse(all(a));

  rep(i,plus) a[i]++;

  cout << 50 << endl;
  rep(i,49) cout << a[i] << " ";
  cout << a[49] << endl;
}


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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<string,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(void){

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll e = a * c, f = a * d, g = b * c, h = b * d;
    cout << max(max(e, f),  max(g, h)) << "\n";

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
 
int main(void){
  
  int X, A, B, C;
  std::cin >> A >> B >> C >> X;
  
  int cnt = 0;
  for(int i = 0; i <= A; i++)
    for(int j = 0; j <= B; j++)
      for(int k = 0; k <= C; k++)
        if(X == i * 500 + j * 100 + k * 50)
          cnt++;
  
  std::cout << cnt << std::endl;
  return 0;
}


Measured memory_bytes: 256
import math
N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        dis = 0
        for k in range(D):
            dis += (abs(X[i][k]-X[j][k]))**2
        ans += (math.sqrt(dis)).is_integer()
print(ans)


Measured memory_bytes: 9200
#ループする
import sys
n, y  = map(int, input().split( ))

m = y//10000
g = y//5000
for i in range(m+1):
    for j in range(g+1):
        s = (y-10000*i-5000*j)//1000
        if i+j+s == n and s>=0:
            print(i,j,s)
            sys.exit()
print(-1,-1,-1)



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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(2*M);
  for (int i=0; i <2*M; i++) {
    cin >> A[i];
  }
  vector<int> B(M);
  vector<int> C(M);
  for (int i=0; i <M; i++) {
    B[i] = A[2*i];
    C[i] = A[(2*i)+1];
  }
  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  sort(C.begin(),C.end());
  if(C[0] - B[0] < 0) {
    cout << 0 << endl;
  }
  else {
    cout << C[0] - B[0] + 1 << endl;
  }
}

Measured memory_bytes: 1792
require 'pp'

def gets; ARGF.gets; end

class Solver

  def initialize
  end

  def main
    s = gets.chomp

    puts case s
         when "MON" then 6
         when "TUE" then 5
         when "WED" then 4
         when "THU" then 3
         when "FRI" then 2
         when "SAT" then 1
         when "SUN" then 7
         else 0
         end
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2172
#include <stdio.h>
#include <iostream>
using namespace std;

const int maxn = 500000 + 10;

int f[maxn][27];
int step[maxn][27];

int main() {
    int n;
    string  s;
    cin >> s;
    n = s.size();
    for (int i = n + 1; i > -1; i--)
        for (int j = 0; j < 26; j++) f[i][j] = n + 1;

    for (int i = n - 1; i > -1; i--) {
        f[i][ s[i] - 'a' ] = i + 1;
        for (int c = s[i] - 'a'; c < 26; c++) {
            f[i][c + 1] = f[ f[i][c] ][c];
        }
        for (int c = 0; c < s[i] - 'a'; c++) 
            f[i][c] = f[ f[i][26] ][c];
    }
    for (int i = 0; i < n; i++) step[i][0] = f[i][26];
    step[n][0] = n + 1; step[n + 1][0] = n + 1;

    int bits;
    for (bits = 1; (1 << bits) < n; bits++) 
        for (int i = 0; i <= n + 1; i++)
            step[i][bits] = step[step[i][bits - 1]][bits - 1];
    int q, l, r;
    cin >> q;
    while (q--) {
        cin >> l >> r;
        int cur = l - 1;
        for (int i = bits - 1; i > -1; i--) {
            if (step[cur][i] <= r) cur = step[cur][i];
        }
        if (cur == r) {
            printf("Yes\n");
        }
        else printf("No\n");
    }
}

Measured memory_bytes: 106756
#include<stdio.h>
#include<string.h>

int main(void)
{
  char A[10],B[10],C[10];
  int a,b;
  scanf("%s%s%s",A,B,C);
  a = strlen(A);
  b = strlen(B);
  if((A[a-1] == B[0])&&(B[b-1] == C[0]))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
s = input()
length = len(s)
cnt = 0
if s[0] == '1':
  for i in range(1, length):
    if i % 2 == 0:
      if s[i] != '1':
        cnt += 1
    else:
      if s[i] != '0':
        cnt +=1
else:
  for i in range(1, length):
    if i % 2 == 0:
      if s[i] != '0':
        cnt += 1
    else:
      if s[i] != '1':
        cnt +=1
print(cnt)
    

Measured memory_bytes: 3188
#include<stdio.h>
int main(){
    int a[4][14],n,i,j;
    scanf("%d",&n);
    
    for(i=0;i<4;i++){
        for(j=1;j<14;j++){
            a[i][j]=0;
        }
    }
    int c;
    scanf("%d",&c);
    for(i=0;i<n;i++){
        char b;
        int c;
        scanf("%c %d\n",&b,&c);
        if(b=='S'){
            a[0][c]=1;
        }else if(b=='H'){
            a[1][c]=1;
        }else if(b=='C'){
            a[2][c]=1;
        }else if(b=='D'){
            a[3][c]=1;
        }
    }
    
    char p[] = {'S','H','C','D'};
    for(i=0;i<4;i++){
        for(j=1;j<14;j++){
            if(a[i][j]==0){
                printf("%c %d\n",p[i],j);
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

int main(){
    int n, x;
    
    while(true){
        int cnt = 0;
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        
        for(int i = 1; i <= n; i++){
            for(int j = i+1; j <= n; j++){
                for(int k = j+1; k <= n; k++){
                    if(i+j+k == x) cnt++;
                }
            }
        }
        
        cout << cnt << endl;
    }
    
    return 0;
}

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

int main(){
  int N,j=0;
  cin>>N;
  vector<int> a(N);
  for(int &i:a){
    cin>>i;
    j+=i;
  }
  double h=(double)j/N,k=10000;
  int l=-1;
  for(int i=0;i<N;i++){
    if(abs(a[i]-h)<k){
      k=abs(a[i]-h);
      l=i;
    }
  }
  cout<<l<<endl;
}

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


Measured memory_bytes: 1624
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     int a,b,c,d;
     cin>>a>>b>>c>>d;
     while(a && c){
        c-=b;
        if(c<=0) {cout<<"Yes"<<endl; return 0;}
        a-=d;
        if(a<=0) {cout<<"No"<<endl; return 0;}
     }

     return 0;

}
///Alhamdulillah


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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n, l;cin >> n >> l;
    string s[100];
    rep(i, n){
        cin >> s[i];
    }
    sort(s, s + n);
    rep(i, n){
        cout << s[i];
    }
	
	return 0;
}


Measured memory_bytes: 256
S = input()
n = len(S)

ans = 0

for bit in range(1 << (n - 1)):
    partial_sum = S[0]
    for i in range(n-1):
        if bit & (1 << i):
            partial_sum += "+"
        partial_sum += S[i+1]
    ans += sum(map(int, partial_sum.split("+")))

print(ans)


Measured memory_bytes: 9068
#include <stdio.h>
#include <stdlib.h>

#define LL long long int

typedef struct {
    int index;
    LL value;
} tValueLL;

int cmpLL(const void *n1, const void *n2) {

    if (((tValueLL *)n1)->value > ((tValueLL *)n2)->value) {
        return 1;
    } else if (((tValueLL *)n1)->value < ((tValueLL *)n2)->value) {
        return -1;
    }

    return 0;
}


int main(void) {

    int n;
    scanf("%d", &n);
    tValueLL *a = (tValueLL *)malloc(n * sizeof(tValueLL));
    tValueLL *b = (tValueLL *)malloc(n * sizeof(tValueLL));
    for (int i = 0; i < n; i ++) {
        a[i].index = i;
        b[i].index = i;
        scanf("%lld %lld", &a[i].value, &b[i].value);
    }

    qsort(a, n, sizeof(tValueLL), cmpLL);
    qsort(b, n, sizeof(tValueLL), cmpLL);

    int ret;
    if (n % 2 == 1) {
        ret = b[(n - 1) / 2].value - a[(n - 1) / 2].value + 1;
    } else {
        ret = (b[n / 2 - 1].value + b[n / 2].value) - (a[n / 2 - 1].value + a[n / 2].value) + 1;
    }

    printf("%d", ret);

    return 0;
}


Measured memory_bytes: 11080
"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	lines.some(function(line){
		var ary = line.split(" ").map(Number);
		var a = ary[0], b = ary[1], c = ary[2];
		if(!(a+1||b+1||c+1)) return true;
		console.log(a==-1||b==-1?"F":a+b>=80?"A":a+b>=65?"B":a+b>=50?"C":a+b>=30?c>=50?"C":"D":"F");
	});
}

Measured memory_bytes: 15528
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_C
#include<iostream>
using namespace std;
int main(void){
  int a,b;
  cin>>a>>b;
  cout<<a*b<<" "<<2*(a+b)<<endl;
  return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long int
#define tc int t; cin>>t; while(t--)
#define inn ll arr[n]; for(int i=0;i<n;i++) cin>>arr[i];
#define fora(i,n)for(ll i=0;i<n;i++)
#define forb(i,a,n) for(int i=a;i<n;i++)
#define MOD 1000000007
template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1);}
double ans=0;
ll n;
pair<ll,ll> arr[1000];
//ll n;
void printArr(ll a[],ll n)
{
    for (ll i=0; i<n-1; i++)
    {
        double ax=arr[a[i]].first,ay=arr[a[i]].second,bx=arr[a[i+1]].first,by=arr[a[i+1]].second;
        ans+=sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));


    }
}

void heapPermutation(ll *a, ll size, ll n)
{
    // if size becomes 1 then prints the obtained
    // permutation
    if (size == 1)
    {
        printArr(a, n);
        return;
    }

    for (int i=0; i<size; i++)
    {
        heapPermutation(a,size-1,n);

        // if size is odd, swap first and last
        // element
        if (size%2==1)
            swap(a[0], a[size-1]);

            // If size is even, swap ith and last
            // element
        else
            swap(a[i], a[size-1]);
    }
}
ll fact(ll n)
{
    if(n<2)
        return 1;
    else return n*fact(n-1);
}
int main()
{
 //THIS CODE IS CREATED BY ANSHJAIN18


cin>>n;

forb(i,1,n+1)
cin>>arr[i].first>>arr[i].second;

ll a[n];
fora(i,n)
a[i]=i+1;

heapPermutation(a, n, n);
cout<<setprecision(10)<<ans/fact(n);

return 0;


}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    vector<int> v;
    cin>>n>>k;
    int m;
    for(int i=0;i<n;i++){
        cin>>m;
        v.push_back(m);
    }
    sort(v.begin(),v.end());
    int sum=0;
    for(int i=0;i<k;i++){
        sum += v[i];
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
constexpr lint MOD = 1000000007;

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

    lint ans = 1;
    int status = 3;
    for (int i=0; i<N; i++)
    {
        if (s[i] == t[i])
        {
            ans *= status;
            status = 2; 
        }
        else
        {
            if (status == 3)
            {
                ans *= 6;
            }
            else if (status == 2)
            {
                ans *= 2;
            }
            else if (status == 1)
            {
                ans *= 3;
            }
            status = 1;
            i++;
        }
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18+5;

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

// chess moves...
// int dx[] = {+0, +0, -1, +1}; ///Up-down, Left-Right
// int dy[] = {+1, -1, +0, +0};
// int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
// int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1};
// int dx[] = {-2, -2, -1, -1,  1,  1,  2,  2}; ///Knight's Move
// int dy[] = {-1,  1, -2,  2, -2,  2, -1,  1};

// structs...
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

// functions...
ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


int n, ara[100001];
vector<bool> vis(100001);
vector<vi> edge(100001);
void bfs()
{
	queue<int> q;
	q.push(1);
	int u;
	
	while(!q.empty()){
		u = q.front();
		q.pop();
		vis[u] = 1;
		
		for(int K=0; K<sz(edge[u]); K++){
			if(!vis[edge[u][K]] && ara[edge[u][K]]==-1){
				ara[edge[u][K]] = u;
				q.push(edge[u][K]);
			}
		}
	}
}
void task()
{
    //code here...
    
    int m, a, b;
    memset(ara, -1, sizeof ara);
    
    cin >> n >> m;
    while(m--){
		cin >> a >> b;
		edge[a].PB(b);
		edge[b].PB(a);
	}
	
	for(int K=1; K<=n; K++) sort(edge[K].begin(), edge[K].end());
	
	bfs();
	
	for(int K=2; K<=n; K++){
		if(ara[K]==-1){
			cout << "No\n";
			return;
		}
	}
	
	cout << "Yes\n";
	for(int K=2; K<=n; K++) cout << ara[K] << "\n";
}


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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    return 0;
}


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

int main(){
  int a,b,c;
  int coin=0,day=0;
  cin>>a>>b>>c;

  do{
    day++;
    coin += a;
    if(day%7 == 0){
      coin += b;
    }
  }while(coin < c);
  cout<<day<<endl;

  return 0;
}


Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int main(){
	int a, b;
	cin>>a>>b;
	if(a<=5)
		cout<<0<<endl;
	else if(a>=6&&a<=12)
		cout<<b/2<<endl;	 
	else
		cout<<b<<endl; 
	return 0;
} 
 


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

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

long long a[100][100], b[100][100], c[100][100];

int main() {

    int n, m, l;

    std::cin >> n >> m >> l;

    REP(i, n) REP(j, m) std::cin >> a[i][j];
    REP(j, m) REP(k, l) std::cin >> b[j][k];

    REP(i, n) REP(j, m) REP(k, l) c[i][k] += a[i][j] * b[j][k];

    REP(i, n) {

        REP(k, l) {

            if ( k ) std::cout << " ";
            std::cout << c[i][k];
        }

        std::cout << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3236
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
	char s[500];
	scanf("%s",s);
	int flag=0;
	for (int i=0;i<strlen(s);i++)
		if (flag==1&&s[i]=='F') return cout<<"Yes",0;
			else if (flag==0&&s[i]=='C') flag=1;
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli c,n,a,b,cnt;
    cin>>n>>a>>b;
     c=a+b;
    cnt=n/c;
    cnt=cnt*a;
     
    cnt+=min(n%c,a);
    
     cout<<cnt<<"\n";
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef vector<int,vector<int>> vec;
typedef pair<int,int> P;
typedef long double ld;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n,j) for (int i = n; j<i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;

int main(){
  int N,K,a;cin>>N>>K;
  map<int,int> mp;
  REP(i,0,N){
    cin>>a;
    mp[a]++;
  }
  int ans=0,idx=0;
  vector<int>vec(mp.size());
  for(auto m:mp){
    vec[idx]=m.second;
    idx++;
  }
  sort(all(vec));
  REP(i,0,max((int)vec.size()-K,0)){ans+=vec[i];}
  print(ans)

}


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

static const int MAX = 1005;

int N,M;
long long cake[MAX][3];

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

  for(int i=0;i<N;i++){
    cin >> cake[i][0] >> cake[i][1] >> cake[i][2];
  }

  for(int i=0;i<8;i++){
    bitset<3> bs(i);
    vector<long long> S;
    for(int j=0;j<N;j++){
      long long sum=0;
      for(int k=0;k<3;k++){
        if(bs[k] == true) sum += cake[j][k];
        else sum -= cake[j][k];
      }
      S.push_back(sum);
    }
    sort(S.begin(),S.end());
    reverse(S.begin(),S.end());
    long long maxv = 0;
    for(int j=0;j<M;j++) maxv += S[j];
    ans = max(ans , maxv);
  }

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


Measured memory_bytes: 256
const main = (input) => {
  const [, n] = input.trim().split('\n')
  const nums = n.split(' ').map(v => Number(v)).sort((a, b) => a - b)

  const max = nums[nums.length - 1]
  const arr = new Array(max+1).fill(0)

  for (let v of nums) {
    for (let i=v; i<=max; i+=v) arr[i]++
  }

  let ans = 0
  for (let v of nums) {
    if (arr[v] === 1) ans++
  }
  console.log(ans)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 67280
var
	N,L,R,M,i,cnt:Longint;
	A:Array[1..200000]of Longint;
	ans:int64;
begin
	read(N);
	for i:=1 to N do begin
		read(A[i]);
		dec(A[i],i);
	end;
	L:=-1000000;
	R:=1000000000;
	while R-L>1 do begin
		M:=(L+R)div 2;
		cnt:=0;
		for i:=1 to N do if A[i]<=M then inc(cnt);
		if cnt*2>=N then R:=M else L:=M;
	end;
	for i:=1 to N do inc(ans,abs(A[i]-R));
	writeln(ans);
end.


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec(3*N);
  for (int i = 0; i < 3*N; i++)
  {
    cin>>vec[i];
  }
  priority_queue<int, vector<int>, greater<int> >que;
  int SUM = 0;
  vector<int> data1(N+1),data2(N+1);

  for (int i = 0; i < N; i++)
  {
    que.push(vec[i]);
    SUM += vec[i];
  }
  data1[0] = SUM;
  

  for (int i = 0; i < N; i++)
  {
    SUM += vec[N+i];
    que.push(vec[N+i]);
    int A = que.top();
    que.pop();
    SUM -= A;
    data1[i+1] = SUM;
  }
  SUM = 0;

  priority_queue<int> que1;

  for (int i = 0; i < N; i++)
  {
    SUM += vec[3*N-1-i];
    que1.push(vec[3*N -1 - i]);
  }

  data2[0] = SUM;
  

  
  for (int i = 0; i < N; i++)
  {
    SUM += vec[2*N-i-1];
    que1.push(vec[2*N-i-1]);
    int A = que1.top();
    que1.pop();
    SUM -= A;
    data2[i+1] = SUM;
  }
  
  int ANS = -1*INF;
  for (int i = 0; i < N+1; i++)
  {
    chmax(ANS,data1[i] - data2[N-i]);
  }
  // DEBUG(data1);DEBUG(data2);
  cout<<ANS<<endl;
  
  
  

  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 6516
A,B=map(int,input().split())

if A>B:
    A,B=B,A

if B%A==0:
    print(-1)

else:
    for i in range(((B//A+1)*A),B+A*2,A):
        if i//A < i//B+(i-i//B*B)//A+(i-i//B*B)%A:
            print(i)
            break

    else:
        print(-1)


Measured memory_bytes: 5600
def main():
    num = int(input())
    data = list(input())
    ans = 0
    for i in range(1, num - 1):
        pre = data[:i]
        aft = data[i:]
        kari = len(set(pre) & set(aft))
        if ans < kari:
            ans = kari

    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    int n;
    ll x;
    cin >> n >> x;
    ll a[n];
    rep(i,n)cin>>a[i];

    ll mini[n][n];
    rep(i,n){
        mini[i][0] = a[i];
    }
    srep(i,1,n){
        rep(j,n){
            mini[j][i] = min(mini[j][i-1], a[(j+i)%n]);
        }
    }

    ll ans = 100000000000000;

    rep(i,n){
        ll tmp = x*i;
        rep(j,n){
            tmp += mini[j][i];
        }
        ans = min(ans,tmp);
    }

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


Measured memory_bytes: 31488
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
    int A, B, C, K, op = 0;
    scanf("%d %d %d %d", &A, &B, &C, &K);
    while (B <= A) B *= 2, ++op;
    while (C <= B) C *= 2, ++op;
    if (K >= op) printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 1728
N, K = map(int, input().split())
H = list(map(int, input().split()))
H = [0] + H
dp = [0] * (N + 1)
dp[1] = 0
dp[2] = abs(H[2] - H[1])

for i in range(3, N+1):
    dp[i] = dp[i - 1] + abs(H[i] - H[i - 1])
    for j in range(1, K + 1):
        if i - j <= 0:
            break
        dp[i] = min(dp[i], dp[i - j] + abs(H[i] - H[i - j]))
print(dp[N])

Measured memory_bytes: 85616
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef double D;
D dp[30][20000]={};
int main(){
	while(true){
		int n,m,k;
		cin>>n>>m>>k;
		if(n==0) break;
		rep(i,n+1) rep(j,i*m+1) dp[i][j]=0;
		dp[0][0]=1;
		rep(i,n){
			rep(j,i*m+1){
				rep1(k,m) dp[i+1][j+k]+=dp[i][j]/m;
			}
		}
		D ans=0;
		rep(i,n*m+1) ans+=dp[n][i]*max(1,i-k);
		printf("%.12f\n",ans);
	}
}

Measured memory_bytes: 3376
#include <stdio.h>
#include <vector>
#include <algorithm>

const int kN = 200000 + 5;
int n, k, a[kN];

int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++ i) {
        int x;
        scanf("%d", &x);
        a[x] ++;
    }
    std::vector<std::pair<int, int>> v;
    for (int i = 0; i < kN; ++ i)
        if (a[i])
            v.emplace_back(a[i], i);
    std::sort(v.begin(), v.end());
    std::reverse(v.begin(), v.end());
    int result = 0;
    for (int i = k; i < v.size(); ++ i)
        result += v[i].first;
    printf("%d\n", result);
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
int main(){
	int n;
	cin>>n;
	cout<<n/60/60<<":"<<n%(60*60)/60<<":"<<n%60%60<<endl;
	return 0;
}


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

#define mod 1000000007
#define int long long

int power(int a,int b)
{
    int ans=1;

    while(b>0)
    {
        if(b&1)
        {
            ans*=a;
            ans%=mod;
            //cerr<<a<<endl;
        }
        a*=a;
        a%=mod;
        b/=2;
    }

    return ans;
}

int fact(int a)
{
    if(a==0)
        return 1;
    int tr =a*fact(a-1);
    tr%=mod;
    return tr;
}
 
int32_t main()
{
    int n;
    cin>>n;

    vector<int> a,b,c,d;

    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        a.push_back(x+y);
        b.push_back(x-y);
        c.push_back(y-x);
        d.push_back(-x-y);
    }

    sort(a.begin(),a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    sort(d.begin(), d.end());

    int am=a[n-1];
    int bm=b[n-1];
    int cm=c[n-1];
    int dm=d[n-1];
    //cout<<am<<" "<<bm<<" "<<cm<<" "<<dm;
    cout<<max({am+dm,bm+cm});
}

Measured memory_bytes: 9740
import sys
readline = sys.stdin.readline

H,W,K = map(int,readline().split())
grid = [None] * (H+1)
grid[0] = [0] * (W+1)
for i in range(1,H+1):
  grid[i] = [0] + list(map(int,list(input())))
  
# 二次元累積和でチョコレートの数を管理
# 直前に選んだチョコのY座標をp,X座標をqとすると、
# チョコレートの数をO(1)で求められる
# 最初に空行を入れているので1-indexで。

for i in range(len(grid)-1):
  for j in range(len(grid[i])):
    grid[i+1][j] = grid[i][j] + grid[i+1][j]

for i in range(len(grid)):
  for j in range(len(grid[i])-1):
    grid[i][j+1] = grid[i][j] + grid[i][j+1]
  
def get_choco_cnt(i,j,p,q):
  return grid[i][j] - grid[i][q] - grid[p][j] + grid[p][q]
  
# Hが10と少ないので、切る場所9箇所をすべて試しても2^9 = 512通り
# すべてに対して、Wのどこを切るかを求める。
# 二分探索なら　O(2^(H-1) * (log W * H)) = 約51200
# 線形探索でも　O(2^(H-1) * WH) = 5,120,000

def isOk(x,lastq,cond,K,H,W):
  # xで切ったとき、iで分割されたすべての領域の数がK以下になればOK
  lastp = 0 # Hを最後に切った場所
  for j in range(H-1):
    if (cond >> j) & 1: # j+1で切る
      if get_choco_cnt(j+1,x,lastp,lastq) > K:
        return False
      lastp = j+1
  # 最後に切った場所から、最後まで
  if get_choco_cnt(H,x,lastp,lastq) > K:
    return False
  return True
  
def decide_cut(cond,lastq,K,H,W):
  ok = lastq
  ng = W+1
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if isOk(mid,lastq,cond,K,H,W):
      ok = mid
    else:
      ng = mid
  return ok

ans = 10000
for cond in range(2 ** (H-1)):
  cut_num = (bin(cond)[2:]).count("1") # カットした回数
  lastq = 0 # 最後にカットした場所
  while lastq < W+1:
    new_lastq = decide_cut(cond,lastq,K,H,W)
    if new_lastq == W:
      break
    if new_lastq == lastq:
      cut_num = 10000
      break
    cut_num += 1
    lastq = new_lastq
  if ans > cut_num:
    ans = cut_num
print(ans)

Measured memory_bytes: 47196
import collections

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

P = collections.Counter(prime_factorize(n))

def counter(n):
    i = 1
    counter = 0
    while True:
        n-=i
        if n<0:
            break
        else:
            counter += 1
            i += 1
    return counter
  
ans = 0
for p in P.values():
  ans += counter(p)

print(ans)

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

char next(char s, long long k){
    char ans;
    if(s + k <= 'z'){
        ans = s + k;
    }
    else{
        long long distance = 'z' - s;
        k -= distance;
        k -= 1;
        ans = 'a' + k;
    }
    return ans;
}

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

    for(long long i = 0; i < s.size(); i++){
        if(i == s.size()-1){
            k = k % 26;
            s[i] = next(s[i], k);
        }
        else{
            if(s[i] == 'a'){
                continue;
            }
            long long distance = 'z' - s[i] + 1;
            if(distance > k){
                continue;
            }
            else{
                k -= distance;
                s[i] = 'a';
            }
        }
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3764
from math import gcd
from itertools import combinations
N=int(input())
dif3=list(combinations(range(1,N+1), 3))
dif2=list(combinations(range(1,N+1),2))
res = 0
for i in dif3:
    a = gcd(i[0], i[1])
    res += 6 * gcd(a, i[2])
for i in dif2:
    res += 6 * gcd(i[0], i[1])
res += int(N*(N+1)/2)
print(res)

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

#define pb push_back
#define all(a) (a).begin(), (a).end()

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

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int a, b; cin >> a >> b;
    for (int i = 1; i < 1500; ++i) {
        if (((i*8)/100) == a && (i/10) == b) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << "-1\n";
}

Measured memory_bytes: 256
import itertools
n,m,q=map(int, input().split())
arr=[[0]*4 for i in range(q)]

for i in range(q):
    arr[i][0],arr[i][1],arr[i][2],arr[i][3]=map(int, input().split())

ans=0
for i in itertools.combinations_with_replacement(range(1,m+1),n):
    score=0
    for j in range(q):
        tmp1=i[arr[j][1]-1]
        tmp0=i[arr[j][0]-1]
        if tmp1-tmp0==arr[j][2]:
            score+=arr[j][3]
    if ans<score:
        ans=score
print(ans)

Measured memory_bytes: 9232
/*
    superfuckjp fuckfuckfuck
 */

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctype.h>
#include <stack>
using namespace std;

char buf[100000];

int main() {
  while (1) {
    if (fgets(buf, sizeof(buf), stdin) == NULL) return 0;

    char *p;
    p = strchr(buf, '\n');
    if (p) *p = '\0';

    stack<double> st;
    int n = strlen(buf);
    p = buf;
    while (p < buf+n) {
      if (*p == ' ') {
        ++p;
        continue;
      }

      char *next;
      long t = strtol(p, &next, 10);
      if (p != next) {
        st.push(t);
        p = next;
      } else {
        double b = st.top(); st.pop();
        double a = st.top(); st.pop();

        if (*p == '+') st.push(a+b);
        else if (*p == '-') st.push(a-b);
        else if (*p == '*') st.push(a*b);
        else if (*p == '/') st.push(a/b);
        else {
          st.push(a);
          st.push(b);
        }
        ++p;
      }
    }

    printf("%f\n", st.top());
  }
}

Measured memory_bytes: 2560
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
using System.Runtime.InteropServices.ComTypes;

class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {
        var HW = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var H = HW[0];
        var W = HW[1];

        var map = new String[H];
        for (int i = 0; i < H; i++)
        {
            map[i] = Console.ReadLine();
        }

        var dic = new Dictionary<char, long>();
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (dic.ContainsKey(map[i][j]))
                {
                    dic[map[i][j]]++;
                }
                else
                {
                    dic.Add(map[i][j], 1);
                }
            }
        }

        long one = (H * W) % 2 == 0 ? 0 : 1;

        long two = (H % 2 == 0 ? 0 : W) + (W % 2 == 0 ? 0 : H) - 2 * one;
        long four = (H * W - one - two) / 4;
        two /= 2;

        var Sorted = dic.OrderBy((x) => x.Value);
        var ans = true;

        var a = 0L;
        var b = 0L;
        var c = 0L;

        foreach (var item in Sorted)
        {
            var res = item.Value;
            a += res / 4;
            b += (res % 4) / 2;
            c += ((res % 4) % 2);
        }

        if (four <= a)
        {
            a -= four;
            b += a * 2;
        }
        else
        {
            ans = false;
        }

        if (two <= b)
        {
            b -= two;
            c += b / 2;
        }
        else
        {
            ans = false;
        }
        Console.WriteLine(ans ? "Yes" : "No");
    }



}


Measured memory_bytes: 28500
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   int ans = 0;
   rep(i, 0, 3) {
      if (s[i] == '1') ans++;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> Map(H, vector<char>(W));
	vector<vector<int>> Rows(H), Columns(W);
	vector<vector<int>> RowNums(H), ColNums(W);
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> Map[i][j];
	for (int i = 0; i < H; i++) {
		int left = -1, num = 0;
		for (int j = 0; j < W; j++) {
			if (Map[i][j] == '.') {
				if (left < 0) {
					left = j;
					Rows[i].push_back(left);
				}
				num++;
			}
			else {
				if (left >= 0) {
					RowNums[i].push_back(num);
					left = -1;
					num = 0;
				}
			}
		}
		if (left >= 0) RowNums[i].push_back(num);
	}
	for (int j = 0; j < W; j++) {
		int up = -1, num = 0;
		for (int i = 0; i < H; i++) {
			if (Map[i][j] == '.') {
				if (up < 0) {
					up = i;
					Columns[j].push_back(up);
				}
				num++;
			}
			else {
				if (up >= 0) {
					ColNums[j].push_back(num);
					up = -1;
					num = 0;
				}
			}
		}
		if (up >= 0) ColNums[j].push_back(num);
	}
	int MAX = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (Map[i][j] == '.') {
				int y = distance(Columns[j].begin(), upper_bound(Columns[j].begin(), Columns[j].end(), i)) - 1;
				int x = distance(Rows[i].begin(), upper_bound(Rows[i].begin(), Rows[i].end(), j)) - 1;
				MAX = max(MAX, ColNums[j][y] + RowNums[i][x]);
			}
		}
	}
	cout << MAX - 1 << endl;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

ldouble a, b, c;

int main()
{
  while (scanf("%Lf %Lf %Lf", &a, &b, &c) != EOF)
  {
    printf("%s\n", a + 2*sqrt(a)*sqrt(b) + b < c ? "Yes" : "No");
  }
  return 0;
}

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

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

typedef long long ll;
using namespace std;

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

  ll N;
  cin >> N;

  ll result = 0;

  map<ll, ll> answer;
  for (ll i = 1; i < N; ++i) {
    if ((N - i) != i && answer.find(min(i, N - i)) == answer.end()) {
      ++result;
      answer.insert(make_pair(min(i, N - i), max(i, N - i)));
    }
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 31488
N, M = map(int,input().split())
A = sorted(list(map(int,input().split())))
L = [list(map(int,input().split())) for k in range(M)]
L = sorted(L,key=lambda x: -x[1])
now = 0
for e in L:
    if now == N:
        break
    while True:
        if A[now] < e[1] and e[0] > 0:
            A[now] = e[1]
            now += 1
            e[0] -= 1
            if now == N:
                break
        else:
            break

print(sum(A))


Measured memory_bytes: 83052
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    ans = ""
    while N != 0:
        if N % 2 != 0:
            N -= 1
            ans = "1" + ans
        else:
            ans = "0" + ans
        N //= -2
    if ans == "":
        ans = "0"
    
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	string n_str = to_string(n);
	
	int sn = 0;
	int i;


	for (i = 0; i < n_str.size(); i++) {
		sn += (n_str[i] - '0');
	}

	if (n%sn == 0) {
		cout << "Yes" << endl;
		return 0;
	}

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


Measured memory_bytes: 256