akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int a,b,c,d,x;
    cin>>x;
    //cout<<x;
    vector<int>dig;
    while(x>0){
        int rem=x%10;
        x=x/10;
        dig.push_back(rem);
    }
    while(dig.size()!=4){
        dig.push_back(0);
    }
    //for(int i=0;i<dig.size();i++)cout<<dig[i]<<" ";
    reverse(dig.begin(),dig.end());
    a=dig[0];b=dig[1];c=dig[2];d=dig[3];
    ll ans=a;
    int f=0;
    //cout<<a<<" "<<b<<" "<<c<<" "<<d;
    vector<char>v;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                if(i%2==0){
                    ans+=b;
                }else ans-=b;
                if(j%2==0)ans+=c;
                else ans-=c;
                if(k%2==0)ans+=d;
                else ans-=d;
                if(ans==7 && f==0){
                    f=1;
                    if(i%2==0)v.push_back('+');
                    else v.push_back('-');
                    if(j%2==0)v.push_back('+');
                    else v.push_back('-');
                    if(k%2==0)v.push_back('+');
                    else v.push_back('-');
                    break;
                }else ans=a;
            }
        }
    }
    //for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
    cout<<a<<v[0]<<b<<v[1]<<c<<v[2]<<d<<"="<<7;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << "i" << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n ; cin >> n;
    vector<ll> ans(n,0);
    for(int i=2;i<=n;i++){
        ll a; cin >> a;
        a--;
        ans.at(a)++;
    }
    rep(i,n) cout << ans.at(i) << endl;
    return 0 ;
}


Measured memory_bytes: 4840
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;

#define N 100000
#define M 100

int main(){
	long long a, b,r,x, i,j,n, ans = 0;
	char  s[M], t[M], u[N];

	cin >> a >> b;

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


	cout << x / b << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
using namespace std;
int main(){
  int ans=0,x,y,h,w,n,i,j,g1[15],g2[15],a[1010][1010],k=0,b[1010][1010];
  char s;
  queue<int> q1;
  queue<int> q2;
  scanf("%d %d %d\n",&h,&w,&n);
  for(i=0;i<=h+1;i++){
    for(j=0;j<=w+1;j++){
      a[i][j]=-2;
    }
  }
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      scanf("%c",&s);
      if(s=='S'){
        a[i][j]=-1;
        q1.push(i),q2.push(j);
      }
      else if(s=='.'){
        a[i][j]=-1;
      }
      else if(s>='1' && s<='9'){
        a[i][j]=-1;
        g1[s-'0'-1]=i,g2[s-'0'-1]=j;
      }
    }
    scanf("\n");
  }
  for(i=0;i<n;i++){
    for(j=0;j<=h+1;j++){
      for(k=0;k<=w+1;k++){
        b[j][k]=a[j][k];
      }
    }
        b[q1.front()][q2.front()]=0;
  while(1){
    x=q1.front(),y=q2.front();
    if(x==g1[i] && y==g2[i]){
      break;
    }
    q1.pop(),q2.pop();
    if(b[x+1][y]==-1){
      q1.push(x+1),q2.push(y);
      b[x+1][y]=b[x][y]+1;
    }
    if(b[x-1][y]==-1){
      q1.push(x-1),q2.push(y);
      b[x-1][y]=b[x][y]+1;
    }
    if(b[x][y+1]==-1){
      q1.push(x),q2.push(y+1);
      b[x][y+1]=b[x][y]+1;
    }
     if(b[x][y-1]==-1){
      q1.push(x),q2.push(y-1);
      b[x][y-1]=b[x][y]+1;
    }
  }
    ans=ans+b[g1[i]][g2[i]];
    while(!q1.empty()){
      q1.pop(),q2.pop();
    }
    q1.push(g1[i]),q2.push(g2[i]);
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 10492
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <iterator>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define PA pair<ll,ll>
#define VE vector<ll>
#define VP vector<pair<ll,ll> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
int main(){
  int A,B;
  cin>>A>>B;
  if(A<=B){
    cout<<A<<endl;
  }else{
    cout<<A-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
    "fmt"
)

func main() {
    var a, b, value int
    fmt.Scan(&a, &b)
    
    var i, ans float64
    
    for {
        value = int(i * 0.08)
        
        if value == a {
            if value = int(i * 0.1); value == b {
                ans = i
                break
            }
        }else if value > a {
            ans = -1
            break
        }
        
        i++
    }
    fmt.Println(ans)
    
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct Node{
  int key;
  struct Node *right,*left,*parent;
}Node;

#define NIL NULL

Node *root;

Node * find(Node *u,int k){
  while(u!=NIL &&  k!=u->key){
    if(k < u->key)u=u->left;
    else u=u->right;
  }
  return u;
}


void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;

  z=malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;


while(x!=NIL){
  y=x;
  if(z->key < x->key){
    x=x->left;
  }else {
    x=x->right;
  }
 }

z->parent=y;
if(y==NIL){
  root=z;
 }else{
  if(z->key < y->key){
    y->left=z;
  }else{
    y->right=z;
  }
 }
}

void inorder(Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
} 

int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",com);

    if(strcmp(com,"find")==0){
	scanf("%d",&x);
	Node *t=find(root,x);
	if(t!=NIL)printf("yes\n");
	else printf("no\n");
      }else if(strcmp(com,"insert")==0){
	scanf("%d",&x);
	insert(x);
      }
      else if(strcmp(com,"print")==0){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 19364
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i in range(n):
    if a[i]==b[i]==c[i]:
        continue
    elif a[i]==b[i] or b[i]==c[i] or c[i]==a[i]:
        ans+=1
    else:
        ans+=2
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mk make_pair
#define PII pair<ll,int>
#define PB push_back
const int maxn=2e5+9;
const int mod=998244353;
ll n,a[maxn],ans;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	priority_queue<ll>pq;
	pq.push(a[n]);
	for(int i=n-1;i>=1;i--)
	{
		ans+=pq.top();pq.pop();
		pq.push(a[i]);
		pq.push(a[i]);
	}
	printf("%lld\n",ans);
}

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

int N;
int a[8];
pair<double,double> p[8];

int main()
{
    cin>>N;
    for(int i=0;i<N;i++)
        a[i]=i;
    double x,y;

    for(int i=0;i<N;i++)
    {
        cin>>x>>y;
        p[i]=make_pair(x,y);
    }
    int pnum=0;
    double d=0;
    do{
        pnum++;
        for(int i=0;i<N-1;i++)
            d+=sqrt((p[a[i+1]].second-p[a[i]].second)*(p[a[i+1]].second-p[a[i]].second)+(p[a[i+1]].first-p[a[i]].first)*(p[a[i+1]].first-p[a[i]].first));

    }while(next_permutation(a,a+N));

    printf("%.7f\n",d/pnum);
}


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

using namespace std;
#define INF (1e9)

int N, F[105][10], P[105][11];

int main(int argc, const char *argv[])
{
    cin >> N;
    for (int i = 0; i < N; i++)
        for (int j = 0; j < 10; j++)
            cin >> F[i][j];
    for (int i = 0; i < N; i++)
        for (int j = 0; j < 11; j++)
            cin >> P[i][j];

    int ans = -INF;
    for (int bit = 1; bit < (1 << 10); bit++)
    { // 全組み合わせ
        int count[105] = {};
        for (int i = 0; i < 10; i++)
        {
            if (bit & (1 << i))
            { // iに店を開くとき
                for (int j = 0; j < N; j++)
                {
                    if (F[j][i] == 1)
                        count[j]++;
                }
            }
        }

        int x = 0;
        for (int j = 0; j < N; j++)
        {
            x += P[j][count[j]];
        }

        ans = max(ans, x);
    }

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


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n,a,b = map(int, input().split())

if a>b:
    print(0)
    exit()

if a==b:
    print(1)
    exit()

if n==1 and a!=b:
    print(0)
    exit()

mi = a*(n-1)+b
ma = a+b*(n-1)

print(ma-mi+1)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <math.h>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main(void){
    int n, a, b, p[105];
    int x = 0, y = 0, z = 0;
    cin >> n;
    cin >> a >> b;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        if (p[i] <= a) x++;
        else if (p[i] <= b) y++;
        else z++;
    }
    
    cout << min(x, min(y, z)) << endl;
    
    
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char array1[200];
    int i, j, l;
    int count = 0;
    int hug = 0;
    scanf("%s", array1);

    for (i = 0; i < 200; i++)
    {
        if (array1[i] == '\0')
            break;
        count++;
    }

    j = count - 1;
    l = (count - 1) / 2;
    for (i = 0; i <= l; i++)
    {
        if (array1[i] == array1[j - i])
        {
        }
        else
        {
            hug++;
        }
    }

    printf("%d\n", hug);

    return 0;
}

Measured memory_bytes: 128
from itertools import *

N, M = map(int, input().split())
G = [set() for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    G[a-1].add(b-1)
    G[b-1].add(a-1)

ans = 0

for p in permutations(range(N)):
    if p[0]!=0:
        continue
    
    flag = True
    
    for i in range(N-1):
        if p[i+1] not in G[p[i]]:
            flag = False
    
    if flag:
        ans += 1

print(ans)

Measured memory_bytes: 68132
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using namespace std;
using pii = pair<int,int>;

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

   char s[10];
   cin >> s;

   int sum = 700;
   for (int i=0; i<3; ++i) {
      if (s[i] == 'o') sum += 100;
   }

   outl(sum);
}



Measured memory_bytes: 768
#!/usr/bin/env ruby

def main
    a = gets.to_i
    b = gets.to_i
    c = gets.to_i
    x = gets.to_i

    ans = 0
    (0..a).reverse_each do |a_|
        (0..b).reverse_each do |b_|
            if ((x - 500*a_ - 100*b_) / 50 <= c) && (x - 500*a_ - 100*b_ >= 0)
                ans += 1
            end
        end
    end
    puts ans
end

main

Measured memory_bytes: 1788
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
 
/**
 * Created on 2017/10/20 7:35.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
 
        while (sc.hasNextInt()) {
            int N = sc.nextInt();
            int K = sc.nextInt();
            int[] x = new int[N];
            int[] y = new int[N];
 
            Set<Integer> setX = new HashSet<>();
            Set<Integer> setY = new HashSet<>();
 
            for (int i = 0; i < N; i++) {
                x[i] = sc.nextInt();
                y[i] = sc.nextInt();
                setX.add(x[i]);
                setY.add(y[i]);
            }
 
            List<Integer> listX = new ArrayList<>(setX);
            listX.sort(Integer::compareTo);
            List<Integer> listY = new ArrayList<>(setY);
            listY.sort(Integer::compareTo);
            int sizeX = listX.size();
            int sizeY = listY.size();
 
            long ans = Long.MAX_VALUE;
 
            for (int yi = 0; yi < sizeY; yi++) {
                int yFrom = listY.get(yi);
                for (int yj = yi; yj < sizeY; yj++) {
                    int yTo = listY.get(yj);
                    int xi = 0;
                    int xj = 0;
 
                    while (xj < sizeX) {
                        int xFrom = listX.get(xi);
                        int xTo = listX.get(xj);
                        int cnt = 0;
                        for (int i = 0; i < N; i++) {
                            if (xFrom <= x[i] && x[i] <= xTo && yFrom <= y[i] && y[i] <= yTo) {
                                cnt++;
                            }
                        }
                        if (cnt >= K) {
                            ans = Math.min(ans, (long) (xTo - xFrom) * (yTo - yFrom));
                            xi++;
                            xj = Math.max(xj, xi);
                        } else {
                            xj++;
                        }
                    }
                }
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 28872
cards = [input() for _ in range(3)]
dict = {'a':0, 'b':1, 'c':2}
inv = ['A', 'B', 'C']
turn = 'a'
game = True
while game:
    if cards[dict[turn]] == '':
        print(inv[dict[turn]])
        game = False
    else:
        next_turn = cards[dict[turn]][0]
        cards[dict[turn]] = cards[dict[turn]][1:]
        turn = next_turn
    # print(turn, cards)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		int e = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		sc.close();

		if(e - a <= k) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}
	}
}

Measured memory_bytes: 21844
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String a = sc.next();
      String b = sc.next();
      String c = b.substring(0,b.length()-1);
      if(a.equals(c)){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 35692
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans=(a*b>c*d)?a*b:c*d;
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
inp = list(map(int,input().split()))
c=Counter(inp)
arr=[1]*(max(inp)+1)
inp.sort()
d=Counter([])
for i in range(len(arr)):
    if c[i]>=1 and arr[i]==1:
        if d[i]==0:
            d[i]+=1
        else:
            continue
        k=2
        while k*i<len(arr):
            arr[k*i]=0
            k+=1
ans=0
for item in d.keys():
    if c[item]==1:
        ans+=1
print (ans)
            

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i=0; i<N; ++i) {
        cin >> A[i];
    }

    vector<int> b(N, 0);
    for (int i=0; i<N; ++i) {
        ++b[A[i]];
    }

    sort(b.begin(), b.end(), greater<int>());
    int c = 0;
    for (int i=0; i<K; ++i) {
        c += b[i];
    }

    cout << N - c << endl;

}

Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  ll x;
  cin >> x;
  int ans = 0;
  ll m = 100;
  while(m<x){
    m *= 1.01;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
program making_palindrome
  implicit none
  integer(8), parameter :: inf = 1e18
  integer :: n, i, l
  character(20) :: s(50, 0:1) = ''
  integer(8) :: c(50) = 0, m(50, 21, 0:1) = 0, x = inf
  logical :: u(50, 21, 0:1) = .false.
  read(*,*) n
  do i = 1, n
    read(*,*) s(i, 0), c(i)
    l = len_trim(s(i, 0))
    s(i, 1)(1:l) = reverse(s(i, 0)(1:l))
  end do
  do i = 1, n
    x = min(x, solve(i, 1, 0) + c(i))
  end do
  write(*,'(i0)') merge(x, -1_8, x < inf)
contains
  function reverse(s) result(res)
    character(*), intent(in) :: s
    character(len_trim(s)) :: res
    integer :: n, i
    n = len_trim(s)
    do i = 1, n
      res(i:i) = s(n - i + 1:n - i + 1)
    end do
  end
  recursive integer(8) function solve(i, j, k) result(res)
    integer, intent(in) :: i, j, k
    integer :: l, r, t, l1, l2, h
    logical :: f
    res = m(i, j, k)
    if (u(i, j, k)) return
    u(i, j, k) = .true.
    m(i, j, k) = inf
    l = j
    r = len_trim(s(i, k))
    f = .true.
    do while (l < r)
      if (s(i, k)(l:l) /= s(i, k)(r:r)) then
        f = .false.
        exit
      end if
      l = l + 1
      r = r - 1
    end do
    if (f) then
      m(i, j, k) = 0
      res = 0
      return
    end if
    l1 = len_trim(s(i, k))
    h = 1 - k
    do t = 1, n
      l = j
      r = 1
      l2 = len_trim(s(t, 1 - k))
      do while (l <= l1 .and. r <= l2)
        if (s(i, k)(l:l) /= s(t, h)(r:r)) exit
        l = l + 1
        r = r + 1
      end do
      if (l == l1 + 1) then
        m(i, j, k) = min(m(i, j, k), solve(t, r, h) + c(t))
      end if
      if (r == l2 + 1) then
        m(i, j, k) = min(m(i, j, k), solve(i, l, k) + c(t))
      end if
    end do
    res = m(i, j, k)
  end
end program making_palindrome

Measured memory_bytes: 2924
#include <bits/stdc++.h>
using namespace std;
int inf = 1000000000; //10e9
 
int main() {
    
    int N, ans = 0;
    cin >> N;

    int cost_ceil = ceil(N/1.08);
    int cost_floor = floor(N/1.08);
    int ceil_init = cost_ceil*1.08;
    int floor_init = cost_floor*1.08;

    if(ceil_init == N || floor_init == N){
        if(ceil_init == N){
            cout << cost_ceil << endl;
        } else {
            cout << cost_floor << endl;
        }
    } else {
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
import heapq

def main():
    xs, ys, xt, yt = map(int, input().split())
    n = int(input())
    
    def dijkstra(s):
        hq = [(0, s)]
        cost = [float('inf')] * (n + 2)
        cost[s] = 0
        while hq:
            c, v = heapq.heappop(hq)
            if c > cost[v]:
                continue
            for d, u in edges[v]:
                tmp = d + cost[v]
                if tmp < cost[u]:
                    cost[u] = tmp
                    heapq.heappush(hq, (tmp, u))
        return cost[-1]
    
    circles = []
    circles.append([xs, ys, 0])
    for _ in range(n):
        circles.append(list(map(int, input().split())))
    circles.append([xt, yt, 0])
    edges = [[] for _ in range(n + 2)]
    for i in range(n + 2):
        for j in range(i + 1, n + 2):
            dx = circles[i][0] - circles[j][0]
            dy = circles[i][1] - circles[j][1]
            d = (dx ** 2 + dy ** 2) ** 0.5
            r = circles[i][2] + circles[j][2]
            edges[i].append([max(0, d - r), j])
            edges[j].append([max(0, d - r), i])

    ans = dijkstra(0)
    print(ans)
    
main()

Measured memory_bytes: 218300
#include <stdio.h>
#include <algorithm>
#include <utility>
using namespace std;
typedef pair<int,int> pi;
#define F first
#define S second
const int N=1e2+10;
bool cmp(pi a,pi b){
    return a.F>b.F;
    
}
int main(){
    int n,a,b,c,d,tot,ans[N],now=1;
    pi val[N];
    scanf("%d",&n);
    for(int i=1;i<=n;i++)val[i]={0,i};
    tot=(n*(n-1))/2;
    while(tot--){
        scanf("%d%d%d%d",&a,&b,&c,&d);
        if(c==d){
            val[a].F++;
            val[b].F++;
        }
        else if(c>d)val[a].F+=3;
        else val[b].F+=3;
    }
    sort(val+1,val+1+n,cmp);
    ans[val[1].S]=now;
    for(int i=2;i<=n;i++){
        if(val[i].F!=val[i-1].F)now=i;
        ans[val[i].S]=now;
    }
    for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
}


Measured memory_bytes: 2704
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int power(int a, int b){ int S = 1; while(b--)S *= a; return S;}

int32_t main(){
	double r;
	cin >> r;
	cout << 2 * 3.14159265358979323846 * r;
	return 0;
}



Measured memory_bytes: 3784
#include <iostream>
#include <iomanip>
#include <cmath>
#define ll long long int
using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	cout << setprecision(15);
	while(n != 0){
			ll sum = 0;
			ll sum2 = 0;
			for(int i = 0; i < n; i++){
					int a;
					cin >> a;
					sum += a;
					sum2 += a * a;
			}
			cout << sqrt(((double)sum2)/n - ((double)sum * sum)/((double)n*n)) << endl;
			cin >> n;
	}
	return 0;
}



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

int main(){
 int n,m,c;
 int a[100][100],b[100];
 cin >> n >> m;
 a[n][m]={};
 b[m]={};

 for(int i=0;i<n;++i){
  for(int j=0;j<m;++j){
   cin >> a[i][j];
  }
 }

 for(int j=0;j<m;++j){
  cin >> b[j];
 }
 
 for(int i=0;i<n;++i){
  c=0;
  for(int j=0;j<m;++j){
   c+=a[i][j]*b[j];
  }
  cout << c << endl;
 }
return 0;
}

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

using namespace std;
vector <char> v;
vector<int> num;
string s ;
int table[2][101];
int main(){
  string a,b;
  int A;
  s = "No";
  cin >> a>>b;
  A = stoi(a+b);

  int x = (int)(sqrt(A));

  if (x*x == A){
    s ="Yes";
  }


  cout << s << endl;



  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;

bool solve() {
    if (s == "keyence") return true;
    int sz = s.size();
    for (int i = 0; i < sz; i++) {
        for (int j = i+1; j <= sz; j++) {
            if (s.substr(0, i) + s.substr(j) == "keyence")
                return true;
        }
    }
    return false;
}

void input() {
    cin >> s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << (solve()?"YES":"NO") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long 
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
signed main() {
	int cnt = 0;
	string s;
	cin >> s;
	for (int i = s.size() - 3; i >= 0; i -= 2) {
		cnt = 0;
		for (int j = 0; j <= (i + 1) / 2 - 1; j++) {
			if (s[j] == s[j + (i + 1) / 2])cnt++;
			if (cnt == (i + 1) / 2) {
				cout << i + 1 << endl;
				getchar(); getchar(); return 0;
			}
		}
	}
	cout<<1<<endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		var input = Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray();
		double T = input[0];
		double A = input[1];
		var inputh = Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray();
        
		List<Tuple<double,int>> temp = new List<Tuple<double,int>>();
        for(var i = 0; i < N; i++)
		{
			temp.Add(new Tuple<double,int>(Math.Abs(T - ((inputh[i]) * 0.006 )- A), i + 1));
		}
		temp.Sort();
		Console.WriteLine(temp[0].Item2);
		
	}
}

Measured memory_bytes: 13396
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
 
int main() {
    int n, x[100], y[100];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < n; i++) cin >> y[i];
    double p1 = 0, p2 = 0, p3 = 0, pInf[n];
    for (int i = 0; i < n; i++){
        p1 += fabs(x[i] - y[i]);
        p2 += pow(x[i] - y[i],2);
        p3 += pow(fabs(x[i] - y[i]),3);
        pInf[i] = fabs(x[i] - y[i]);
    }
    p2 = sqrt(p2);
    p3 = pow(p3,1.0/3);
    double pI = 0;
    for (int i = 0; i < n; i++){
        if (pI < pInf[i]) pI = pInf[i];
    }
    printf("%lf\n%lf\n%lf\n%lf\n",p1,p2,p3,pI);
    return 0;
}


Measured memory_bytes: 3328
import collections
mod=10**9+7
base=37
n=int(input())
S=list(ord(s)-96 for s in input())
B=[0]*(n+1)
B[0]=1
for i in range(n):
  B[i+1]=(B[i]*base)%mod

def chk(x):
  ret=False
  h=0
  bx=B[x]
  d=collections.defaultdict(int)
  for i in range(x):
    h=(h*base+S[i])%mod
  d[h]=x
  for i in range(x,n):
    h=(h*base+S[i]-S[i-x]*bx)%mod
    if d[h]==0:
      d[h]=i+1
    elif d[h]<=i-x+1:
      if S[d[h]-x:d[h]]==S[i-x+1:i+1]:
        ret=True
  return ret

l,r=0,n//2
while r-l>1:
  m=(l+r)//2
  if chk(m):
    l=m
  else:
    r=m
print(r if chk(r) else l)


Measured memory_bytes: 4288
n = int(input())
table = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for l in range(n):
    b, f, r, v = map(int, input().split())
    table[b-1][f-1][r-1] += v

k = 0
for i in range(4):
    for j in range(3):
        output = " ".join(map(str, table[i][j]))
        print(" %s" % output)
    if k < 3:
        print("####################")
        k += 1

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

typedef unsigned long long int ulint;
typedef long long int lint;


template<class T>
T power(T x, T p)
{
  if (p == 0) return 1;
  if (p == 1) return x;

  T tmp = myPow(x, p/2);
  if (p%2 == 0) return tmp * tmp;
  else return x * tmp * tmp;
}

ulint BIG = 1000000000;

int main(){
  ulint N, M;
  cin >> N >> M;

  vector<ulint> costs; // costs[i] := cost of i-th key
  vector<ulint> can_open; // can_open[i][j] := box that i-th key can open
  
  for (int i = 0; i < M; ++i) {
    ulint a, b;
    cin >> a >> b;

    // vector<ulint> cs;
    ulint cs = 0;
    for (int j = 0; j < b; ++j) {
      ulint c;
      cin >> c;
      --c;
      cs += (1 << c); // c-th bit is set to 1.
    }
    
    costs.push_back(a);
    can_open.push_back(cs);
  }

  ulint n_power = (1 << N); // power(2, N);

  // cout << "npower=" << n_power << endl;

  vector<vector<ulint>> DP(M, vector<ulint>(n_power, BIG));
  // DP(i, j) := Covers all element in j. Can have other elements.
  
  for (ulint i = 0; i < M; ++i) {
    for (ulint j = 0; j < n_power; ++j) {
    // cout << "i=" << i << endl;
    // i := using key up to i-th one
      // cout << "j=" << j << endl;
      if (j == 0) {
	DP[i][j] = 0;
      } else if (i == 0) {
	if ((j & can_open[i]) == j ) {
	  DP[i][j] = costs[i];
	} else {
	  DP[i][j] = BIG;
	}
	// if (can_open[0] == j) {
	//   DP[i][j] = costs[0];
	// }
      } else {
	// DP[i][j | can_open[i]] = min(DP[i-1][j | can_open[i]], DP[i-1][j] + costs[i]);
	// if (j == 15) {
	//   cout << "DP[i-1][j]=" << DP[i-1][j] << endl;
	//   cout << "DP[i-1][j - (j & can_open[i])] + costs[i]="
	//        << DP[i-1][j - (j & can_open[i])] + costs[i] << endl;
	//   
	// }
	// Dont use i -> DP[i-1][j]
	// Use i      -> DP[i-1][j'] + costs[i]. j' is j without elements in can_open[i].
	DP[i][j] = min(DP[i-1][j], DP[i-1][j - (j & can_open[i])] + costs[i]);
      }
      // cout << "(" << i << ", " << j << ") = " << DP[i][j] << endl;
    }
  }

  if (DP[M - 1][n_power - 1] == BIG) {
    cout << -1 << endl;
  } else {
    cout << DP[M - 1][n_power - 1] << endl;
  }
}


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    int s, c;
    cin >> s >> c;
    int ans = min(s, c / 2);
    c -= ans * 2;
    ans += c / 4;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
using namespace std;
typedef long long LL;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c&&c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

int c[30];
int st[30][100000];
ll dp[52][2510];
ll a[101];
void Solve() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
		
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   vector<int> cnt(n+1);
   f(i,1,n){
      int x;
      cin >> x;
      cnt[x]++;
   }
   f(i,1,n+1){
      cout << cnt[i] << '\n';
   }
   return 0;
}


Measured memory_bytes: 4764
#include <bits/stdc++.h>
#define up(i,a,b) for(int i=a;i<=b;i++)
#define down(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a-1;i>=b;i--)
#define CL(x) (x<<1)
#define CR(x) (x<<1)+1
#define pb push_back
#define bit1(x) __builtin_popcount(x)
#define self (*this)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,pii> plii;
#define x first
#define y second

template<typename T> inline void _read(T &x){
    char ch; x=0; bool neg=false;
    for(ch=getchar();ch<'0'||ch>'9';ch=getchar())
        if(ch=='-') neg=true;
    for(;ch>='0'&&ch<='9';ch=getchar()) x=10*x+ch-'0';
    if(neg) x=-x;
}
#define read(a) _read(a)
#define Read(a,b) _read(a),_read(b)
#define READ(a,b,c) _read(a),_read(b),_read(c)

const int maxn=1e2+7;
const int Nblocks=400;
const int maxS=(1<<5)+7;
const ll mod=9901;
const int inf=1e9+7;
const ll linf=1e16+9;
const double pi=4*atan(1);
const ll Radix=1e9;
const int Length=9;
const int MaxDigit=2e4+1;
const int nDigits=MaxDigit/Length+1;

int a,b;

inline void Enter(){
    cin>>a>>b;
}

inline void Prepare(){

}

inline void Solve(){
    if((a*b)%2) cout<<"Yes";
    else cout<<"No";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
  #define Kamisama
    #ifndef Kamisama
    freopen("TEST.INP","r",stdin);
    freopen("TEST.OUT","w",stdout);
    #endif // Kamisama

    Enter();
    Prepare();
    Solve();

    return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N,D,X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin >> A.at(i);
  int sum=0;
  
  for(int i=0;i<N;i++){
    for(int j=1;j<=D;j++){
      if((j-1)%A.at(i)==0) ++sum;
    }
  }

  cout << sum+X << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int r1, r2, in;
	scanf("%d %d %d", &r1, &r2, &in);

	int ans = 0;
	for (int i = r1; i <= r2; i++) {
		if (in%i == 0)ans++;
	}

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


Measured memory_bytes: 2760
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
#define PI  3.14159265358979323846264338327950
 
 
int main () {
    int A,B,H,M;
    cin >> A >> B >> H >> M;

    double Akaku, Bkaku,kaku;
    Akaku =  (H*60+M)*0.5;
    Bkaku = M*6;

    kaku = abs(Akaku-Bkaku);
    if(kaku > 180) kaku = 360-kaku;

    double cosc,c;
    cosc = cos((kaku*PI)/180.0);
    
    c = sqrt( pow(A,2) + pow(B,2) - (2*A*B*cosc));


    cout << fixed << setprecision(15)  << c  << endl;

}


Measured memory_bytes: 4236
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int N = 3;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		int c = parseInt(sc.next());
		sc.close();
		out.println(a<=c&&c<=b?"Yes":"No");
	}
}


Measured memory_bytes: 22996
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <algorithm>
#define lowbit(i)((i)&(-i))
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
int n;
int main() {
	read(n);
	if (n == lowbit(n)) {
		puts("No");
		return 0;
	}
	puts("Yes");
	printf("1 2\n2 3\n3 %d\n%d %d\n%d %d\n", n + 1, n + 1, n + 2, n + 2, n + 3);
	for (register int i = 4; i < n; i += 2) {
		printf("1 %d\n", i);
		printf("1 %d\n", i + 1);
		printf("%d %d\n", i + 1, n + i);
		printf("%d %d\n", i, n + i + 1);
	}
	if (!(n & 1)) {
		for (register int i = 4; i < n; ++i) {
			if ((n ^ 1 ^ i) != 3 && (n ^ 1 ^ i) < n) {
				printf("%d %d\n", i, n);
				printf("%d %d\n", n ^ 1 ^ i, (n << 1));
				return 0;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3708
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,k;
signed main(){
	cin>>n>>k;
	cout<<k*(k-1)/2+n*(n-1)/2<<endl;
}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
// const int MOD = 1e9 + 7;
const int MOD = 998244353;
const ll LINF = 1e18;
const ll NMAX = 1e6;
ll fac[NMAX + 1], inv[NMAX + 1], finv[NMAX + 1];
ll N, A, B, K;

void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR(i, 2, NMAX + 1) {
        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(ll n, ll k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

int main() {
    cin >> N >> A >> B >> K;
    if(K == 0) {
        cout << 1 << "\n";
        return 0;
    }
    cominit();
    ll ans = 0;
    REP(n, N + 1) {
        if((K - A * n) % B || K - A * n < 0) {
            continue;
        } else {
            ll m = (K - A * n) / B;
            ans += (comb(N, n) * comb(N, m)) % MOD;
            ans %= MOD;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 23680
while True:
    n=int(input())
    if n==0:
        break
    books=[]
    read_t=0
    write_t=0
    for i in range(n):
        r,w=map(int,input().split())
        read_t+=r
        write_t+=w
        books.append((r,w))
    books=sorted(books)
    if books[-1][0]<=read_t//2:
        print(read_t+write_t)
        continue
    sukima=books[-1][0]-(read_t-books[-1][0])
    dp=[[0 for i in range(sukima+1)] for i in range(n)]
    for i in range(1,n):
        for j in range(1,sukima+1):
            dp[i][j]=max(dp[i-1][j],
            dp[i-1][j-books[i-1][1]]
            +books[i-1][1] if j-books[i-1][1]>=0 else 0)

    print(read_t+write_t+sukima-dp[-1][-1])

    


Measured memory_bytes: 7600
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <map>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

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

    pair<pair<string, int>, int> p[110];

    REP(i, n){
        string s;
        int tmp;
        cin >> s >> tmp;
        p[i] = make_pair(make_pair(s, -tmp), i);
    }
    sort(p, p+n);

    REP(i, n) cout << p[i].second+1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long int
#define loop(a,n) for(long i=a;i<n;i++)
#define loopr(a,n) for(long i=n-1;i>=a;i--)
#define MOD 10000007
#define mod 1000000007
#define MAX 26
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;
using namespace std;
int main()
{
    fastio;
	#ifndef ONLINE_JUDGE
		freopen("input1.txt  ","r",stdin);
		freopen("output1.txt","w",stdout);
	#endif

    ll k;
    cin>>k;
    string s;
    cin>>s;
    ll n=s.size();
    if(n<=k)
    cout<<s;
    else
    {
        for(int i=0;i<k;i++)
        cout<<s[i];
        cout<<"...";
    }
	return 0;
}


Measured memory_bytes: 3648
my @data =<STDIN>;
chomp $data[0];
chomp $data[1];
my $tn = $data[0];
my @num = split(/ /, $data[1]);

my @sort = sort {$a <=> $b} @num;

my $sum=0;

for $c (1..$tn) {
	$sum+=$sort[$tn*3-2*$c];
}

print $sum, "\n";

Measured memory_bytes: 74400
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long h;

long long fun(long long v)
{
	if (v == 1) return 1;
	long long ret = 2 * fun(v / 2);
	ret++;
	return ret;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> h;
	cout << fun(h) << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
from functools import reduce

# 入力
s = input()

# AA..ABC -> BCAA..A に変換するのを繰り返す
ans, _, _ = reduce(
    lambda acc, c: (
        (acc[0], (1 - acc[2]) * acc[1] + 1, 0) if c == 'A' else
        (acc[0], (1 - acc[2]) * acc[1], 1 - acc[2]) if c == 'B' else
        (acc[0] + acc[2] * acc[1], acc[2] * acc[1], 0)
    ),
    s,
    (0, 0, 0)
)

# 出力
print(ans)


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
string S[101];
int SY,SX;
int dp[101][101][101][101];
int sum[105][105];

int range(int L,int R,int T,int B) {
	if(L>R || T>B) return 0;
	if(L>=W || R<0 || T>=H || B<0) return 0;
	return sum[B+1][R+1]-sum[T][R+1]-sum[B+1][L]+sum[T][L];
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) {
		cin>>S[y];
		FOR(x,W) {
			if(S[y][x]=='E') S[y][x]='.', SY=y,SX=x;
			if(S[y][x]=='o') sum[y+1][x+1]=1;
			sum[y+1][x+1] += sum[y][x+1] + sum[y+1][x] - sum[y][x];
		}
	}
	
	int L,R,U,D;
	for(L=0;SX-L>=0;L++) for(R=0;SX+R<W;R++) for(U=0;SY-U>=0;U++) for(D=0;SY+D<H;D++) {
		int& ret=dp[L][R][U][D];
		//_P("%d %d %d %d : %d\n",L,R,U,D,ret);
		int AL=max(SX-L,R);
		int AR=min(SX+R,W-1-L);
		int AT=max(SY-U,D);
		int AB=min(SY+D,H-1-U);
		
		dp[L][R+1][U][D]=max(dp[L][R+1][U][D], ret+((AR+1<W-L)?range(AR+1,AR+1,AT,AB):0));
		dp[L+1][R][U][D]=max(dp[L+1][R][U][D], ret+((R+1<=AL)?range(AL-1,AL-1,AT,AB):0));
		dp[L][R][U][D+1]=max(dp[L][R][U][D+1], ret+((AB+1<H-U)?range(AL,AR,AB+1,AB+1):0));
		dp[L][R][U+1][D]=max(dp[L][R][U+1][D], ret+((D+1<=AT)?range(AL,AR,AT-1,AT-1):0));
	}
	
	cout<<dp[SX][W-1-SX][SY][H-1-SY]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 97920
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String K = sc.next();
		int N = K.length();
		int D = Integer.parseInt(sc.next());
		int mod = 1_000_000_007;

		int[] Remainder = new int[Math.min(10,D)];
		for (int i=0;i<Math.min(10,D);i++) {
			// int tmp;
			// if (i==0) {
			// 	tmp = 0;
			// } else {
			// 	tmp = i%D;
			// }
			// Remainder[tmp]++;
			Remainder[i]=1;
		}
		// System.out.println((int)K.charAt(1));
		// System.out.println(K.charAt(0));
		// System.out.println(K.charAt(1));

		int[][][] dp = new int[N+1][D][2];
		dp[0][0][0]=1;
		dp[0][0][1]=0;
		for (int i=0;i<N;i++) {
			for (int j=0;j<D;j++) {
				// for (int k=0;k<Math.min(10,D);k++) {
				for (int k=0;k<10;k++) {
					if (K.charAt(i)-48<k) {
						dp[i+1][(j+k)%D][0]+=0;
						dp[i+1][(j+k)%D][1]=(dp[i+1][(j+k)%D][1]+dp[i][j][1])%mod;
						// dp[i+1][(j+k)%D][1]+=dp[i][j][1]*Remainder[k];
					} else if (K.charAt(i)-48==k) {
						dp[i+1][(j+k)%D][0]=(dp[i+1][(j+k)%D][0]+dp[i][j][0])%mod;
						dp[i+1][(j+k)%D][1]=(dp[i+1][(j+k)%D][1]+dp[i][j][1])%mod;
						// System.out.println(K.charAt(i)-48);
						// System.out.println(i + " " + k);
						// dp[i+1][(j+k)%D][0]+=dp[i][j][0]*Remainder[k];
						// dp[i+1][(j+k)%D][1]+=dp[i][j][1]*Remainder[k];
					} else if (K.charAt(i)-48>k) {
						dp[i+1][(j+k)%D][0]+=0;
						dp[i+1][(j+k)%D][1]=(dp[i+1][(j+k)%D][1]+dp[i][j][1]+dp[i][j][0])%mod;
						// dp[i+1][(j+k)%D][1]+=dp[i][j][1]*Remainder[k]+dp[i][j][0]*Remainder[k];
					}
				}
			}
		}
		System.out.println((dp[N][0][0]+dp[N][0][1]+mod-1) % mod);
	}
}

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

int main(){
    int m, h;
    string a;
    while(cin >> a && a != "-"){
        cin >> m;
        for(int i = 0 ; i < m ; i++){
            cin >> h;
            a = a.substr(h) + a.substr(0, h);
        }
        cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 3220