akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      string S;
      cin >> S;
      vector<char> alp(27);
      alp = {'a', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
      if (S == "snuke") {
        cout << alp.at(j)<< i << endl;
        break;
      }
    }
  }
}

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

const int INF = 1 << 29;
int n, m;
int main()
{
    cin >> n >> m;
    vector<int> s(n + 1, INF);
    int ans = 0;
    for (size_t i = 0; i < m; i++)
    {
        /* code */
        int x, y;
        cin >> x >> y;
        s[x] = min(s[x], y);
    }
    int mn = INF;
    for (size_t i = 1; i <= n; i++)
    {
        /* code */
        mn = min(mn, s[i]);
        if (i >= mn)
        {
            ans++;
            mn = s[i];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

char soroban_table[8][10]={
    '*','*','*','*','*',' ',' ',' ',' ',' ',
    ' ',' ',' ',' ',' ','*','*','*','*','*',
    '=','=','=','=','=','=','=','=','=','=',
    ' ','*','*','*','*',' ','*','*','*','*',
    '*',' ','*','*','*','*',' ','*','*','*',
    '*','*',' ','*','*','*','*',' ','*','*',
    '*','*','*',' ','*','*','*','*',' ','*',
    '*','*','*','*',' ','*','*','*','*',' '
};

/*
*****
     *****
==========
 **** ****
* **** ***
** **** **
*** **** *
**** ****
*/
int main(){
    string input;
    bool flag = true;
    while(cin >> input){
        if(flag)flag=false;
        else cout<<endl;
        
        while(input.length()<5){
            input='0'+input;
        }
        for(int i=0; i<8; i++){
            for(int j=0; j<input.length(); j++){
                cout<<soroban_table[i][input[j]-'0'];
            }
            cout<<endl;
        }
        
    }
}

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

int main() {
	int n; cin >> n;
	vector<int>a(3*n); for (auto&& x : a)cin >> x;
	sort(a.begin(), a.end());
	long long ans = 0;
	for (int i = 3 * n - 2, cnt = 0; cnt < n; i -= 2, cnt++) {
		ans += a[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
/*
ABC128
C - Switches
bit全探索(ビット演算 (bit 演算) の使い方を総特集！-Qiita)

bit全探索の流れ
for ０~n-1の集合を全探索 (1<<n)
    for 0~n-1探索
        if i が bit に入るかどうか (S&(1<<i))
*/
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
using namespace std;

int main()
{
    int n,m;//N個のスイッチ M個の電球
    cin>>n>>m;
    //a()への入力
    vector<int>a(n);//縦軸はN個のスイッチ　横軸はM個の電球
    REP(i,m)//i番目の電球
    {
        int k;//ki個のスイッチ
        cin>>k;
        REP(j,k)//電球iはki個のスイッチに繋がっておる
        {
            int s;
            cin>>s;
            s--;
            a[s]|=1<<i;//!!ビットa[s]にi番目のフラグを立てる
        }
    }
    int p=0;//スイッチのうちonになっているスイッチの個数を2で割った余りがpiに等しい時に点灯します。
    REP(i,m)
    {
        int x;
        cin>>x;
        p|=x<<i;//!!ビットpにi番目のフラグを立てる
    }
//入力部分完了
    int ans=0;
    REP(s,(1<<n))//０~n-1の集合を全探索
    {
         int t=0;//ｔはスイッチの状態sで電球の状態　初期化
        REP(i,n)//0~n-1探索
        {
            if(s>>i&1)//スイッチを押したかどうかを確認  i∈Sかどうか or if(S&(1<<i))
            {
                 t^=a[i];//押したら電球状態更新　^は排他的論理和(XOR)　2で割った余りの状態
            }
        }
      if(t==p)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

int main(){
	string s;
	cin>>s;
	string ans;
	for(int i = 0; i < s.length(); i++){
		switch(s[i]){
			case '0':ans+='0';break;
			case '1':ans+='1';break;
			case 'B':if(!ans.empty())ans.pop_back();break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    osatu = N // 1000
    amari = (osatu + 1)*1000 - N
    if amari == 1000:
        print(0)
    else:
        print(amari)

    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9164
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int ans=1;
	for(int i=a;i!=0;i--) {
		if(Math.sqrt(i)==(int)Math.sqrt(i)){
			System.out.println(i);
			break;
	}
	}
	scan.close();
}
}

Measured memory_bytes: 21716
#include <stdio.h>

#define MAX_N (50)

int memo[MAX_N];

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

    memo[0] = memo[1] = 1;

    for ( int i = 2; i <= n; i++ ) {
    	memo[i] = memo[i-1] + memo[i-2];
    }
    printf("%d\n", memo[n]);

    return 0;
}

Measured memory_bytes: 1024
h, w, n = map(int, input().split())

d = {}
ab = []

for i in range(n):
    s = input()
    d[s] = 1
    a, b = map(int, s.split())
    ab.append((a, b))

memo = [0] * 10

def check(a,b):
    cnt = 0
    for i in range(a,a+3):
        for j in range(b,b+3):
            if str(i) + ' ' + str(j) in d:
                cnt += 1
    memo[cnt] += 1
                
for a, b in ab:
    for i in range(max(1,a-2), min(h-1,a+1)):
        for j in range(max(1,b-2), min(w-1,b+1)):
            check(i,j)

for i in range(1, 10):
    memo[i] = memo[i] // i

memo[0] = (h-2) * (w-2) - sum(memo)

for memoi in memo:
    print(memoi)


    




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

using namespace std;

bool is_prime[300001];

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

int main(void){
	sieme(300000);
	while(1){
		long long int ans=0;
		int n;
		cin >> n;
		if(n==0)break;
		long long int a=2;
		while(n>0){
			if(is_prime[a]==true)ans+=a,n--;
			a++;
		}
		cout << ans << endl;
		
	}
	return 0;
}

Measured memory_bytes: 0
require 'prime'
DBG = !true

def combi(n,k)
  k=n-k if 2*k > n
  return 1 if k == 0
  ((n-k+1)..n).reduce(&:*)/((1..k).reduce(&:*))
end

n = gets.to_i

a = {}
for i in 2..n
  ls = i.prime_division
  for x in ls
    pr = x[0]
    ex = x[1]
    if a.keys.include?(pr)
      a[pr] += ex
    else
      a[pr] = ex
    end
  end
end

# now a : { 2:3, 3:1, ... }

b = []
for x in a.keys
  b << [x, a[x]]
end

print b if DBG
puts ""

sum = 0
for x in b
  psum = 0
  if x[1] >= 74
    psum += 1
  end
  sum += psum
  if DBG && psum != 0
    printf("%d - add %d", x[0], psum)
    puts ""
  end
end

b.combination(2) { |x,y|
  psum = 0
  if x[1] >= 24 && y[1] >= 2
    psum += 1
  end
  if y[1] >= 24 && x[1] >= 2
    psum += 1
  end
  if x[1] >= 14 && y[1] >= 4
    psum += 1
  end
  if y[1] >= 14 && x[1] >= 4
    psum += 1
  end
  sum += psum
  if DBG && psum != 0
    printf("%d %d - add %d", x[0], y[0], psum)
    puts ""
  end
}

b.combination(3) { |x,y,z|
  if DBG && false
    print x
    puts "--x"
    print y
    puts "---y"
    print z
    puts "----z"
  end
  psum = 0
  if x[1] >= 4 && y[1] >= 4 && z[1] >= 2
    psum += 1
  end
  if x[1] >= 4 && z[1] >= 4 && y[1] >= 2
    psum += 1
  end
  if z[1] >= 4 && y[1] >= 4 && x[1] >= 2
    psum += 1
  end
  sum += psum
  if DBG && psum != 0
    printf("%d %d %d - add %d", x[0], y[0], z[0], psum)
    puts ""
  end
}

print sum


Measured memory_bytes: 2044
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

struct ModCombination {
    vector<mint> Fac;
    vector<mint> Facinv;

    ModCombination(int x) {
        Fac.assign(x+1,1);
        Facinv.resize(x+1);
        for (long long i = 1; i <= x; i++) Fac[i] = Fac[i-1]*i;
        for (int i = 0; i <= x; i++) Facinv[i] = mint(1)/Fac[i];
    }

    mint get(int n, int k) {
        return Fac[n]*Facinv[k]*Facinv[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; cin >> N >> K;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    sort(all(A));
    ModCombination MC(N);
    mint MAX = 0;
    mint MIN = 0;
    for (int i = K-1; i < N; i++) {
        if (A[i] >= 0) MAX += MC.get(i,K-1)*A[i];
        else MAX -= MC.get(i,K-1)*(-A[i]);
    }
    for (int i = 0; i <= N-K; i++) {
        if (A[i] >= 0) MIN += MC.get(N-1-i,K-1)*A[i];
        else MIN -= MC.get(N-1-i,K-1)*(-A[i]);
    }
    
    cout << (MAX-MIN).a << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
typedef unsigned long long ull;
typedef signed long long sll;
using namespace std;

#define INF 0x7FFFFFFFFFFFFFFF
#define BIG_PRIME 1000000007

#define COUNT(x,mask,shift) ((((x)&((mask)<<(shift)))>>(shift))+((x)&(mask)))

ull Count(ull x)
{
  x=COUNT(x,0x5555555555555555,1);
  x=COUNT(x,0x3333333333333333,2);
  x=COUNT(x,0x0F0F0F0F0F0F0F0F,4);
  x=COUNT(x,0x00FF00FF00FF00FF,8);
  x=COUNT(x,0x0000FFFF0000FFFF,16);
  x=COUNT(x,0x00000000FFFFFFFF,32);
  return x;
}

int main()
{
  ull i,j,N,count;
  cin >> N;
  vector<ull> dp(1<<N,0);
  vector<vector<ull>> a(N);
  for(i=0;i<N;++i)
  {
    a[i].resize(N);
    for(j=0;j<N;++j)
    {
      cin >> a[i][j];
    }
  }
  dp[0]=1;
  for(i=1;i<(1<<N);++i)
  {
    count = Count(i)-1;
    for(j=0;j<N;++j)
    {
      if(i&(1<<j))
      {
        if(a[count][j])
        {
          dp[i]=(dp[i]+dp[i&~(1<<j)])%BIG_PRIME;
        }
      }
    }
  }
  cout << dp[(1<<N)-1];
  return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>list(N);
  for(int i=0;i<N;i++){
    cin>>list.at(i);
  }
  sort(list.begin(),list.end());
  int sum=0;
  for(int i=0;i<N-1;i++){
    sum=sum+list.at(i);
  }
  if(list.at(N-1)<sum){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5;
int n,m,d[35],x[N],y[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x[i],&y[i]);
		if(((x[i]+y[i])&1)!=((x[1]+y[1])&1)){
			puts("-1");
			return 0;
		}
	}
	for(int i=30;~i;i--)	d[++m]=1<<i;
	if(!((x[1]+y[1])&1))	d[++m]=1;
	printf("%d\n",m);
	for(int i=1;i<=m;i++)	printf("%d ",d[i]);
	putchar('\n');
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(abs(x[i])>abs(y[i])){
				if(x[i]<0)	x[i]+=d[j],putchar('L');
				else	x[i]-=d[j],putchar('R');
			}
			else{
				if(y[i]<0)	y[i]+=d[j],putchar('D');
				else	y[i]-=d[j],putchar('U');
			}
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 256
from collections import deque
n = int(input())
e = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)



def bfs(x):
    dis = [float("INF")]*n
    q = deque([])
    dis[x] = 0
    q.append((x,-1))
    while q:
        now,bef = q.popleft()
        for nex in e[now]:
            if nex != bef:
                dis[nex] = dis[now]+1
                q.append((nex,now))
    return dis

dis1 = bfs(0)
dis2 = bfs(n-1)
count = 0
for i in range(n):
    if dis1[i] <= dis2[i]:
        count += 1
    else:
        count -= 1
if count > 0:
    print("Fennec")
else:
    print("Snuke")



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

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

using namespace std;

void init();
void solve();

int main()
{
	init();
	solve();
}

string s;

void init()
{
	cin >> s;
}

void solve()
{
	int res = 0;
	rep(i, s.length()-1) {
		if (s[i+1] != s[i]) res++;
	}
	cout << res << endl;
}

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

int main(){
    int n,x,t;
    cin>>n>>x>>t;
    int ret=0,ans=0;
    
    while(ans<n){
        //cout<<"hi"<<endl;
        ans = ans + x;
        ret = ret + t;
    }
    cout<<ret;












    return 0;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define each(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vd vector<double>
#define vvd vector<vd>
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
const double PI = 3.14159265;
const int MAXN = 1 << 15;
const ll LINF = 1LL << 60;
const int INF = 1 << 30;
///////////////////////////////////////////////////////////
int n;
deque<int> d;

int main() {
  cin >> n;
  rep(i, 0, n) {
    int q, p, x;
    cin >> q >> p;
    if (q == 0) {
      cin >> x;
      if (p == 0) d.push_front(x);
      if (p == 1) d.push_back(x);
    } else if (q == 1) {
      if (q == 1) cout << d[p] << endl;
    } else {
      if (p == 0) d.pop_front();
      if (p == 1) d.pop_back();
    }
  }
}


Measured memory_bytes: 4588
/**
 * Created by hiramekun at 20:50 on 2020-04-04.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll rec(ll n, ll k, ll prev) {
    if (n >= prev) return prev;
    return rec(abs(n - k), k, n);
}

ll lcm(ll m, ll n) {
    if ((0 == m) || (0 == n)) return 0;
    return ((m / gcd(m, n)) * n);
}

void solve() {
    ll n, k;
    cin >> n >> k;
    if (n % k == 0) cout << 0 << '\n';
    else if (n < k) cout << min(n, abs(n - k)) << '\n';
    else {
        n %= k;
        cout << min(n, abs(n - k)) << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int ans=0;
		for(int i=1;i<=n;i++)
		{
			int tep=i;
			int len=0;
			while(tep>0)
			{
				tep=tep/10;
				len++;
			}
			if(len%2==1)
			{
				ans++;
			}
		}
		System.out.println(ans);
	}
}
	

Measured memory_bytes: 21844
k = gets.to_i
qs = k.times.map{gets.chomp.split.map(&:to_i)}
ans = Array.new(8){Array.new(8,".")}

[*0..7].permutation do |as|
  flag = true
  pos = qs.dup
  as.each_with_index do |c,r|
    pos.each do |x,y|
      break if [r,c] == [x,y]
      if (r - x).abs == (c - y).abs || (r == x && y != c)
        flag = false
        break
      else
        pos << [r,c]
      end
    end
  end
  if flag
    pos.each do |x,y|
      ans[x][y] = "Q"
    end
    break
  end
end

ans.each do |a|
  puts a.join
end



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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

int dp[100010] = {};

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

    int N, K;
    cin >> N >> K;
    Vi a(N);
    int a_min = I_INF;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        a_min = min(a_min, a[i]);
    }

    for (int i = 0; i < a_min; ++i) {
        dp[K - i] = -1;
    }

    for (int i = K; i >= 0; --i) {
        bool nok = true;
        for (const auto& ai : a) {
            if (i + ai <= K and dp[i + ai] != 1) {
                nok = false;
                break;
            }
        }
        if (nok) dp[i] = -1;

        if (dp[i] == -1) {
            for (const auto& ai : a) {
                if (i - ai >= 0) dp[i - ai] = 1;
            }
        }
    }

    if (dp[0] == 1) {
        cout << "First" << endl;
    }
    else {
        cout << "Second" << endl;
    }

    return 0;
}

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



int main() {
    int h, n;
    cin >> h >> n;
    
    int sum = 0;
    rep(i,n) {
        int a;
        cin >> a;
        sum += a;
    }
    
    if(h <= sum)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    
    return 0;
}




Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <queue>
using namespace std;
main(){
	queue<pair<string,int> >v;
	int N,q,Q,T;
	string s;
	for(cin>>N>>Q;N--;)cin>>s>>T,v.push(make_pair(s,T));
	for(T=0;!v.empty();){
		pair<string,int>p=v.front();v.pop();
		if(p.second<=Q){
			T+=p.second;
			cout<<p.first<<' '<<T<<endl;
		}else{
			p.second-=Q;
			T+=Q;
			v.push(p);
		}
	}
}

Measured memory_bytes: 1300
#include <iostream>
#include <algorithm>
#include <fstream>

using namespace std;

void printArray(int A[], int num){
    for(int j=0; j<num; j++){
        if (j > 0) printf(" ");
        printf("%d", A[j]);
    }
    printf("\n");
}

int SelectionSort(int A[], int num){
    int sw = 0;
    int minj;

    for(int i=0; i<num; i++){
        minj = i;
        for(int j=i; j<num; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if (A[i] != A[minj]){
            swap(A[i], A[minj]);
            sw++;
        } 
    }
    return sw;
}

int main(){

    int num;
    int A[100];

    cin >> num;

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

    int sw = SelectionSort(A, num);

    printArray(A, num);

    cout << sw << endl;

    return 0;
}

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

string S;
int sums,sumt;

int main()
{
    cin>>S;
    for(int i=0;i<S.size();i++)
    {
        if(S[i] == 'S') sums++;
        if((sums)&&(S[i]=='T'))
        {
            sums--;
            sumt+=2;
        }
    }
    cout<<S.size()-sumt<<"\n";
}


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

#define ll long long int
#define pb push_back
#define f(i,x,y) for(i=x;i<y;i++)
#define vll vector<ll>
#define fast    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;

bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
}

void addEdge(vll adj[], ll u, ll v) 
{ 
    adj[u].push_back(v); 
    adj[v].push_back(u); 
}
void DFSE(vll adj[],vector<bool> &visited,ll u)
{
    ll i;
    visited[u] = true;
    cout<<u<<" ";
    f(i,0,adj[u].size())
    {
        if(visited[adj[u][i]]==false)
        {
            DFSE(adj,visited,adj[u][i]);
        }
    }
    
}
void DFS(vll adj[],ll u,ll v)
{
    ll i;
    vector<bool> visited(v,false);
    f(i,0,v)
    {
        if(visited[i]==false)
        {
            DFSE(adj,visited,i);
        }
    }
}
bool isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 

int main()
{
    fast;
    ll d,t,s;
    cin>>d>>t>>s;
    
    if(s*t>=d)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
using ll = long long;

const int INF = (int) 1e9 + 9;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, sum = 0;
    cin >> n >> k;
    int h[n];
    rep(i,0,n) {
        cin >> h[i];
        if (h[i] >= k) sum++;
    }
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n,k;cin >> n>> k;
    vector<int> v(n);
    REP(i,n) cin >> v[i];

    int mn = 1<<30;
    int md = 0;
    int cnt = 0;
    REP(i,n-1) {
        mn = min(v[i],mn);
        int d = v[i+1] - mn;
        cerr << d << endl;
        if (d > md) {
            md = d;
            cnt = 1;
        } else if (d == md) {
            cnt++;
        }
    }


    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int w,a,b;cin>>w>>a>>b;
  if(a<b && a+w<b){
    P(b-a-w);
  }else if(b<a && b+w<a){
    P(a-b-w);
  }else{
    P(0);
  }
  return 0;
}


Measured memory_bytes: 256
s=raw_input()
p=raw_input()

hits=[]
for j in range(len(s)):
    if p[0] == s[j]:
        hits.append(j)


flg=False
_i = 0
for _j in hits:
    if flg: break
    j=_j
    while True:
        for idx, i in enumerate(range(_i, len(p))):
            if j + i > len(s) -1:
                break 
            if p[i] == s[j+idx]:
                flg=True
            else:
                flg=False
                break
        else:
            break

        if flg:
            j = 0
            _i = i
        else:
            break

if flg:
    print "Yes"
else:
    print "No"

Measured memory_bytes: 4232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] S = sc.next().toCharArray();
		sc.close();
		int cnt = 0;
		for(int i = 0;i < 1000;i++){
			int[] c = {i%10, (i/10)%10, i/100};
			int f = 0;
			for(int j = 0;j < N;j++){
				if(S[j] == c[f] + '0')f++;
				if(f == 3)break;
			}
			if(f == 3)cnt++;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 24148
x, y = list(map(int, input().split()))
ans = 0

if x==1 and y==1:
  ans += 400000

if x == 3:
  ans += 100000
elif x == 2:
  ans += 200000
elif x == 1:
  ans += 300000


if y == 3:
  ans += 100000
elif y == 2:
  ans += 200000
elif y == 1:
  ans += 300000

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    final long MOD = 1000000007;
    long[] num = new long[n];
    long sum = 0;
    long[] count = new long[60];
    for(int i = 0; i < n; i++) {
      num[i] = Long.parseLong(sc.next());
      for(int j = 0; j < 60; j++) {
        count[j] += (1 & (num[i] >> j));
      }
    }
    for(int i = 0; i < 60; i++) {
      sum += (count[i] * (n - count[i]) % MOD) * ((1L << i) % MOD) % MOD;
      sum %= MOD;
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 65660
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
ll n, k, b, l[100000] = {}, r, e[6], dp[100005][13] = {}, i, j, g = 1000000007, m = -5, c, d, a;
string s;


int main() {
	
	cin >> s;
	a = s.size();

	dp[0][0]=1;
	rep(i, a) {
		if (s[i] == '?')c = -1;
		else c = (s[i] - '0');
		rep(j, 10) {
			if (c != -1 && c != j)continue;
			rep(k, 13) {
				d = (10 * k + j)%13;
				dp[i + 1][d] += dp[i][k];
			}
		}
		rep(j, 13) {
			dp[i + 1][j] = dp[i + 1][j] % g;
			//cout << dp[i + 1][j] << " ";
		}
		//cout << "\n";
	}

	cout <<dp[a][5]<< "\n";
	return 0;
}

Measured memory_bytes: 10880
#include<iostream>
#include<stack>
#include<string>
#include<cstdlib>
using namespace std;
int main()
{
    string word;
    stack<int>S;
    int m,n;
    while(cin>>word)
    {
        if(word=="+")
        {
            n=S.top();
            S.pop();
            m=S.top();
            S.pop();
            S.push(m+n);
        }
        else if(word=="-")
        {
            n=S.top();
            S.pop();
            m=S.top();
            S.pop();
            S.push(m-n);
        }
        else if(word=="*")
        {
            n=S.top();
            S.pop();
            m=S.top();
            S.pop();
            S.push(m*n);
        }
        else
        {
            S.push(atoi(word.c_str()));
        }
    }
    cout<<S.top()<<endl;
    return 0;
}


Measured memory_bytes: 3244
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

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

int main(){
	
	priority_queue<long long int> que;
	
	while(true){
		string str;
		cin >> str;
		if(str == "insert"){
			int num;
			cin >> num;
			que.push(num);
		}else if(str == "extract"){
			cout << que.top() << endl;
			que.pop();
		}else{
			break;
		}
	}
	
	return 0;
}



Measured memory_bytes: 11160
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)
const ll LINF = 1001002003004005006ll;

int main() {
    ll x;
    cin >> x;
    int rest = x % 100;
    int num = 0;
    for (int i = 5; i >= 1; --i) {
        num += rest / i;
        rest = rest % i;
        // cout << rest << " " << num << endl;
    }
    // cout << num << endl;
    if (x / 100 >= num) {
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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



int main(void)
{
  ll n, t;
  cin >> n >> t;
  ll minc = 2000;
  REP(i, n) {
    ll c, t1;
    cin >> c >> t1;
    if(t1 <= t && c < minc) minc = c;
  }
  if(minc <= 1000) {
    cout << minc << endl;
  } else {
    cout << "TLE" << endl;
  }
}


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

int main() {
	int n; cin >> n;
	int64_t x[n], y[n];
	for(int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i];
	}
	bool even = false;
	{
		bool flg[2] = {};
		for(int i = 0; i < n; ++i) {
			flg[(x[i] + y[i]) % 2] = true;
		}
		if(flg[0] and flg[1]) {
			cout << -1 << '\n';
			return 0;
		}
		if(flg[0]) even = true;
	}
	vector<int64_t> d;
	for(int64_t i = 31; i >= 0; --i) {
		d.push_back(1ll << i);
	}
	if(even) {
		d.push_back(1);
	}
	int dn = d.size();
	cout << dn << '\n';
	for(int i = 0; i < dn; ++i) {
		cout << d[i] << (i == dn - 1 ? "\n" : " ");
	}
	constexpr char c[] = {'L', 'U', 'D', 'R'};
	for(int i = 0; i < n; ++i) {
		int64_t u = x[i] + y[i];
		int64_t v = x[i] - y[i];
		int64_t nu = 0, nv = 0;
		string ans;
		for(int64_t dd : d) {
			int mask = 0;
			if(nu < u) {
				mask |= 0b01;
				nu += dd;
			} else {
				nu -= dd;
			}
			if(nv < v) {
				mask |= 0b10;
				nv += dd;
			} else {
				nv -= dd;
			}
			ans += c[mask];
		}
		cout << ans << '\n';
	}
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    char c = 'a';
    string res = "";
    while (n) {
        n--;
        res += (c + (n % 26));
        n /= 26;
    }
    reverse(all(res));
    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 3636
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

long long a[100005] = {0};

int main(){
  long long x, y;
  cin >> x >> y;
  long long work = x;
  int ans = 0;
  for(long long i = x; i <= y; i *= 2){
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# 繰り返しの始まり + 繰り返し + 途中で終わった繰り返し分
N,X,M = map(int,input().split())
p = [0] * (M+2)
sum = [0] * (M+2)
p[X] = 1
sum[1] = X

repeat_start = 0
repeat_end = 0

for i in range(2,N+1):
  X = (X**2) % M
  if p[X] != 0:
    repeat_start = p[X]
    repeat_end = i
    break
  else:
    sum[i] = sum[i-1] + X
    p[X] += i

if repeat_start == 0:
  print(sum[N])
else:
  repeat_cnt,mod=divmod(N-repeat_start+1,repeat_end-repeat_start)
  print(repeat_cnt*(sum[repeat_end-1]-sum[repeat_start-1]) + sum[repeat_start+mod-1])

Measured memory_bytes: 14012
n, k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A = sorted(A)
Minus_A = [-x for x in A]
F = sorted(F, reverse=True)

high = 10**12
low = 0
while high - low > 1:
    mid = low + (high-low)//2
    count = 0

    for i in range(n):
        now = mid // F[i]
        count += max(A[i] - now, 0)
    
    # print('-'*30)
    # print(mid)
    # print(count)
    if count > k:
        low = mid
    else:
        high = mid
    
ans = high

if sum(A) <= k:
    ans = 0

print(ans)


Measured memory_bytes: 119500
#include <bits/stdc++.h> 
    //#define M_PI 3.14159265358979323846



using namespace std;

#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define vc vector<char>
#define vld vector<ld>
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
#define vvld vector<vector<ld> >
#define vpii vector<pii>
#define vpll vector<pll>
#define ld long double
#define ll long long
#define sz(a) (ll)a.size()
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define ssortB(arr)   stable_sort(arr.begin(),arr.end(),greater<ll >());
#define pii pair<int,int>
#define pll pair<long long,long long>
#define ff first
#define ss second
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define endl "\n" 
#define PI acos(-1.0)
#define GCD(a,b) __gcd(a,b)
#define popcount(x) __builtin_popcountll(x)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define r1(x) cin>>x
#define r2(x,y) cin>>x>>y
#define r3(x,y,z) cin>>x>>y>>z
#define r4(a,b,c,d) cin>>a>>b>>c>>d
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define fix(f,n) fixed<<setprecision(n)<<f<<endl
#define check(ds, a) (ds.find(a)!=ds.end()?1:0)
#define mem(arr)  memset(arr,0,sizeof(arr))
const int M=(int)1e9+7;
int c=0;
vi adj[200005];
vb visited(200005,false);
void dfs(int a){
    visited[a]=true;++c;
    for(auto it:adj[a]){
        if(!visited[it]){
            dfs(it);
        }
    }
}
int main(){
    int n,m;cin>>n>>m;
    rep(i,0,m){
        int u,v;cin>>u>>v;
        adj[u].pb(v);adj[v].pb(u);
    }
    int maxi=0;
    rep(i,1,n+1){
        c=0;
        if(!visited[i]){
            dfs(i);
        }
        maxi=max(maxi,c);
    }
    cout<<maxi<<endl;
}

Measured memory_bytes: 20832
'use strict'

function Main(input) {
  const inputList = input.split('\n');
  const n = inputList[0]
  const numbersList = inputList[1].split(' ')

  let count = -1;
  let result = numbersList

  while(result.length !== 0) {
    result = checkArrayEven(result)
    count++
  }

  console.log(count)
}

function checkArrayEven(array) {
  const newArray = new Array(array.length)
  for (let i=0; i<array.length; i++) {
    if (array[i] % 2 === 1) {
      return []
    } else {
      newArray[i] = array[i] / 2
    }
  }
  return newArray
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i,x in enumerate(xy):
  x1, y1 = x[0], x[1]
  for x2,y2 in xy[i+1:]:
    ans += ((x2-x1) ** 2 + (y2-y1) ** 2) ** 0.5
ans /= n / 2
print(ans)

Measured memory_bytes: 38384
from collections import Counter

num = int(input())
range_arr = range(num)

strs = [[] for i in range_arr]
for i in range_arr:
    strs[i] = input()

def sort(str):
    str_arr = list(str)
    str_arr.sort()
    return ''.join(str_arr)

new_strs = list(map(lambda v: sort(v), strs))
strs_length = len(new_strs)

sum = 0
counter = Counter()
for tmp_str in new_strs:
    sum += counter[tmp_str]
    counter[tmp_str] += 1

print(sum)


Measured memory_bytes: 26964
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

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

  int diff = b - a;
  int l_height = 0;
  repp(i, 1, diff - 1) { l_height += i; }
  int ans = l_height - a;
  cout << ans << endl;
}

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

using namespace std;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mod 998244353 
#define N 10000000
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>

const int inf = 100000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};
string to_string(char x){
	string s(1,x);
	return s;
}

int main()
{
    fio;
    ll n;cin>>n;
    ll ans=1000*(n/500);n=n%500;
    ans+=5*(n/5);
    cout<<ans<<"\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(a,b) for(int a = 0;a < b;++a)
int main(){
   long long ans = 0;
long long n,k;
cin >> n>>k;
long long now = 0;
map<long long,long long> go;
go[0] = 1;
queue<long long> nya;
nya.push(0);
REP(i,n){
long long a;
cin >> a;
a--;now += a;now %= k;
nya.push(now);
while(nya.size() > k){
int now = nya.front();
nya.pop();
go[now]--;
}
ans += go[now];
go[now]++;
}
cout << ans << endl;
}

Measured memory_bytes: 14336
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.concurrent.SynchronousQueue;

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

	void run() throws FileNotFoundException {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] a = new long[3 * N];
		for (int i = 0; i < 3 * N; ++i) {
			a[i] = sc.nextLong();
		}
		long[] f = new long[3 * N];
		long[] b = new long[3 * N];
		PriorityQueue<Long> pf = new PriorityQueue<>();
		PriorityQueue<Long> pb = new PriorityQueue<>();
		for (int i = 0; i < N; ++i) {
			f[i] = (i > 0 ? f[i - 1] : 0) + a[i];
			b[3 * N - i - 1] = (i > 0 ? b[3 * N - i] : 0) + a[3 * N - i - 1];
		}
		for (int i = 0; i < N; ++i)
			pf.add(a[i]);
		for (int i = 2 * N; i < 3 * N; ++i)
			pb.add(-a[i]);
		for (int i = N; i < 3 * N; ++i) {
			f[i] = f[i - 1] + a[i];
			pf.add(a[i]);
			long v = pf.poll();
			f[i] -= v;
		}
		for (int i = 2 * N - 1; i >= 0; --i) {
			b[i] = b[i + 1] + a[i];
			pb.add(-a[i]);
			long v = -pb.poll();
			b[i] -= v;
		}
		long ans = -Long.MAX_VALUE / 16;
		for (int i = N - 1; i < 2 * N; ++i) {
			ans = Math.max(f[i] - b[i + 1], ans);
		}
		System.out.println(ans);

	}

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


Measured memory_bytes: 101808
using System;
using System.IO;

class Solve{
    static void Main(string[] args){
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split();
        var answer = 0;
        var or = 0;
        for (int i = 0; i < N; i++){
            var ai = int.Parse(A[i]);
            if ((ai & 1) == 1){
                or = 0;
                break;}
            or |= ai;}
        if (or != 0){
            while ((or & 1) == 0){
                or >>= 1;
                answer++;}}
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int main(){
	int N;
	cin>>N;
	char s[MAX+1];
	rep1(i,N)cin>>s[i];
	//0はひつじ1はおおかみ
	int a[MAX+1];
	bool okN,ok1;
	rep(k,2)rep(l,2){
		a[1]=k;
		a[2]=l;
		for(int i=3;i<=N;i++){
			if(a[i-1]==0&&s[i-1]=='o')a[i]=a[i-2];
			if(a[i-1]==0&&s[i-1]=='x')a[i]=1-a[i-2];
			if(a[i-1]==1&&s[i-1]=='o')a[i]=1-a[i-2];
			if(a[i-1]==1&&s[i-1]=='x')a[i]=a[i-2];
		}
		okN=false,ok1=false;
		if(s[N]=='o'&&a[N]==0&&a[N-1]==a[1])okN=true;
		if(s[N]=='o'&&a[N]==1&&a[N-1]!=a[1])okN=true;
		if(s[N]=='x'&&a[N]==0&&a[N-1]!=a[1])okN=true;
		if(s[N]=='x'&&a[N]==1&&a[N-1]==a[1])okN=true;
		if(s[1]=='o'&&a[1]==0&&a[N]==a[2])ok1=true;
		if(s[1]=='o'&&a[1]==1&&a[N]!=a[2])ok1=true;
		if(s[1]=='x'&&a[1]==0&&a[N]!=a[2])ok1=true;
		if(s[1]=='x'&&a[1]==1&&a[N]==a[2])ok1=true;
		if(okN&&ok1){
			rep1(i,N){
				if(a[i]==0)cout<<"S";
				else cout<<"W";
			}
			return 0;
		}
	}
	cout<<-1;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		ll n;
		cin>>n;
		ll hp[n][3];
		ll dp[n+1][4];
		//ll a,b,c;
		for(ll i=0;i<n;i++)
		{
			cin>>hp[i][0]>>hp[i][1]>>hp[i][2];
		}
		dp[1][1]=hp[0][0];
		dp[1][2]=hp[0][1];
		dp[1][3]=hp[0][2];
		for(ll i=2;i<=n;i++)
		{
			dp[i][1]=max(dp[i-1][2]+hp[i-1][0],dp[i-1][3]+hp[i-1][0]);
			dp[i][2]=max(dp[i-1][1]+hp[i-1][1],dp[i-1][3]+hp[i-1][1]);
			dp[i][3]=max(dp[i-1][1]+hp[i-1][2],dp[i-1][2]+hp[i-1][2]);
		}
		cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
		return 0;
	}


Measured memory_bytes: 5760
#include<iostream>

using namespace std;

int main() {
	int x;
	cin >> x;
	int h, m, s;
	s = x % 60;
	m = int(x / 60) % 60;
	h = int(x / 3600) % 24;
	cout <<h<<":"<<m<<":"<<s<< endl;
	return 0;
}

Measured memory_bytes: 1168
#include "bits/stdc++.h"
using namespace std;

const int N=1e5+20;

int n,u,v,a,b,dp[2][N],ans;
vector <int> adj[N];
bool vis[2][N];

void dfs(int node,int parent,int idx,int depth=0)
{
	dp[idx][node]=depth;
	for(auto child:adj[node])
		if(child!=parent)
			dfs(child,node,idx,depth+1);
}

int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for(int i=0;i<n-1;i++)
	{
		scanf("%d%d",&u,&v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	dfs(a,0,0),dfs(b,0,1);
	for(int i=1;i<=n;i++)
		if(dp[0][i]<=dp[1][i])
			ans=max(ans,dp[1][i]-1);
	printf("%d",ans);
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    string s;
    cin >> s;
    vector<int> ctoi(256);
    ctoi['r'] = 2;
    ctoi['s'] = 0;
    ctoi['p'] = 1;

    int ans = 0;
    rep(i,k){
        vector<int> x;
        for(int j = i; j < n; j += k){
            x.push_back(ctoi[s[j]]);
        }

        vector<int> dp(3);
        for(int nx : x){
            vector<int> p(3);
            swap(dp,p);
            if(nx == 0){
                dp[0] = max(p[1],p[2]) + a[0];
                dp[1] = max(p[2],p[0]);
                dp[2] = max(p[0],p[1]);
            }else if(nx == 1){
                dp[0] = max(p[1],p[2]);
                dp[1] = max(p[2],p[0]) + a[1];
                dp[2] = max(p[0],p[1]);
            }else{
                dp[0] = max(p[1],p[2]);
                dp[1] = max(p[2],p[0]);
                dp[2] = max(p[0],p[1]) + a[2];
            }
        }
        ans += max({dp[0], dp[1], dp[2]});
    }

    cout << ans << endl;
 }

Measured memory_bytes: 1020
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		boolean ok = false;
		for(int i = 1; i < 4; i++) {
			if((a * b * i) % 2 == 1) ok  = true;
		}
		System.out.println(ok ? "Yes" : "No");
	}
}


Measured memory_bytes: 21972