akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=255;
ll dp[N<<1][N],an;
PI a[N<<1];
int main(){
	int n=read(); const int mod=read();
	For(i,0,2*n-1){
		int l=0; while(l*l+i*i<n*n)l++;
		int r=sqrt(4*n*n-i*i); if(r==2*n)r--;
		a[i]=i<n?mp(l-1,r):mp(r,l); //cout<<l<<" "<<r<<endl;
	}
	sort(a,a+2*n);
	For(o,0,n){
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		int sum=0; 
		For(i,0,2*n-1)if(a[i].se){
			For(j,0,o)if(dp[i][j]){
				dp[i][j]%=mod;
				int rk=n+n-((n-sum)-(o-j)); //if(o==0)cout<<rk<<" fjzzq"<<" "<<a[i].se+1-rk<<" "<<endl;
				dp[i+1][j]+=dp[i][j]*(a[i].se+1-rk);
				rk=j+i-sum;
				dp[i+1][j+1]+=dp[i][j]*(a[i].fi+1-rk);
			}
			sum++;
		}else{
			For(j,0,o)if(dp[i][j]){
				dp[i][j]%=mod;
				int rk=j+(i-sum); //if(o==0)cout<<rk<<" "<<j<<" "<<a[i].fi+1-rk<<endl;
				dp[i+1][j]+=dp[i][j]*(a[i].fi+1-rk);
			}
		}
		//cout<<o<<" "<<dp[n*2][o]<<endl;
		an=(an+(o%2?-dp[2*n][o]:dp[2*n][o]))%mod;
	}
	cout<<(an+mod)%mod<<endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N, K;
    cin >> N >> K;
    
    vector<int> l(N);
    for (int i = 0; i < N; i++) cin >> l[i];
    
    sort(l.begin(), l.end());
    
    int ans = 0;
    for (int i = N-1; i > N-1-K; i--){
        ans += l[i];
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <limits.h>
#include <math.h>
#include <iomanip>
using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;

void solve() {
	int N,D;
	cin >> N >> D;
	if (N % (2 * D + 1) == 0)cout << N / (2 * D + 1) << endl;
	else cout << (int)floor(N / (2 * D + 1)) + 1 << endl;
	return;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=200000;
const int inf=1e9;
const ll mod=1e9+7;

int main()
{
    FasterIO;

    int tc, cs=1;

    int n;
    cin>>n;
    cout<<(n/2+n%2)<<endl;
    return 0;
}


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

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

#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define sz size()
#define fe first
#define se second

#define batr ONLINE_JUDGE
#define all(x) (x).begin(),(x).end()
#define skip continue

using namespace std;

string s;
int sum;

int main () {
	Need_For_Speed;
	cin >> s;
	char c = '0';
	for (int i = 0; i < s.sz; i++) {
		c = max(s[i], c);
		sum += (s[i] - '0');
	}
	if (c == 1) {
		cout << (s.sz - 1) * 9;
		return 0;
	}
	s[0]--;
	int ans = (int(s[0] - '0') + (s.sz - 1) * 9);
	cout << max(ans, sum);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
import java.util.Stack;
import java.util.HashSet;
public class Main {

  int n;
  HashMap<Integer, Integer[]> graph;
  HashSet<Integer> visited = new HashSet<Integer>();
  int timestamp;
  int[] d;
  int[] f;

  public Main(HashMap<Integer, Integer[]> graph, int n) {
    this.n = n;
    this.graph = graph;
    this.timestamp = 1;
    this.d = new int[n];
    this.f = new int[n];
  }

  public void dfs() {
    for (int i = 1; i <= this.n; i++) {
      if (!this.visited.contains(i))
        dfsHelper(i);
    }
  }

  public void dfsHelper(Integer elem) {
    visited.add(elem);
    this.d[elem-1] = this.timestamp;
    this.timestamp++;
    for (Integer neighbor : this.graph.get(elem)) {
      if (!this.visited.contains(neighbor)) {
        dfsHelper(neighbor);
      }
    }
    this.f[elem-1] = this.timestamp;
    this.timestamp++;
  }

  public void displayResults() {
    for (int i = 0; i < n; i++) {
      System.out.println((i+1) + " " + this.d[i] + " " + this.f[i]);
    }
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    HashMap<Integer, Integer[]> graph = new HashMap<Integer, Integer[]>();
    for (int i = 0; i < n; i++) {
      int id = s.nextInt();
      int degree = s.nextInt();
      Integer[] edges = new Integer[degree];
      for (int j = 0; j < degree; j++) {
        int val = s.nextInt();
        edges[j] = val;
      }
      graph.put(id, edges);
    }
    s.close();
    Main main = new Main(graph, n);
    main.dfs();
    main.displayResults();
  }
}



Measured memory_bytes: 28348
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <stdio.h>

using namespace std;

int N = 105;
int val[105];
int top;

void initialize(){
    top = 0;
    for(int i = 0; i < N; ++i) val[i] = 0;

    return;
}

bool isFull(){
    return (top >= (N - 1));
}

bool isEmpty(){
    return (top == 0);
}

void push(int x){
    if(isFull()){
        cout << "overflow" << endl;
        return;
    }
    top++;
    val[top] = x;
    return;
}

int pop(){
    if(isEmpty()){
        cout << "underflow" << endl;
        return -1;
    }
    top--;
    return val[top + 1];
}


int main(){
    int a, b;
    initialize();
    char s[100];
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        }else if(s[0] == '-'){
            a = pop();
            b = pop();
            push(b - a);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }else{
            push(atoi(s));
        }
    }

    cout << pop() << endl;

    return 0;
}






















Measured memory_bytes: 3244
#include <stdio.h>
#define INFTY (1<<30)

int H,A[2000001];

void maxHeapify(int i){
  int l,r,largest,tmp;;
  l=i*2;
  r=i*2+1;

  if (l<=H && A[l] > A[i]) largest=l;
  else largest=i;
  if (r<=H && A[r] > A[largest]) largest=r;

  if(largest!=i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }
}


int heapExtractMax(){
  int max;
  if(H<1) return -INFTY;
  max = A[1];
  A[1] = A[H--];
  maxHeapify(1);
       return max;
}

void heapIncreaseKey(int i,int key){
  int tmp;
  if (key < A[i]) return;
  A[i] = key;
  while (i > 1 && A[i/2] < A[i]){
    tmp=A[i];
    A[i]=A[i/2];
    A[i/2]=tmp;
    i = i/2;
  }
}

void maxHeapInsert(int key){
  H++;
  A[H]=-INFTY;
  heapIncreaseKey(H,key);
}

int main(){
  int key;
  char order[10];
  int i=1;

  while(1){
  scanf("%s",order);
  if(order[0]=='i'){
    scanf("%d",&key);
    maxHeapInsert(key);
  }
  if(order[0]=='e' && order[1] != 'n') printf("%d\n",heapExtractMax());
  if(order[0]=='e' && order[1] == 'n') break;
  }
  return 0; 
}



Measured memory_bytes: 5608
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  string s;cin>>s;
  cout<<(s=="ABC" ? "ARC" : "ABC")<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 3612
#include<stdio.h>
int N,M,A[10],i,P[9],p,T,c;
 
int dfs(int n,int t)
{
	int i,r,x;
	if(n==p)return t%10?0:1;
	for(i=r=0;i<M;i++)
	{
		x=P[n]%2?A[i]:A[i]*2;
		r+=dfs(n+1,t+x/10+x%10);
	}
	return r;
}
 
int main()
{
	scanf("%d\n",&N);
	for(i=p=T=0;i<N;i++)
	{
		c=getchar();
		if(c=='*')P[p++]=N-i;
		else
		{
			c=c-'0';c=(N-i)%2?c:c*2;
			T+=c/10+c%10;
		}
	}
 
	scanf("%d",&M);
	for(i=0;i<M;i++)scanf("%d",&A[i]);
	printf("%d\n",dfs(0,T));
	return 0;
}

Measured memory_bytes: 604
//In the name of ALLAH
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = false;
#define cerr if(DEBUG)cerr
using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long long maxn = 2e5 + 5;
const long long INF = 1e18 + 1;
const long long M = 1e9 + 7;
const int lg = 21;

ll n, a, b;
vector<ll> v;

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> a >> b;
	if(b - 1 + a > n or a * b < n)
		return cout << -1 << endl, 0;
	for(int i = b; i >= 1; i--)
		cout << i << " ";
	ll now = b + 1, rem = a - 2;
	n -= b;
	for(int i = 1; i < a; i++){
		int t = min(b, n - rem);
		//cout << now << " " << t << " " << rem << endl;
		for(int j = now + t - 1; j >= now; j--)
			cout << j << " ";
		n -= t;
		now += t;		
		rem--;
	}	
	return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>

using namespace std;
int main(){
	int a,b;

	scanf("%d %d",&a,&b);
	if(a>=13)cout<<b;
	else if(a>=6)cout<<b/2;
	else cout<<"0";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<int> h(N);
  rep(i, N) cin >> h[i];

  int ans = 0;
  for (int i = 0; i < N; ++i){
    bool flag = true;
    for (int j = i; j >= 0; --j){
      if (h[j] > h[i]) flag = false;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k=0,aa,bb,cc;
	scanf("%d %d %d",&a,&b,&c);
	while(1)
	{
		if(a%2!=0||b%2!=0||c%2!=0)break;
		k++;
		aa=a/2;
		bb=b/2;
		cc=c/2;
		a=bb+cc;
		b=aa+cc;
		c=aa+bb;
		if(k>10000000)break;
	}
	if(k>10000000)printf("-1");
	else printf("%d",k);
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	n := scanInt(sc)
	orders := make(map[int]int, n)
	for i := 1; i <= n; i++ {
		orders[scanInt(sc)] = i
	}
	buf := &strings.Builder{}
	buf.WriteString(fmt.Sprintf("%d", orders[1]))
	for i := 2; i <= n; i++ {
		buf.WriteString(" ")
		buf.WriteString(fmt.Sprintf("%d", orders[i]))
	}
	fmt.Println(buf.String())
	return
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}

Measured memory_bytes: 8708
//BROWNIE TK

#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second

#define forz(i, n) for (int i = 0; i < n; i++)
#define forzm(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rforzm(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order
using namespace std;

/*STD fucntions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        //y must be even now
        y = y >> 1; //y=y/2
        x = (x * x) % p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{
    return a * b / gcd(a, b);
}
lli modi(lli a, lli m)
{
    // fermat little thm where m is prime
    return power(a, m - 2, m);
}
/*CODE BEGINS*/

int main()
{
    kira;
    lli n,k;
    cin>>n>>k;
    lli a[n];
    lli c=0;
    forz(i,n)
    {
        cin>>a[i];
        if(a[i]>=k)c++;
    }
    p0(c);
    return 0;
}


Measured memory_bytes: 1024
N, K = gets.chomp.split.map(&:to_i)
p = 0.0
(1..N).each do |x|
  if x < K then
    t = Math.log2(K.to_f / x)
    y = t.ceil
    p = p + (1.0 / N) * (0.5) ** y
  else
    p = p + (1.0 / N)
  end
end
puts p

Measured memory_bytes: 1788
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
  // cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
        
     string s;
     cin>>s;
     ll ans=0;
     ll cnt=0;
     for(int i=0;i<3;i++)
     {
        if(s[i]=='R')
          cnt++;
        else
        {
          ans=max(cnt,ans);
          cnt=0;
        }
     }
     ans=max(cnt,ans);
     cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3640
#ABC057.B
N,M = map(int,input().split())
L1 = []
L2 = []

for i in range(N):
    a,b = map(int,input().split())
    L1.append([a,b])
for m in range(M):
    c,d = map(int,input().split())
    L2.append([c,d])

for j in range(N):
    L3 = []
    for l in range(M):
        L3.append(abs(L1[j][0]-L2[l][0]) + abs(L1[j][1]-L2[l][1]))
    print(L3.index(min(L3))+1)

Measured memory_bytes: 3064
<?php

$n = (int) trim(fgets(STDIN));

$limits[] = (int) trim(fgets(STDIN));
$limits[] = (int) trim(fgets(STDIN));
$limits[] = (int) trim(fgets(STDIN));
$limits[] = (int) trim(fgets(STDIN));
$limits[] = (int) trim(fgets(STDIN));

$min = min( $limits );

echo (int)ceil( $n / $min ) + 4;



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    double n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; ++i){
        if(i % 2 != 0){
            ++cnt;
        }
    }
    double ans = (double)cnt / n;
    
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 256
week = input()
if week == "SUN":
	print(7)
elif week == "MON":
	print(6)
elif week == "TUE":
	print(5)
elif week == "WED":
	print(4)
elif week == "THU":
	print(3)
elif week == "FRI":
	print(2)
else:
	print(1)

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

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int N,M,X; cin>>N>>M>>X;
  int Left=0,Right=0;
  while (M--) {
    int A; cin>>A;
    Left+=(A<X?1:0); Right+=(A>X?1:0);
  }
  cout<<min(Left,Right)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>dp;
void rec(int x)
{
	if(x==0)return;
	rec(x-dp[x]);
	if(x-dp[x]!=0)cout<<" ";
	cout<<dp[x];
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m,i;
	string s;
	cin>>n>>m>>s;
	dp.resize(n+1);
	for(i=1;i<=m;i++)
		if(s[i]=='0')
			dp[i]=i;
	int c=0;
	for(;i<=n;i++)
	{
		while((c+m<i || s[c]=='1') && c<i)
			c++;
		if(c==i)
		{
			cout<<"-1\n";
			return 0;
		}
		dp[i]=i-c;
	}
	rec(n);
	cout<<'\n';
}


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

using namespace std;

int main()
{
  string str, add;
  int n, sh;
  while (1)
  {
    cin >> str;

    if (str == "-")
      break;

    cin >> n;

    for (int i = 0; i < n; i++)
    {
      cin >> sh;

      add = str.substr(0, sh);
      str.erase(0, sh);
      str += add;
    }
    cout << str << endl;
  }
}


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

int main() {

	int n, t = 0, h = 0;
	cin >> n;
	string ts, hs;
	
	for (int i = 0; i < n; i++) {
		cin >> ts >> hs;
		if (ts > hs) {
			t += 3;
		} else if (ts < hs) {
			h += 3;
		} else if (ts == hs) {
			t++; h++;
		}
	}
	cout << t << ' ' << h << '\n';
	
	return 0;
}


Measured memory_bytes: 3184
#include <stdio.h>

#define M 100000

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(){

  int H,i,C[M+1];

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&C[i]);
  }

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,C[i]);
    if(parent(i)>=1)
      printf("parent key = %d, ",C[parent(i)]);
    if(left(i)<=H)
      printf("left key = %d, ",C[left(i)]);
    if(right(i)<=H)
      printf("right key = %d, ",C[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2104
#include<iostream>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s[1]=='R'){
        if(s[0]=='R'&& s[2]=='R'){
            printf("%d\n",3);
        }else if(s[0]=='R'|| s[2]=='R'){
            printf("%d\n",2);
        }else{
            printf("%d\n",1);
        }
    }else if(s[0]=='R' || s[2]=='R'){
        printf("%d\n",1);
    }else{
        printf("%d\n",0);
    }
}

Measured memory_bytes: 3724
use std::collections::*;
fn main() {
    let s: Vec<char> = read::<String>().chars().collect();

    let l = (s.len() - 1) / 2;
    let l_2 = (s.len() + 3) / 2;

    let i = {
        let x = s.clone();
        let mut y = s.clone();
        y.reverse();
        x == y
    };
    let j = {
        let x = s.clone();
        let x = x.split_at(l).0.to_vec();
        let y = s.clone();
        let y = y.split_at(l).0.to_vec();
        let mut y = y;
        y.reverse();
        x == y
    };
    let k = {
        let x = s.clone();
        let y = s.clone();
        let x = x.split_at(l_2 - 1).1.to_vec();
        let mut y = y.split_at(l_2 - 1).1.to_vec();
        y.reverse();
        x == y
    };

    if i && j && k {
        println!("Yes");
    } else {
        println!("No");
    }
}

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep( i, n ) for( int ( i ) = 0; ( i ) < ( n ); ( i )++ )
#define repr( i, n ) for( int ( i ) = ( n ); ( i ) >= 0; ( i )-- )
#define FOR( i, m, n ) for( int ( i ) = ( m ); ( i ) < ( n ); ( i )++ )
#define all( x ) ( x ).begin(), ( x ).end()
typedef long long lint;
using namespace std;

int main( void ){
	
	lint n, t, c, tn, ret;
	
	ret = 1500;
	
	cin >> n >> t;
	
	rep(i,n){
		cin >> c >> tn;
		if( t >= tn ){
			if( ret > c ){
				ret = c;
			}
		}
	}
	
	if(ret == 1500){
		cout << "TLE" << endl;
	}else{
		cout << ret << endl;
	}
	
	return 0;
	
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 30 22:06:02 2019
WarshallFloyd_search
@author: maezawa
"""
import collections


class WarshallFloyd():
    def __init__(self, N):
        self.edges = []
        self.N = N
        self.d = [[float("inf") for i in range(N)]
                  for i in range(N)]  # d[u][v] : 辺uvのコスト(存在しないときは'inf')

    def add(self, u, v, c, directed=False):
        """
        0-indexedであることに注意
        u = from, v = to, c = cost
        directed = Trueなら、有向グラフである
        """
        if directed:
            self.d[u][v] = c
        else:
            self.d[u][v] = c
            self.d[v][u] = c
        if directed:
            self.edges.append([u, v, c])
        else:
            self.edges.append([u, v, c])
            self.edges.append([v, u, c])


    def WarshallFloyd_search(self):
        # これを d[i][j]: iからjへの最短距離 にする
        # 本来無向グラフでのみ全域木を考えるが、二重辺なら有向でも行ける
        for k in range(self.N):
            for i in range(self.N):
                for j in range(self.N):
                    self.d[i][j] = min(
                        self.d[i][j], self.d[i][k] + self.d[k][j])
        for i in range(self.N):
            self.d[i][i] = 0
        return self.d

    def BellmanFord_negative_bool(self, numNodes, start, zero_indexed=False):
        # 負の閉路の検出, Trueなら負の閉路が存在する
        dd = collections.defaultdict(lambda: float('inf'))
        dd[0] = 0
        numEdges = len(self.edges)
        for i in range(numNodes):
            for j in range(numEdges):
                e = self.edges[j]
                if dd[e[1]] > dd[e[0]] + e[2]:
                    dd[e[1]] = dd[e[0]] + e[2]
                    if i == numNodes-1:
                        return True
        return False
    

# 使い方の例
        
num_v, num_edges = list(map(int, input().split()))      
graph = WarshallFloyd(num_v)

for i in range(num_edges):
    u,v,w = list(map(int, input().split()))
    graph.add(u, v, w, directed=True)

if graph.BellmanFord_negative_bool(num_v, 0, zero_indexed=True):
    print('NEGATIVE CYCLE')
else:
    result = graph.WarshallFloyd_search()
    for i in range(num_v):
        s = []
        for j in range(num_v):
            if result[i][j] == float("inf"):
                s.append('INF')
            else:
                s.append(str(result[i][j]))
        print(' '.join(s))

    


Measured memory_bytes: 7688
import numpy as np

INF = 10000000 * 50 + 1

N, K = map(int, input().split())
V = np.fromiter(map(int, input().split()), np.int)

ans = -INF
for l in range(K + 1):
	for dr in range(K + 1 - l):
		r = N - dr
		if r < l:
			break
		ms = np.sort(np.concatenate((V[:l], V[r:])))
		score = np.sum(ms)
		score -= np.sum(ms[ms < 0][:K-(l+dr)])
		ans = max(ans, score)

print(ans)


Measured memory_bytes: 12508
// DP

#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
const int mod = 1e9 + 7;
int main(void){
  int S;
  cin >> S;

  // 最後の項は3の場合、4の場合。...Nの場合がある
  // 漸化式を考える
  // A[N] = A[N - 3] + A[N - 4] + ... + A[0]
  // A[0] = 1, A[1] = 0, A[2] = 0, ...
  vector <ll> dp(S+1, 0);
  dp[0] = 1;

  // O(S^2)解法
  // for (int i = 3; i <= S; i++){
  //   for (int j = i - 3; j >= 0; j--){
  //     dp[i] += dp[j];
  //     dp[i] %= mod;
  //   }
  // }

  //O(S)解法
  for (int i = 3; i <= S; i++){
    dp[i] = dp[i - 1] + dp[i - 3];
    dp[i] %= mod;
  }
  cout << dp[S] << endl;
  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
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; }

const long long INF = 1LL << 60;

int main(){
    int N; cin >> N;
    long long dp[N+10];
    for(int i =0;i<N+10;i++) dp[i] = INF;
    dp[0] = 0;
    dp[1] = 1;

    for(int i = 2;i<=N; i++){
        chmin(dp[i],dp[i-1] + 1);
        int six = 1; int nine = 1;
        while((i - pow(6,six)) >= 0){
            chmin(dp[i],dp[i - (long long)pow(6,six)] + 1);
            six++;
        }
        while((i - pow(9,nine)) >= 0){
            chmin(dp[i],dp[i - (long long)pow(9,nine)] + 1);
            nine++;
        }
    }
    //for(int i = 0;i<N+1;i++) cout << dp[i] << ' ';
    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
# https://atcoder.jp/contests/abc094/tasks/arc095_a
from copy import deepcopy
n = int(input())
nums = [int(i) for i in input().split()]
c = deepcopy(nums)
c.sort()
left = c[n // 2 - 1]
right = c[n // 2]

for num in nums:
    if num <= left:
        print(right)
    else:
        print(left)

Measured memory_bytes: 120952
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
 
int dp[100100];
int n,l;
int a[100100];
 
int rec(int p){
  if(0<=dp[p])return dp[p];
 
  if(a[p-1] < a[p] && a[p] < a[p])return dp[p] = l-a[p];
 
  int tmp = 0;
  if(a[p]<a[p-1])tmp = max(tmp,rec(p-1));
  if(a[p]<a[p+1])tmp = max(tmp,rec(p+1));
  return dp[p]= l-a[p] + tmp;
}
   
int main(){
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int ans = 0;
  cin >> n >> l;
  for(int i=1;i<=n;i++)cin >> a[i];
  memset(dp,-1,sizeof(dp));
  a[0] = a[n+1] = dp[0] = dp[n+1] = 0;
 
  for(int i=1;i<=n;i++)ans = max(ans,rec(i));
 
  cout << ans << endl;
}

Measured memory_bytes: 3352
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <functional>
#include <map>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct frep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr frep(int l_, int r_): l(std::min(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct brep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr brep(int r_, int l_): r(std::max(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}


int main() {
  constexpr int inf = 1000000000;
  int N, M;
  std::cin >> N >> M;
  std::vector<int> D(N);
  for (int& x : D) {
    std::cin >> x;
  }
  std::vector<std::vector<int>> graph(N);
  std::map<std::pair<int, int>, int> edge;
  for (const int i: frep(0, M)) {
    int v = scan<int>() - 1;
    int u = scan<int>() - 1;
    graph[v].emplace_back(u);
    graph[u].emplace_back(v);
    edge[std::minmax(u, v)] = i;
  }
  std::vector<int> answer(M, inf);
  std::vector<std::vector<int>> remain(N);
  for (const int v: frep(0, N)) {
    int val = inf, match = inf;
    for (const int u: graph[v]) {
      if (val > D[u]) {
        val = D[u];
        match = u;
      } else if (val == D[u]) {
        chmin(match, u);
      }
    }
    if (val > D[v]) {
      std::cout << "-1\n";
      return 0;
    }
    answer[edge[std::minmax(v, match)]] = D[v];
    remain[v].emplace_back(match);
    remain[match].emplace_back(v);
  }
  std::vector<int> color(N);
  std::function<void(int, int)> dfs = [&](int v, int c) {
    if (color[v] > 0) {
      return;
    }
    color[v] = c;
    for (const int u: remain[v]) {
      dfs(u, 3 - c);
    }
  };
  for (const int v: frep(0, N)) {
    dfs(v, 1);
    std::cout << (color[v] == 1 ? 'B' : 'W');
  }
  std::cout << '\n';
  for (const int i: frep(0, M)) {
    std::cout << answer[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 28160
#include <iostream>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;

int main(void){
	char S[5];
	cin>>S;
	int ans=0;
	rep(i,4){
		if(S[i] == '+')ans++;
		else ans--;
	}
	cout<<ans<<endl;
}


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

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int max_x = 0;

    int x =0;
    for(int i=0; i<N; i++){
        if(S[i] == 'I'){
            x += 1;
        }else{
            x -= 1;
        }

        if(max_x < x){
            max_x = x;
        }
    }

    cout << max_x << endl;
    return 0;
}

Measured memory_bytes: 3592
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front

const int maxn = 2005;
bool a[maxn][maxn];
int h[maxn][maxn], v[maxn][maxn], nod[maxn][maxn];

int32_t main(){
    int n, m, Q;
    cin >>n >>m >>Q;
    for(int i = 0; i < n; i ++){
        string s;
        cin >>s;
        for(int j = 0; j < m; j ++){
            a[i][j] = s[j] - '0';
        }
    }
    for(int i = n - 1; i >= 0; i --){
        for(int j = m - 1; j >= 0; j --){
            nod[i][j] = nod[i + 1][j] + nod[i][j + 1] - nod[i + 1][j + 1] + a[i][j];
            v[i][j] = v[i + 1][j] + v[i][j + 1] - v[i + 1][j + 1] + (a[i][j] and a[i][j + 1]);
            h[i][j] = h[i + 1][j] + h[i][j + 1] - h[i + 1][j + 1] + (a[i][j] and a[i + 1][j]);
/*            cout <<i <<' ' <<j <<endl;
            cout <<"nod" <<' ' <<nod[i][j] <<endl;
            cout <<'v' <<' ' <<v[i][j] <<endl;
            cout <<'h' <<' ' <<h[i][j] <<endl;
*/        }
    }
    while(Q --){
        int x1, y1, x2, y2;
        cin >>x1 >>y1 >>x2 >>y2;
        x1 --;
        y1 --;
        x2 --;
        y2 --;
        int eg = h[x1][y1] - h[x2][y1] - h[x1][y2 + 1] + h[x2][y2 + 1] +
        v[x1][y1] - v[x1][y2] - v[x2 + 1][y1] + v[x2 + 1][y2];
        cout <<(nod[x1][y1] - nod[x1][y2 + 1] - nod[x2 + 1][y1] + nod[x2 + 1][y2 + 1]) - eg <<'\n';
    }
}


Measured memory_bytes: 99968
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res;
int f(int x)
{
    if (0 < x)
    {
        return -(x + 1);
    }
    else if (x < 0)
    {
        return -x;
    }
    else
    {
        return x = -1;
    }
}

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

    int X, N;
    cin >> X >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
    }
    if (N == 0)
    {
        res = X;
        cout << X << endl;
        return 0;
    }
    int min = 100000;
    int number = 0;
    int cnt = 0;
    bool flag = true;
    while (flag)
    {
        int data = abs(X + number);
        bool isOK = true;
        for (int j = 0; j < N; j++)
        {

            if (data == P[j])
            {
                isOK = false;
            }
        }
        if (isOK)
        {
            res = X + number;
            flag = false;
        }
        //cout << number << endl;
        number = f(number);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

const ll MOD = 1000000007LL;

int main(void) {
  ll H, W, K;
  cin >> H >> W >> K, K--;

  vector<vector<ll>> dp(H + 1, vector<ll>(W));
  dp[0][0] = 1;

  REP(h, 0, H) {
    REP(w, 0, W) {
      REP(s, 0, 1LL << (W - 1)) {
        vector<bool> row(W - 1);
        REP(i, 0, W - 1) row[i] = (s & (1LL << i));

        bool ok = true;
        REP(i, 0, W - 2) ok = ok && !(row[i] && row[i + 1]);
        if (!ok) continue;

        ll n = w;
        if (w < W - 1 && row[w]) n = w + 1;
        if (w - 1 >= 0 && row[w - 1]) n = w - 1;

        dp[h + 1][n] += dp[h][w];
        dp[h + 1][n] %= MOD;
      }
    }
  }

  cout << dp[H][K] << endl;
}

Measured memory_bytes: 256
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

x = dict()
for i in d:
    x[i] = x.get(i, 0) + 1

y = dict()
for i in t:
    y[i] = y.get(i, 0) + 1

for i, j in y.items():
    if x.get(i, 0) < j:
        print("NO")
        exit()
print("YES")


Measured memory_bytes: 56788
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

ll N;
ll A[200010];
map < ll,ll > cnt;

int main ()
{
    cin >> N;
    REP(i,N) cin >> A[i];
    REP(i,N) cnt[A[i]]++;
    sort(A, A + N);
    reverse(A, A + N);

    ll ans = 0;
    REP(i,N) {
        ll rev = 0;
        bool flag = false;
        if (cnt[A[i]] == 0) continue;
        for (int j = 31; j >= 0; j--) {
            if ((A[i] >> j) & 1) {
                flag = true;
            } else {
                if (flag) {
                    rev |= (1LL << j);
                }
            }
        }
        rev += 1;
        if (rev == A[i]) {
            if (cnt[rev] > 1) {
                cnt[rev] -= 2;
                ans++;
            }
        } else {
            if (cnt[rev] > 0) {
                cnt[rev]--;
                cnt[A[i]]--;
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 26752
L,R = map(int,input().split())

ans = 10 ** 7

di = R//2019 - L//2019

L=L%2019
R=R%2019



if(di == 0):
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans = min(ans, (i*j)%2019)

else:
    ans = 0


print(ans)


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

using namespace std;

map<string, bool> mapa;

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

	string s, last;
	cin >> last;
	mapa[last] = true;
	for (int i = 1; i < n; ++i) {
		cin >> s;
		if (last.back() == s[0] && mapa[s] == 0) {
			mapa[s] = 1;
			last = s;
			continue;
		}
		printf("No");
		return 0;
	}
	printf("Yes");
}

Measured memory_bytes: 256
#include<stdio.h>
typedef long long int lli;
int main() {
  lli x;
  scanf("%lld", &x);
  
  lli ans = 0;
  lli t1 = (x/500)*1000;
  lli t2 = x%500/5 *5;
  
  printf("%d", t1+t2);
}



Measured memory_bytes: 1676
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itc ll t;cin>>t;while(t--)
#define otc ll t=1;while(t--)
#define ll long long int
#define ld long double
#define pb push_back
#define gcd(a,b) __gcd(a,b)
#define fi first
#define se second
#define ull unsigned long long int
#define memset(arr) memset(arr, 0, sizeof(arr));
bool sortinrev(const pair<ll, ll> &a, const pair<ll, ll> &b)
{return (a.fi > b.fi);}//sort by first in descending order
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b)
{ return (a.se < b.se); }//sort by second in ascending order
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
#define PI 3.141592653589793238
ld calcAngle(double h, double m)  
{  

    ld hour_angle = 0.5 * (h * 60 + m); 
    ld minute_angle = 6 * m;  
  
    ld angle = abs(hour_angle - minute_angle);  
  
    angle = min(360 - angle, angle);  
  
    return angle;  
}
int main()
{
    ld a,b,h,m;
    cin>>a>>b>>h>>m;
    ld ang=calcAngle(h,m);
    //cout<<ang<<endl;
   
    ld s= cos ( ang * PI / 180.0 );
    
   // cout<<s<<endl;
    
    ld ans=sqrt(((a*a)+(b*b))-(2*b*a*s));
    cout<<fixed<<setprecision(10)<<ans<<endl;
    
    

    return 0;
}


Measured memory_bytes: 4172
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    map<int,int> N;
    REP(i,4){
        int a;cin>>a;
        if(a==1||a==9||a==7||a==4)N[a]++;
        else {
            cout<<"NO"<<endl;
            return 0;
        }
        
    }
    cout<<(N.size()==4?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
N=int(input())
A=[0]
for i in range(N):
    A.append(int(input()))
if A.count(2)==0:
    print(-1)
else:
    m=1
    for i in range(N):
        m=A[m]
        if m==2:
            print(i+1)
            break
        else:
            continue
    if m!=2:
        print(-1)



Measured memory_bytes: 7080
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for(int i=a;\
                    c>0?i<b:\
                    i>b;\
                    i+=c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif
 
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 1 << 28;
const ll INFL = (ll)1 << 58;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real& r) { return (r > eps) - (r < -eps); }
int sgn(const Real& a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep) {
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}
 
template<class InputIterator>
int sum(InputIterator begin, InputIterator end) {
	return accumulate(begin, end, 0ll);
}

int N, M;
int a[100];
int b[100];
int c[100];
int d[100];

void solve() {
	cin >> N >> M;
	rep(i, N) cin >> a[i] >> b[i];
	rep(i, M) cin >> c[i] >> d[i];
	rep(i, N) {
		int min_id = -1;
		int min_dist = (int)1e9;
		rep(j, M) {
			int cur_dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (cur_dist < min_dist) {
				min_dist = cur_dist;
				min_id = j;
			}
		}
		cout << min_id + 1 << endl;
	}
}

signed main() {
	cout << fixed << setprecision(20);
	solve();
	while(true) {
		char s[MAX];
		if (scanf("%s", s) == EOF) break;
		int n = strlen(s);
		for (int i = n - 1; i > -1; i--) {
			ungetc(s[i], stdin);
		}
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    x=II()
    c,x=divmod(x,500)
    ans=c*1000+x//5*5
    print(ans)

main()


Measured memory_bytes: 3444
n,m,q=map(int,input().split())
q_list=[]
for i in range(q):
    a=list(map(int,input().split()))
    q_list.append(a)
import itertools
ans=0
for i in itertools.combinations_with_replacement(range(1,m+1),n):
#     i=sorted(i)
    count=0
    for a,b,c,d in q_list:
        if i[b-1]-i[a-1]==c:
            count+=d

    ans=max(count,ans)
print(ans)

Measured memory_bytes: 67996
mod = 10**9 + 7  # 998244353 # 変える


def table():
    k = 2 * 10**6 + 5  # 変える
    fac = [1] * k
    finv = [1] * k
    inv = [0] * k
    inv[1] = 1
    for i in range(2, k):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod
    return fac, finv


fac, finv = table()


def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


k = int(input())
s = input()
n = len(s) - 1
ans = 1
for i in range(k + 1):
    x = pow(26, k - i, mod) * pow(25, i, mod) % mod
    ans += (comb(n + i, i) * x)
    ans %= mod
print((ans - 1) % mod)


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

int main() {
  int n; cin >>n;
  vector<int> x(n),c(n);
  rep(i,n) {
    cin >>x[i];
    c[i]=x[i];
  }
  sort(x.begin(), x.end());
  rep(i,n){
    if(c[i]<x[n/2]) cout << x[n/2] << endl;
    else cout << x[n/2-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 4764
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
int num[10];
vector<int> res;
bool check(int *ar,int cnt){
    int tmp[10]={0};
    rep(i,10)tmp[i] = ar[i]; 
    if(cnt == 4)return true;
    reps(i,1,10){
        if(tmp[i] < 3)continue;
        tmp[i] -= 3;
        if(check(tmp,cnt+1)) return true;
        tmp[i] += 3;
    }
    reps(i,1,8){
        if(tmp[i] < 1 || tmp[i+1] < 1 || tmp[i+2] < 1) continue;
        tmp[i]--;
        tmp[i+1]--;
        tmp[i+2]--;
        if(check(tmp,cnt+1)) return true;
        tmp[i]++;
        tmp[i+1]++;
        tmp[i+2]++;
    }
    return false;
}
void solve(){
    reps(i,1,10){
        if(num[i] < 4)num[i]++;
        else continue;
        reps(j,1,10){
            bool f = false;
            if(num[j] > 1){
                num[j] -= 2;
                if(check(num,0)){
                    res.push_back(i);
                    f = true;
                }
                num[j] += 2;
            }
            if(f)break;
        }
        num[i]--;
    }
}
int main(){
    char str[16];
    while(~scanf("%s",str)){
        memset(num,0,sizeof(num));
        res.clear();
        rep(i,13)num[str[i]-48]++;
        solve();
        if(res.size() == 0){
            puts("0");
        }
        else{
            rep(i,res.size()-1)printf("%d ",res[i]);
            printf("%d\n",res[res.size()-1]);
        }
    }
    return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define N 200010
#define MAX 1000000000000000000

#include <stdio.h>

int main (void) {
    char s[1001], t[1001];
    int count = 1000, count_tmp = 1000, i, j, k;

    scanf("%s %s", s, t);

    count = strlen(t);

    for (i = 0; i < strlen(t); i++) {
        for (j = i; j < strlen(s) - strlen(t) + i + 1; j++) {
            // printf("%c %c\n", t[i], s[j]);
            if (t[i] == s[j]) {
                count_tmp = strlen(t);
                for (k = -1 * i; k < (int)strlen(t) - i; k++) {
                    // printf("%d %c %c\n", k, t[i + k], s[j + k]);
                    if (t[i + k] == s[j + k]) {
                        count_tmp--;
                        // printf("c_tmp = %d\n", count_tmp);
                    }
                }
                if (count_tmp < count) count = count_tmp;
            }
        }
    }

    printf("%d", count);

    return 0;
}



Measured memory_bytes: 1732
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const double EPS = 1e-9;

bool check(char a, char b, char c){
	if(a == 's') return false;
	return (a == b && b == c);
}

int main(){
	string s;
	char winner;

	while(cin >> s){
		winner = 'd';
		for(int i = 0; i < 3; i++){
			if( check(s[i], s[i+3], s[i+6]) ){
				winner = s[i];
				break;
			}
		}
		for(int i = 0; i < 9; i+=3){
			if( check(s[i], s[i+1], s[i+2]) ){
				winner = s[i];
				break;
			}
		}
		if( check(s[2], s[4], s[6]) || check(s[0], s[4], s[8]) ){
			winner = s[4];
		}

		cout << winner << endl;
	}
	
    return 0;
}

Measured memory_bytes: 1172