akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define INF 1000000007
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define CLR(a) memset((a), 0, sizeof(a))

using ll = long long;
using namespace std;

inline int toInt(string s){
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

template<class T> inline string toString(T x){
    ostringstream sout;
    sout << x;
    return sout.str();
}

int main(void){

    int h, w;
    cin >> h >> w;

    int ans = 0;
    FOR(i,0,h){
        FOR(j,0,w){
            char c;
            cin >> c;
            if(c=='#')ans++;
        }
    }

    if(ans!=(h+w-1))cout << "Impossible" << endl;
    else cout << "Possible" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 
 
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
 
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
 
        // その結果を push
        res.push_back({a, ex});
    }
 
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}
 
int main(int argc, const char * argv[]) {

    ll X; cin >> X;
    if(X>=30){
        cout << "Yes" << endl;
        return 0;
    }
    else{
        cout <<"No"<< endl;
    }
    
    return 0;
}


Measured memory_bytes: 6236
#include<cstdio>
int quotient_minustwo(int x){
    if(x>=0)return -(x/2);
    else return (1-x)/2;
}
bool iseven(int x){
    if(x>=0)return (x%2==0);
    else return ((-x)%2==0);
}
int main(){
    int n;
    scanf("%d",&n);
    if(n==0)printf("0");
    else{
        int i=-1;
        char a[40];
        while(n!=0){
            i++;
            if(iseven(n))a[i]='0';
            else a[i]='1';
            n=quotient_minustwo(n);
        }
        for(int j=i;j>=0;j--)printf("%c",a[j]);
    }
    return 0;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int a,b;
  cin>>a>>b;
  if(a+b==15){
    cout<<'+'<<endl;
  }else if(a*b==15){
    cout<<'*'<<endl;
  }else{
    cout<<'x'<<endl;
  }
}

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

typedef long long int ll;

#define rep(i,n) for(ll i = 0; i < n; i++)

int main() {
  int x;
  cin >> x;
  rep(i,100000) {
    if (i*(i-1)/2 < x && x <= i*(i+1)/2) {
      cout << i << endl;
      exit(EXIT_SUCCESS);
    }
  }
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(int i=a; i<n; i++)
#define loop(i,a,n)	for(int i=a; i>=n; i--)

int main() 
{	
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	int a,b;
	cin>>a>>b;
	forr(i,1,10000)
	{//cout<<i*0.08<<' '<<i*0.1<<'\n';
		if(int(i*0.08)==a and int(i*0.1)==b)	
		{
			cout<<i; return 0;
		}
	}
	cout<<-1;
	return 0;	
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int N, M;
    cin >> N >> M;
    string s(N, 'N');
    REP(i, M){
        int a;
        char b;
        cin >> a >> b;
        a--;
        if(s[a]=='N' || s[a]==b){
            s[a]=b;
        }else{
            cout << -1 << el;
            return;
        }
    }
    if(N>1){
        if(s[0]=='N'){
            s[0]='1';
        }
        if(s[0]=='0'){
            cout << -1 << el;return;
        }
    }
    REP(i, N){
        if(s[i]=='N'){
            cout << 0;
        }else{
            cout << s[i];
        }
    }
    cout << el;
}



Measured memory_bytes: 3616
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
int main(){
  char in[120];
  int t;
  cin>>t;
  int num;
  pair<pair<string,int>,int>finder[120];
  for(int i=0;i<t;i++){
    scanf("%s%d",&in,&num);
    finder[i]=make_pair(make_pair(in,-num),i);
  }
  sort(finder,finder+t);
  //int k=finder.size();
  for(int z=0;z<t;z++){
    cout<<finder[z].second+1<<"\n";
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		int A = ni(), B = ni(), C = ni(), D = ni();
		for(int i = 0; ;i++) {
			if(i % 2 == 0) {
				C -= B;
				if(C <= 0) {
					out.println("Yes");
					return;
				}
			}
			else {
				A -= D;
				if(A <= 0) {
					out.println("No");
					return;
				}
			}
		}
	}


	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

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

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

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

using namespace std;

struct Edge {
    int u, v;
    long long c;
    long long p;
    long long w;
    Edge() {}
    Edge(long long p): p(p) {}
    friend istream& operator>>(istream& in, Edge& edge) {
        in >> edge.u >> edge.v >> edge.c;
        --edge.u;
        --edge.v;
        edge.w = edge.p - edge.c;
        return in;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    long long p;
    cin >> n >> m >> p;
    vector<Edge> edges(m, Edge(p));
    for (Edge& edge : edges) {
        cin >> edge;
    }
    // If the coins were c we have set the weight to be p-c.
    // Now it remains to find the shortest distance from 0 to n-1.
    // We do this using Bellman Ford.
    // But first we find all nodes that can reach the end node.
    vector<bool> can_reach(n, false);
    can_reach[n-1] = true;
    for (int i = 0; i < m; ++i) {
        for (Edge& edge : edges) {
            if (can_reach[edge.v]) {
                can_reach[edge.u] = true;
            }
        }
    }
    long long inf = 1000000000000000LL;
    vector<long long> dist(n, inf);
    dist[0] = 0;
    auto bellman_ford_step = [&]() {
        bool any_changes = false;
        for (Edge& edge : edges) {
            // We disregard all edges that either cannot reach the end node or cannot be reached by the start node.
            if (dist[edge.u] == inf || !can_reach[edge.v]) {
                continue;
            }
            long long new_dist = dist[edge.u] + edge.w;
            if (new_dist < dist[edge.v]) {
                dist[edge.v] = new_dist;
                any_changes = true;
            }
        }
        return any_changes;
    };
    int num_steps = 0;
    while (num_steps <= m && bellman_ford_step()) {
        ++num_steps;
    }
    if (num_steps == m+1) {
        // Found a negative cycle
        // Since the cycle can be reached from the start node and can reach the end node there is no maximum.
        cout << -1 << endl;
    } else {
        cout << max(0LL, -dist[n-1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let mut ab = i::uv2(n);
    ab.sort_by_key(|a| a.1);
    let mut k = 0;
    for i in 0..n {
        let (a, b) = ab[i];
        k += a;
        if k > b {
            println!("{}", "No");
            return;
        }
    }
    println!("{}", "Yes");
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 10492
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(a%b,b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}

int main(){
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1e18 //10^12:∞

int main()
{
  int n,x,t;
  int times;
  cin >> n >> x >> t;
  if(n%x == 0) times = n/x;
  else times = n/x + 1;
  cout << t*times;
  
  return 0;
}

Measured memory_bytes: 3632
k,n = map(int,input().split())
a = list(map(int,input().split()))
max = 0
b = []
for i in range(n):
  if i ==0:
    b.append(a[0]+k-a[n-1])
  elif not i==0:
    b.append(a[i]-a[i-1])
for i in range(n):
  if max < b[i]:
    max = b[i]
print(k-max)
  

Measured memory_bytes: 32272
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector<pair<char,int> >vepa;
typedef set<string>se;
typedef map<char ,int> mpp;
const ll N=1e5+5 ,OO=1e18;
const int di[]={1,-1,0,0};
const int dj[]={0,0,1,-1};
int TC,n,a,arr[N];
bool vis[N],f;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
   int x,mn=INT_MAX,ans;
   cin>>x>>n;
   if(n==0)
   {
       cout<<x;
       return 0;
   }
   rep(i,n)
   {
       cin>>a;
       vis[a]=1;
   }
   for(int i=0;i<=101;i++)
   {
     if(vis[i])continue;
     if(abs(x-i)<mn){
        mn=abs(x-i);
        ans=i;
     }
   }
   cout<<ans;
go;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  cout << a[n-1]-a[0] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a[] = new int[26];
		for (int i=0;i<s.length();i++) {
			a[s.charAt(i)-'a']++;
			if (a[s.charAt(i)-'a']>1) {
				System.out.println("no");
				return ;
			}
		}

		System.out.println("yes");
	}
}

Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="SUN")
    cout<<"7";
 	else if(s=="SAT")
      cout<<"1";
  	else if(s=="MON")
      cout<<"6";
  	else if(s=="TUE")
      cout<<"5";
  	else if(s=="WED")
      	cout<<"4";
  	else if(s=="THU")
      	cout<<"3";
  	else 
      cout<<"2";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}
int main(){
    fastio;
    file();
    lld a,b;
    cin>>a>>b;
    for(lld i=1;i<=b;++i){
        if((a*i)%b==0){
            cout<<a*i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#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 t1, t2;
  ll a1, a2;
  ll b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

  ll A1 = a1 * t1;
  ll A2 = A1 + a2 * t2;
  ll B1 = b1 * t1;
  ll B2 = B1+ b2 * t2;

  if(A2 == B2){
    cout << "infinity" << endl;
    return 0;
  }

  //A1 > B1にセットしておく
  if(A2 < B2){
    swap(A1,B1);
    swap(A2,B2);
  }

  ll d = A2 - B2;
  ll c = B1 - A1;

  ll ans = 0;

  if (c > 0){
    ans = (c-1)/d +1;
    ans *= 2;
    if(c%d != 0) --ans;
  }
  else{
    ans = 0;
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if (a >= 13){
    cout << b << '\n';
  }
  if (a >= 6  && a <= 12){
    cout << b / 2 << '\n'; 
  }
  if (a <= 5){
    cout << "0\n";
  }
  
  return 0; 
}

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

#define rep(i, j) for(int i=0; i < (int)(j); i++)
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }

class Solver {
  public:    
    bool solve() {
        int N, D, X; cin >> N >> D >> X;
        vector<vector<int>> P(D, vector<int>(N)); cin >> P;

        int x = X;
        rep(d, D - 1) {
            vector<int> dp(x + 1);
            rep(i, x + 1) dp[i] = i;
            rep(i, x + 1) {
                rep(n, N) {
                    if(i - P[d][n] >= 0) {
                        set_max(dp[i], dp[i - P[d][n]] + P[d + 1][n]);
                    }
                }
            }
            x = dp[x];
        }
        cout << x << endl;
        return 0;
    }
};

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

Measured memory_bytes: 3248
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll n, INF = 1000000000000000000;

vll dat;

vvl calc(){
  vvl dp = VV(n+1, 16, INF, ll);
  dp[0][0] = 0;
  for(ll i=0;i<=15;i++) dp[1][i] = 2*i;
  for(ll i=2;i<=n;i++){

    ll min_upd = 0;
    ll lef = dat[n-i], ri = dat[n-i+1];
    if(lef>ri) {
      while(lef>ri) lef/=4, min_upd++;
    }else {
      while(4LL*lef<=ri) ri/=4, min_upd--;
    }
    for(ll j=0;j<=15;j++){
      ll tmp = max(min_upd + j, 0LL);
      //iでj回操作を行う場合、a[i]*4^j <= a[i+1]*4^kを満たす
      //kが更新対象、dp[i][j] = dp[i-1][k] + j
      //k==15については dp[i][j] = dp[i-1][15] + L*(k - 15);
      for(ll k=tmp;k<=15;k++) dp[i][j] = min(dp[i][j], dp[i-1][k] + 2*j);
      if(tmp>=15) dp[i][j] = min(dp[i][j], dp[i-1][15] + 2*(i-1)*(tmp-15) + 2*j);
    }
  }
  return dp;
}
int main(int argc, char const *argv[]) {
  std::cin >> n;
  dat.resize(n);
  re(i, n) scanf("%lld", &dat[i]);
  vvl R = calc();
  reverse(all(dat));
  vvl L = calc();
  ll ans = INF;
  //for(int i=0;i<=n;i++) std::cout << R[i][0] << (i==n?"\n":" ");
  //for(int i=0;i<=n;i++) std::cout << L[i][0] << (i==n?"\n":" ");

  for(int i=0;i<=n;i++) {
    //std::cout << L[i][0] << " " <<  R[n-i][0] << " " << i << '\n';
    ans = min(ans, L[i][0] + R[n-i][0] + i);
  }
  std::cout << ans << '\n';
  return 0;
}


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

int main(){
  int X;
  cin>>X;
  if(X>=400 && X<=599)
    cout<<8<<endl;
  else if(X>=600 && X<=799)
    cout<<7<<endl;
  else if(X>=800 && X<=999)
    cout<<6<<endl;
  else if(X>=1000 && X<=1199)
    cout<<5<<endl;
  else if(X>=1200 && X<=1399)
    cout<<4<<endl;
  else if(X>=1400 && X<=1599)
    cout<<3<<endl;
  else if(X>=1600 && X<=1799)
    cout<<2<<endl;
  else if(X>=1800 && X<=1999)
    cout<<1<<endl;
  
}

Measured memory_bytes: 3632
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static final int MOD = (int)Math.pow(10,9)+7;

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int n = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();

        long ret = powMod(2, n) - 1 - combinationMod(n, a) - combinationMod(n, b);
        ret %= MOD;

        os.println(ret < 0 ? ret + MOD : ret);
    }


    static long powMod(long seed, long n) {
        long ret = 1;
        while(n > 0) {
            if((n & 1) == 1) ret = seed * ret % MOD;
            seed = seed * seed % MOD;
            n = n >> 1;
        }
        return ret;
    }

    static long combinationMod(long n, long k) {
        long child = 1;
        long mother = 1;

        for(long i = n; i >= n-k+1; i--) {
            child = child * i % MOD;
            mother = mother * (n-i+1) % MOD;
        }

        long ret = child * powMod(mother, MOD-2) % MOD;

        return ret;
    }

}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const LL MOD = 1000000007;

void solve(long long N){
    map<string, LL> memo, tmp;

    REP(i, 4) memo[""] = 1LL;
    REP(i, N) {
        for (auto it = memo.begin(); it != memo.end(); ++it) {
            string now = it->first;
            string next = "";
            for(int j = (now.length() == 3 ? 1 : 0); j < now.length(); j++) {
                next += now[j];
            }

            // 'a'
            if(tmp.count(next + 'a') == 0) tmp[next + 'a'] = 0;
            tmp[next + 'a'] += it->second;
            tmp[next + 'a'] %= MOD;

            // 'c'
            if(next != "ag" && next != "ga" && !(now.length() == 3 && now[0] == 'a' && now[1] == 'g')
                && !(now.length() == 3 && now[0] == 'a' && now[2] == 'g')) {
                if(tmp.count(next + 'c') == 0) tmp[next + 'c'] = 0;
                tmp[next + 'c'] += it->second;
                tmp[next + 'c'] %= MOD;
            }
            
            // 'g'
            if(next != "ac") {
                if(tmp.count(next + 'g') == 0) tmp[next + 'g'] = 0;
                tmp[next + 'g'] += it->second;
                tmp[next + 'g'] %= MOD;
            }

            // 't'
            if(tmp.count(next + 't') == 0) tmp[next + 't'] = 0;
            tmp[next + 't'] += it->second;
            tmp[next + 't'] %= MOD;
        }

        memo = tmp;
        tmp.clear();
        // for(auto it = memo.begin(); it != memo.end(); it++) {
        //     cout << it->first << " : " << it->second << endl;
        // }
    }

    LL ans = 0;
    for(auto it = memo.begin(); it != memo.end(); it++) {
        ans += it->second;
        ans %= MOD;
    }
    
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
import bisect
import sys
input = sys.stdin.readline
N = int(input())
ls = list(map(int, input().split()))
ls.sort()

ans = 0
for i in range(N-2):
  a = ls[i]
  for j in range(i+1, N-1):
    b = ls[j]
    pos = bisect.bisect_left(ls, a+b)
    ans += pos - j - 1
print(ans)


Measured memory_bytes: 3188
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
n = N * (N + 1) // 2
s = sum(A)
if s % n != 0:
    print('NO')
    exit()
c = s // n
d = [A[(i + 1) % N] - A[i] for i in range(N)]
for i in range(N):
    if c < d[i] or (c - d[i]) % N != 0:
        print('NO')
        exit()
print('YES')


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

using namespace std;

int64_t calc(const std::vector<uint32_t> as) {
  int const n = static_cast<int>(as.size());
  int64_t ret = 0;
  uint32_t ored = as[0];
  int64_t r = 1;
  for (; r < n; ++r) {
    uint32_t const a = as[r];
    if (ored & a) {
      break;
    }
    ored |= a;
  }
  ret += r;
  for (int64_t l = 1; l < n; ++l) {
    ored &= ~as[l - 1];
    for (; r < n; ++r) {
      uint32_t const a = as[r];
      if (ored & a) {
        break;
      }
      ored |= a;
    }
    ret += r - l;
  }
  return ret;
}

int main() {
  uint32_t n;
  std::cin >> n;
  std::vector<uint32_t> as(n, 0);
  for (int i = 0; i < n; ++i) {
    std::cin >> as[i];
  }
  auto ret = calc(as);
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 100004
#define INF 1e9+7

using namespace std;

ll n,t;
ll cost,tim,ans = INF;
int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> t;

    rep(i,0,n)
    {
        cin >> cost >> tim;

        if(tim <= t)
        {
            ans = min(ans,cost);
        }
    }

    if(ans < INF)
    {
        cout << ans << endl;
    }
    else
    {
        cout << "TLE\n";
    }

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define rep2r(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

vector<long long> divisors(long long n) {
  vector<long long> res;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i * i != n) {
        res.push_back(n / i);
      }
    }
  }
  return res;
}


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll n; cin >> n;
  ll ans = 1e18;
  for (ll x : divisors(n)) {
    ans = min(ans, x - 1 + n / x - 1);
  }
  cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define SORT(V) sort((V).begin(),(V).end())

int main(){
  double R;
  cin >> R;
  cout << R*2*3.14 << endl;

  return 0;
}


Measured memory_bytes: 3764
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    imfor(i, n) {
        int a;
        cin >> a;
        if (mp.find(a) == mp.end()) {
            mp[a] = 1;
        }
        else {
            mp[a]++;
        }
    }
    vector<int> v;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        v.push_back(itr->second);
    }
    sort(v.begin(), v.end());
    int tmp = 0;
    k = min(k, (int)v.size());
    imfor(i, k) {
        tmp += v[v.size() - 1 - i];
    }
    cout << n - tmp << endl;
}

Measured memory_bytes: 10748
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int k = Integer.parseInt(str[1]);
		for(int i = 0; i < (1 << n); i++){
			int sum = 0;
			int pow2 = 1;
			int cnt = 0;
			ArrayList<Integer> a = new ArrayList<Integer>();
			for(int j = 0; j < n; j++){
				if((i & (1 << j)) != 0){
					sum += pow2;
					a.add(j);
					cnt++;
				}
				pow2 *= 2;
			}
			if(cnt != k) continue;
			pw.print(sum + ":");
			if(i > 0) pw.print(" ");
			for(int j = 0; j < a.size(); j++){
				pw.print(a.get(j));
				if(j != a.size() - 1) pw.print(" ");
			}
			pw.print("\n");
		}
		pw.close();
	}
}



Measured memory_bytes: 65428
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const LL INF = 1LL << 60;
const LL MOD = 1000000007LL;
using namespace std;
typedef pair<int, int> P;
vector<P> G[1000];
LL dist[1000];
int main() {
	int N, M;
	cin >> N >> M;
	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c; a--; b--;
		G[a].push_back(P(b, -c));
	}
	fill((LL*)dist, (LL*)(dist + N), INF);
	dist[0] = 0;
	rep(k, N - 1) {
		bool update = 0;
		rep(i, N) {
			rep(j, G[i].size()) {
				int to = G[i][j].first;
				int cost = G[i][j].second;
				if (dist[to] > dist[i] + cost) {
					dist[to] = dist[i] + cost;
					update = 1;
				}
			}
		}
		if (!update) break;
	}
	bool inf = 0;
	rep(k, N - 1) {
		bool update = 0;
		rep(i, N) {
			rep(j, G[i].size()) {
				int to = G[i][j].first;
				int cost = G[i][j].second;
				if (dist[to] > dist[i] + cost) {
					if (to == N - 1) inf = 1;
					dist[to] = dist[i] + cost;
					update = 1;
				}
			}
		}
		if (!update) break;
	}
	if (inf) {
		cout << "inf" << endl;
	}
	else {
		cout << -dist[N - 1] << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  char a[101],b[101],c[101];
  cin>>a>>b>>c;
  int ia=1,ib=0,ic=0;
  char next = a[0];
  while(true){
    if(next=='a'){
      if(ia>=strlen(a)){
        cout << "A" << endl;
        return 0;
      }else{
        next = a[ia++];
      }
    }
    if(next=='b'){
      if(ib>=strlen(b)){
        cout << "B" << endl;
        return 0;
      }else{
        next = b[ib++];
      }
    }
    if(next=='c'){
      if(ic>=strlen(c)){
        cout << "C" << endl;
        return 0;
      }else{
        next = c[ic++];
      }
    }
  }
  return 0;
}

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

bool warshall_floyd(int n, vector<vi> d){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                int check=d[j][k];
                d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
                if(check!=d[j][k]) return false;
            }
        }
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    vector<vi> d(n,vi(n));
    rep(i,n) rep(j,n) cin >> d[i][j];
    if(!warshall_floyd(n,d)){
        cout << "-1" << endl;
        return 0;
    }
    ll ans=0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            bool flag=true;
            rep(k,n){
                if(k==i||k==j) continue;
                if(d[i][j]==d[i][k]+d[k][j]){
                    flag=false;
                }
            }
            if(flag){
                ans+=d[i][j];
            }
        }       
    }
    cout << ans << endl;
    return 0;
}

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

int main(){

    string s,t;
    cin >> s >> t;

    for (int i = 0;i < s.size();i++){
        if (s == t){
            cout << "Yes" << endl;
            return 0;
        }
        s = s.back() + s;
        s.pop_back();
    }
    cout << "No" << endl;
    return 0;
}

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

int cntDigits(int n){
	int cnt=0;
	while(n){
		n/=10;
		cnt++;
	}return cnt;
}

int main() {
	// your code goes here
	int n,cnt=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(cntDigits(i)%2)cnt++;
	}cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
// file name: 逻辑操作2: 两个数按位与,或,非
// Written by: by_sknight
// Date: 2019/6/13

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

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

	unsigned int a, b; cin >> a >> b;
	bitset<32> bs_a(a), bs_b(b), bs;
	bs = bs_a & bs_b;
	cout << bs << endl;
	bs = bs_a | bs_b;
	cout << bs << endl;
	bs = bs_a ^ bs_b;
	cout << bs << endl;
}


Measured memory_bytes: 3216
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	string s;
	cin >> s;
	string ss = "CODEFESTIVAL2016";
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != ss[i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = [int(i) for i in input().split()]
dic = {}
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

ans = 0

for k, v in dic.items():
    if k > v:
        ans += v
    else:
        ans += v - k

print(ans)


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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;

lld n, m, q;
vi a;
vector<pair<pair<lld, lld>, pair<lld, lld>>> llist;
lld ans = 0;
void solve(lld pos, lld mn) {
    if (pos == n) {
        lld c = 0;
        for (lld i = 0; i < q; i++) {
            if (a[llist[i].first.second] - a[llist[i].first.first] == llist[i].second.first) {
                c += llist[i].second.second;
            }
        }
        ans = max(ans, c);
        return;
    }

    for (lld i = mn; i <= m; i++) {
        a[pos] = i;
        solve(pos + 1, i);
    }
}

int main() {
    fast;
    cin.tie(0);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w" , stdout);
#endif*/
    lld i;
    cin >> n >> m >> q;

    for (i = 0; i < q; i++) {
        lld a, b, c, d;
        cin >> a >> b >> c >> d;
        --a; --b;
        llist.push_back({{a, b}, {c, d}});
    }

    a.resize(n, 1);


    solve(0, 1);

    cout << ans << endl;

}

Measured memory_bytes: 3624
n, x, y = map(int, input().split())

ans = [0] * (n)
#グラフを0-indexで使用するため、デクリメントする
x -= 1
y -= 1

for i in range(n - 1):
    for j in range(i + 1, n):
        dist = min(j - i, abs(x - i) + 1 + abs(j - y))
        ans[dist] += 1

for x in range(1, len(ans)):
    print(ans[x])


Measured memory_bytes: 3444
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const ll MAX= 3e3+100;


int main(){
	fastio;
	ll n,ans=0;
	cin>>n;
	ans+=(n/500)*1000;
	n=n%500;
	ans+=(n/5)*5;
	cout<<ans<<endl;
  	return 0;	
}

Measured memory_bytes: 256
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define DBG(str) cerr<<(str)<<endl;
int main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i, 0, 4) {
		if (s[i] == '+')ans++;
		else ans--;
	}
	cout << ans;
	return 0;
}





Measured memory_bytes: 764
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long a = 0, b = 0, c = 0;
		a = x / 500; b = (x - a * 500) / 5; c = ( a * 1000 + b * 5);
		System.out.println(c);
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;


int n,k,r,s,p;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> k >> r >> s >> p;
	string t,t2;
	cin >> t;

	ll ans = 0;
	REP(i,n){
		if(t[i]=='r'){
			if(i-k>=0 && t2[i-k]=='p'){
				if(i+k<n) t2.push_back(t[i+k]);
				else t2.push_back('r');
			}else{
				ans += p;
				t2.push_back('p');
			}
		}else if(t[i]=='s'){
			if(i-k>=0 && t2[i-k]=='r'){
				if(i+k<n) t2.push_back(t[i+k]);
				else t2.push_back('s');
			}else{
				ans += r;
				t2.push_back('r');
			}
		}else if(t[i]=='p'){
			if(i-k>=0 && t2[i-k]=='s'){
				if(i+k<n) t2.push_back(t[i+k]);
				else t2.push_back('p');
			}else{
				ans += s;
				t2.push_back('s');
			}
		}
	}

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



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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,m;
    cin >> n;
    vector<P> edges(n-1);
    vector<vector<int>> G(n,vector<int>(n,100));
    for (int i = 0;i < n-1;++i) {
        cin >> edges[i].first >> edges[i].second;
        edges[i].first--;edges[i].second--;
        G[edges[i].first][edges[i].second] = 1;
        G[edges[i].second][edges[i].first] = 1;
    }
    for (int i = 0;i < n;++i) G[i][i] = 0;
    for (int i = 0;i < n;++i) for (int j = 0;j < n;++j) for (int k = 0;k < n;++k) G[j][k] = min(G[j][k],G[j][i]+G[i][k]);
    cin >> m;
    vector<P> p(m);
    for (int i = 0;i < m;++i) cin >> p[i].first >> p[i].second,p[i].first--,p[i].second--;
    vector<ll> dp(1<<m,0);
    dp[0] = 1;
    for (int i = 0;i < n-1;++i) {
        int s = 0;
        for (int j = 0;j < m;++j) if (G[p[j].first][p[j].second] == G[p[j].first][edges[i].first]+G[edges[i].first][p[j].second] && G[p[j].first][p[j].second] == G[p[j].first][edges[i].second]+G[edges[i].second][p[j].second]) s |= (1<<j);
        for (int j = (1<<m)-1;j >= 0;--j) dp[j|s] += dp[j];
    }
    cout << dp[(1<<m)-1] << endl;
    return 0;
}

Measured memory_bytes: 8448
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if (a<=5) cout<<"0";
	else if (a>12) cout<<b;
	else cout<<b/2;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static boolean find_k(int a, int b,int x){
        if (x==0)
            return true;
        else{for(int i=1;i<=a;i++){
            for(int j=1; j<=b;j++){
                int y=i*j+(a-i)*(b-j);
                if(y==x){
                    return true;
                }
                if(y>x){
                    break;
                }

            }
        }
        return false;}
    }

    public static void main(String[] args) {
        Scanner r=new Scanner(System.in);
        int m=r.nextInt();
        int n=r.nextInt();
        int k=r.nextInt();
        if (find_k(m,n,k))
            System.out.println("Yes");
        else
            System.out.println("No");


    }
}


Measured memory_bytes: 23508
/*
            _ _  ___            __ _ _  _       _     
 _   _  ___| | |/ _ \__      __/ _| | || |  ___| |__  
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ 
| |_| |  __/ | | |_| |\ V  V /|  _| |__   _\__ \ | | |
 \__, |\___|_|_|\___/  \_/\_/ |_| |_|  |_| |___/_| |_|
 |___/                 

*/

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define debug(x) cout<<#x<<": "<<x<<endl
#define For(i, st, en) for(ll i=st; i<en; i++)
#define rfor(i, st, en) for(ll i=st; i>=en; i--)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define printv(x) For(i, 0, x.size()){cout<<x[i]<<" ";} cout<<endl;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define int long long
#define F first
#define S second
#define pb push_back
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector< vector<int> > vvi;
typedef vector< pair<int, int> > vpi;
#define MAXN 300005
#define MOD 1000000007
#define INF 1000000000000000007


signed main(){
	fast
	int n;
	cin>>n;
	double temp;
	double ans=0;

	For(i, 0, n){
		cin>>temp;
		ans+=(1/temp);
	}
	ans = (1/ans);
	cout<<fixed<<setprecision(10);
	cout<<ans<<endl;
    return 0;
}
    



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int S[13]={0};int H[13]={0};int C[13]={0};int D[13]={0};int n;string s;int a;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s;
        if(s=="S"){
            cin >> a;S[a-1]=1;
        }else if(s=="H"){
            cin >> a;H[a-1]=1;
        }else if(s=="C"){
            cin >> a;C[a-1]=1;
        }else{
            cin >> a;D[a-1]=1;
        }
    }
    for(int i=0;i<13;i++){
        if(S[i]==0){cout << "S" << " " << i+1 << endl;}
    }
    for(int i=0;i<13;i++){
        if (H[i]==0){cout << "H" << " " << i+1 << endl;}
    }
    for(int i=0;i<13;i++){
        if (C[i]==0){cout << "C" << " " << i+1 << endl;}
    }
    for(int i=0;i<13;i++){
        if (D[i]==0){cout << "D" << " " << i+1 << endl;}
    }
    
}



Measured memory_bytes: 3128
n = int(input())

adj = [list(map(int, input().split())) for i in range(n)]

def mst():
    T = [0]
    gross_weight = 0
    cnt = n - 1
    while cnt:
        ew = 2001
        for i in range(len(T)):
            for tv, tew in enumerate(adj[T[i]]):
                if (tv not in T) and (tew != -1):
                    if tew < ew:
                        v, ew = tv, tew
        T.append(v)
        gross_weight += ew
        cnt -= 1
    print(gross_weight)


mst()

Measured memory_bytes: 7908