akhauriyash/Code-Regression huggingface dataset:
import sys
from math import sqrt
from collections import Counter

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n = I()
    d = LIN(n)

    print(len(set(d)))
    pass


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
import java.util.Scanner;
class Main{
	static Scanner s=new Scanner(System.in);
	static int gInt(){return Integer.parseInt(s.next());};
	public static void main(String[]$){
		int[]v=s.next().chars().map(i->i-'0').toArray();
		int a=v[0];
		int b=v[1];
		int c=v[2];
		int d=v[3];

		if(a+b+c+d==7) {o("+","+","+",a,b,c,d);return;}
		if(a-b+c+d==7) {o("-","+","+",a,b,c,d);return;}
		if(a+b-c+d==7) {o("+","-","+",a,b,c,d);return;}
		if(a+b+c-d==7) {o("+","+","-",a,b,c,d);return;}
		if(a-b-c+d==7) {o("-","-","+",a,b,c,d);return;}
		if(a-b+c-d==7) {o("-","+","-",a,b,c,d);return;}
		if(a+b-c-d==7) {o("+","-","-",a,b,c,d);return;}
		if(a-b-c-d==7) {o("-","-","-",a,b,c,d);return;}
	}
	static void o(String s1,String s2,String s3,int a,int b,int c,int d){
		System.out.println(a+s1+b+s2+c+s3+d+"=7");
	}
}


Measured memory_bytes: 28244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n+1);
    vector<ll> s1(n+1,0),s2(n+1,0);
    FOR(i,1,n+1){
      cin>>a[i];
      s1[i]=s1[i-1]+a[i];
      if(a[i]>0) s2[i]=s2[i-1]+a[i];
      else s2[i]=s2[i-1];
    }
    ll ans=0;
    //cout_vec(s2);
    FOR(i,1,n+1){
      if(i+k-1>n) break;
      //cout<<i<<' '<<s1[i+k-1]-s1[i-1]<<' '<<s2[i-1]<<' '<<s2[n]-s2[i+k-1]<<endl;
      ans=max(ans,s1[i+k-1]-s1[i-1]+s2[i-1]+s2[n]-s2[i+k-1]);
      ans=max(ans,s2[i-1]+s2[n]-s2[i+k-1]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main{
    boolean[] prm;
    final int mx = 10001;

    void mkPrm(){
	prm = new boolean[mx];
	for(int i = 0; i < mx; i++) prm[i] = true;
	prm[0] = prm[1] = false;

	for(int i = 0; i < mx; i++)
	    if(prm[i])
		for(int j = i+i; j < mx; j+=i) prm[j] = false;

	return ;
    }

    Main(){
	Scanner sc = new Scanner(System.in);
	mkPrm();

	while(sc.hasNext()){
	    int n = sc.nextInt(), cnt = 0;

	    for(int i = 0; i < n; i++)
		if(prm[i+1] && prm[n-i]) cnt++;

	    System.out.println(String.valueOf(cnt));
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 12000
#![allow(unused)]

use std::cmp::{max, min};
use std::io::stdin;
use std::str::FromStr;

fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse()
}

fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse())
        .collect()
}

fn main() {
    let (a, p): (usize, usize) = {
        let tmp = input_vec().unwrap();
        (tmp[0], tmp[1])
    };

    let p = p + 3 * a;
    let ans = p / 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

template <int N>
struct union_find {
    int len;
    int parent[N];

    union_find(int N_) {
        assert(N_ <= N);
        len = N_;
        fill(parent, parent+len, -1);
    }

    int find(int x) {
        if (parent[x] < 0) return x;
        return parent[x] = find(parent[x]);
    }

    bool unite (int x, int y) {
        int rx = find(x), ry = find(y);
        if (rx == ry) return false;

        if (parent[rx] < parent[ry]) {
            parent[rx] += parent[ry];
            parent[ry] = rx;
        } else {
            parent[ry] += parent[rx];
            parent[rx] = ry;
        }
        return true;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return - parent[find(x)];
    }
};

struct edge {
    int from, to, weight;
    edge() {}
    edge(int a, int b, int c): from(a), to(b), weight(c) {}

    bool operator < (const edge& o) const {
        return weight < o.weight;
    }
};

constexpr int LIM = 10005;

int N, M;
vector<edge> graph;

int solve () {
    int ret = LIM;

    for (int lw = 1; lw <= LIM; ++lw) {
        union_find<LIM> uf(N);
        int max_weight = -1;
        for (const edge& e: graph) {
            if (e.weight < lw) continue;
            if (!uf.same(e.from, e.to)) uf.unite(e.from, e.to);
            if (uf.size(0) == N) {
                max_weight = e.weight;
                break;
            }
        }
        if (max_weight >= 1) {
            ret = min(ret, max_weight - lw);
        }
    }

    return ret != LIM ? ret : -1;
}

int main() {
    while (true) {
        cin >> N >> M;
        if (N == 0 && M == 0) break;
        graph.clear();
        for (int j = 0; j < M; ++j) {
            int a, b, w;
            cin >> a >> b >> w;
            --a; --b;
            graph.emplace_back(a, b, w);
        }
        sort(begin(graph), end(graph));
        cout << solve() << endl;
    }
    return 0;
}

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

int k, m, n;
string s = "1122", t = "";
vector<int> v(4);

int main(){
    for (int i = 0; i++ < 6;){
        cin >> m;
        v[m - 1]++;
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < 4; i++) t = t + to_string(v[i]);
    cout << (s == t ? "YES" : "NO") << endl;
}


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

#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define lg long long
#define db double
#define lb(x) ((x)&-(x))
#define ft first
#define sd second

#define HII cerr<<"HI"<<endl
#define LLLINE cerr<<"@@@@@@@@@@@@@@@@@@@@"<<endl

template <class _T_>
void read(_T_& d){
	d=0;int f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f*=-1;
	for(;c>='0'&&c<='9';c=getchar())d=d*10+c-'0';
	d*=f;
}

/************************************************/
#define MN 500005
int n,m;
int a[MN];
int lbd[MN];
int main(){
	read(n);read(m);n*=2;
	for(int i=1;i<=n;++i)read(a[i]);
	sort(a+1,a+n+1);a[n+1]=m;
	for(int i=n;i;--i){
		int L=0,R=n+1;
		while(L<R){
			int mid=L+R>>1;
			if(a[mid]+a[i]>=m)R=mid;else L=mid+1;
		}
		lbd[i]=L;
	}
	int li=0,hi=0;
	for(int i=n;i;--i){
		hi=max(hi+1,lbd[i]);
		li=max(hi+i-n-1,li);
	}
	if((li&1))++li;
	int res=0;
	for(int i=1;i<=li;++i)res=max(res,a[i]+a[li-i+1]);
	for(int i=li+1;i<=n;++i)res=max(res,a[i]+a[n-i+li+1]-m);
	cout<<res;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
	int n, m;
	int a[101], b[101][101], s[101];

	cin >> n >> m;

	for (int i = 1; i <= m; i++)
		cin >> a[i];

	for (int i = 1; i <= m; i++)
		for (int j = 1; j <= n; j++)
			cin >> b[i][j];

	memset(s, 0, sizeof(s));

	for (int i = 1; i <= m; i++) {

		s[a[i]] += n;

		for (int j = 1; j <= n; j++) {
			if (j != a[i] && b[i][j] == a[i]) {
				s[j]++;
				s[a[i]]--;
			}
		}
	}

	for (int i = 1; i <= n; i++)
		cout << s[i] << endl;

	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long n;
    cin >> n;
    vector<long> l(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
        l[i]--;
    }
    long cnt = 0;
    for(int i = 0; i < n; i++){
        if(i == l[l[i]]) cnt++;
    }
    cnt /= 2;
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

int n,num[200010],cnt_R;

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	char c;
    	cin>>c;
    	if(c=='R')
    	{
    		num[i]=1;
    		cnt_R++;
		}	    
	}
	if(cnt_R==0 || cnt_R==n)
	    cout<<"0"<<endl;
	else
	{
		int ans=min(cnt_R,n-cnt_R);
		int l=1,r=n,cnt=0;
		while(1)
		{
			while(num[l]==1)
			    l++;
			while(num[r]==0)
			    r--;
			if(l>r)
			    break;
			else
			{
				swap(num[l],num[r]);
				cnt++;
			}
		}
		ans=min(ans,cnt);
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 4412
// Aizu Vol-1 0042: A Thief
// 2017.8.5

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

char *gets(char *);
char buf[100], *p;

int getInt(void)
{
	int n = 0;
	while (isspace(*p) || *p == ',') p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

#define MAX 1000

int w[MAX + 2], v[MAX + 2];
int W[2][MAX + 2], V[2][MAX + 2];

int main()
{
	int i, j, k1, k2, lim, n;
	int ci = 0;

	while (1) {
		gets(p = buf); if (!(lim = getInt())) break;
		printf("Case %d:\n", ++ci);
		gets(p = buf), n = getInt();
		for (i = 1; i <= n; i++) gets(p = buf), v[i] = getInt(), w[i] = getInt();

		memset(V, 0, sizeof(V)), memset(W, 0, sizeof(W));
		for (i = 1, k1 = 0, k2 = 1; i <= n; i++, k1 = k2, k2 = !k1) {
			for (j = 1; j <= lim; j++) {
				if (w[i] > j) V[k2][j] = V[k1][j], W[k2][j] = W[k1][j];
				else {
					int d = j - w[i], v1 = V[k1][d] + v[i], w1 = W[k1][d] + w[i];
					if (v1 >= V[k1][j]) V[k2][j] = v1, W[k2][j] = w1;
					else                V[k2][j] = V[k1][j], W[k2][j] = W[k1][j];
				}
			}
		}
		printf("%d\n%d\n", V[k1][lim], W[k1][lim]);
	}
	return 0;
}

Measured memory_bytes: 540
import java.util.*;
import java.math.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		while(in.hasNext()){
			int n = in.nextInt();
			if( n == 0) return;
			int y = in.nextInt();

			int ans = 0;
			double d, m = 0.0;

			for(int i = 0; i < n; i++){
				int b = in.nextInt(), r = in.nextInt(), t = in.nextInt();
				if(t == 1) d = 1 + y * (double)r / 100;
				else d = Math.pow(1 + (double)r / 100, y);
				if(i == 0 || m < d){
					m = d;
					ans = b;
				}
			}

			System.out.println(ans);
		}
		
	}
	
}

// while(in.hasNext()){
		// 	int n = in.nextInt();
		// 	if(n == 0) return;
			
		// }

Measured memory_bytes: 42540
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  int x, y;
  cin >> x >> y;
  
  vi a = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  cout << (a.at(x) == a.at(y) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 18;

int n;
vector <int> a, ans[1 << 18];

void add(vector <int> &c, int x){
    c.push_back(x);
    sort(c.rbegin(), c.rend());
    while(c.size() > 2) c.pop_back();
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(1 << n);
    for(auto &i : a) cin >> i;
    for(int i = 0 ; i < (1 << n) ; i++){
        add(ans[i], a[i]);
    }
    for(int j = 0 ; j < n ; j++){
        for(int i = 1 ; i < (1 << n) ; i++){
            if((i >> j) & 1){
                for(auto &k : ans[i ^ (1 << j)]){
                    add(ans[i], k);
                }
            }
        }
    }
    int res = 0;
    for(int i = 1 ; i < (1 << n) ; i++){
        res = max(res, ans[i][0] + ans[i][1]);
        cout << res << endl;
    }
}


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

#define int long long

#define K 10000

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

	int x;
	cin >> x;

	int r = pow(x, 0.2), a[K * 2], j = 0;
	for (int i = r + K; i > r - K; --i) a[j++] = pow(i, 5);

	for (int i = 0; i < K * 2; ++i) {
		bool exit = false;
		for (int j = i; j < K * 2; ++j) {
			if (a[i] - a[j] == x) {
				cout << r + K - i << ' ' << r + K - j;
				exit = true;
				break;
			}
		}
		if (exit) break;
	}
}


Measured memory_bytes: 4328
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if(a + b > c + d ) cout << "Left" << endl;
  else if(a + b == c + d ) cout << "Balanced" << endl;
  else cout << "Right" << endl;

  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
        cout << "YES\n";
        return 0;
    }
    cout << "NO\n";
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

int main() {
  long long A, B, C, D; cin >> A >> B >> C >> D;
  
  long long c_low, c_high, d_low, d_high;
  
  c_low = A / C + 1; c_high = B / C;
  d_low = A / D + 1; d_high = B / D;
  if (A % C == 0) c_low--;
  if (A % D == 0)  d_low--;
  
  long long x = C * D;
  
  long long tmp;
  
    if(C<D){
    tmp = C;
    C = D;
    D = tmp;
  }
 
  /* ユークリッドの互除法 */
  long long r = C % D;
  while(r!=0){
    C = D;
    D = r;
    r = C % D;
  }
  
  long long gcd = x / D;
  
  long long gcd_low, gcd_high;
  gcd_low = A / gcd + 1; gcd_high = B / gcd;
  if (A % gcd == 0) gcd_low--;  
  
  long long k = c_high - c_low + 1;
  long long m = d_high - d_low + 1;
  long long n = gcd_high - gcd_low + 1;
  
  long long count = k + m - n;
  long long total = B - A + 1;
  
  cout << total - count << endl;
  
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split(' '))
H = list(map(int, input().split(' ')))
drop = []

for _ in range(M):
  A, B = map(int, input().split(' '))
  A -= 1
  B -= 1
  if H[A] > H[B]:
    drop.append(B)
  elif H[B] > H[A]:
    drop.append(A)
  else:
    drop.extend([A, B])

print(len(H) - len(set(drop)))

Measured memory_bytes: 20040
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod = 1e9+7;
 
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};




int32_t main()
{

ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

    
     int a,b,c,d;
	 cin>>a>>b>>c>>d;
     int i=0;
	 while(a>0&&b>0)
	 {

		 if(i%2==0){
		 c-=b;
		 if(c<=0)
		 {
			 cout<<"Yes\n"; return 0;
		 }
		 }
		 else{
			 a-=d;
			 if(a<=0)
			 {
				 cout<<"No\n"; return 0;
			 }
		 }
		 i++;
	 }


}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main() {
	long long int h, w;
	cin >> h >> w;
	long long int ans;
	if (h == 1 || w == 1)
		ans = 1;
	else
		ans = ((w * h) + 1) / 2;
	cout << ans << "\n";
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
 
int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) cin >> s[i]; 
    ll ab = 0, lb = 0, ra = 0;
    ll ans = 0;
    for (int i = 0; i < n; ++i)
    {
        if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') ++ab;
        else if (s[i][0] == 'B') ++lb;
        else if (s[i][s[i].size() - 1] == 'A') ++ra;
        for (int k = 0; k < s[i].size() - 1; ++k)
        {
            if (s[i][k] == 'A' && s[i][k + 1] == 'B')
                ++ans;
        }
    }
 
    if (ab == 0)
    {
        ans += min(ra, lb);
    }
    else if (ab > 0 && ra + lb > 0)
    {
        ans += min(ra, lb) + ab;
    }
    else if (ab > 0 && ra + lb == 0)
    {
        ans += ab - 1;
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define eps 1e-6
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, k=0, i, j,l=2e9+7;
  string s, r, y;
  cin>>n>>a;
  if(n>a) k=n;
  else k=a;
  ll ans=k;
  if(k==a) a--;
  else n--;
  if(a>n) k=a;
  else k=n;
  ans+=k;
  cout<<ans;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

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

int main() {
  int A, B, cnt=0;
  cin >> A >> B;

  while (A <= B)
  {
    if (
      (A % 10) == (A/10000) &&
      ((A/10) % 10) == ((A/1000) % 10)
      )
    {
      cnt++;
    }
    A++;
  }
  cout << cnt << endl;  
}


Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<queue>
#include<functional>
#include<algorithm>
#include<cstring>
#include<vector>
#include<climits>
#include<map>
using namespace std;
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define INF (2<<25)
typedef pair<int,int> pii;
typedef vector<int> vi;

int main()
{
	while(true)
	{
		int n,m;
		int cost[200][200];
		bool used[200]={};
		
		cin>>n>>m;
		if(n==0&&m==0)break;
		FOR(i,200)FOR(j,200)cost[i][j]=INF;
		
		FOR(i,m)
		{
			int a,b,c;
			cin>>a>>b>>c;
			cost[a][b]=cost[b][a]=c;
		}
		
		priority_queue< pii,vector<pii>,greater<pii> > que;
		que.push(pii(0,0));
		int ans=0;
		while(!que.empty())
		{
			pii now=que.top();que.pop();
			if(used[now.second])continue;
			used[now.second]=true;
			ans+=now.first;
			FOR(i,200)
			{
				if(cost[now.second][i]==INF)continue;
				que.push(pii(cost[now.second][i],i));
			}
		}
		cout<<ans<<endl;
		
		
	}
}

Measured memory_bytes: 3204
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000000
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef long long ll;

int main() {
	string s;
	cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4) << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			double xa1 = in.nextDouble();
			double ya1 = in.nextDouble();
			double xa2 = in.nextDouble();
			double ya2 = in.nextDouble();
			double xb1 = in.nextDouble();
			double yb1 = in.nextDouble();
			double xb2 = in.nextDouble();
			double yb2 = in.nextDouble();
			String result = xa1 <= xb2 && xa2 >= xb1 && ya1 <= yb2
					&& ya2 >= yb1 ? "YES" : "NO";
			System.out.println(result);
		}
	}
}

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

int main() {
  
  string s;
  cin >> s;
  
  int l = s.size();
  
  if (s.at(l-1) == 's') {
    cout << s << "es" << endl; 
  }
  else {
    cout << s << "s" << endl; 
  }

return 0;
}

Measured memory_bytes: 3628
//When I wrote this, only God and I understood what I was doing
//Now, God only knows :-)
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ch char
#define vc vector

int main() {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
double n;
  cin>>n;
  double k=n/3.0;
  double p=(n-k)/2.0;
  double h=n-(k+p);
 // cout<<k<<" "<<p<<" "<<h<<"\n";
 double ans=(k*p*h);
  printf("%0.12f\n",ans);

}


Measured memory_bytes: 384
import math

def main():
  n, d = map(int, input().split())
  xlist = []
  for _ in range(n):
    xlist.append(list(map(int, input().split())))
  ans = 0
  for i in range(n):
    for j in range(n):
      if i == j:
        continue
      dist = 0
      for k in range(d):
        dd = xlist[i][k] - xlist[j][k]
        dist += dd*dd
      if int(math.sqrt(dist)) * int(math.sqrt(dist)) == dist:
        ans += 1
  print(ans // 2)


if __name__ == '__main__':
  main()


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

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

    int sum = 0;
    for (int i = 0; i < n; i++){
        int a, b;
        double s = 0.0;

        cin>>a>>b;
        s = sqrt(pow(a,2) + pow(b,2));
        if (s <= d) sum++;
    }
    
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define endl "\n"
#define pb push_back
#define se second
#define fi first
#define int long long 
#define pi pair<int,int>
#define vpi vector<pi>
#define vvi vector<vpi>
#define For(i,n) for(int i=0;i<n;i++)
#define pie =3.14159265358979323846264338327950
const int mod= 1e9+7;

void findn(vector<vector<int>> &vecn,int i, vector<int> &temp1,int &n){
	if(temp1.size()!=0)
	vecn.pb(temp1);
	for(int j=i;j<n;j++){
		temp1.pb(j);
		findn(vecn,j+1,temp1,n);
		temp1.pop_back();
	}
}

void findm(vector<vector<int>> &vecm,int i, vector<int> &temp2,int &m){
	if(temp2.size()!=0)
	vecm.pb(temp2);
	for(int j=i;j<m;j++){
		temp2.pb(j);
		findm(vecm,j+1,temp2,m);
		temp2.pop_back();
	}
}

int32_t main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    int n,m,k;
	cin>>n>>m>>k;
	vector<vector<char>> ar(n,vector<char>(m));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>ar[i][j];
		}
	}
	vector<vector<int>> vecn;
	vector<vector<int>> vecm;
	vector<int> temp1;
	vector<int> temp2;
	findn(vecn,0,temp1,n);
	findm(vecm,0,temp2,m);
	int ans=0;
	//cout<<vecn.size()<<endl;
	//cout<<vecm.size()<<endl;
	for(int i=0;i<(int)vecn.size();i++){
		for(int j=0;j<(int)vecm.size();j++){
			int cnt=0;
			for(int x=0;x<(int)vecn[i].size();x++){
				for(int y=0;y<(int)vecm[j].size();y++){
					if(ar[vecn[i][x]][vecm[j][y]]=='#'){
						cnt++;
					}
				}
			}
			if(cnt==k){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

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

  int n;
  string s;
  cin >> n >> s;
  string res = "Yes";
  if (n%2 == 1) {
    res = "No";
  } else {
    for (int i = 0; i < n/2; ++i) {
      if (s[i] != s[n/2+i]) {
        res = "No";
        break;
      }
    }

  }
  cout << res << endl;

  return 0;
}



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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    while(cin >> n) {
        vector<int> v(n);
        map<int,int> mp;
        for(int i = 0; i < n; i++) {
            cin >> v[i];
            mp[v[i]] = 0;
        }
        int f = 0;
        for(auto &it : mp) {
            it.second = f;
            f = !f;
        }
        int cont = 0;
        for(int i = 0; i < n; i++) {
            int p = (i&1? 1 : 0);
            if(mp[v[i]] != p)
                cont++;
        }
        cout << cont/2 << '\n';
    }
    return 0;
}

Measured memory_bytes: 5376
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;

void main() {
  int N, L; readf("%d %d\n", &N, &L);
  string[] Sn = new string[N];
  foreach(i; 0..N) {
    Sn[i] = readln.chomp;
  }
  Sn.sort.joiner.writeln;
}


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

long long int N;

long long int F(long long int A, long long int B) {

	long long int tmp = A;
	int count1 = 0;
	while (tmp > 0) {
		tmp /= 10; count1++;
	}
	int count2 = 0;
	tmp = B;
	while (tmp > 0) {
		tmp /= 10; count2++;
	}
	return max(count1, count2);
}

int main(void) {

	cin >> N;
	long long int ans = F(1, N);
	for (long long int i = 1; i*i <= N; i++) {
		if (N%i == 0) { long long int tmp = F(i, N / i);
		ans = min(ans, tmp);
		     }
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

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

typedef long long ll;

#define all(x) x.begin(), x.end()
#define sz(x) (ll) x.size()
#define deb(x) cout << (#x) << " is " << (x) << "\n";
#define debv(v) for (auto usb: v) cout << usb << " "; cout << "\n";

// n == (1 || 0) ???? memory?


void solve(){
	ll n;
	cin >> n;
	ll ans = 0LL, mx = -1LL;
	
	for (int i = 0; i < n; i++)
	{
		ll k;
		cin >> k;
		ans += max(0LL, mx - k);
		mx = max(mx, k);
	}
	cout << ans << "\n";
}

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.precision(20);	
	solve();
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll n;
    cin >> n;
    ll a[n];
    for (ll i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    for (ll i = 0; i < n;i++){
        while(a[i]%2==0&&a[i]!=0){
            a[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vll a(n),b(n),c(m),d(m);
    REP(i,n)cin >> a[i] >> b[i];
    REP(i,m)cin >> c[i] >> d[i];
    REP(i,n){
        int ans = 0;
        int dis = INF;
        REP(j,m){
            if(abs(a[i]-c[j])+abs(b[i]-d[j])<dis){
                ans = j;
                dis = abs(a[i]-c[j])+abs(b[i]-d[j]);
            }
        }
        cout << ans + 1 << endl;
    }

    return 0;
}

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

int main() {
	string s;

	cin >> s;
	int size = s.size();
	bool result = true;
	for(int i = 0;i <= (size - 1)/2; i++) {
		if (s[i] != s[size - i - 1]) {
			result = false;
		}
	}
	if (result == true) {
		int count = 0;
		for(int i = (size +3)/2 - 1;i < size; i++) {
			if (s[i] != s[size - count - 1]) {
				result = false;
			}
			count = count + 1;
		}
	}
	if (result == false) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
  int N; cin>>N;
  vector<int> C(N,0),V(N,0);
  for(int i=0;i<N;i++) cin>>V[i];
  for(int i=0;i<N;i++) cin>>C[i];
  int X=0,Y=0;
  for(int bit=0;bit<(1<<N);bit++){
    int tempX=0,tempY=0; 
    for(int j=0;j<N;j++){
      if(bit&(1<<j)){
        tempX+=V[j];
        tempY+=C[j];
      }
      if((tempX-tempY)>(X-Y)){
        X=tempX; Y=tempY;
      }
    }
  }

  cout<<X-Y<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int n;
  cin >> n;
  int maxv = -MOD;
  vector<int> r(n);
  for (int i = 0; i < n; ++i) cin >> r[i];

  int minv = r[0];
  for (int i = 1; i < n; ++i) {
    maxv = max(maxv, r[i] - minv);
    minv = min(minv, r[i]);
  }

  cout << maxv << endl;
  return 0;
}



Measured memory_bytes: 3624
S = input()
if (int(S[:2]) == 0 or 13 <= int(S[:2]) <= 99) and 1 <= int(S[2:4]) <= 12:
  print('YYMM')
elif 1 <= int(S[:2]) <= 12 and (int(S[2:4]) == 0 or 13 <= int(S[2:4]) <= 99):
  print('MMYY')
elif 1 <= int(S[:2]) <= 12 and 1 <= int(S[2:4]) <= 12:
  print('AMBIGUOUS')
else:
  print('NA')

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

/*
##Knigh's moves without attack
ll sq = n*n;
ll a = sq*(sq-1)/2; //all moves
ll b = 4*(n-1)*(n-2); //moves with attack
z = a - b; //moves without

##2^k
for(int i = 0; i < n; ++i)
ans = 2*ans%((int)1e9+7);

## 'x' from (a) and 'y' from (b) 
(a+b)%(x+y)==0  2*a>=b && 2*b>=a gap checker 




*/

const int MOD = 1e9+7;
const int MX = 1e6+5;
int arr[MX];
//int dp[MX];



int main() {
      ios::sync_with_stdio(0);
      cin.tie(0);
      int n, x;
      cin >> n >> x;

        
        ll dp[x+1] = {};
        vector<pair<ll, ll>> v(n);
      
        for(int i = 0; i < n; ++i)
          cin >> v[i].first >> v[i].second;

        for(int i = 0; i < n; ++i)
          for(int j = x; j >= 0; --j)
            if(j>=v[i].first)
            dp[j] = max(dp[j], dp[j-v[i].first] + v[i].second);


      cout<<dp[x];
      
    return 0;
}




Measured memory_bytes: 4404
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	vector<int> v(n);
	for(int i = 0; i < n; ++i){
		scanf("%d", &v[i]);
	}
	sort(v.begin(), v.end());
	int r = n - 2;
	long long ans = v[n - 1];
	for(int i = n - 2; i >= 0; --i){
		int t = min(r, 2);
		ans += t * v[i];
		r -= t;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
long long n,sum1,sum2,xa,xb,xc,xd,ya,yb,yc,yd;
long long xp1,xp2,xp3,xp4,yp1,yp2,yp3,yp4;
int main(){	
	scanf("%lld",&n);
	for(int i=1; i<=n; i++){
		scanf("%lld%lld%lld%lld",&xp1,&yp1,&xp2,&yp2);
		scanf("%lld%lld%lld%lld",&xp3,&yp3,&xp4,&yp4);
		xa=min(xp1,xp2);
		xb=max(xp1,xp2);
		ya=min(yp1,yp2);
		yb=max(yp1,yp2);
		xc=min(xp3,xp4);
		xd=max(xp3,xp4);
		yc=min(yp3,yp4);
		yd=max(yp3,yp4);
		if(xc>xb||xa>xd||yc>yb||ya>yd){
			printf("0\n");
			continue;
		}
		xb=xp4-xp3;
		yb=yp4-yp3;
		xa=xp1-xp3;
		ya=yp1-yp3;
		sum1=xa*yb-xb*ya;
		xa=xp2-xp3;
		ya=yp2-yp3;
		sum2=xa*yb-xb*ya;
		if(sum1*sum2>0){
			printf("0\n");
			continue;
		}
		xb=xp2-xp1;
		yb=yp2-yp1;
		xa=xp3-xp1;
		ya=yp3-yp1;
		sum1=xa*yb-xb*ya;
		xa=xp4-xp1;
		ya=yp4-yp1;
		sum2=xa*yb-xb*ya;
		if(sum1*sum2>0){
			printf("0\n");
			continue;
		}
		printf("1\n");
	}
}


Measured memory_bytes: 3144
n=input()
a,b,c,d=int(n[0]),int(n[1]),int(n[2]),int(n[3])
l=0
for i in range(2):
    x=a
    if i==0:
        x+=b
    else:
        x-=b
    for j in range(2):
        if j==0:
            x+=c
        else:
            x-=c
        for k in range(2):
            if k==0:
                x+=d
            else:
                x-=d
            if x==7:
                l=1
                m=[i,j,k]
                break
            if k==0:
                x-=d
            else:
                x+=d
        if j==0:
            x-=c
        else:
            x+=c
    if i==0:
        x-=b
    else:
        x+=b

        if l==1:
            break
    if l==1:
        break

ans=""
ans+=str(a)
if m[0]==0:
    ans+="+"
else:
    ans+="-"
ans+=str(b)
if m[1]==0:
    ans+="+"
else:
    ans+="-"
ans+=str(c)
if m[2]==0:
    ans+="+"
else:
    ans+="-"
ans+=str(d)
ans+="=7"
print(ans)


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

def dfs(n):
  if int(n) > N:
    return 0
  if ('3' in n) and ('5' in n) and ('7' in n):
    ret = 1
  else:
    ret = 0
  for c in '357':
    ret += dfs(n+c)
  return ret

print(dfs('0'))

Measured memory_bytes: 69168
#include <iostream>

int main() {
	int n, k;
	std::cin >> n >> k;
	if(k == 0) {
		std::cout << (long long) n * n << '\n';
		return 0;
	}
	long long ans = 0;
	for(int i = k + 1; i <= n; i++) {
		ans += (long long) n / i * (i - k) + std::max(n % i - k + 1, 0);
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, M) = readInputLine().split(" ").map { it.toInt() }
    val edges = mutableMapOf<Int, MutableList<Int>>()
    
    for (i in 1..M) {
        val (a, b) = readInputLine().split(" ").map { it.toInt() }
        val aEdges = edges.get(a) ?: mutableListOf<Int>()
        aEdges.add(b)
        edges.put(a, aEdges)
        
        val bEdges = edges.get(b) ?: mutableListOf<Int>()
        bEdges.add(a)
        edges.put(b, bEdges)
    }
    
    println(dfs(edges, 1, (2..N).toSet()))
}

fun readInputLine(): String {
    return readLine()!!
}

fun dfs(edges: Map<Int, List<Int>>, now: Int, rest: Set<Int>): Int {
    if (rest.isEmpty()) {
        return 1
    }
    
    var ans = 0
    
    for (e in edges.get(now)!!) {
        if (rest.contains(e)) {
            ans += dfs(edges, e, rest.minusElement(e))
        }
    }
    
    return ans
}


Measured memory_bytes: 40488
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
set<pll> s;
vector<pll> v;
ll vans[20];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll h,w,n; cin>>h>>w>>n;
	for (ll i=0;i<n;i++) {
		ll a,b; cin>>a>>b;
		s.insert(MP(a,b));
		v.PB(MP(a,b));
	}
	for (ll i=0;i<20;i++) vans[i]=0;
	for (auto &ww:v) {
		ll origa=ww.first,origb=ww.second;
		for (ll a=origa-1;a<=origa+1;a++)for (ll b=origb-1;b<=origb+1;b++){
			if (!(2<=a&&a<=h-1)) continue;
			if (!(2<=b&&b<=w-1)) continue;
			ll cnt=0;
			for (ll x=a-1;x<=a+1;x++) for (ll y=b-1;y<=b+1;y++) {
				pll sig=MP(x,y);
				if (s.find(sig)!=s.end()) cnt++;
			}
			//cout<<a<<","<<b<<":"<<cnt<<endl;
			vans[cnt]++;
		}
	}
	ll have=0;
	for (ll j=1;j<=9;j++) {vans[j]/=j; have+=vans[j];}
	vans[0]=((h-2)*(w-2))-have;
	for (ll j=0;j<=9;j++) cout<<vans[j]<<endl;

}

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

int main() {
    std::array<bool, 100001> is_prime;
    vector<int> primes;
    is_prime.fill(true);
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<is_prime.size(); ++i) {
        if(is_prime[i]) {
            primes.push_back(i);
            for(int j=i*2; j<is_prime.size(); j+=i) {
                is_prime[j] = false;
            }
        }
    }

    int m, a, b;
    while(cin >> m >> a >> b, m) {
        int p=0, q=0;
        for(int i=0; i<primes.size(); ++i) {
            auto it1 = lower_bound(primes.begin()+i, primes.end(), primes[i]*b/a);
            auto it2 = lower_bound(primes.begin()+i, primes.end(), m/primes[i]);
            if(m / primes[i] != *it2 && *it2 > primes[i]) --it2;
            if(primes[i]*b / a != *it1) --it1;
            if(it2 < it1) it1 = it2;
            
            if(primes[i] * (*it1) <= m && *it1 * primes[i] > p*q) {
                p = primes[i];
                q = *it1;
            }
        }
        cout << p << " " << q << endl;
    }
}


Measured memory_bytes: 3244
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {

    int n, m, x;
    cin >> n >> m >> x;

    bool A[n + 1];
    for (int i = 0; i < n + 1; i++) {
        A[i] = false;
    }

    for (int i = 0; i < m; i++) {
        int input;
        cin >> input;
        A[input] = true;
    }

    int cost_to_n = 0;
    for (int i = x; i < n; i++) {
        if (A[i + 1]) {
            cost_to_n++;
        }
    }

    int cost_to_0 = 0;
    for (int i = x; i > 0; i--) {
        if (A[i - 1]) {
            cost_to_0++;
        }
    }

    cout << min(cost_to_n, cost_to_0) << endl;

    return 0;
}

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

void Main()
{
    int n;
    cin >> n;
    int ans = 0;
    int m = 1;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (a == m) m++;
        else ans++;
    }
    if ( ans == n ) ans = -1;
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3624
from collections import Counter
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, = read_line(int)

counter = Counter()
for _ in range(n):
    a, = read_line(int)
    counter[a] += 1

count = 0
for n in counter.values():
    if n % 2 != 0:
        count += 1

print(count)


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

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

 int x;
 cin >> x;
 int ans = 0;
 ans += 1000 * (x/500);
 x %= 500;
 ans += x - x%5;
 cout << ans << "\n";

}


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

int main(void)
{
  char abc[26];
  int counter = 0;
  char C;
  scanf("%c",&C);
  char *tmp;
  int result;

  for (char alpha = 'a'; alpha <= 'z'; ++alpha) {
    abc[counter] = alpha;
    counter++;
  }
  
  tmp = strchr(abc,C);
  result = (int)(tmp - abc + 1);
  
  printf("%c",abc[result]);
}

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

    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846
    const int MOD=1e9+7;

    void solve(){
        int x,y;
        cin>>x>>y;
        for(int i=0;i<=100;i++){
            int a=x-i;
            if(a>=0){
                if(i*2 + a*4 == y){
                    cout<<"Yes";
                    return;
                }
            }
        }
        cout<<"No";
        return;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


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

int main(){
    string s;
    cin >> s;
    int n = s.length() + 1;
    vector<ll> ans(n, 0);
    rep(i, n-1) {
        if ( s[i] == '<') {
            ans[i+1] = max(ans[i+1], ans[i] + 1);
        }
    }
    for ( int i = n-2; i >= 0; --i ) {
        if ( s[i] == '>' ) {
            ans[i] = max(ans[i], ans[i+1] + 1);
        }
    }
    ll ret = 0;
    ret = accumulate(ans.begin(), ans.end(), (ll)0);
//    rep(i, n) {
//        ret += ans[i];
//    }
    cout << ret << endl;
    return 0;
}

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

int main(){   
    int cou=0;
    string s;
    cin >> s;
    for(int i=0;i<3;i++){
        if(s.at(i)=='o'){cou++;}
    }
    cout << 700+cou*100 <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll in()
{
    ll res=0,p=1;
    char c=getchar();
    while(c<'0'||c>'9') {if(c=='-') p=-1; c=getchar();}
    while(c>='0'&&c<='9') res=res*10+c-48,c=getchar();
    return p*res;
}
void out(ll x)
{
    if (x>9) out(x/10);
    putchar(x%10+48);
}

const int maxn = 1e2 + 5;
const int mod = 7;

int a[maxn], b[maxn];

int main()
{
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < m; ++i) cin >> b[i];
    sort(a, a + n); sort(b, b + m);
    bool exist = 0;
    for (int i = a[n - 1] + 1; i <= b[0]; ++i){
        if (i > x && i <= y) exist = 1;
    }
    cout << (exist ? "No War" : "War") << endl;
    return 0;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long n,cnt=0,i;
    cin>>n;
    long long a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long long min=a[0];
    for(i=0;i<n;i++)
    {
        if(a[i]<=min)
        {
            min=a[i];
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    int a,b,i,j;
    while(1){
        scanf("%d %d",&a,&b);
        if(a==0&&b==0){
            break;
        }
        for(i=1;i<=a;i++){
            for(j=1;j<=b;j++){
                if(j%2==1){
                    if(i%2==1)printf("#");
                    else printf(".");
                }
                else{
                    if(i%2==1)printf(".");
                    else printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
const string el = "\n";
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
template<class T> T gcd(T a,  T b) {return b ? gcd(b, a % b) : a;}
template<class U> U lcm( U m, U n ){if((0 == m )||( 0 == n ))return 0; return ((m / gcd(m, n)) * n); }
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
signed main(){
    fast_io();
    int N,X; cin >> N >> X;
    vector<int>v(N); for(auto& e : v) cin >> e;
    v.push_back(X);
    sort(all(v));
    vector<int>dif;
    for(int i = 0; i + 1 < v.size(); ++i)
        dif.push_back(v[i+1] - v[i]);
    int ans = gcd(dif[0],dif[1]);
    for(auto e : dif) ans = gcd(ans,e);
    cout << ans << endl;
    
}


Measured memory_bytes: 2800
import java.util.*;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = Integer.MAX_VALUE;
		int total = 0;
		for(int i = 1; i<=N; i++) {
			int n = sc.nextInt();
			total += n;
			if(n < M && n%10 != 0) M = n;
		}
		
		if(total % 10 != 0) System.out.println(total);
		else if(M == Integer.MAX_VALUE) System.out.println(0);
		else System.out.println(total-M);
	}

}


Measured memory_bytes: 23252
import java.util.*;

public class Main{

    int m,n;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            m = sc.nextInt();
            n = sc.nextInt();
            if(m==0 && n==0) break;

            int[] player = new int[m];
            int num = m;

            int idx = 0;
            for(int i=0; i<n; i++){
                String s = sc.next();
                if(num==1) continue;
                if(!correct(i+1,s)){
                    player[idx] = -1;
                    num--;
                }
                while(true){
                    idx++; idx %= m;
                    if(player[idx]==0) break;
                }
            }

            idx = 0;
            int[] ans = new int[num];
            for(int i=0; i<m; i++){
                if(player[i]==0) ans[idx++] = i+1;
            }

            for(int i=0; i<num-1; i++) System.out.print(ans[i]+" ");
            System.out.println(ans[num-1]);

        }
    }

    boolean correct(int idx, String s){
        boolean b = false;
        if(idx%3==0 && idx%5==0){
            if(s.equals("FizzBuzz")) b = true;
        }else if(idx%5==0){
            if(s.equals("Buzz")) b = true;
        }else if(idx%3==0){
            if(s.equals("Fizz")) b = true;
        }else if(String.valueOf(idx).equals(s)) b = true;
        
        return b;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 13000