akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

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

void solve() {
    int c[9] = {};
    int n;
    cin >> n;
    int in;
    REP(i,0,n) {
        cin >> in;
        if (in < 3200) c[in / 400]++;
        else c[8]++;
    }
    int sum = 0;
    REP(i,0,8) sum += c[i] > 0;
    cout << max(sum, min(1, c[8])) << " " << sum + c[8] << endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<math.h>
#include<set>
#include<iomanip>
#include<stdio.h>
#include<deque>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;string s;cin>>n>>s;
	int i,o=1;
	for(i=1;i<n;i++)
	{
		if(s[i]!=s[i-1])
			o++;
	}
	cout<<o<<endl;
}
		

Measured memory_bytes: 592
#include <stdio.h>
#define REP(i, a, b) for(int i = a; i <= b; i++)

int main(void){
    int a, b, c, x, count = 0;
    scanf("%d%d%d%d", &a, &b, &c, &x);
    REP(i, 0, a) {
        REP(j, 0, b) {
            REP(k, 0, c) {
                if (500 * i + 100 * j + 50 * k == x) {
                    count++;
                }
            }
        }
    }
    printf("%d\n", count);
    return 0;
}

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

const int maxn = 5500;

bool f[maxn][maxn], ff[maxn][maxn];
vector<int> g[maxn];
int a[maxn];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k; cin >> n >> k;
	for(int i = 1; i <= n; ++ i) {
		cin >> a[i];
		a[i] = min(a[i], k + 1);
	}
	f[0][0] = true;
	for(int i = 1; i <= n; ++ i) {
		for(int j = 0; j <= k + 1; ++ j) {
			if(f[i - 1][j]) {
				f[i][j] = true;
				f[i][min(k + 1, j + a[i])] = true;
			}
		}
	}
	reverse(a + 1, a + n + 1);
	ff[0][0] = true;
	for(int i = 1; i <= n; ++ i) {
		for(int j = 0; j <= k + 1; ++ j) {
			if(ff[i - 1][j]) {
				ff[i][j] = true;
				ff[i][min(k + 1, j + a[i])] = true;
			}
		}
	}
	for(int i = 0; i <= n; ++ i) for(int j = 0; j <= k + 1; ++ j) if(ff[i][j]) g[i].push_back(j);
	reverse(a + 1, a + n + 1);
	int ans = 0;
	for(int i = 1; i <= n; ++ i) {
		bool flag = false;
		int id = g[n - i].size() - 1;
		for(int v = 0; v <= k + 1; ++ v) {
			if(f[i - 1][v]) {
				int nv = k - v - a[i];
				while(id > 0 && g[n - i][id - 1] >= nv) -- id;
				if(g[n - i][id] >= nv) {
					if(g[n - i][id] + v < k) {
						flag = true;
						break;
					}
				}
			}
		}
		if(!flag) ++ ans;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 173696
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
for i in range(N):
  H[i] = T - H[i] * 0.006 - A
  if H[i] < 0:
    H[i] = (-1) * H[i]
M = -1
for i in range(N):
  if H[i] == min(H):
    M = i+1
print(M)

Measured memory_bytes: 3060
a,b,c = map(int,input().split())
cnt = 0
ans = 0

s = min(a,b)
for i in range(s,0,-1):
#  print("i:" + str(i))
  if a%i == 0 and b%i == 0:
    cnt += 1
    if cnt == c:
      ans = i
      break
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
ll a[200005];
vector<ll>v[200005];
ll ans[200005];
void dfs(ll cur,ll pre,ll sum)
{
	ans[cur]=sum;
	for(ll i=0; i<v[cur].size(); i++)
	{
		if(v[cur][i]!=pre)
			dfs(v[cur][i],cur,sum+a[v[cur][i]]);
	}
}
int main()
{
	boost
	ll n,q;
	cin>>n>>q;
	for(ll i=1; i<n; i++)
	{
		ll x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	for(ll i=0; i<q; i++)
	{
		ll x,y;
		cin>>x>>y;
		a[x]+=y;
	}
	dfs(1,0,a[1]);
	for(ll i=1; i<=n; i++)
		cout<<ans[i]<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 28800
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

void max_self(int&a , int b){
	a = max(a , b);
}

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n;
	cin >> n;
	vector<int> h(3);
	vector<int> dp(3 , 0);
	for (int i = 0; i < n; ++i){
		vector<int> dp1(3 , 0);
		for (int j = 0; j < 3; j++){
			cin >> h[j];
		}
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 3; k++){
				if (j != k){
					max_self(dp1[j] , dp[k] + h[j]);
				}
			}
		}
		dp = dp1;
	}
	cout << max(dp[0] , max(dp[1] , dp[2]));
	
	return 0;
}


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


void solve(long long N, long long K){
    int ans = 1;
    long long target = K;
    while(N >= target){
        target *= K; 
        ans++;
    }
    cout << ans << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a, b);
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a, b, m; cin>>a>>b>>m;
	vector<int> ref(a), mic(b);
	int nin1 = 1e9, nin2 = 1e9;
	for(int i = 0; i < a; i++){
		cin>>ref[i];
		nin1 = min(nin1, ref[i]);
	}
	for(int i = 0; i < b; i++){
		cin>>mic[i];
		nin2 = min(nin2, mic[i]);
	}
	int ans = nin1 + nin2;
	for(int i = 0; i < m; i++){
		int x, y, z; cin>>x>>y>>z;
		ans = min(ans, ref[x-1] + mic[y-1] - z);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, m, k, l;

class Union_Find {
private:
	int par[200010], rank[200010];
public:
	void init(int n) {
		for (int i = 1; i <= n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rank[x] < rank[y])par[x] = y;
		else {
			par[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

signed main() {
	cin >> n >> m;
	Union_Find ta;
	ta.init(n + m);
	for (int i = 0; i < n; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> l;
			ta.unite(i + 1, n + l);
		}
	}
	for (int i = 1; i < n; i++) {
		if (!ta.same(i, i + 1)) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 3328
// C - Lining Up
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
	int N; cin>>N;

	map<int,int> A;
	for(int i=1; i<=N; i++){
		int a; cin>>a;
		A[a]++;
	}

	int ans = 1;
	int i, is_odd = (N-1)%2;
	for(i=is_odd; i<N; i+=2){
		if( (A.count(i)!=1) || (A[i]!=2 && is_odd==1 || i==0 && A[i]!=1) ){
			cout<< '0' <<endl;
			return 0;
		}
		ans = ans * A[i] % MOD;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 3200
T_HP,T_ATK,A_HP,A_ATK = [int(i) for i in input().split()]
while 1:
    A_HP -= T_ATK
    if A_HP <1:
        print("Yes")
        break
    T_HP -= A_ATK
    if T_HP <1:
        print("No")
        break

Measured memory_bytes: 61824
import java.util.Scanner;

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

		String c = scan.next();
		if(c.equals("a")){
			System.out.println("vowel");
		}
		else if(c.equals("i")){
			System.out.println("vowel");
		}
		else if(c.equals("u")){
			System.out.println("vowel");
		}
		else if(c.equals("e")){
			System.out.println("vowel");
		}
		else if(c.equals("o")){
			System.out.println("vowel");
		}
		else{
			System.out.println("consonant");
		}
	}
}


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

int main(void) {
    int A,B;
    cin>>A>>B;
    int cnt = 0;
    for (int i = A; i <= B; i++) {
        if (i % 10 == 0) continue;
        string str = to_string(i);
        string r_str = str;
        reverse(r_str.begin(), r_str.end());
        if (str == r_str) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 504
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

s = input()
if not ('ABC' in s):
  print(0)
  exit()

from collections import deque
S = deque(maxlen=200000)
tmp = 'C'
for ss in s:
  if tmp == 'B' and ss == 'C':
    S.pop()
    S.append('D')
    tmp = 'C'
  elif ss == 'C':
    S.append('B')
    tmp = 'C'
  else:
    S.append(ss)
    tmp = ss

ans = 0
ihavea = 0
#保持してる文字列
Acnt = 0
while 1:
  try:
    tmp = S.popleft()
  except:
    print(ans)
    exit()
  if tmp=='B':
    ihavea = 0
    Acnt = 0
    continue
  if ihavea == 0 and tmp=='A':
    ihavea = 1
    Acnt += 1
    continue
  if ihavea == 1 and tmp=='A':
    ihavea = 1
    Acnt += 1
    continue
  if ihavea == 1 and tmp=='D':
    ihavea = 1
    ans += Acnt
    #Aはそのまま引き継ぐ
    continue


Measured memory_bytes: 4968
#include <stdio.h>

int main()
{
    int pop;
    int days;
    int last;
    int eat[100];
    int cnt = 0;
    
    scanf("%d",&pop);
    scanf("%d %d",&days,&last);
    
    while(cnt < pop){
        scanf("%d",&eat[cnt]);
        cnt++;
    }
    
    cnt = 0;
    
    while(cnt < pop){
        last += 1 + (days-1)/eat[cnt];
        cnt++;
    }
    
    printf("%d",last);

    return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,0,-1};
const static int ty[] = {-1,0,1,0};

const static double EPS = 1e-8;

int main(){
  int num_of_players;
  map<string,int> dict;
  dict["Rock"] = 0;
  dict["Fire"] = 1;
  dict["Scissors"] = 2;
  dict["Snake"] = 3;
  dict["Human"] = 4;
  dict["Tree"] = 5;
  dict["Wolf"] = 6;
  dict["Sponge"] = 7;
  dict["Paper"] = 8;
  dict["Air"] = 9;
  dict["Water"] = 10;
  dict["Dragon"] = 11;
  dict["Devil"] = 12;
  dict["Lightning"] = 13;
  dict["Gun"] = 14;

  map<int,bool> canWin;
  for(int hand_i = 0; hand_i < 15; hand_i++){
    for(int hand_j = 0; hand_j < 15; hand_j++){
      canWin[hand_i * 15 + hand_j] = false;
      for(int offset = 1; offset <= 7; offset++){
        if(hand_j == (hand_i + offset) % 15){
          canWin[hand_i * 15 + hand_j] = true;
        }
      }
    }
  }

  while(~scanf("%d",&num_of_players)){
    if(num_of_players == 0){
      break;
    }
    vector<string> players;
    for(int player_i = 0; player_i < num_of_players; player_i++){
      string hand;
      cin >> hand;
      players.push_back(hand);
    }

    bool lose[1001] = {};
    bool win[1001] = {};
    for(int player_i = 0; player_i < num_of_players; player_i++){
      for(int player_j = player_i + 1; player_j < num_of_players; player_j++){
        if(canWin[dict[players[player_i]] * 15 + dict[players[player_j]]]){
          lose[player_j] = true;
          win[player_i] = true;
        }
        if(canWin[dict[players[player_j]] * 15 + dict[players[player_i]]]){
          lose[player_i] = true;
          win[player_j] = true;
        }
      }
    }

    string res = "Draw";
    for(int player_i = 0; player_i < num_of_players; player_i++){
      if(!lose[player_i] && win[player_i]){
        res = players[player_i];
        break;
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1316
#include<iostream>
#include<tuple>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int N; cin >> N;
  vector<tuple<string,int,int>> a;
  for(int i = 1; i <= N; i++){
    string s; int p;
    cin >> s >> p;
    p = -p;
    a.push_back(tie(s,p,i));}
    
    sort(a.begin(),a.end()); //文字列について辞書式に、被った時は満足度についてソート
    
    for(int i = 0; i < N ; i++){
      cout << get<2>(a[i]) << endl;}
    
    return 0;
  }


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

int main() {
    string s;
    cin >> s;
    if (s == "A") cout << "T" << endl;
    else if (s == "T") cout << "A" << endl;
    else if (s == "G") cout << "C" << endl;
    else cout << "G" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
int n;
bool sortrule(const pair<int,int> &p1,const pair<int,int> &p2)
{
  if(p1.first!=p2.first)
    {
      return p1.first>p2.first;
    }
  else
    {
      return p1.second<p2.second;
    }
}
int main(void)
{
  while(cin >> n && n)
    {
      set<int> st;
      st.clear();
      vector<pii> scores(10005);
      for(int i=0;i<=10000;i++)
	{
	  scores[i]=(pii(0,i));
	}
      vector<pair<int,int> > bowling[10005];
      for(int i=0;i<n;i++)
	{
	  //cout << "ID"<< endl;
	  int id;
	  cin >> id;
	  st.insert(id);
	  for(int j=0;j<10;j++)
	    {
	      
	      int fi=0,se=0,th=0;
	      cin >> fi;
	      if(j!=9 && fi==10) se=0;
	      else
		{
		  cin >> se;
		}
	      if(j==9 && ((fi==10) || (fi+se)==10))
		{
		  cin >> th;
		}
	      if(j!=9) bowling[id].push_back(pii(fi,se));
	      else 
		{
		  bowling[id].push_back(pii(fi,se));
		  scores[id].first+=(fi+se+th);
		}
	    }
	  for(int j=0;j<9;j++)
	    {
	      if(j!=8)
		{
		  int one=bowling[id][j].first;
		  int two=bowling[id][j].second;
		  int nxone=bowling[id][j+1].first;
		  int nxtwo=bowling[id][j+1].second;
		  int nxxone=bowling[id][j+2].first;
		  if(one+two<10)
		    {
		      scores[id].first+=(one+two);
		    }
		  else if(one!=10 && one+two==10)
		    {
		      scores[id].first+=(10+nxone);
		    }
		  else if(one==10)
		    {
		      if(nxone!=10)
			{
			  scores[id].first+=(10+nxone+nxtwo);
			}
		      else if(nxone==10)
			{
			  if(j<=8)
			    {
			      scores[id].first+=(10+nxone+nxxone);
			    }
			}
		    }
		}
	      else if(j==8)
		{
		  int one=bowling[id][j].first;
		  int two=bowling[id][j].second;
		  int nxone=bowling[id][j+1].first;
		  int nxtwo=bowling[id][j+1].second;
		  if(one+two<10)
		    {
		      scores[id].first+=(one+two);
		    }
		  else if(one!=10 && one+two==10)
		    {
		      scores[id].first+=(10+nxone);
		    }
		  else if(one==10)
		    {
		      if(nxone!=10)
			{
			  scores[id].first+=(10+nxone+nxtwo);
			}
		      else if(nxone==10)
			{
			  scores[id].first+=(10+nxone+nxtwo);
			}
		    }
		}
	      //cout << "Now ID score " << scores[i].second << ' ' << scores[id].first << endl;
	    }
	}
      sort(scores.begin(),scores.end(),sortrule);
      int cnt=0;
      for(int i=0;i<=10000;i++)
	{
	  if(cnt==n) break;
	  auto it=st.find(scores[i].second);
	  if(it!=st.end())
	    {
	      cnt++;
	      cout << scores[i].second << ' ' << scores[i].first << endl;
	    }
	}
    }
  return 0;
}



Measured memory_bytes: 3432
H1, M1, H2, M2, K = map(int,input().split())

wake = H1 * 60 + M1
sleep = H2 * 60 + M2 - K
ans = 0
if wake <= sleep:
    ans = sleep - wake
else:
    time = 24 * 60
    ans = time - wake + sleep

print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N, A, counter = 0;
  cin >> N;
  rep(i, N) {    
    cin >> A;

    int power = 0;
    while (A % 2 == 0) {
      A /= 2;
      power++;
    }

    if (counter > power || i == 0) {
      counter = power;
    }
  }

  cout << counter << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <cmath>
using namespace std;
int y[101],r,n;

bool check(double cy){
  double x=sqrt(r*r-cy*cy);
  if(cy>=0)x=r;
  int L=(-x-0.9999),R=(x+0.9999),hb[101]={};

  for(int i=L+50;i<R+50;i++){
    int x1=i-49-i/50;
    double y1=y[i]-cy;
    if(sqrt(x1*x1+y1*y1)>=r)hb[i]++;
  }
  for(int i=L+50;i<R+50;i++)if(!hb[i])return 0;
  return 1;
}

int main(){
  while(1){
    cin>>r>>n;
    if(!r&&!n)break;
    for(int i=0;i<100;i++)y[i]=0;

    for(int i=0;i<n;i++){
      int x1,x2,h;
      cin>>x1>>x2>>h;
      for(int j=x1;j<x2;j++) y[j+50]=max(y[j+50],h);
    }
    double ans=0;
    while(check(ans-r))ans+=0.0009;
    cout << ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int32_t main(){
   int n,p; cin>>n>>p;
   string s; cin>>s;
   if(p==2){
       int ans=0;
       rep(i,0,n){
           int d=s[i]-'0';
           if(d%2==0)ans+=(i+1);
       }
       cout<<ans<<"\n";
       return 0;
   }
   if(p==5){
       int ans=0;
       rep(i,0,n){
           int d=s[i]-'0';
           if(d==0 or d==5)ans+=(i+1);
       }
       cout<<ans<<"\n";
       return 0;
   }
   int cur=0,ans=0; 
   map<int,int> mp;
   mp[0]++;
   rep(i,0,n){
       cur*=10; 
       cur+=s[i]-'0';
       cur%=p;
       int val=powermod(10,n-i-1,p)*cur;
       val%=p;
       ans+=mp[val]++;
   }
   cout<<ans<<"\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read problem. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


Measured memory_bytes: 4156
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int N,A,B,C,X,Y;
    string s,t;
    cin>>N;
    cout<<N*N<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int a = sc.nextInt(); // 赤
        int b = sc.nextInt(); // 緑
        int c = sc.nextInt(); // 青
        int k = sc.nextInt();

        // 赤 < 緑 < 青 にする
        for (int i = 0; i < k; i++) {
            if (a >= b) {
                b *= 2;
                continue;
            }
            if (b >= c) {
                c *= 2;
                continue;
            }
            break;
        }

        if (a < b && b < c)
            System.out.println("Yes");
        else
            System.out.println("No");
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

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

using namespace std;
 
#define ll long long 
#define IOS ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

int main()
{
	string ch;
	int n, m,a;
	cin>>n  >>m;
	map<int,int>mp;
	int num = 0;
	int arr[1000005];
	int coun = 0;
	memset(arr, 0, sizeof(arr));
	while(m--)
	{
		cin >> a >> ch;
		if(ch == "AC" && arr[a] == 0) 
		{
			arr[a] = 1;
			num++;
		}
		else if(ch == "WA" && arr[a] == 0)
		{
			mp[a]++;
		}
	}
	for(auto it : mp)
	{
		if(arr[it.first] == 1) coun+= it.second;
	}
	cout << num <<  " " << coun << endl;
	return 0;
}


Measured memory_bytes: 7040
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

vector<int> demical(ll n,int k,int l){
    vector<int> rtn(l);
    REP(i,l){
        rtn[i]=n%k;
        n/=k;
    }
    //while(n>0){
    //rtn.push_back(n%k);
    //n/=k;
    //}
    return rtn;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> k(m),p(m);
    vector<vector<int>> s(m);
    REP(i,m){
        cin >> k[i];
        REP(j,k[i]){
            int ts;
            cin >> ts;
            ts--;
            s[i].push_back(ts);
        }
    }
    REP(i,m){
        cin >> p[i];
    }
    int res = 0;
    int beki = pow(2,n);
    REP(i,beki){
        vector<int> b = demical(i,2,n);
        bool flag = true;
        REP(j,m){
            int cnt = 0;
            REP(l,k[j]){
                if(b[s[j][l]]==1)cnt++;
            }
            if(cnt%2!=p[j])flag = false;
        }
        if(flag)res++;
    }
    put(res);
    return 0;
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll A, B;
  std::cin >> A >> B;

  if ((A + B) % 2 == 1) {
    print("IMPOSSIBLE");
  } else {
    ll ans = (A + B) / 2;
    print(ans);
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        long[] nm = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long allc = nm[0] * 2 + nm[1];
        long possibleS = allc / 4;
        Console.WriteLine(Math.Min(possibleS, nm[1] / 2));
    }
}

Measured memory_bytes: 13396
#include<stdio.h>
#define a 2000
#define b 2000

int A[a], Mi[b];
int hantei(int, int);

int main()
{
  int n, q, i, j, k;
  // int A[a], Mi[b];

  scanf("%d", &n);
  for(i=0; i<n; i++)
    {
      scanf("%d", &A[i]);
    }

  scanf("%d", &q);
  for(j=0; j<q; j++)
    {
      scanf("%d", &Mi[j]);
    }

  for(k=0; k<q; k++)
    {
      if(hantei(n, Mi[k]))
	{
	  printf("yes\n");
	}
      else
	{
	  printf("no\n");
	}	
    }

  return 0;
}

int hantei(int v, int w)
{
  int x;
  if(w == A[v])
    {
      return 1;
    }
  if(v == -1)
    {
      return 0;
    }
  if(w <= 0)
    {
      return 0;
    }
  if(hantei(v-1,w))
    {    
      return 1;
    }
  if(hantei(v-1,w-A[v]))
    {
      return 1;
    }

  return 0;   
}

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

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            var elements = Console.ReadLine().Split(' ');
            var a = int.Parse(elements[0]);
            var b = int.Parse(elements[1]);
            var c = int.Parse(elements[2]);
            var X = int.Parse(elements[3]);
            var Y = int.Parse(elements[4]);

            var min = -1;
            foreach(var aN in Enumerable.Range(0, X + 1))
            {
                var cN = (X - aN) * 2;
                var bN = Y - cN / 2;

                var sum = aN * a + cN * c;
                if (bN > 0) sum += bN * b;
                if (min < 0 || sum < min) min = sum;
            }

            foreach (var bN in Enumerable.Range(0, Y + 1))
            {
                var cN = (Y - bN) * 2;
                var aN = X - cN / 2;

                var sum = bN * b + cN * c;
                if (aN > 0) sum += aN * a;
                if (min < 0 || sum < min) min = sum;
            }
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 13268
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        mut a: [i64; n],
    }
    let mut xy = vec![];
    a.sort();
    let mut a_min = a[0];
    let mut a_max = a[n-1];
    for i in 1..n-1 {
        if a[i] >= 0 {
            xy.push((a_min, a[i]));
            a_min -= a[i];
        } else {
            xy.push((a_max, a[i]));
            a_max -= a[i];
        }
    }
    let val = a_max -  a_min;
    println!("{}", val);
    xy.push((a_max, a_min));
    for (x, y) in xy {
        println!("{} {}", x, y);
    }
}



Measured memory_bytes: 10108
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int X = sc.nextInt();
    int count =0;
    for (int i=0; i<A+1; i++) {
      for (int j=0; j<B+1; j++) {
        for (int k=0; k<C+1; k++) {
        if(i * 500 + j * 100 + k * 50 == X) {
          count++;
          }
        }
      }
    }
    System.out.println(count);
  }
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int A, B, C;
  vector<int> cnt(11);

  cin >> A >> B >> C;
  cnt[A]++;
  cnt[B]++;
  cnt[C]++;

  if(cnt[5] == 2 && cnt[7] == 1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  

  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toLong();

    var i = 1
    var sameCounter = 0
    while (i <= N) {
        val dd = readLine()!!.toString().split(" ")
        if (dd[0].toLong()==dd[1].toLong()) {
            sameCounter++
            if (sameCounter==3){
                println("Yes")
                return
            }
        } else {
            sameCounter = 0
        }
        i++
    }

    println("No")
}

Measured memory_bytes: 36956
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	List<String> direc = new ArrayList<String>();
	direc.add("RIGHT");
	direc.add("LEFT");

	int n,m;
	n = sc.nextInt();
	while(n!=0){
	    int posX = 1;
	    int posY = 1;
	    int nowDirec = 0;

	    m = sc.nextInt();

	    while(true){
		String instruct = sc.next();
		if(instruct.equals("STOP")){break;}
		if(direc.contains(instruct)){
		    if(instruct.equals(direc.get(0))){nowDirec++; nowDirec%=4;}
		    else {
			nowDirec--; 
			if(nowDirec==-1){nowDirec = 3;}
		    }
		}
		else{
		    int step = sc.nextInt();
		    if(instruct.equals("BACKWARD")){step = -step;}
		    if(nowDirec==0){
			posY+=step;
			if(posY>m){posY=m;}
			if(posY<1){posY=1;}
		    }
		    else if(nowDirec==1){
			posX+=step;
			if(posX>n){posX=n;}
			if(posX<1){posX=1;}
		    }
		    else if(nowDirec==2){
			posY-=step;
			if(posY>m){posY=m;}
			if(posY<1){posY=1;}
		    }
		    else if(nowDirec==3){
			posX-=step;
			if(posX>n){posX=n;}
			if(posX<1){posX=1;}
		    }
		}
	    }

	    System.out.println(posX+" "+posY);

	    n = sc.nextInt();
	}
    }
}

Measured memory_bytes: 12000
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline

N, *A = map(int, read().split())

A.sort()
a = Counter(A)
answer = 0


while A:
    n = A.pop()
    if a[n] == 0:
        continue

    a[n] -= 1
    # 実現可能な最大の2冪
    s = 1 << (2 * n).bit_length()
    while n < s:
        b = s - n
        if a[b] > 0:
            answer += 1
            a[b] -= 1
            break
        s //= 2

print(answer)


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

bool d[100009];
int a[109];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 1; i <= k; i++)
		for (int j = 0; j < n; j++)
			if (i - a[j] >= 0 && !d[i - a[j]]) {
				d[i] = true;
				break;
			}
	if (d[k]) cout << "First" << '\n';
	else cout << "Second" << '\n';
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		if (k % 2 == 1) {
			System.out.println((k / 2) * ((k / 2) + 1));
		} else {
			System.out.println((k / 2) * (k / 2));
		}
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIII pair< int, pair<int,int> >
const int MaxN = 1e3+2;
const int MOD = 1e9+7;
vector<string> g;
int Row,Col;
int dp[MaxN][MaxN];

int rec(int x,int y){

    if(x<0 || y<0 || g[x][y]=='#' ) return 0;
    if(x==0 && y==0) return 1;
    auto &ret = dp[x][y];
    if(ret!=-1) return ret;
    ll retm = ( rec(x-1,y) + rec(x,y-1) )% MOD;
    return ret = retm;

}


void read(){

    cin>>Row>>Col;
    memset(dp, -1, sizeof dp);
    for(int i=0; i<Row; i++){
        string str;
        cin>>str;
        g.push_back(str);
    }
}

void solve(){

    read();
    cout<< rec(Row-1,Col-1) << "\n";
}


int main(){

    //freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();

    return 0;
}


Measured memory_bytes: 8712
// author: gary
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ( (int) (x).size() )
typedef pair<int, int> pii;
typedef long long ll;
const int N = 333;

int n;
int a[N][N];

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
      scanf("%d", &a[i][j]);
  bool bad = false;
  for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
      for(int k = 0; k < n; k++)
        bad |= a[i][j] > a[i][k] + a[k][j];

  if(bad) {
    puts("-1");
  } else {
    long long sum = 0;
    for(int i = 0; i < n; i++)
      for(int j = 0; j < i; j++) {
        int need = 1;
        for(int k = 0; k < n; k++) 
          need &= k == i || k == j || a[i][j] < a[i][k] + a[k][j];
        sum += need * a[i][j];
      }

    printf("%lld\n", sum);
  }

  return 0;
}


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

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

using namespace std;

int main(){
	int n,p[10]; cin>>n;
	rep(i,n) cin>>p[i];

	sort(p,p+n);

	cout<<accumulate(p,p+n,0)-p[n-1]/2<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
  int n;
  int i;
  int a[200001]={0};
  int ai;
  scanf("%d",&n);
  for(i=1;i<n;i++){
    scanf("%d",&ai);
    a[ai]++;
  }
  
  for(i=1;i<=n;i++){
    printf("%d\n",a[i]);
  }
  return 0;
}


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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> p(M);
    vector<vector<int>>s(M);
    for(int i = 0; i < M;i++){
        int k;cin >> k;
        int l;
        for(int j = 0; j < k; j++){
            cin >> l;
            l--;
            s[i].push_back(l);
        }
    }
    for(int i = 0; i < M; i++)cin >> p[i];
    long long ans = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        bool flag = true;
        for(int i = 0; i < M;i++){
            int con = 0;
            for(auto q:s[i]){
                if(bit & (1<<q))con++;
            }            
            if(con % 2 != p[i]) flag = false;
        }
        if(flag)++ans;
    }
    cout << ans << endl;
}

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

typedef long long int ll;
typedef long int li;

const ll mod = 1000000007;
const ll inf = 1000000000000000000;

typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vli> vvli;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef map<ll, ll> mll;
typedef map<ll, string> mls;
typedef map<string, ll> msl;

#pragma GCC optimize ("-O3")
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
#define PI 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define tol(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define tou(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define all(v) v.begin(), v.end()
#define FOR(i, j, k, in) for(li i=j; i<k; i+=in)
#define RFOR(i, j, k, de) for(li i=j; i>=k; i-=de)
#define rep(i,j,k) FOR(i, j, k, 1)
#define rrep(i,j,k) RFOR(i, j, k, 1)
#define repc(v) for(auto it=v.begin(); it!=v.end(); it++)
#define T ll t; cin>>t; while(t--)

int main(){
  FAST

  li x;
  cin>>x;
  
  if(x==0)
    cout<<0;
  
  else{
    li pts=0;
  	 	pts= (x/500)*1000;
    	x=x%500;
      	pts+= (x/5)*5;
    
    cout<<pts;
    
  }
    
  
  return 0;
}









Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
using namespace std;
int a[1000000];
long long s=0;
int main()
{   priority_queue<int>q;
	int n,m,i;
	long long int k;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
	{
	scanf("%d",&a[i]);
	q.push(a[i]);
	}
	for(i=0;i<m;i++)
	{
	   	k=q.top();
	   	k>>=1;
	   	q.push(k);
	   	q.pop();
	} 
	while(!q.empty())
	{
		s+=q.top();
	    q.pop()	;	
	}
	printf("%lld",s);
	
}

Measured memory_bytes: 1148
A, B, C, D, E, F = map(int, input().split())

density = -1
s_water = -1
sugar = -1
for a in range(31):
    for b in range(31):
        for c in range(101):
            for d in range(101):
                w = (100*A)*a + (100*B)*b
                s = C*c + D*d
                if w == 0:
                    continue
                if w + s > F or w + s < 100*A:
                    continue
                if w/100 * E >= s:
                    tmp = 100*s / (w + s)
                    if tmp > density:
                        density = tmp
                        s_water = w + s
                        sugar = s
print(s_water, sugar)


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

int main(){
	int N;
	cin >> N;
	int cak;
	int don;
	int ans = 0;
	for(cak = 0; cak <= N/4 && ans == 0; cak++){
		for(don = 0; don <= N/7 && ans == 0; don++){
			//cout << cak << ',' << don << endl;
			if(4*cak + 7*don == N)
				ans++;
		}
	}
	if(ans > 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
} 

Measured memory_bytes: 256
c_lst = [[int(c) for c in input().split()] for i in range(3)]
if c_lst[0][0] + c_lst[1][1] == c_lst[0][1] + c_lst[1][0] and c_lst[1][1] + c_lst[2][2] == c_lst[1][2] + c_lst[2][1] and c_lst[0][0] + c_lst[2][2] == c_lst[0][2] + c_lst[2][0]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
const ll MOD = 1e9 + 7;
const ll INF = (ll)1e18;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}

bool cmp(const pair<string,int>& a, pair<string,int>& b){
  return a.second > b.second || (a.second==b.second && a.first<b.first);
}
int main() {
#ifdef HIRO
  string quiz(QUIZ);
  ifstream cin("input/" + quiz + ".txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  
  map<string, int> m;
  while(n--){
    string s;
    cin>>s;
    m[s]++;
  }
  vector<pair<string,int> > arr;
  for(auto kv: m) {
    // cout<<kv.first<<","<<kv.second<<endl;
    arr.push_back(mp(kv.first,kv.second));

  }
  sort(all(arr), cmp);
  int max = arr[0].second;
  for(auto x: arr) {
    if(x.second==max){
      cout<<x.first<<endl;
    }
    else break;
  }
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 28788
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n, m;
  cin >> n >> m;
  vector<int> E[100010];
  int in_d[100010] = {};
  rep(i, m)
  {
    int x, y;
    cin >> x >> y;
    x--, y--;
    E[x].push_back(y);
    in_d[y]++;
  }

  queue<int> que;
  rep(i, n)
  {
    if (in_d[i] == 0)
      que.push(i);
  }

  int dp[100010] = {};

  while (!que.empty())
  {
    int q = que.front();
    que.pop();
    for (auto to : E[q])
    {
      dp[to] = max(dp[to], dp[q] + 1);
      in_d[to]--;
      if (in_d[to] == 0)
        que.push(to);
    }
  }
  int Max = 0;
  rep(i, n) Max = max(Max, dp[i]);
  cout << Max << endl;
  return 0;
}

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

//0018
int main(){
	int x;
	vector<int> vec;
	vector<int>::iterator ite;
	for(int i=0; i<5; ++i){
		cin >> x;
		vec.push_back(x);
	}

	sort(vec.begin(), vec.end(), greater<int>());
	for(ite=vec.begin(); ite!=vec.end(); ite++){
		if(ite!=vec.begin()){
			cout << " ";
		}
		cout << *ite;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
 #include <vector>
 #include <map>
 #include <string>
 #include <algorithm>
 using namespace std;

 typedef long long ll;



 int main()
 {
    ll L, R;
    cin >> L >> R;

    R = min(L + 2 * 2019, R);

    int ans = 2018;

    for(ll i = L; i < R; i++){
        for(ll j = i+1; j <= R; j++)
        {
            int y = (i * j) % 2019;
            ans = min(ans , y);
        }
    }

    cout << ans << endl;

     return 0;
 }

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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





int main() {
    ll n, m, x, y;
    cin >> n >> m >> x >> y;
    ll xmx = -INF;
    REP(i, n){
        ll t;
        cin >> t;
        xmx = max(xmx, t);
    }
    ll ymn = INF;
    REP(i, m){
        ll t;
        cin >> t;
        ymn = min(ymn, t);
    }
    
    ll z = max(x, xmx) + 1;
    if(z <= y && z <= ymn){
        cout << "No War" << endl;
    }
    else{
        cout << "War" << endl;
    }
}

Measured memory_bytes: 256