akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  string kaiwa[n];
  for(int i = 0; i < n; i++) {
    cin >> kaiwa[i];
  }

  int count = 0;
  for(int i = 0; i < n; i++) {
    if(kaiwa[i] == "A") {
      count++;
    } else {
      count--;
    }
    if(count < 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  if(count == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}



Measured memory_bytes: 3172
N=int(input())
S1=input()
S2=input()

mod=10**9+7

if S1[0]==S2[0]:
    cnt=3
    i=1
    f=0
if S1[0]!=S2[0]:
    cnt=6
    i=2
    f=1

while i<N:
    if S1[i]==S2[i]:
        if f==0:
            cnt=(cnt*2)%mod
        elif f==1:
            cnt=(cnt*1)%mod
        i+=1
        f=0
    elif S1[i]!=S2[i]:
        if f==0:
            cnt=(cnt*2)%mod
        elif f==1:
            cnt=(cnt*3)%mod
        i+=2
        f=1

print(cnt)



Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

const string YES = "Yes";
const string NO = "No";

void solve(ll N) {
  string s = to_string(N);
  reverse(ALL(s));
  bool pred = N == stoi(s);
  cout << (pred ? YES : NO) << endl;
}

int main() {
  ll N;
  cin >> N;
  solve(N);
  return 0;
}


Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

struct FenwickTree<T, F> {
    n: usize,
    a: Vec<T>,
    id: T,
    op: F
}

impl<T: Clone, F: Fn(T, T) -> T> FenwickTree<T, F> {
    pub fn new (n: usize, id: T, op: F) -> FenwickTree<T, F> {
        FenwickTree {
            n: n,
            a: vec![id.clone(); n + 1],
            id: id,
            op: op,
        }
    }
    pub fn update (&mut self, x: usize, v: T) {
        let mut k = x;
        while k <= self.n {
            self.a[k] = (self.op) (self.a[k].clone(), v.clone());
            k += k & (!k + 1);
        }
    }
    pub fn find (&self, x: usize) -> T {
        let mut v = self.id.clone();
        let mut k = x;
        while k > 0 {
            v = (self.op) (v.clone(), self.a[k].clone());
            k -= k & (!k + 1);
        }
        v
    }
}

fn run() {
    input! {
        n: usize,
        h: [usize; n],
        a: [u64; n],
    }
    let mut bit = FenwickTree::new(n, 0, std::cmp::max);
    for i in 0..n {
        let v = bit.find(h[i]) + a[i];
        bit.update (h[i], v);
    }
    let ans = bit.find (n);
    println! ("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 13560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<ll,ll,ll,ll> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
ll n,m,out=INF;
#define int long long
int F(int a,int b,int c){
	return max(a,max(b,c))-min(a,min(b,c));
}
void f(int q,int a,int b){
	out=min(out,min(F(q,a/2*b,b*(a-a/2)),F(q,b/2*a,a*(b-b/2))));
}
signed main(){
	cin>>n>>m;
	loop(i,1,n)f(i*m,n-i,m);
	loop(i,1,m)f(i*n,n,m-i);
	cout<<out<<endl;
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 10*10
#define EPS 1e-9

//----***パーツ***----
#define fr first
#define se second

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

int N,M,K;
string S;

signed main(){
  cin>>N>>K;
  int sum=0;
  vector<int> v(200100,0);
  REP(i,1,N+1){
    v[i]+=i+v[i-1];
  }

  REP(i,K,N+1){
    int left=v[i-1],right=v[N]-v[N-i];
    sum+=right-left+1;
    sum%=MOD;
  }
  sum++;
  print(sum)


}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int n;
    cin >> n;
    int a[n];
    for (i = 0; i < n; i++) cin >> a[i];
    if (n % 3 == 0) {
        sort(a, a + n);
        int m = n / 3;
        bool ng = 0;
        for (i = 0; i < m - 1; i++) {
            for (j = 0; j < 3; j++) {
                if (a[m * j + i] != a[m * j + i + 1]) ng = 1;
            }
        }
        if (ng) {
            cout << "No" << endl;
            return 0;
        }
        if ((a[0] ^ a[m] ^ a[2 * m]) == 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    } else {
        for (i = 0; i < n; i++)
            if (a[i] != 0) {
                cout << "No" << endl;
                return 0;
            }
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 4020
#include<cstdio>
#include<iostream>
using namespace std;
int n,k,a[262144],f[262144],g[262144],x[262144],y[262144];
int main(){
	scanf("%d",&n);
	for(int i=0;i<(1<<n);i++){
		scanf("%d",&a[i]);
		f[i]=a[i]; x[i]=i; y[i]=-1;
	}
	for(int S=0;S<(1<<n);S++){
		for(int j=0;j<=18;j++){
			if(S&(1<<j)){
				if(f[S^(1<<j)]>f[S]&&x[S^(1<<j)]!=x[S]&&x[S^(1<<j)]!=y[S]) g[S]=f[S],f[S]=f[S^(1<<j)],y[S]=x[S],x[S]=x[S^(1<<j)];
				else if(f[S^(1<<j)]>g[S]&&x[S^(1<<j)]!=x[S]&&x[S^(1<<j)]!=y[S]) g[S]=f[S^(1<<j)],y[S]=x[S^(1<<j)];
				if(g[S^(1<<j)]>f[S]&&y[S^(1<<j)]!=x[S]&&y[S^(1<<j)]!=y[S]) g[S]=f[S],f[S]=g[S^(1<<j)],y[S]=x[S],x[S]=y[S^(1<<j)];
				else if(g[S^(1<<j)]>g[S]&&y[S^(1<<j)]!=x[S]&&y[S^(1<<j)]!=y[S]) g[S]=g[S^(1<<j)],y[S]=y[S^(1<<j)];
			}
		}
	}
	int ans=0;
	for(int i=1;i<(1<<n);i++){
		ans=max(ans,f[i]+g[i]);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 8320
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

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

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

    bool f = false;
    for (int i = 0; i < s.length(); i++) {
        if (s == t) {
            f = true;
            break;
        }

        s = s.back() + s.substr(0, s.length()-1);
    }

    std::cout << ((f)?"Yes":"No") << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep (i ,n) for(int i=0;i<(n);i++) 
ll gcd (ll a,ll b) {return b?gcd(b,a%b):a;}   
ll lcm (ll a,ll b) {return a/gcd(a,b)*b;} 
const int mod=1e9+7;
int main(){
	int n,m;
	cin>>n>>m;
	double ans=0;
	for(int i=1;i<=n;i++){
		int nn=i;
		double d=1.0/n;
		while(nn<m){
			nn*=2;
			d/=2.0;
		}
		ans+=d;
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;
import java.util.concurrent.*;

class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	
    public static void main(String args[]) throws Exception
    {
		int x=sc.nextInt()*100,y=sc.nextInt()*10,z=sc.nextInt();
		
		out.println((x+y+z)%4==0?"YES":"NO");out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

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

int main()
{
    int a, b, c, d, distance;

    scanf("%d%d%d%d", &a, &b, &c, &d);

    distance = abs(a-b);

    if(abs(a-c) <= d)
        printf("Yes\n");
    else if(abs(b-c) <= d && distance <= d)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 1612
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 


int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll A,B;
	cin>>A>>B;
	
	if(A*B==2)
	{
		cout<<3<<endl;
	}
	else{
		if(A*B==3)
		{
			cout<<2<<endl;
		}
		else{
			cout<<1<<endl;
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 256
N=int(input())
number=[int(i) for i in input().split(" ")]
a=number.pop(-1)

if number[0]==0:
    N-=1
    number.pop(0)


numbermap=[[0 for i in range(21)] for j in range(N)]

numbermap[0][0]=1

for i in range(N-1):
    for j in range(21):
        if j+number[i]<=20:
            numbermap[i+1][j+number[i]]+=numbermap[i][j]
        if j-number[i]>=0:
            numbermap[i+1][j-number[i]]+=numbermap[i][j]



print (numbermap[-1][a])

Measured memory_bytes: 7728
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define U (LL)0
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
map<char,LL>u,v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a,b;
    cin>>a>>b;
    k=1;
    for(i=0; a[i]; i++)
    {
        if(u[a[i]]==0 || u[a[i]]==b[i]-'0')
        {
            u[a[i]]=b[i]-'0';
        }
        else
        {
            k=0;
            break;
        }
        if(v[b[i]]==0 || v[b[i]]==a[i]-'0')
        {
            v[b[i]]=a[i]-'0';
        }
        else
        {
            k=0;
            break;
        }
    }
    if(k==0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }


    return 0;

}


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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  vector<int> ar(n);
  vector<int> c(n);
  ll res = 0;
  for(int i = 0; i < n; ++i) {
    int x; cin >> x;
    --x;
    ar[i] = x;
    res += c[x];
    c[x]++;
  }
  for(int i = 0; i < n; ++i) {
    cout << res - c[ar[i]] + 1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 4224
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Beginner066
{
    public class ABC066A_ringring
    {
        public static void Main(string[] args)
        {
            
            // 価格の入力
            int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            
            // 結果出力
            Console.WriteLine( nums.Sum() - nums.Max() );

        }

    }
}

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

int main() {
  
  int N, M;
  cin >> N >> M;
  
  string S;
  cin >> S;
  
  reverse(S.begin(), S.end());
  
  for (int i = 0; i < M; i++) {
    S += "0";
  }
  
  vector<int> step(N);
  int t = N + M;
  
  for (int i = N - 1; i >= 0; i--) {
    if (t - i == M + 1) t--;
    if (S[t] == '1') {
      while (S[t] == '1' && t > i) t--;
    }
    if (t == i) break;
    step[i] = t - i;
  }
  
  if (step[0] == 0) cout << -1 << endl;
  else {
    
    vector<int> ans;
    
    int k = 0;
    while (k < N) {
      if (k + step[k] > N) {
        ans.push_back(N - k);
        break;
      }
      ans.push_back(step[k]);
      int m = k + step[k];
      k = m;
    }
    
    reverse(ans.begin(), ans.end());
    
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i] << " ";
    }
    
  }
  
}

Measured memory_bytes: 1528
import sys
e = sys.stdin.readlines()
while 1:
 r=int(e[0].split()[0])
 if r<1:break
 d=[int(''.join(x),2)for x in zip(*map(lambda x:x.split(),e[1:r+1]))]
 a=[]
 for i in range(1<<r):
  b=0
  for j in d:
   c=bin(i^j).count('1')
   b+=c if c>r//2 else r-c
  a+=[b]
 print(max(a))
 del e[:r+1]


Measured memory_bytes: 6972
#include <bits/stdc++.h>
using namespace std;
string x;
int main()
{
	set<string> s;
	int n,i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		s.insert(x);
	}
	cout<<s.size();
	return 0;
}

Measured memory_bytes: 19188
#include <bits/stdc++.h>
using namespace std;
int MOD = 1000000007; 
int main() {
  int n,m;
  cin>>n>>m;
  long long kotae=1;
  if(abs(m-n)>1){
    cout<<0<<endl;
    return 0;
  }else if(n==m){
    kotae=n+m;
    kotae%=MOD;
    kotae*=n;
    kotae%=MOD;
    for(int i=1;i<n;i++){
      //cout<<kotae<<" ";
      kotae*=(n-i);
      kotae%=MOD;
      kotae*=(n-i);
      kotae%=MOD;
    }
  }else{
    for(int i=0;i<min(n,m);i++){
      kotae*=(n-i);
      kotae%=MOD;
      kotae*=(m-i);
      kotae%=MOD;
    }    
  }
  cout<<kotae<<endl;
  return 0;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 100005;

int main() {
    string s;
    cin >> s;
    int ok = 0;
    for (auto x : s) {
        if (x == '7') ok = 1;
    }
    puts(ok ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,int> pdi;
bool cnta[30], cntb[30];
int main()
{
    int n;
    scanf("%d", &n);
    string s;
    cin >> s;
    int cnt = 0, ans = 0;
    for(int i = 1; i < n; i++)
    {
        cnt = 0;
        memset(cnta,0,sizeof(cnta));
        memset(cntb,0,sizeof(cntb));
        for(int j = 0; j < i; j++)
        {
            cnta[s[j]-'a']=1;
        }
        for(int j = i; j < n; j++)
        {
            cntb[s[j]-'a']=1;
        }
        for(int i = 0; i < 26; i++)
        {
            if(cnta[i]&&cntb[i])
                cnt++;
        }
        ans = max(ans, cnt);
    }
    printf("%d\n", ans);
}









Measured memory_bytes: 256
from sys import stdin


def iterate_tokens():
    for line in stdin:
        for word in line.split():
            yield word


def main():
    tokens = iterate_tokens()
    next(tokens)
    Q = int(next(tokens))
    S = next(tokens)
    L = []
    R = []
    for i in range(Q):
        L.append(int(next(tokens)))
        R.append(int(next(tokens)))
    AC = []
    pre = None
    cnt = 0
    for c in S:
        if c == "A":
            pre = "A"
        elif pre == "A" and c == "C":
            cnt += 1
            pre = None
        elif pre == "A":
            pre = None
        AC.append(cnt)
    for l, r in zip(L, R):
        print(AC[r - 1] - AC[l - 1])
    return


main()


Measured memory_bytes: 14196
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            while(true) {
            	int n = sc.nextInt();
            	int m = sc.nextInt();
                if(n + m == 0) break;
                int sum = 0;
                int max = 0;
                int [] a = new int[n];
                for(int i=0; i<n; i++) {
                	a[i] = sc.nextInt();
                }
                
                for(int i=0; i<n; i++) {
                	for(int j=i+1; j<n; j++) {
                		sum = a[i] + a[j];
                		if(sum <= m) {
                			max = Math.max(sum, max);
                		}
                	}
                }
                if(max == 0) {
                	System.out.println("NONE");
                }
                else {
                	System.out.println(max);
                }
            }
        }
    }
}



Measured memory_bytes: 50560
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k, s, cnt;
    int z;
    cnt = 0;
    cin >> k >> s;
    for (int x = 0; x <= k; ++x)
    {
        for (int y = 0; y <= k; ++y)
        {
            z = s - x - y;
            if (z >= 0 && z <= k) ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){

}

void solve(){
    ll n,m;
    cin>>n>>m;
    ll MAX=0;
    ll sum=0;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
        sum += a[i];
        MAX = max(MAX , a[i]);
    }
    multiset<ll> SET;
    for(ll i=0;i<n;i++){
        if(a[i]*4*m >= sum)
            SET.I(i);
    }
    if(SET.size() >= m)
        cout << "Yes";
    else cout << "No";
}

int main(){
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
using namespace std;
ll dp[100002][101];
ll knap(ll wt[],ll val[],ll w,ll n)
{
	if(n<0||w<=0)
	return 0;
	if(dp[w][n]!=-1)
	return dp[w][n];
	else 
	{
		if(w>=wt[n])
		{
			dp[w][n]=max(knap(wt,val,w,n-1),knap(wt,val,w-wt[n],n-1)+val[n]);
		}
		else 
		dp[w][n]=knap(wt,val,w,n-1);
	}
	return dp[w][n];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n,w;
	cin>>n>>w;
	for(int a=0;a<100002;a++)
	{
		for(int b=0;b<101;b++)
		dp[a][b]=-1;
	}
	ll wt[n],val[n];
	for(int a=0;a<n;a++)
	{
		cin>>wt[a]>>val[a];
	}
	dp[w][n-1]=knap(wt,val,w,n-1);
	cout<<dp[w][n-1];
	return 0;
}

Measured memory_bytes: 79232
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int a, b, c;
    int tmp;
 
    scanf("%d%d%d", &a, &b, &c);
    if (a > b) tmp = a, a = b, b = tmp;
    if (b > c) {
        tmp = b, b = c, c = tmp;
        if (a > b) tmp = a, a = b, b = tmp;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}


Measured memory_bytes: 2040
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;

template <typename T>void read(T &t)
{
	t=0;int f=0;char c=getchar();
	while(!isdigit(c)){f|=c=='-';c=getchar();}
	while(isdigit(c)){t=t*10+c-'0';c=getchar();}
	if(f)t=-t;
}

int a,b,k;

int main()
{
	read(a),read(b),read(k);
	int x=0;
	for(register int i=min(a,b);i;--i)
	{
		if(a%i==0 && b%i==0)++x;
		if(x==k)
		{
			printf("%d",i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int N;
    cin >> N;
    vector<int> s(N);
    int sum = 0;
    REP(i, N) {
        cin >> s[i];
        sum += s[i];
    }
    if (sum % 10 != 0){
        cout << sum << endl;
        return 0;
    }
    sort(s.begin(), s.end());
    REP(i, N){
        if (s[i] % 10 != 0){
            cout << (sum - s[i]) << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define AMAX 10000

int main()
{
  unsigned short *X,*Y;

  int o,i,j;
  int B[AMAX+1];

  scanf("%d",&o);

  X = malloc(sizeof(short) * o + 1);
  Y = malloc(sizeof(short) * o + 1);

  for(i=0;i<=AMAX;i++) B[i] = 0;

  for(i=0;i<o;i++)
    {
      scanf("%hu",&X[i+1]);
      B[X[i+1]]++;
    }

  for(i=1;i<=AMAX;i++) B[i] = B[i] + B[i-1];

  for(j=1;j<=o;j++)
    {
      Y[B[X[j]]] = X[j];
      B[X[j]]--;
    }

  for (i=1;i<=o;i++)
    {
      if(i>1)printf(" ");
      printf("%d",Y[i]);
    }
  printf("\n");

  return 0;
}



Measured memory_bytes: 9656
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin, (x).end
#define pb push_back

int N, K, val, res = 0;
vector<int> p;

int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){ cin >> val; p.pb(val); }
    sort(p.begin(), p.end());
    for(int i = 0; i < K; i++){ res += p[i]; }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(){
  long int n,b[40]={},i,j=0;
  scanf("%ld",&n);
  if(!n){printf("0");return 0;}
  for(i=0;n;i++)if(n%(1L<<(i+1))){b[i]=1;n+=(i%2*2-1)*1L<<i;}
  for(i=39;i>=0;i--){if(!j)j=b[i];if(j)printf("%ld",b[i]);}
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int a[20];

int main() {
   a[4] = a[6] = a[9] = a[11] = 1;
   a[2] = 2;
   int x, y;
   cin >> x >> y;
   if (a[x] == a[y]) {
      puts("Yes");
   } else {
      puts("No");
   }

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define For(i,a,b) for(long long i=a;i<b;i++)
#define pb push_back
using namespace std;
typedef long long ll;
ll power(ll x,ll y,ll p){
ll res = 1;x = x % p;
while (y > 0){
if (y & 1){res = (res*x) % p;}
y = y>>1;
x = (x*x) % p;}
return res;}
ll mcd(ll a,ll b){
    if(b>a)swap(a,b);
    if(b==0)return a;
    else return mcd(b,a%b);
}
ll t,n,m,k;
bool esprimo(ll n){
ll s=0;
for(ll i=1;i*i<=n;i++){
    if(n%i==0){s++;}}
if(s>=2){return false;}
return true;
}
ll primos[]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997,1009 };
ll b[1000005];
vector<ll> gtf(ll x){
vector<ll> ans;
ll y=x;

for(ll i=0;primos[i]*primos[i]<=x;i++){
    ll p=0;
    while(y%primos[i]==0){
        y/=primos[i];
        if(p==0)ans.pb(primos[i]);
        p++;
    }
}
if(y!=1){
ans.pb(y);
}
return ans;
}


int main(){
    //    cout<<fixed<<setprecision(2);
//cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
memset(b,0,sizeof b);
cin>>n;
ll a[n];
t=0;
for(int i=0;i<n;i++){
cin>>a[i];
vector<ll> cur;
cur=gtf(a[i]);
    for(int j=0;j<cur.size();j++){
        if(b[cur[j]]!=0){
            t++;
        }
        b[cur[j]]++;
    }
}
ll g=a[0];

if(t!=0){
for(int i=0;i<n;i++){
g=__gcd(g,a[i]);
}
if(g==1){
cout<<"setwise coprime"<<endl;
}else{
cout<<"not coprime"<<endl;
}
}else{

cout<<"pairwise coprime"<<endl;
}


}



Measured memory_bytes: 19240
#include <bits/stdc++.h>
using namespace std;
#define loop(i,n) for (int i =0;i<(n);++i)
typedef long long ll;
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
 
    ll A, B; cin >> A >> B;
    if (A % 2 == B % 2) {
        cout << (A+B) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
long long int n;
  cin>>n;
  string res = "";

	while (n > 0)
	{
	
		int index = (n - 1) % 26;
		res = char(index + 'a') + res;
		n = (n - 1) / 26;
	}

	cout<< res<<endl;
  
  return 0;
}


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

using namespace std;

int main()
{
  string s1, s2;
  getline(cin, s1);
  getline(cin, s2);
  
  int count = 0;
  for (int i = 0; i < s1.size(); i++){
    if (s1[i] != s2[i])
      count++;
  }
  cout << count;
  
  return 0;
}

Measured memory_bytes: 3828
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (int i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
 
const lli MOD=1e9+7;
const lli MAXN=2e6;
const ld PI=acos(-1);

int main(){
    rapgame
    //freopen("brokeday.in", "r", stdin);
    //freopen("richday.out", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
        read2ll(n,m);
        cout << n*(n-1)/2+m*(m-1)/2;
    }
    return 0;
}

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

int main() {
  int r;
  cin >> r;
  if(r < 1200){
    cout << "ABC" << endl;
  }
  else if (r < 2800){
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B, C;
  cin >> A >> B >> C;
  int first = A % B;
  int k = 1;
  while (true) {
    k++;
    int r = k * A % B;
    if (r == C) {
      cout << "YES" << '\n';
      return 0;
    }
    if (r == first) {
      cout << "NO" << '\n';
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    string s;cin>>s;
    string a="",b="";
    ll q;cin>>q;
    ll now=0;
    while(q){
        q--;
        ll x;cin>>x;
        if(x==1){
            now=1-now;
        }else{
            ll f;char c;cin>>f>>c;
            if(now==0){
                if(f==1){
                    a+=c;
                }else{
                    b+=c;
                }
            }else{
                if(f==1){
                    b+=c;
                }else{
                    a+=c;
                }
            }
        }
    }
    if(now==0){
        reverse(all(a));
        cout<<a<<s<<b<<endl;
    }else{
        reverse(all(s));
        reverse(all(b));
        cout<<b<<s<<a<<endl;
    }
}

Measured memory_bytes: 1088
import java.util.*;

public class Main{
   public static void main(String[] args) {
	  Scanner sc =new Scanner(System.in);
   int po[]=new int[2];
   for(int i=0;i<2;i++){
	   for(int j=0;j<4;j++){
		   po[i]+=sc.nextInt();
	   }}
   System.out.println(Math.max(po[0], po[1]));
   }
}

Measured memory_bytes: 17180
#include<iostream>
using namespace std;
bool d[10];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<k;++i){
		int x;
		cin>>x;
		d[x]=true;
	}
	while(true){
		int p=n;
		while(p!=0){
			if(d[p%10])
				break;
			p/=10;
		}
		if(p==0)
			break;
		++n;
	}
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S; cin >> S;
    int ans = 0;
    for(auto c : S) {
        if(c == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
}

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

int main(){
    string s[3];
    int next = 0, i[3] = {};
    cin >> s[0] >> s[1] >> s[2];
    char mem = s[0][i[0]];
    i[0]++;
    while(i[next] < s[next].length()){
        mem = s[next][i[next]];
        i[next]++;
                next = mem - 'a';
    }
    cout << (char)('A' + next);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<tuple<string, int, int> > S;
int main()
{
  int N; cin >> N;
  for(int i=0; i<N; ++i)
  {
    string s; cin >> s;
    int t; cin >> t;
    S.emplace_back(s, -t, i);
  }
  sort(S.begin(), S.end());
  for(auto x: S) cout << get<2>(x) +1<< endl;
}

Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.range;

  auto s=readln.chomp.to!(char[]);

  int[char] cnt;
  foreach(c; s){
    if(!(c in cnt)) cnt[c]=1;
  }

  auto mi=s.length;
  foreach(tg; cnt.keys){
    int i=-1, j;
    int r=0;
    while(j<s.length){
      if(s[j]==tg){
        r=max(r, j-i-1);
        i=j;
      }
      j++;
    }
    mi=min(mi, max(r, s.length-i-1));
  }

  writeln(mi);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll A;
    string B;
    cin >> A >> B;
    ll iB = (ll)(B[0] - '0');
    ll dB = 0;
    if (B.length() == 4) {
        dB = 10 * (B[2] - '0') + (B[3] - '0');
    } else if (B.length() == 3) {
        dB = (B[2] - '0');
    }
    ll ans = (A *dB) / 100ll + A * iB;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3580
import itertools
import math
N = int(input())
P = [0] * N 
for i in range(N):
    P[i] = list(map(int,input().split()))
distance = 0
for root in itertools.permutations(P,N):
    start = root[0]
    for r in root:
        distance += pow((r[0]-start[0])**2 + (r[1]-start[1])**2,1/2)
        start = r
print(distance/math.factorial(N))


Measured memory_bytes: 9384
<?php
// Your code here!
    $N = intval(trim(fgets(STDIN)));
    
    $d = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    sort($d);
    
    if(($d[($N/2)-1]) != ($d[($N/2)])){
        echo ($d[($N/2)]) - ($d[($N/2)-1]);
    }else{
        echo "0";
    }
    
    

?>

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

int abs(int a)
{
  if (a>0) return a;
  return -a;
  }
int a,b,c,d;
int ab,ac,bc;
int main() {
  cin>>a>>b>>c>>d;
  ac=abs(a-c);
  ab=abs(a-b);
  bc=abs(b-c);
  if (ac<=d || (ab<=d && bc<=d))
  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    string s;cin>>s;
    sort(s.begin(),s.end());
    if(s[0]!=s[2] && s[0]==s[1] && s[2]==s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	if (a < b&&b < c)
	{
		printf("Yes\n");
	}

	else
	{
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] ary = new int[n];
        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            ary[a - 1]++;
            ary[b - 1]++;
        }
        for (int num : ary) {
            System.out.println(num);
        }
    }
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
//#include <iostream>
//#include <vector>
//#include <string>
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

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

template<class T>inline bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }




#define P3 pair<P, lint>

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

	lint h, w; cin >> h >> w;
	string in;
	svec m;
	lint ori = 0;

	if (h == 1 && w == 1) {
		co(0);
		return 0;
	}

	rep(i, h) {
		cin >> in;
		m.pb(in);
		rep(j, w)if (m[i][j]=='#')++ori;
	}

	queue<P3> que; que.push({ {0,0},0 });
	lint x, y, l, p, q;
	while (cont(que)) {
		x = que.front().first.first;
		y = que.front().first.second;
		l = que.front().second;
		que.pop();
		rep(i, 4) {
			p = x + dx4[i]; q = y + dy4[i];
			if (q < 0 || h <= q || p < 0 || w <= p)continue;
			
			if (p == w-1 && q == h-1) {
				co(h*w - ori - l - 2);
				gc();
				return 0;
			}
			if (m[q][p] == '.') {
				que.push({ { p,q },l + 1 });
				m[q][p] = '+';
			}
		}
	}
	co(-1);
	gc();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define endl            "\n"


 
void fastIO()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}


void solve()
{
    int x;
    cin>>x;

    int ans=x/500;

    ans*=1000;
    x%=500;

    x=x/5;

    ans+=(x*5);

    cout<<ans;
}
 
 
int32_t main()
{
    fastIO();
    //w(t)
    {
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, m;
  map<string, int> mp;
  cin >> n;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cin >> m;
  rep(i, m) {
    string s;
    cin >> s;
    mp[s]--;
  }
  int mx = 0;
  for(auto v : mp) mx = max(mx, v.second);
  cout << mx << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Console.WriteLine(Solve() ? "Yes" : "No");
		Out.Flush();
	}
	bool Solve()
	{
		var N = F;
		var t = new int[N];
		var x = new int[N];
		var y = new int[N];
		for (var i = 0; i < N; i++)
		{
			var I = G;
			t[i] = I[0];
			x[i] = I[1];
			y[i] = I[2];
		}
		int t0 = 0, x0 = 0, y0 = 0;
		for (var i = 0; i < N; i++)
		{
			if (!IsFeasible(t[i] - t0, x[i] - x0, y[i] - y0)) return false;
			t0 = t[i];
			x0 = x[i];
			y0 = y[i];
		}
		return true;
	}
	bool IsFeasible(int dt, int dx, int dy)
	{
		if (dx < 0) dx *= -1;
		if (dy < 0) dy *= -1;
		return (dt % 2) == (dx + dy) % 2 && dt >= dx + dy;
	}
}


Measured memory_bytes: 17412
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <cctype>
#define rep(x,y,z) for(long long x=y;x<z;++x)
#define dwn(x,y,z) for(long long x=y;x>z;--x)
using namespace std;

typedef long long ll;

int main() {
    ll n;
    cin >> n;
    ll A, B;
    cin >> A >> B;
    vector<ll> v(n);
    rep(i,0,n) {
        cin >> v[i];
    }

    ll cnt1 = 0, cnt2 = 0, cnt3 = 0;
    rep(i,0,n) {
        if (v[i] <= A) {
            cnt1++;
        } else if ((A + 1) <= v[i] && v[i] <= B) {
            cnt2++;
        } else {
            cnt3++;
        }
    }
    cout << min(min(cnt1, cnt2), cnt3) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,i,a[101];
  scanf("%d",&n);
  for(i=1; i<=n; i++){
    scanf("%d" ,&a[i]);
  }
  for(i=n; i>0; i--){
    printf("%d",a[i]);
    if(i!=1){
      printf(" ");
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600