akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.text.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		for(int i=0; i<n; i++){
			double x1 = in.nextDouble();
			double y1 = in.nextDouble();
			double x2 = in.nextDouble();
			double y2 = in.nextDouble();
			double x3 = in.nextDouble();
			double y3 = in.nextDouble();
			double a1 = 2*(x2-x1);
			double b1 = 2*(y2-y1);
			double c1 = x1*x1+y1*y1-x2*x2-y2*y2;
			double a2 = 2*(x3-x1);
			double b2 = 2*(y3-y1);
			double c2 = x1*x1+y1*y1-x3*x3-y3*y3;
			double x = (b1*c2-b2*c1)/(a1*b2-a2*b1);
			double y = (c1*a2-c2*a1)/(a1*b2-a2*b1);
			double r = Math.sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
			BigDecimal ax = new BigDecimal(x);
			BigDecimal ay = new BigDecimal(y);
			BigDecimal ar = new BigDecimal(r);
			double aax = ax.setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue();
			double aay = ay.setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue();
			double aar = ar.setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue();
			DecimalFormat df = new DecimalFormat("###.000");
			System.out.println(df.format(aax)+" "+df.format(aay)+" "+df.format(aar));
		}
	}
}

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

typedef long long int ll;


ll dp[3010][3010];
ll arr[3010];
ll n;

ll go(int i, int j){
    if(i > j)   return 0;
    if(dp[i][j] != -1)  return dp[i][j];
    return dp[i][j] = max(arr[i]-go(i+1,j),arr[j]-go(i,j-1));
}
int main(){
    memset(dp,-1,sizeof dp);
    ll k;
    scanf("%lld",&n);
    for(int i = 1; i <= n; i++){
        scanf("%lld",arr+i);
    }
    ll ans = go(1,n);
    printf("%lld\n",ans);
}


Measured memory_bytes: 71296
#include<bits/stdc++.h>
using namespace std;
long int n,a[4005],memo[4005],ans;

int main(){

     for(int i=0;i<=1000;i++){
        for(int j=0;j<=1000;j++){
            a[i+j]++;
        }
     }

    while(scanf("%d",&n)!=EOF){

    for(int i=0;i<4001;i++)memo[i]=0;

    for(int i=0;i<2001;i++){
        for(int j=0;j<2001;j++){
                memo[i+j]+=a[i]*a[j];
        }
    }
    cout << memo[n] << endl;

    }

return 0;
}

Measured memory_bytes: 3220
n, m = list(map(int, input().split()))
if n == m:
  print(0)
  exit()
h = list(map(int, input().split()))
maxi = sum(h)
f = [e for e in h]
# print(f)
for i in range(n - m - 1):
  for j in range(n - 1, i, -1):
    res = maxi
    for k in range(i, j):
      res = min(res, f[k] + max(0, h[j] - h[k]))
    f[j] = res
  # print(f)
print(min(f[n - m - 1:]))

Measured memory_bytes: 43356
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
  
typedef struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
}* Node;

void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);

Node root;

Node treeMinimum(Node x){
  
}

Node treeMaximum(Node x){

}

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

Node treeSuccessor(Node x){

}


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

  for ( i = 0; i < n; i++ ){
    scanf("%s", elm);
    if ( elm[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( elm[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( elm[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( elm[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

}

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

  z = malloc(sizeof(struct node));
  z->key = key;
  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){// T が空の場合
    root=z;
  }
  
  else if(z->key < y->key){// z を y の左の子にする
    y->left = z;
  }
  
  else y->right = z;// z を y の右の子にする


}

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

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



Measured memory_bytes: 20444
from collections import defaultdict
from copy import deepcopy
from math import log
from itertools import accumulate

N,C=map(int,input().split())
T=10**5+1
programs=defaultdict(list)
for i in range(N):
    s,t,c=map(int,input().split())
    programs[c].append((s,t))
imos=[0]*(T)
for c,p in programs.items():
    p.sort()
    ps,pt=p[0]
    for s,t in p[1:]:
        if pt==s:
            pt=t
            continue
        imos[ps-1]+=1
        imos[pt]-=1
        ps,pt=s,t
    imos[ps-1]+=1
    imos[pt]-=1
print(max(accumulate(imos)))


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

const int INF = pow(2, 31) - 1;
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)

int main() {
  int x, y;
  cin >> x >> y;
  int ans = x + y / 2;
  cout << ans << endl;
  return 0;
}


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

int main(){

    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0&&m==0)break;
        int r,q;
        cin >> r;
        vector<vector<int>> tt(m,vector<int>(1261,0));
        for(int i=0;i<r;i++){
            int t,pc,sid,s;
            cin >> t >> pc >> sid >> s;
            sid--;
            if(s==1){
                for(int j=t;j<1261;j++){
                    ++tt[sid][j];
                }
            }else{
                for(int j=t;j<1261;j++){
                    --tt[sid][j];
                }
            }
        }
        cin >> q;
        for(int i=0;i<q;i++){
            int s,e,sid;
            cin >> s >> e >> sid;
            sid--;
            int ans=0;
            for(int j=s;j<e;j++){
                if(tt[sid][j]>0){
                    ++ans;
                }
            }
            cout << ans << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 50824
///******* In the name of Allah *******///

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

long int gcd(long int a, long int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}

void Ok()
{
    long long int a,b,c,d[1013],e,f,g,h,t,i,j = 0,k,l1,l2,m,n,x,y,sum,ans_1,ans_2,ans_3,cnt,Max,Min,flag,div,rcv,temp;
    long double aa,bb,cc,dd,ee,ff,gg;
    char aaa[100013],bbb[1013],ccc[1013],alpbt;

    cin>>a>>b>>c;
    for(i=1;i<=10;i++)
    {
        c = a*c - b;
        cout<<c<<endl;
    }

    return;
}

int main()
{
    Ok();

    return 0;
}


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

int main()
{
    int a , b , ans ;
    char c ;
    while(cin >> a >> c >> b)
    {
        if(c == '?') break ;
        else if(c == '+') ans = a + b ;
        else if(c == '-') ans = a - b ;
        else if(c == '*') ans = a * b ;
        else if(c == '/') ans = a / b ;
        cout << ans << endl ;
    }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
#define MOD 998244353 //1000000007

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

    // solution comes here

    char S[10010];
    ll N;
    scanf("%lld %s", &N, S);
    ll size=strlen(S);
    rep(i, size){
        char c=(S[i] - 'A'+N)%26 + 'A';
        printf("%c", c);
    }
    printf("\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <string>
#define int long long
#define REP(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define mp make_pair
#define Pii pair< int, int > 
#define Pid pair< int, double > 
#define Pdd pair< double, double > 
#define MOD 998244353
#define EPS 0.00000001
#define MAX 200001

using namespace std;

signed main() {
    int n;
    cin >> n;
    vector<int> b(n);
    vector<int> a(n);
    REP(i,n) {
        int tmp;
        cin >> tmp;
        a[i] = tmp;
        b[tmp - 1]++;
    }
    int sum;
    REP(i,n) sum += b[i] * (b[i] - 1) / 2;
    REP(i,n) cout << sum - (b[a[i] - 1] - 1) << "\n";
    return 0;
}

Measured memory_bytes: 5760
n, p = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
od = a.count {|x| x % 2 != 0 }
ev = n - od

res = 0
d = 1
(0..od).each do |i|
  if i == 0
    d = 1
  else
    d *= (od + 1 - i)
    d /= i
  end

  if i % 2 == p
    res += d
  end
end

while ev > 0 && res > 0
  res *= 2
  ev -= 1
end

puts res

Measured memory_bytes: 14272
#include <stdio.h>

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

    if(x<1200 && x>=1)
        {
        printf("ABC\n");
        }

if(x>= 1200 && x<= 3000)
        {
        printf("ARC\n");
        }
    return 0;
}


Measured memory_bytes: 128
use std::collections::*;
// use std::io::prelude;
use std::io;
use std::io::Read;
use std::cmp::*;

fn main(){
    let t_cases = 1;
    for _ in 0..t_cases{
        solve();
    }
}

fn solve(){
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let a = buf
                .trim()
                .split_whitespace()
                .map(|x| x.parse::<i32>().unwrap())
                .collect::<Vec<i32>>();
    let (n,m) = (a[0],a[1]);
    buf.clear();
    io::stdin().read_to_string(&mut buf).unwrap();
    // println!("{}",buf);
    let mut dp = vec![0i64;(m+1) as usize];
    // println!("{}",m);
    for line in buf.trim().lines(){
        let a = line
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse::<i32>().unwrap())
                    .collect::<Vec<i32>>();
        // println!("{}",line);
        for i in (1..(m+1)).rev(){
            if i>=a[0]{
                dp[i as usize] = max(dp[i as usize],dp[(i-a[0]) as usize]+a[1] as i64);
            }
        }
    }
    println!("{}",dp[m as usize]);
}

Measured memory_bytes: 4352
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a,b,c,d;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d)
	cout<<"Yes";
	else if(abs(a-b)<=d&&abs(b-c)<=d)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int a[50][3];
	int i, j, k;
	for (i = 0; i < 50; i++) {
		for (j = 0; j < 3; j++) {
			scanf("%d", &a[i][j]);
		}
		if (j == 3 && a[i][0] == -1 && a[i][1] == -1) {
			break;
		}
	}
	for (j = 0; j < i; j++) {
		k = a[j][0] + a[j][1];
		if (a[j][0] == -1 || a[j][1] == -1) puts("F");
		else if (k >= 80) puts("A");
		else if (k >= 65) puts("B");
		else if (k >= 50) puts("C");
		else if (k >= 30) {
			if (a[j][2] >= 50) puts("C");
			else puts("D");
		}
		else puts("F");
	}
	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	string s;
	char ch[4] = {'.', '?', '!', ' '};
	while(cin >> s) {
		if(s.length()%2!=0) {
			cout << "NA" << endl;
			continue;
		}
		string ret;
		bool f = 0;
		rep(i,s.length()/2) {
			int x = s[2*i]-'0';
			if(x<1 || 6<x) {
				f = 1;
				break;
			}
			int y = s[2*i+1]-'0';
			if(y<1 || 5<y) {
				f = 1;
				break;
			}
			int code = (x-1)*5+y; 
			if(code<=26) ret += (char)('a'+code-1);
			else ret += ch[code-27];
		}
		if(f) cout << "NA" << endl;
		else cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int n;
int t[20000];

bool check(int a,int b){
	int now=a*b;
	int keta[100];
	int pos=0;
	rep(i,100)keta[i]=0;

	while(now>0){
		keta[pos++]=now%10;
		now/=10;
	}
	int d=keta[0];
	rep(i,pos){
		if(d-i!=keta[i])return 0;
	}
	return 1;
}
int main(){
cin>>n;
rep(i,n)cin>>t[i];
int ans=-1;
for(int i=0;i<n;i++){
	for(int j=i+1;j<n;j++){
		if(check(t[i],t[j]))ans=max(ans,t[i]*t[j]);
	}
}
cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>

int main(void){
    int a,b,c,n;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b||b==c||c==a){
        n=2;
        if(a==b&&a==c)n=1;
    }else{
        n=3;
    }
    printf("%d",n);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

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

    if(n/h > n/w){
        if(n%w == 0){
            ans = n/w;
        } else {
            ans = n/w+1;
            } 
    } else {
        if(n%h == 0){
            ans = n/h;
        } else {
            ans = n/h+1;
        }
    }
    printf("%d\n", ans);
return 0;
}

Measured memory_bytes: 1692
#include <iostream>
#include <algorithm>
using namespace std;
int mp[101][101];
bool flg[101] ={};
int n,q;
int dis[101];

int sssp(int s,int g) {
  for(int i=1;i<=n;i++) dis[i] = 1000000000,flg[i] = 0;
  //flg[s] = 1;
  dis[s] = 0;
  int ima;

  while(1) {
    int mindis = 1000000000;
   
    for(int i=1;i<=n;i++)
      if(mindis > dis[i] && flg[i] == 0) {
	ima = i;
	mindis = dis[i];
      }

    if(mindis == 1000000000) return -1;    
    flg[ima] = 1;
    if(ima == g) return dis[ima];


    for(int i=1;i<=n;i++) 
      if(dis[i] >dis[ima] + mp[ima][i] && mp[ima][i] != -1) 
	dis[i] = dis[ima]+mp[ima][i];
    
  }

  return dis[g];
}


int main() {

  while(1) {
  cin >> n >> q;
  if(n == 0 && q == 0) break;

  for(int i=0;i<=n;i++){ 
    //    dis[i] = 1000000000;
    //flg[i] = 0;
    for(int j=0;j<=n;j++)
      mp[i][j] = -1; 
  }

  bool sta;
  int s,g,c;
  for(int i=0;i<q;i++) {
    cin >> sta;
    if(sta == 0) {
      cin  >> s >> g;
      //for(int i=1;i<=n;i++) if(mp[s][i] !=-1)dis[i] = mp[s][i];
      int ans = sssp(s,g);
      cout << ans<< endl;
    }
    else {
      cin >> s >> g >> c;
      if(mp[s][g] != -1) {
	mp[s][g] = min(c ,mp[s][g]);
	mp[g][s] = min( mp[g][s] ,c);      
      }
      else {
	mp[s][g] = c;
	mp[g][s] = c;
      }
      
    }
  }
  }
  
  
  return 0;
  
  }
      

Measured memory_bytes: 1200
#include<iostream>
#include<bitset>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
    }
  bitset<4000000> s;
  s=1;
  for(int i=0;i<n;i++)
    s|=s<<a[i];
  int u=(sum+1)/2;
  for(int i=u;i<=sum;i++){
    if(s[i]){
      cout<<i<<endl;
      return 0;
      }
    }
  }


Measured memory_bytes: 1664
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}

#define QUERY_MAX 100000
#define NUM_MAX (1<<17)

enum {
    COMMAND_ADD,
    COMMAND_GET_SUM,
};

struct range {
    int start;
    int end;
};

void add(int *seg, int num, int idx, int x) {
    int node = num + idx;
    while(node) {
        seg[node] += x;
        node /= 2;
    }
    return;
}

int is_overlap(struct range r1, struct range r2) {
    return r1.end >= r2.start && r2.end >= r1.start;
}

int is_contain(struct range r, struct range in) {
    return r.end <= in.end && in.start <= r.start;
}

int64_t get_sum(int *seg, struct range target, int node, struct range this) {
#ifdef DEBUG
    printf("get_sum(seg, (%d,%d), %d, (%d,%d))\n", target.start, target.end, node, this.start, this.end);
#endif
    if(!is_overlap(target, this)) return 0;
    if(is_contain(this, target)) {
        return seg[node];
    }
    // if overlap
    struct range left = { this.start, (this.start+this.end)/2 };
    struct range right = { left.end+1, this.end };
    int64_t s1 = get_sum(seg, target, node*2, left);
    int64_t s2 = get_sum(seg, target, node*2+1, right);
    return s1 + s2;
}

#define ROOT_NODE 1

int main(void) {
    int _num, queries;
    get_int2(&_num, &queries);
    int num = 1;
    while(_num > num) num*=2;
    static int seg[NUM_MAX*2];
    static int64_t ans[QUERY_MAX];
    int aidx = 0;
    int i;
    struct range whole = {0, num-1};
    for(i = 0; i < queries; i++) {
        int type; int arg1, arg2;
        get_int3(&type, &arg1, &arg2);
        switch(type) {
            case COMMAND_ADD:
                {
                    int idx = arg1; int x = arg2;
                    // idx: 1-indexed -> 0-indexed
                    idx--;
                    add(seg, num, idx, x);
                }
                break;
            case COMMAND_GET_SUM:
                {
                    struct range r = {arg1-1, arg2-1};
                    ans[aidx++] = get_sum(seg, r, ROOT_NODE, whole);
                }
                break;
            default:
                break;
        }
    }

    for(i = 0; i < aidx; i++) {
        printf("%lld\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 2988
n,m=map(int,input().split())
p=[input().split() for i in range(m)]
AC=[int(0) for i in range(n)]
WA=[int(0) for i in range(n)]
for i in range(m):
  s=int(p[i][0])-1
  if p[i][1]=="WA" and AC[s]==0:
    WA[s]+=1
  if p[i][1]=="AC" and AC[s]==0:
    AC[s]+=1
for i in range(n):
  if AC[i]==0:
    WA[i]=0
print(sum(AC)," ",sum(WA))

Measured memory_bytes: 33856
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
    public class Point
    {
        public double x;
        public double y;
    }


    class Program
    {
        static void Main(string[] args)
        {
            List<Point> pointList = new List<Point>();

            string input;
            while ((input = Console.ReadLine()) != null)
            {
                string[] array = input.Split(',');

                Point tmp = new Point();
                tmp.x = double.Parse(array[0]);
                tmp.y = double.Parse(array[1]);

                pointList.Add(tmp);
                
            }

            int n = pointList.Count();

            double area = 0;

            for (int i = 0; i < n - 2; i++)
            {
                area += GetTriangleArea(pointList[i], pointList[i + 1], pointList[n - 1]);
            }

            Console.WriteLine(area);


        }

        static double GetTriangleArea(Point A, Point B, Point C)
        {
            double a = GetLong(B, C);
            double b = GetLong(C, A);
            double c = GetLong(A, B);

            double z = (a + b + c) / 2;

            double S = Math.Sqrt(z * (z - a) * (z - b) * (z - c));

            return S;
        }

        static double GetLong(Point A, Point B)
        {
            return Math.Sqrt(Math.Pow(B.x - A.x, 2) + Math.Pow(B.y - A.y, 2));
        }
    }
}

Measured memory_bytes: 5968
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=8000;
const long INF=1e9;
int main(){
	int N;cin>>N;
	int A[101]={};
	rep(i,1,10)rep(j,1,10) if(i*j<101) A[i*j]++;
	if(A[N]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

namespace {
struct Pos {
  int x, y;
  Pos() = default;
  constexpr Pos(int x_, int y_) : x(x_), y(y_) {}
  constexpr Pos& operator+=(const Pos& rhs) {
    x += rhs.x, y += rhs.y;
    return *this;
  }
  constexpr Pos& operator*=(int rhs) {
    x *= rhs, y *= rhs;
    return *this;
  }
};
Pos operator+(Pos lhs, const Pos& rhs) { return lhs += rhs; }
Pos operator*(Pos lhs, int rhs) { return lhs *= rhs; }
}  // namespace

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int H, W, K;
  cin >> H >> W >> K;
  Pos s, g;
  cin >> s.y >> s.x >> g.y >> g.x;
  s += Pos(-1, -1);
  g += Pos(-1, -1);
  vector<string> field(H);
  for (auto& e : field) cin >> e;
  constexpr array<Pos, 4> Dir = {{
      Pos(0, 1),
      Pos(0, -1),
      Pos(1, 0),
      Pos(-1, 0),
  }};
  constexpr int kInf = INT_MAX;
  vector<vector<int>> rec(H, vector<int>(W, kInf));
  queue<Pos> q;
  rec[s.y][s.x] = 0;
  q.push(s);
  while (!q.empty()) {
    Pos cur = q.front();
    q.pop();
    for (const auto& dir : Dir) {
      for (int i = 1; i <= K; ++i) {
        Pos nxt = cur + dir * i;
        if (nxt.x < 0 || W <= nxt.x || nxt.y < 0 || H <= nxt.y) continue;
        if (field[nxt.y][nxt.x] == '@') break;
        if (rec[nxt.y][nxt.x] <= rec[cur.y][cur.x]) break;
        if (rec[nxt.y][nxt.x] <= rec[cur.y][cur.x] + 1) continue;
        rec[nxt.y][nxt.x] = rec[cur.y][cur.x] + 1;
        q.push(nxt);
      }
    }
  }
  for (auto& row : rec)
    for (auto& e : row)
      if (e == kInf) e = -1;
  cout << rec[g.y][g.x] << '\n';
}


Measured memory_bytes: 12168
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

bool A[2001] = {true};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t;
    cin>>n;
    for(int i=0; i<n; i++) {
        cin>>t;
        for(int j=2000-t; j>=0; j--) {
            if(A[j]) A[j+t]=true;
        }
    }
    cin>>n;
    for(int i=0; i<n; i++) {
        cin>>t;
        if(A[t]) cout<<"yes\n";
        else cout<<"no\n";
    }
    return 0;
}

Measured memory_bytes: 1172
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if a<b:
    if a+v*t>=b+w*t:
        print('YES')
    else:
        print('NO')
else:
    if b-w*t>=a-v*t:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
// 座標圧縮(map実装)
map<ll,int> zip; // zipではない 定数倍重めなので二分探索が必要ないならunordered_map実装を
map<int,ll> un_zip;
void zip_in(vector<ll>& a){
  for(auto &i:a) zip[i] = 1;
  int cnt = 1; // 好みだけど0はエラー検出のために利用しない方がよさげ
  for(auto &p:zip){ // ちゃんと参照渡しにしよう（2敗）
    p.second = cnt++;
    un_zip[p.second] = p.first;
  }
  /*
    DEB;
    for(auto a: zip) SHOW(a.first,a.second);
    for(auto a: un_zip) SHOW(a.first,a.second);
  */
}
bool area[250][250]={};

int main(){
  int n;
  while(cin>>n,n){
    zip.clear();
    un_zip.clear();
    rep(i,250)rep(j,250)  area[i][j] = 0;
    vector<int>x(n),y(n);
    vector<long long>x2(2*n);
    vector<int>cx,cy;
    for(int i=0;i<n;i++){
      cin>>x[i]>>y[i];
      x2[i]=x[i];
      x2[i+n]=y[i];
    }
    for(int i=0;i<4;i++){
      int a,b;cin>>a>>b;
      cx.pb(a);
      cy.pb(b);
      x2.pb(a);
      x2.pb(b);
    }
    x2.pb(-1000000);
    x2.pb(1000000);
    sort(x2.begin(),x2.end());
    zip_in(x2);
    for(int i=0;i<n;i++){
      area[zip[x[i]]][zip[y[i]]]=1;
    }
    for(int i=0;i<250;i++){
      int cnt=0;
      for(int j=0;j<250;j++){
	if(area[i][j]==1)
	  cnt++;
	if(cnt%2==0){
	  area[i][j]=0;
	}else{
	  area[i][j]=1;
	}
      }
    }
    for(int i=0;i<250;i++){
      int cnt=0;
      for(int j=0;j<250;j++){
	if(area[j][i]==1)
	  cnt++;
	if(cnt%2==0){
	  area[j][i]=0;
	}else{
	  area[j][i]=1;
	}
      }
    }
    ll ans=0;
    for(int i=0;i<249;i++){
      for(int j=0;j<249;j++){
	int ax=un_zip[i];
	int ay=un_zip[j];
	int bx=un_zip[i+1];
	int by=un_zip[j+1];
  
	int min_x = min(cx[0],cx[2]);
	int min_y = min(cy[0],cy[2]);
	int max_x = max(cx[0],cx[2]);
	int max_y = max(cy[0],cy[2]);
  
	if(area[i][j]){
	  if(min_x <= ax && max_x >= bx && min_y <= ay && max_y >= by)
            ;
	  else ans+=(bx-ax)*(by-ay);
	}
      }
    }
    //rep(i,20){rep(j,20)cerr <<area[i][j];cerr << endl;}
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3228
import os
import sys
from io import BytesIO, IOBase


def main():
    n, x, t = map(int, input().split())
    lol = n // x
    if n % x:
        print(t*(lol+1))
    else:
        print(t*lol)
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

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

using namespace std;

int main() {
    int x, t = 0, left;
    cin >> x;
    t = x / 100;
    left = x % 100;
    if (left >= 0 && left <= 5 * t) {
        cout << "1\n";
    } else {
        cout << "0\n";
    }
    return 0;
}

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

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

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=1e5+5,mod=1e9+7,bit=61;



signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll x;
        cin>>x;
        ll ans=1000*(x/500)+5*((x%500)/5);
        cout<<ans<<endl;
    }
    return 0;
}


















Measured memory_bytes: 256
using System;

namespace Tax_Increase
{
    class Program
    {
        static void Main(string[] args)
        {
            String input = Console.ReadLine();
            String[] splitted = input.Split(' ');
            int A = int.Parse(splitted[0]);
            int B = int.Parse(splitted[1]);

            int taxA, taxB;
            int answer = -1;
            for(int i = 0; i <= 1250; i++)
            {
                taxA = (int)(i * 0.08);
                taxB = (int)(i * 0.1);
                if (taxA == A && taxB == B)
                {
                    answer = i;
                    break;
                }
            }
            Console.WriteLine(answer);
        }
    }
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int ans[100000];
	fill(ans, ans + 100000, 0);

	string s;
	cin >> s;
	s += 'R';

	int r_cnt = 0;
	int l_cnt = 0;
	for (int i = 0; i < s.length(); ++i)
	{
		if (s[i] == 'R')
		{
			r_cnt++;
		}
		else if (s[i] == 'L')
		{
			l_cnt++;
		}
		if (s[i] =='L' && s[i + 1] == 'R')
		{
			for(int i = 0; i < r_cnt - 1; ++i) cout << "0 ";
			cout << (r_cnt + 1) / 2 +  l_cnt      / 2 << " ";
			cout <<  r_cnt      / 2 + (l_cnt + 1) / 2 << " ";
			for(int i = 0; i < l_cnt - 1; ++i) cout << "0 ";

			r_cnt = 0;
			l_cnt = 0;
		}
	}


}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 4172
a=int(input())
divisors = []
for i in range(1, int(a**0.5)+1):
  if a % i == 0:
    divisors.append(i)
    if i != a // i:
      divisors.append(a//i)

c=len(divisors)
if c%2==0:
  print(divisors[c-1]+divisors[c-2]-2)
else:
  print(divisors[c-1]*2-2)

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

int main(){
  int n=5;  vector<ll> a(n);
  ll people;  cin >> people;
  for(int i=0; i<n; i++)  cin >> a.at(i);
  sort(a.begin(), a.end());

  cout << people/a[0]+min(1LL, people%a[0])+4 << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;


int main(){
	int n; cin>>n;
	int a = 0,b = 0;
	int val[n], cost[n];
	for (int i = 0; i < n; i++){
		cin>>val[i];
	}
	for (int i = 0; i < n; i++){
		cin>>cost[i];
	}
	for(int i=0; i<n; i++){
		if(val[i]-cost[i]>0){
			a+=val[i];
			b+=cost[i];
		}
	}
	cout<<a-b<<endl;	
}


Measured memory_bytes: 3620
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
//	freopen("1.txt","r",stdin);
	string s1,s2;
	int minn = 1010,index=-1;
	cin>>s1>>s2;
	for(int i=0;i<=s1.size()-s2.size();i++){
		int sum=0;
		for(int j=0;j<s2.size();j++){
			if(s1[i+j]!=s2[j]) sum++;
		}
		if(sum<minn){
			minn = sum;
			index=i;
		}
	}
	cout<<minn<<endl;
	return 0;
}




Measured memory_bytes: 3628
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll K;
    cin >> K;
    string S;
    cin >> S;
    ll N = S.size();
    if(N <= K){
        print(S);
    }else{
        cout << S.substr(0,K) << "..." << endl;
    }


}

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

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long Int;
int main(){
  vector<Int> v;
  Int n,k;
  cin>>n>>k;
  for(Int i=0;i<n;i++){
    Int a;
    cin>>a;
    v.push_back(a);
  }
  sort(v.begin(),v.end());
  Int ans=2000000000000;
  for(Int i=0;i<=n-k;i++){
    ans=min(ans,v[i+k-1]-v[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int cnt[100005],ans;
int n; 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	forn(i,n)
	{
		int x;
		cin>>x;
		if(x>100000)continue;
		cnt[x]++;
	}
	forn(i,100001)
		if(cnt[i]>=i)ans+=i;
	cout<<n-ans<<endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

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

int main(){
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	printf("%d\n", min(n*a, b));
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main() { 
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll x;
	cin >> n >> x;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0;
	if (a[0] > x) {
		ans += a[0] - x;
		a[0] = x;
	}
	rep(i, n - 1) {
		if (a[i] + a[i + 1] > x) {
			ans += a[i] + a[i + 1] - x;
			a[i + 1] = x - a[i];
		}
	}
	cout << ans << "\n";
	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli k, a, b;
  while (cin >> k >> a >> b) {
    unless (a + 2 < b) {
      cout << k + 1 << endl;
      continue;
    }
    
    if (k + 1 <= a) {
      cout << k + 1 << endl;
      continue;
    }

    k -= a - 1;
    cout << a + (b - a) * (k / 2) + (k % 2) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import math
import bisect
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

Q = int(input())
lr_list = [list(map(int,input().split())) for _ in range(Q)]
flags = [False] * (10 ** 5)


for i in range(1, 10 ** 5 + 1, 2):
    if not flags[i]:
        flag1 = is_prime(i)
        flag2 = is_prime((i + 1) // 2)
        if flag1 and flag2:
            flags[i] = True
True_idxs = []
for i in range(len(flags)):
    if flags[i]:
        True_idxs.append(i)

# print(True_idxs)

for l, r in lr_list:
    l_idx = bisect.bisect_left(True_idxs, l)
    r_idx = bisect.bisect_right(True_idxs, r)
    print(r_idx - l_idx)

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

int n, m, h1[101], w1[101], h2[101], w2[101], dp[101][101];

int max(int a, int b){
    return a > b ? a : b;
}

int main(void){
    int x, y;
    while(scanf("%d", &n) != EOF && n){
        h1[0] = w1[0] = h2[0] = w2[0] = 0;
        for(x = 1; x <= n; x++){
            scanf("%d%d", h1+x, w1+x);
        }
        scanf("%d", &m);
        for(x = 1; x <= m; x++){
            scanf("%d%d", h2+x, w2+x);
        }
        for(x = 0; x <= n; x++){
            for(y = 0; y <= m; y++){
            }
        }
        dp[0][0] = 0;
        for(x = 0; x <= n; x++){
            memset(dp[x], 0, sizeof(dp[x]));
        }
        for(x = 0; x <= n; x++){
            for(y = 0; y <= n; y++){
                if(x){
                    dp[x][y] = max(dp[x][y], dp[x-1][y]);
                    if(h1[x] > h2[y] && w1[x] > w2[y]){
                        dp[x][y] = max(dp[x][y], dp[x-1][y] + 1);
                    }
                }
                if(y){
                    dp[x][y] = max(dp[x][y], dp[x][y-1]);
                    if(h1[x] < h2[y] && w1[x] < w2[y]){
                        dp[x][y] = max(dp[x][y], dp[x][y-1] + 1);
                    }
                }
            }
        }
        printf("%d\n", dp[n][m]);
    }
    return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

int vector_max(vector<int> &vec){
    
    int maximum =vec.at(0);
    for(int i =1; i < vec.size() ; i++){
        
        maximum = max(maximum,vec.at(i));
    }
    
    return maximum;
}

int vector_min(vector<int> &vec){

    int minimum =vec.at(0);
    for(int i =1; i < vec.size() ; i++){
        
        minimum = min(minimum,vec.at(i));
    }

    
    return minimum;
}

int main(){
    int N,M;

    cin >> N >> M;

    vector<int> L(M),R(M);
    int mini,maxi; 
    for(int i =0; i<M; i++){
        cin >> L.at(i) >> R.at(i);  
        
        if(i==0){
            maxi = L.at(0);
            mini = R.at(0);
        }else{
            maxi=max(maxi,L.at(i));
            mini=min(mini,R.at(i));
        }
        
    }

    int c=0;

    for(int i=maxi; i<=mini; i++){
        c++;
    }

    cout << c << endl;



}


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

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

	int q, com, x;
	string key;
	map<string, int> my_map;

	cin >> q;
	while (q--) {
		cin >> com >> key;
		if (com == 0) {
			cin >> x;
			my_map[key] = x;
		} else if(com == 1) {
			cout << my_map[key] << endl;
		} else {
			my_map[key] = 0;
		}
	}
}


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

int main(void) {
    int a, b, ans;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    if (a >= 13) {
        ans = b;
    } else if (a >= 6) {
        ans = b / 2;
    } else {
        ans = 0;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b = map(int, input().split())
    # 素因数分解
    def prime_decomp(n):
        i = 2
        res = []
        while i ** 2 <= n:
            while n % i==0:
                n //= i
                res.append(i)
            i += 1
        if n > 1:
            res.append(n)
        return res

    c = set(prime_decomp(a))
    d = set(prime_decomp(b))
    print(len(c&d)+1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38768
/*  Name: Abu Hurayra
    Handle: HurayraIIT
    Institute: IIT_JU   */

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

typedef long long LL;
typedef string S;
typedef double D;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;

#define pi acos(-1.0)
#define endl '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define Fin freopen("input.txt","r",stdin)
#define Fout freopen("output.txt","w",stdout)

int main()
{
	off;
    
    int a,b,i;
    cin >> a >> b;
    
    int l = max(-1000000,b-a+1);
    int r = min(1000000,b+a-1);
    
    for(i=l;i<=r;i++)
    {
        if(i!=l) cout << " ";
        cout << i << endl;
    }

    


	return 0;

}



Measured memory_bytes: 256
n_and_m = list(map(int, input().split()))
n = n_and_m[0]
m = n_and_m[1]
items = list(map(int, input().split()))
REQUIRED = ( 1 / (4*m) ) * sum(items)
flag = 0

for item in items:
    if item >= REQUIRED:
        flag += 1

        

if flag >= m:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let r: i32 = read();
    println!("{}", r * r);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main(){
  string S;
  cin >> S;
  bool C = false,ans = false;
  for (int i = 0; i < S.size(); i++){
    if (S.at(i) == 'C') C = true;
    if (C && S.at(i) == 'F') ans = true;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int[] xs = new int[N];
        for (int i = 0; i < N; i++) {
            xs[i] = sc.nextInt();
        }
        System.out.println( solve(N, A, xs) );
    }

    private static long solve(int N, int A, int[] xs) {
        long[][] dp = new long[N + 1][A*N + 1];
        dp[0][0] = 1;
        for (int i = 0; i < N; i++) {
            int x = xs[i];
            calc(dp, N, A, x);
        }

        long sum = 0;
        for (int n = 1; n <= N; n++) {
            sum += dp[n][n * A];
        }
        return sum;
    }

    private static void calc(long[][] dp, int N, int A, int x) {
        for (int i = N; i > 0; i--) {
            for (int j = 0; j <= N*A; j++) {
                if( j - x >= 0 ) {
                    dp[i][j] += dp[i-1][j-x];
                }
            }
        }
    }

    private static void show(int[] array) {
        StringJoiner j = new StringJoiner(" ");
        for (int i : array) {
            j.add(String.valueOf(i));
        }
        System.err.println(j.toString());
    }
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int a,b;
  cin >> a >> b;
  int ans = 0;
  ans = max(a,b);
  if(a>b){
    ans += max(a-1,b);
  }
  else{
    ans += max(a,b-1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a ,b;
	for (int i = 1;; i++){
		scanf("%d %d", &a,&b);
		if (a == 0 && b == 0) break;
		else if (a < b)
			printf("%d %d\n", a, b);
		else
			printf("%d %d\n", b, a);
	}
}


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

using namespace std;

typedef long long LL;

#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define LEN(a) int((a).size())
#define SORT(a) sort((a).begin(), (a).end())
#define CLR(a) memset((a), 0, sizeof(a))

const double EPS = 1e-10;

int main() {
    int x, a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ini(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll long long

int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//ll tt;	cin>>tt;	while(tt--)
	{
		ll n,a,b,i;
		cin>>a>>b>>n;

			if(b-1>n)	i=n;
			else	i=b-1;
			cout<<((a*i)/b) - (a*(i/b))<<endl;
 	}
	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
		
		
return 0;
}

Measured memory_bytes: 3820
#include<cstdio>

char s[200000];
int t[500000];

int main(void) {
    int n,k;
    scanf("%d%d",&n,&k);
    k = 2*k+1;
    scanf("%s",s);

    char last = '0';
    int j=2;
    for(int i=0; i<n; i++) {
        if(s[i] == last) {
            t[j]++;
        } else {
            t[++j] = 1;
            last = s[i];
        }
    }
    ++j;
    j+=2*k+10;

    for(int i=0; i<j; i++) {
        /* printf("%d ", t[i]); */
        t[i+1] += t[i];
    }
        /* printf("\n"); */

    int m = 0;
    for(int i=0; i+k<j; i+=2) {
        if(m < t[i+k]-t[i]) m = t[i+k]-t[i];
    }
    printf("%d\n", m);
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 1000005
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef map<ll, ll> Map;

int main(void) {
    ll N;
    ll p[20001];
    ll a[20001], b[20001];
    ll i;
    ll M=20010;
    
    cin >> N;
    for(i=0; i<N; i++) {
        cin >> p[i];
        p[i]--;
    }
    
    for(i=0; i<N; i++) {
        a[i]=M*i+1;
        b[i]=(N-i)*M;
    }
    
    for(i=0; i<N; i++) {
        a[p[i]]+=i;
    }
    
    
    for(i=0; i<N; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
    
    for(i=0; i<N; i++) {
        cout << b[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    int N;
    cin >> N;
    LL sa=0,sb=0;
    LL ca=0,cb=0;
    LL a[N],b[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
        sa+=a[i];
    }
    for(int i=0;i<N;i++){
        cin >> b[i];
        sb+=b[i];
    }
    for(int i=0;i<N;i++){
        if(b[i]>a[i]) cb+=(b[i]+1-a[i])/2;
        else if(b[i]<a[i]) ca+=a[i]-b[i];
    }
    (max(ca,cb)<=sb-sa) ? puts("Yes"):puts("No");
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(){
    int h, w, n;
    scanf("%d", &h);
    scanf("%d", &w);
    scanf("%d", &n);
    
    int big;
    if(h>w){
        big = h;
    }
    else{
        big = w;
    }
    
    n%big ? printf("%d\n", n/big+1) : printf("%d\n", n/big);
    
    return 0;
}


Measured memory_bytes: 1708
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)

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

  int ans = 0;
  rep(i, s.length()) {
    if (s[i] == t[i]) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
def function(args):
    X = int(args)
    ureshisa = 0
    div, mod = divmod(X,500)
    ureshisa += div*1000
    div, mod = divmod(mod,5)
    ureshisa += div*5
    
    return str(ureshisa)

if __name__ == '__main__':
    print(function(input()))


Measured memory_bytes: 2940