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

string S;

deque<int> posarr[30];
string memo[200005];
string ans = "-";

int main(){
	cin >> S;
	for(long long i = 0; i < S.size(); i++){
		int idx = S[i] - 'a';
		posarr[idx].push_back(i);
		memo[i] = "-";
	}
	long long pos = -1;
	while(pos < (long long)S.size()){
		string cur = "";
		if(pos != -1){
			cur = memo[pos];
			memo[pos] = "";
		}
		if(cur == "-"){
			pos++;
			continue;
		}

		for(int i = 0; i <= 'z' - 'a'; i++){
			if(posarr[i].size() > 0 && posarr[i][0] == pos){
				posarr[i].pop_front();
			}
			if(posarr[i].size() == 0){
				if(ans == "-"){
					ans = cur + char(i + 'a');
				}else if(ans.size() > cur.size() + 1){
					ans = cur + char(i + 'a');
				}else if(ans.size() == cur.size() + 1 && ans > (cur + char(i + 'a'))){
					ans = cur + char(i + 'a');
				}
				break;
				//return 0;
			}
			long long nextpos = posarr[i][0];
			string nstr = cur;
			nstr += ('a' + i);
			if(memo[nextpos] == "-"){
				memo[nextpos] = nstr;
			}else{
				if(memo[nextpos].size() > nstr.size()){
					memo[nextpos] = nstr;
				}else if(memo[nextpos].size() == nstr.size() && memo[nextpos] > nstr){
					memo[nextpos] = nstr;
				}
			}
		}
		pos++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 14340
#include<iostream>
#include<vector>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

#define MAX_N 100005
typedef long long ll;
vector<int> prime;
bool is_prime[MAX_N];

void sieve(int n){
    for(int i=0;i<=n;i++){
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
}

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    sieve(100000);
    set<int> st;
    rep(i,n){
        int k = a[i];
        rep(j,prime.size()){
            if((ll)prime[j]*prime[j] > k){
                break;
            }
            while(k%prime[j]==0){
                st.insert(prime[j]);
                k/=prime[j];
            }
        }
        if(k!=1){
            st.insert(k);
        }
    }
    // for(auto x:st){
    //     cerr << x << endl;
    // }
    ll mx = 0;
    for(auto x:st){
        ll tmp = 0;
        rep(i,n){
            if(a[i]%x==0){
                tmp+=a[i];
            }
        }
        mx = max(mx,tmp);
    }
    cout << mx << endl;

    return 0;
}


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

#define fastio ios::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long
#define fi first
#define se second
#define maxn 101

const int mod = 1e9+7 ;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;

int dp[3][maxn];

signed main()
{
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
	fastio;
	int n;	cin >> n;
	int a[3][n+1];
	for (int i = 1; i <= 2; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= 2; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + a[i][j];
		}
	}
	cout << dp[2][n];
}




Measured memory_bytes: 3556
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0);
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}

int main() { _
  int n; cin >> n;
  set<string> s;
  for (int i = 0; i < n; i++) {
    string tmp; cin >> tmp;
    s.insert(tmp);
  }
  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 19196
mojisu=int(input())
moji=input()
mojilist=[]
zenlen=len(moji)
mojilist.append([moji[0], 1])
moji=moji[1:]
for i in range(len(moji)):
    molswi=0
    for mol in range(len(mojilist)):
        if mojilist[mol][0]==moji[i]:
            mojilist[mol][1]+=1
            molswi=1
        if mol==len(mojilist)-1 and molswi==0:
            mojilist.append([moji[i], 1])
#print(mojilist)

kazu=2**(mojisu)
amari=1
for mol in mojilist:
    amari=amari*(mol[1]+1)%(10**9+7)
print(amari-1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
 
  int main(){
      lint h,w,m;
      cin>>h>>w>>m;
      map<P,lint>mp;
      lint x[w];
      lint y[h];
      fill(x,x+w,0);
      fill(y,y+h,0);
      rep(i,m){
          lint a,b;
          cin>>a>>b;
          --a;--b;
          x[b]++;
          y[a]++;
          mp[{a,b}]++;
      }
      lint mxx=*max_element(x,x+w);
      lint myy=*max_element(y,y+h);
      vector<lint> xx;
      vector<lint> yy;
      rep(i,w){
          if(x[i]==mxx)xx.push_back(i);
      }
      rep(i,h){
          if(y[i]==myy)yy.push_back(i);
      }
      rep(i,xx.size()){
          rep(j,yy.size()){
              if(!mp.count({yy[j],xx[i]})){
                  cout<<mxx+myy<<endl;
                  return 0;
              }
          }
      }
      cout<<mxx+myy-1<<endl;
  }
      

Measured memory_bytes: 35000
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws ClassNotFoundException, IOException {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		List<Integer> p = new ArrayList<Integer>();
		for(int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		int count = 0;
		for(int j = 1; j < p.size()-1; j++) {
			boolean pattern1 = (p.get(j) - p.get(j-1) > 0) && (p.get(j) - p.get(j+1) < 0);
			boolean pattern2 = (p.get(j) - p.get(j-1) < 0) && (p.get(j) - p.get(j+1) > 0);
			if(pattern1 || pattern2) {
				count++;
			}
		}
		System.out.println(count);
	}


}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21076
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())

import string
from collections import deque

name_table = string.ascii_lowercase
ans = deque()


while n > 0:
    n -= 1
    m = n % 26
    ans.appendleft(name_table[m])
    n //= 26

print(''.join(ans))


Measured memory_bytes: 68500
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let d: usize = iterator.next().unwrap().parse().unwrap();
    let mut x: Vec<Vec<isize>> = Vec::new();
    for _ in 0..n {
        let mut v: Vec<isize> = Vec::new();
        for _ in 0..d {
            v.push(iterator.next().unwrap().parse().unwrap());
        }
        x.push(v);
    }

    let mut ans: usize = 0;
    for i in 0..n {
        for j in 0..n {
            if i >= j {
                continue;
            }
            let mut s = 0;
            for k in 0..d {
                s += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }

            let mut l = 0;
            while l * l <= s {
                if l * l == s {
                    ans += 1;
                    break;
                }
                l += 1;
            }
        }
    }

    return ans.to_string();
}


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

ll n, x, ans;

void solve(ll nn, ll xx){
    xx = xx < (nn - xx) ? xx : (nn - xx);
    //printf("nn %lld xx %lld ans %lld\n", nn, xx, ans);
    if(nn % xx == 0){
        ans += (nn / xx - 1) * xx * 3;
        printf("%lld\n", ans);
    }
    else {
        ans += (nn / xx - 1) * xx * 3;
        solve(nn - (nn / xx - 1) * xx, nn % xx);
    }
}

int main()
{
    cin >> n >> x;
    x = x < (n - x) ? x : (n - x);
    if(n % x == 0){
        ans = (n / x - 1) * x * 3;
        printf("%lld\n", ans);
    }
    else{
        ans = (n / x - 1) * x * 3;//辺x が n / x - 1個
        //printf("n %lld x %lld ans %lld\n", n, x, ans);
        solve(n - (n / x - 1) * x, n % x);
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, *h, *c, i, j, r;
  cin >> n;
  h = new int[n];
  c = new int[n];
  for(i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  c[n - 1] = 0;
  for(i = n - 2; i >= 0; i--)
  {
    r = INT_MAX;
    for(j = i + 1; j <= i + 2 && j < n; j++)
    {
      r = min(r, abs(h[j] - h[i]) + c[j]);
    }
    c[i] = r;
  }
  cout << c[0] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

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

	vi dv(0);

	rep1(i, sqrt(m)) {
		if (m % i)continue;
		dv.push_back(i);
		dv.push_back(m / i);
	}

	int ans = 1;

	rep(i, dv.size())if (m / dv[i] >= n)ans = max(ans, dv[i]);

	cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    int mod=1000000007;
    int a[4],b[4];
    while (scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=EOF) {
        scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
        int h=0,l=0;
        for (int i=0;i<4;i++) {
            for (int j=0;j<4;j++) {
                if (i!=j && a[i]==b[j]) {
                    l+=1;
                } else if (a[i]==b[j]) {
                    h+=1;
                }
            }
        }
        printf("%d %d\n",h,l);
    }
    return 0;
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(a > 0 || c > 0){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

string S;
bool cnt[3];

void solve(void){
    cin >> S;
    bool f = true;
    rep(3, i) {
        if (S[i] == 'a') cnt[0] = !cnt[0];
        if (S[i] == 'b') cnt[1] = !cnt[1];
        if (S[i] == 'c') cnt[2] = !cnt[2];
    }
    rep(3, i) f = f && cnt[i];

    cout << (f?"Yes":"No") << '\n';
}

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


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	LL dp[40] = {0};
	dp[0] = 1;
	for (int i = 0; i < 31; i++) {
		dp[i + 1] += dp[i];
		dp[i + 2] += dp[i];
		dp[i + 3] += dp[i];
	}

	int n;
	while (cin>>n,n)
	{
		cout << (dp[n] % 3650 ? dp[n] / 3650 + 1 : dp[n] / 3650) << endl;
	}
}


Measured memory_bytes: 3076
#include <cstdio>
#include <algorithm>
using namespace std;
int a[200005],n,cnt,cnt1;
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n;++i)
	{
		scanf("%d",a+i);
		if (a[i]%4==0)
		{
			cnt++;
		}
		else if (a[i]%2==0)
		{
			cnt1++;
		}
	}
	n-=max(cnt1-1,0);
	if (cnt>=n/2)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(1e9 + 7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (b) - 1; (i) >= (a); --(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    ll n,k,ans = 1;
    cin >> n >> k;
    vl a(n);
    rep0(i, n){
        cin >> a[i];
    }
    sort(all(a),greater<>());
    if(a[0] < 0 && (k & 1)){
        rep0(i, k)ans = ans * a[i] % mod;
        ans += mod * 10;
        pf(ans % mod);
        return 0;
    }
    ll l = 0,r = n - 1;
    if(k & 1){
        ans *= a[0];
        l = 1;
    }
    rep0(i, k / 2){
        if(a[l] * a[l + 1] >= a[r] * a[r - 1]){
            ans = a[l] * a[l + 1] % mod * ans % mod;
            l += 2;
        }else{
            ans = a[r] * a[r - 1] % mod * ans % mod;
            r -= 2;
        }
    }
    pf((ans + mod * 10) % mod);
    return 0;
}


Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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(int argc, char const *argv[]) {
  ll x;
  cin >> x;
  ll ans=0;
  ans+=1000*(x/500);
  x%=500;
  ans+=5*(x/5);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
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();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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(void){
    int N,K; cin >> N >> K;
    int x[N], y[N]; char c;
    REP(i,N){
        cin >> x[i] >> y[i] >> c;
        if(c == 'W') y[i] += K;
        x[i] %= 2*K; y[i] %= 2*K;
    }
    int ans = 0, s[2*K+1][2*K+1];
    int a[2*K][2*K];
    REP(i,2*K)REP(j,2*K) a[i][j] = 0;
    REP(i,N) a[x[i]][y[i]]++;
    REP(i,2*K+1)REP(j,2*K+1) s[i][j] = 0;
    REP(i,2*K)REP(j,2*K){
        s[i+1][j+1] = s[i+1][j] + s[i][j+1] - s[i][j] + a[i][j];
    }

    vector<P> pp{P(1,1),P(3,1),P(2,2),P(4,2),P(1,3),P(3,3),P(2,4),P(4,4)};
    REP(i,2*K)REP(j,2*K){
        int tmp = 0;
        VI ii{0,max(0,i-K),i,min(2*K,i+K),2*K}, jj{0,max(0,j-K),j,min(2*K,j+K),2*K};
        for(P p : pp){
            int a = p.first, b = p.second;
            tmp += s[ii[a]][jj[b]] - s[ii[a-1]][jj[b]] - s[ii[a]][jj[b-1]] + s[ii[a-1]][jj[b-1]];
        }

        chmax(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 32256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC164
{
    class Program
    {
        static void Main(string[] args)
        {
            c();
        }

        public static void c() 
        {
            long n = long.Parse(Console.ReadLine());
            var list = new List<string>();
            for (long i = 0; i < n; i++)
            {
                list.Add(Console.ReadLine());
            }
            IEnumerable<string> list2 = list.Distinct();
            long ans = list2.Count();
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 41368
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s,t;
  cin >> s >> t;
  int cnt=0;
  rep(i,3){
    if(s[i]==t[i])cnt++;
  }
  cout << cnt << endl;
}  


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

int main()
{
	char S[100000];
	int i, A = 0, B = 0;
	cin >> S;					

	for (i = 0; i < 100000; i++)
	{
		if (S[i] == '1')
			A += 1;
		else if (S[i] =='0')
			B += 1;
		else break;
	}
	if (A > B)
		cout << B * 2 << endl;
	else
		cout << A * 2 << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <vector>
#include <stack>
#include <list>
#include <queue>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) 
        cin>>a[i];
    int b[n];
    for(int i=0;i<n;i++)
    {
        b[a[i]-1]=i+1;
        
    }
    for(int i=0;i<n;i++)
        cout<<b[i]<<" ";
    cout<<'\n';
    
    return 0;
}


Measured memory_bytes: 4396
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int[] T = new int[N];
		for (int i = 0; i < N; i++) {
			T[i] = scan.nextInt();
		}
		int M = scan.nextInt();
		int[] P = new int[M];
		int[] X = new int[M];
		for (int i = 0; i < M; i++) {
			P[i] = scan.nextInt();
			X[i] = scan.nextInt();
		}

		int time = 0;
		for (int i = 0; i < M; i++) {
			for (int j = 0; j < N; j++) {
				if (j + 1 == P[i]) {
					time += X[i];
				} else {
					time += T[j];
				}
			}
			System.out.println(time);
			time = 0;
		}
	}
}


Measured memory_bytes: 10064
#!/usr/bin/env python3
import sys, math


def solve(N: int, H: int, a: "List[int]", b: "List[int]"):
    amax = max(a)
    bbig = sorted([bb for bb in b if bb > amax])
    if len(bbig) > 0:
        ss = sum(bbig)
        if ss < H:
            print(len(bbig) + math.ceil((H-ss)/amax))
        else:
            counter = 0
            sm = 0
            for bb in reversed(bbig):
                sm += bb
                counter += 1
                if sm >= H:
                    break
            print(counter)
    else:
        print(math.ceil(H/amax))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, H, a, b)

if __name__ == '__main__':
    main()


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


template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    rep(i, 0, 4){
        cout << s[i];
    }
    cout << " ";
    rep(i,4,12){
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define rep(i,a,b)	for(i=a;i<b;i++)
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
int main()
{
	lli n,i,j,ans=0;
	cin >> n;
	string str;
	map<string,lli>ma;
	for(i=0;i<n;i++)
	{
		cin >> str;
		sort(str.begin(),str.end());
		if(ma.count(str)==0)
		{
			ma[str]=1;
		}
		else{
			ans+=(ma.at(str));
			ma[str]++;
			
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=long long;
using P=pair<int,int>;
//pとqの最大公約数
int gcd(int p,int q){
    if(p%q==0)
    return q;
    return gcd(q,p%q);
}
int main(){
    int n;
    cin>>n;
    vector<int64_t> r(87);
    r.at(0)=2;
    r.at(1)=1;
    for(int i=2;87>i;++i)
    r.at(i)=r.at(i-1)+r.at(i-2);
    cout<<r.at(n)<<endl;
}

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define INF2 (1e18)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const int mod = (int)(1e9);

int main(){
    ll s;
    cin >> s;
    int x = (mod-s%mod) % mod, y = (s+x) / mod;
    cout << "0 0 1000000000 1 " << x << ' ' << y << endl;
    return 0;
}


Measured memory_bytes: 3636
s = input()
k = int(input())
N = len(s)
subs = set()
for i in range(1, N):
    l = s[:i]
    r = s[i:]
    if len(l) > k:
        l = l[-k:]
    if len(r) > k:
        r = r[:k]
    while not l == '':
        subs.add(l)
        l = l[1:]
    while not r == '':
        subs.add(r)
        r = r[:-1]
subs.add(s)
subs = sorted(subs)
print(subs[k-1])

Measured memory_bytes: 4456
// inputに入力データ全体が入る
function Main(input) {
        // 1行目がinput[0], 2行目がinput[1], …に入る 
        //console.log("***input = " + input);
        //console.log("type = " + typeof(input));
        //console.log("size=" + input.length);
        input = input.split("\n");
        //console.log("***input.split = " + input);
        //console.log("type = " + typeof(input));
        //console.log("size=" + input.length);
        //文字列から10進数に変換するときはparseIntを使います
        var a = parseInt(input[0], 10);
        var b = parseInt(input[1], 10);
        //出力
        console.log('%d',b*2-a);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define alpha_size 26

const int N = 1e5 + 5;

int n, m;
int cnt[N], visited[N];


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    
     
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
      int x;
      string s;
      cin >> x >> s;
      if (s == "WA"){
        if (!visited[x])
          cnt[x]++;
      }
      else
        visited[x] = true;
    }
    int correct = 0, penalty = 0;
    for (int i = 1; i <= n; i++){
      if (visited[i]){
        correct++;
        penalty += cnt[i];
      }
    }
    cout << correct << " " << penalty << endl;
}

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

int main(){
	string S;
  	cin >> S;
  	int target;
  	int ans = 1000;
  	for(int i=0; i < S.size()-2;i++){
     	
    	target = stoi(S.substr(i,3));
        
        if(ans>abs(target - 753)){
        
          	ans = abs(target - 753);
        
        }
    
    }
  	
  	
  	cout <<ans<< endl;
  
  
  
}

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


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	int D;
	cin >> D;

	D = 25 - D;

	cout << "Christmas";
	for (int i = 0; i < D; i++)
		cout << " Eve";
	cout << endl;

	
	return 0;
}

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

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(i==4) cout << " " << s[i];
        else cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

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

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define arrlen(arr) (sizeof(arr)/sizeof(arr[0]))
#define Sort(arr) sort(arr, arr+arrlen(arr))
#define For(i,s,n) for(int i=s;i<n;i++)

int main(){
	int N,M;
	cin >> N >> M;
	int L[M],R[M];
	For(i,0,M) cin >> L[i] >> R[i];
	
	int Lmax=L[0],Rmin=R[0];
	For(i,0,M){
		Lmax=max(Lmax,L[i]);
		Rmin=min(Rmin,R[i]);
	}
	cout << max(Rmin-Lmax+1,0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);


int main() {
int x,y;cin >>x>>y;
if(x==2||y==2) {
    cout << "No" <<endl;
    return 0;
}
if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))
{
    cout << "Yes" <<endl;
    return 0;
}
if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
    cout <<"Yes" <<endl;
    return 0;
}
cout << "No" <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
typedef long long LL;
LL n;

vector<LL>v;
 LL sum=0;
LL b[100005]={0};
struct node
{
	 LL v,i;
};
bool cmp(const node a,const node b)
{ 
 return a.v<b.v;
}
struct node a[100005];
void bfs(LL index,LL t)
{
LL i=index;
	sum+=(t-b[i]);
	while(i>=0)
	 {
	 	 if(v[i]<t)
	 	 	break;
	 	 	b[i]=t;
			
		     i--;
	 }
	 i=index;
	 while(i<n)
	 {
	 	if(v[i]<t)
	 	 break;
		 
		b[i]=t;
		  i++;
	 }
 } 
int main()
{
 cin>>n;
  for(LL i=0;i<n;i++)
  {
  	cin>>a[i].v;
  	a[i].i=i;
  	v.push_back(a[i].v);
  }
 
  sort(a,a+n,cmp);
  for(LL i=0;i<n;i++)
  {
  	bfs(a[i].i,a[i].v);
//  	cout<<i<<" "<<a[i].v<<" "<<a[i].i<<endl;
//  	for(int i=0;i<n;i++)
//  	cout<<b[i]<<" ";
//  	cout<<"sum= "<<sum;
//  	cout<<"\n";
  }
//  for(int i=0;i<v.size();i++)
//  cout<<v[i]<<" ";
  cout<<sum;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

typedef unsigned long long ull;

long long n,k;
set<pair<long long,long long>> p;
set<long long> x,y;
map<long long,long long> fw_x,fw_y,bw_x,bw_y;

inline long long cvx(long long xx) {
	return fw_x[xx];
}

inline long long cvy(long long yy) {
	return fw_y[yy];
}

inline long long rvx(long long xx) {
	return bw_x[xx];
}

inline long long rvy(long long yy) {
	return bw_y[yy];
}

int main(int argc,char** argv) {
	cin >> n >> k;
	for(long long i = 0;i < n;i++) {
		long long xx,yy;
		cin >> xx >> yy;
		p.insert(make_pair(xx,yy));
		x.insert(xx);
		y.insert(yy);
	}
	int ind = 0;
	for(auto itr = x.begin();itr != x.end();itr++) {
		fw_x[*itr] = ind;
		bw_x[ind] = *itr;
		ind++;
	}
	ind = 0;
	for(auto itr = y.begin();itr != y.end();itr++) {
		fw_y[*itr] = ind;
		bw_y[ind] = *itr;
		ind++;
	}
	long long res = 0x7fffffffffffffff;
	for(long long xx1 = 0;xx1 < x.size();xx1++) {
		for(long long yy1 = 0;yy1 < y.size();yy1++) {
			for(long long xx2 = xx1;xx2 < x.size();xx2++) {
				for(long long yy2 = yy1;yy2 < y.size();yy2++) {
					long long count = 0;
					for(auto& e:p) {
						long long cx = cvx(e.first);
						long long cy = cvy(e.second);
						if(cx >= xx1 && cx <= xx2 && cy >= yy1 && cy <= yy2) count++;
					}
					if(count >= k) res = min(res,((rvx(xx2) - rvx(xx1)) * (rvy(yy2) - rvy(yy1))));
				}
			}
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using std::swap;

// priceをキーに降順でソート
//sort(fruits.begin(), fruits.end(),
//     [](const fruit& x, const fruit& y) { return x.price > y.price;});

int main() {
    int x, y;
    std::cin >> x >> y;
    if (x<10 && y<10){
        std::cout << x*y << std::endl;
    }
    else{
        std::cout << -1 << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x << 1) + (x << 3) + (ch ^ 48);
    return x * fh;
}

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 310;
int A, B, n, d[N][N], f[N][N];

int main () {
	File();

	n = 149;
	A = read(); B = read();
	For (i, 1, A) For (j, 1, B) d[i][j] = read();

	For (i, 0, n) For (j, 0, n)
		For (a_, 1, A) For (b_, 1, B)
			chkmax(f[i][j], d[a_][b_] - a_ * i - b_ * j);

	For (a_, 1, A) For (b_, 1, B) {
		int res = 0x7f7f7f7f;
		For (i, 0, n) For (j, 0, n)
			chkmin(res, f[i][j] + a_ * i + b_ * j);
		if (res != d[a_][b_]) return puts("Impossible"), 0;
	}

	puts("Possible");
	
	printf ("%d %d\n", n * 2 + 2, n * 2 + (n + 1) * (n + 1));
	int S = 1, T = n + 2;
	For (i, 1, n)
		printf ("%d %d X\n", i, i + 1);

	For (i, 1, n)
		printf ("%d %d Y\n", i + n + 2, i + n + 1);

	For (i, 0, n) For (j, 0, n)
		printf ("%d %d %d\n", i + 1, j + n + 2, f[i][j]);

	printf ("%d %d\n", S, T);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;
int main(){
    int n,q;
    cin>>n>>q;
    vector<vector<int>> tr(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        tr[a].push_back(b);
        tr[b].push_back(a);
    }
    vector<int> p(n);
    for(int i=0;i<q;i++){
        int pi,x;
        cin>>pi>>x;
        pi--;
        p[pi]+=x;
    }

    queue<int> bfsq;
    bfsq.push(0);
    vector<int> dist(n,-1);
    vector<int> pnt(n);
    dist[0]=0;
    pnt[0]+=p[0];
    while(!bfsq.empty()){
        int temp=bfsq.front();
        bfsq.pop();

        for(int i=0;i<tr[temp].size();i++){
            if(dist[tr[temp][i]]!=-1) continue;
            dist[tr[temp][i]]=dist[temp]+1;
            pnt[tr[temp][i]]=pnt[temp]+p[tr[temp][i]];
            bfsq.push(tr[temp][i]);
        }
    }
    for(int i=0;i<n;i++){
        cout<<pnt[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 17140
/**
 *    author:  tourist
 *    created: 21.03.2020 15:15:22       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  vector<vector<int>> f(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (i + j == 0) {
        f[0][0] = (s[0][0] == '#');
      } else {
        f[i][j] = (int) 1e9;
        if (i > 0) f[i][j] = min(f[i][j], f[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#'));
        if (j > 0) f[i][j] = min(f[i][j], f[i][j - 1] + (s[i][j - 1] == '.' && s[i][j] == '#'));
      }
    }
  }
  cout << f[h - 1][w - 1] << '\n';
  return 0;
}


Measured memory_bytes: 384
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n,sum=0;
  cin >> n;
  map<int,int> cnt;
  for(int i=1;i<=n;i++){
    int x;
    cin >> x;
    cnt[x]++;
    sum+=x;
  }
  int q;
  cin >> q;
  for(int i=1;i<=q;i++){
    int x, y;
    cin >> x >> y;
    cnt[y]+=cnt[x];
    sum+=(y*cnt[x]-x*cnt[x]);
    cout << sum << endl;
    cnt[x]=0;
  }

return 0;
}
///....


Measured memory_bytes: 9520
A, B, H, M = map(int, input().split())

# 時針と分針の成す角
import math

degM = M*(360/60)
degH = H*(360/12) + M*(30/60)

deg = (degH - degM)

c = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(deg * math.pi / 180))

print(c)

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

typedef unsigned long long ll;

int main()
{
	ll a,b,c;
	cin>>a>>b>>c;
	// unordered_set<set<ll> >st;
	set<set<ll> >st;
	if ( (a%2 ==1) || (b%2 ==1) || (c%2 ==1) )
	{
		printf("0\n");
		return 0;
	}
	ll ans =0;
	while(1)
	{
		set<ll> tmp;
		tmp.insert(a);
		tmp.insert(b);
		tmp.insert(c);
		if (st.find(tmp) != st.end())
		{
			printf("-1\n");
			return 0;
		}
		st.insert(tmp);
		ll tmp1 = (b+c)/2;
		ll tmp2 = (a+c)/2;
		ll tmp3 = (b+a)/2;
		a = tmp1;
		b = tmp2;
		c = tmp3;
		ans++;
		if ( (a%2 ==1) || (b%2 ==1) || (c%2 ==1) )
		{
			break;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
        import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        
        long[][][] dp = new long[n+1][n+1][3010];
        
        dp[0][0][0] = 1;

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k <= 2500; k++) {
                    dp[i + 1][j][k] += dp[i][j][k];
                    if (k>=x[i]) dp[i + 1][j + 1][k] += dp[i][j][k-x[i]];
                }
            }

        }

        long ans = 0;
        for (int k = 1; k <= n; k++) {
            ans += dp[n][k][k * a];
        }
        System.out.println(ans);

    }

}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vp data(0);

    int ans = 0, rest = 0, sum = 0;
    bool rg = true;
    rep(i, n) {
        int2(a, b);
        rg &= a == b;
        sum += a;
        if (a <= b) {
            ans += b;
            rest += b - a;
        } else {
            data.pb( make_pair(b, a) );
        }
    }

    if (rg) {
        cout << 0 << endl;
        return 0;
    }

    sort(all(data));

    cout << sum - data[0].fir << endl;

    return 0;
}









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

const int maxn=2e5+5;
int a[maxn];
int n;

int main(){
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> a[i];	
	}
	sort(a+1,a+n+1);
	bool f=0;
	for (int i=2;i<=n;i++){
		if (a[i]==a[i-1]){
			f=1;
			break;
		}
	}
	if (f) cout << "NO";
	else cout << "YES";
	return 0;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
c=[[] for _ in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    c[a].append(b)
    c[b].append(a)
def des(c,res):
    for i in range(1,n+1):
        if len(c[i])==1:
            c[c[i][0]].remove(i)
            c[i]=[]
            res=des(c,res+1)
    return res
print(des(c,0))

Measured memory_bytes: 3064
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); i++)
#define rep1(i,n) for(int (i) = 1; (i) <= (int)(n); i++)
#define INF 1000000


int main()
{
    int N;
    cin >> N;
    
    vector<int> X(N);
    double sum = 0;
    rep(i, N){
        cin >> X[i];
        sum += X[i];
    }
    
    double ave = sum / N;
    
    int P = (int) (ave + 0.5);
    ll sta=0;
    rep(i, N){
        sta += (P - X[i]) * (P - X[i]);
    }
    
    cout << sta << endl;
    
    return 0;
}



Measured memory_bytes: 256