akhauriyash/Code-Regression huggingface dataset:
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 100002;

int n, m;

vector <int> edges[N_MAX];

bool used[N_MAX];

deque <int> path;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    path.push_back(1);
    used[1] = true;
    while(true)
    {
        bool ok = false;
        for(int v : edges[path.back()])
            if(used[v] == false)
            {
                path.push_back(v);
                used[v] = true;
                ok = true;
                break;
            }
        if(ok == false)
            break;
    }
    while(true)
    {
        bool ok = false;
        for(int v : edges[path.front()])
            if(used[v] == false)
            {
                path.push_front(v);
                used[v] = true;
                ok = true;
                break;
            }
        if(ok == false)
            break;
    }
    cout << path.size() << "\n";
    for(int u : path)
        cout << u << " ";
    cout << "\n";
    return 0;
}


Measured memory_bytes: 9620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  int cnt = 0;
  rep (i, N) {
    double x, y; cin >> x >> y;
    double r = sqrt(x * x + y * y);
    if (r <= D)
      cnt ++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
 
int k;
 
int calc(vector<int> card){
    int ans = 0;
    for(int i = 0 ; i < card.size()-k+1 ; i++){
        int tmp = 1;
        for(int j = 0 ; j < k ; j++){
	  tmp *= card[i+j];   
        }
        ans = max(tmp, ans);
    }
    return ans;
}
 
int main(){
    int n;
    while(cin >> n >> k){
      if(n == 0 && k == 0) break;
      vector<int> card(n);
      
      for(int i = 0 ; i < n ; i++) cin >> card[i];
      int ans = 0 , t = calc(card);
      for(int i = 0 ; i < n ; i++)
	for(int j = i+1 ; j < n ; j++){
	  swap(card[i],card[j]);
	  ans = max(ans,calc(card)-t);
	  swap(card[i],card[j]);
	}
      cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 908
def c_city_savers(N, A, B):
    ans = 0
    for i in range(N):
        t1 = min(A[i], B[i])  # 勇者iが街iで最大限倒せるモンスターの数
        B[i] -= t1  # 倒した分、街i+1で倒せるモンスターの数が減る
        t2 = min(A[i + 1], B[i])  # 勇者iが街i+1で最大限倒せるモンスターの数
        A[i + 1] -= t2
        ans += t1 + t2
    return ans

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
print(c_city_savers(N, A, B))

Measured memory_bytes: 18624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    rep(i,min(s.size(),t.size())){
        if(s[i]>t[i]){
            cout << "No" << endl;
            return 0;
        }
        if(s[i]<t[i]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(s.size()<t.size()){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

# 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)
def main():
    N,A,B = [int(s) for s in input().split()]
    print(B) if B <= A*N else print(A*N)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
h, w = map(int, input().split())
S = []
S.append(['.' for _ in range(w+2)])
for _ in range(h):
    s = list('.' + input() + '.')
    S.append(s)
S.append(['.' for _ in range(w+2)])
for i in range(1, h+1):
    for j in range(1, w+1):
        if S[i][j] == '.':
            cnt = 0
            for p in range(i-1, i+2):
                for q in range(j-1, j+2):
                    if S[p][q] == '#':
                            cnt += 1
            S[i][j] = cnt
for i in range(1, h+1):
    ll = S[i][1:w+1]
    print(''.join([str(lll) for lll in ll]))

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

bool solve() {
    ll A, B;
    cin >> A >> B;
    if ( A <= 8 && B <= 8) return true;
    else return false;
}

int main() {
    string ans = solve() ? "Yay!" : ":(";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = n; i > 0; i--) {
        int flag = 1;
        for (int j = 0; j < i; j++) {
            if (t[j] != s[n - i + j]) {
                flag = 0;
                break;
            }
        }
        if (flag == 1) {
            cout << 2 * n - i << endl;
            return 0;
        }
    }
    cout << 2 * n << endl;
}




Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
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;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

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


    int a, b;
    cin >> a >> b;

    cout << a * b << endl;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int n, K;
    scanf("%d%d", &n, &K);
    vector<int> a(n);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a.begin(), a.end());
    int min = INF;
    for (i = 0; i <= n-K; i++) {
        min = MIN(min, a[i + K - 1] - a[i]);
    }
    printf("%d\n", min);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 640
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

int main()
{	

	ll N;
	cin >> N;

	ll ans = 0;

	for (ll i = 1; i * i <= N - 2 * i; i++)
	{
		if (N % i == 0)
		{
			ans += (N / i - 1);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1e9+7
using namespace std;
#define  pp push_back
#define  po pop_back
#define  mp make_pair
#define clr(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,-1,sizeof(a))
#define fas(a) memset(a,false,sizeof(a))
#define debug(x) cout<<#x<<": "<<x<<endl
#define debug1(x) cout<<#x<<": "<<x<<" "
#define rev(x) reverse(x.begin(), x.end())
#define int long long 
#define F first
#define S second
//int a[2000];
void printvector(std::vector<int> v){  for (int i = 0; i < v.size(); ++i){cout<<v[i]<<" ";}cout<<""<<endl;}
void printarray(int a[],int n){for (int i = 0; i < n; ++i){cout<<a[i]<<" ";}cout<<""<<endl;}
 
 

int get(std::vector<int> &v)
{

    //printvector(v);
    int got=-1;
    for(int i=v.size()-1;i>=0;i--)
    {
        if(v[i]==i+1)
        {
          got=v[i];
          for(int j=i;j<=(int)v.size()-2;j++)
          {
             //if(v.size()==9)debug(j);
             v[j]=v[j+1]; 
          }
          break; 
        }
    }

    v.pop_back();

    return got;
} 

void  solve()
{
   int n;cin>>n;
   std::vector<int> v(n);
   for(int i=0;i<n;i++)cin>>v[i];
    std::vector<int> ans;
    for(int j=0;j<n;j++)
    {
      int g=get(v);
      if(g==-1)
      {
         cout<<-1<<endl;
         return;
      }
      ans.pp(g);
    }



    rev(ans);
    for(int i=0;i<n;i++)cout<<ans[i]<<endl;
    
   

}




 int32_t main() 
{

  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
    
   solve();

return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsinged long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;
int A,B,m;
int a[100005];
int b[100005];

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>A>>B>>m;
	int ma=inf,mb=inf;
	for(int i=0;i<A;i++)
	{
		scanf("%d",a+i);
		chmin(ma,a[i]);
	}
	for(int i=0;i<B;i++)
	{
		scanf("%d",b+i);
		chmin(mb,b[i]);
	}
	int res=ma+mb;
	int x,y,z;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		x--;
		y--;
		chmin(res,a[x]+b[y]-z);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
  int w, n;
  int data[31];
  int i;
  int in1, in2;
  int temp;

  scanf("%d", &w);
  for(i = 1; i <= w; i++) {
    data[i] = i;
  }
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d,%d", &in1, &in2);
    temp = data[in1];
    data[in1] = data[in2];
    data[in2] = temp;
  }

  for(i = 1; i <= w; i++) {
    printf("%d\n", data[i]);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	string a,b,c;
	cin >> a; cin >> b;
	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
		c = "YES";
	}
	else {
		c = "NO";
	}
	cout << c<<endl;
}


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

using namespace std;

int n, k;
vector<int> V;

bool solve(int ans){
	vector<int> freq(k);

	int tot = 0;

	for (int i = 0; i < ans; ++i){
		int a = V[i];
		if (a >= k) continue;
		if (!freq[a]) tot++;
		freq[a]++;
	}

	for (int i = ans; tot < k && i < n; ++i){
		int a = V[i];
		if (a < k){
			if (!freq[a]) tot++;
			freq[a]++;
		}
		a = V[i - ans];
		if (a < k){
			freq[a]--;
			if (!freq[a]) tot--;
		}
	}

	return tot >= k;
}

int main() {
	cin >> n >> k;

	V = vector<int>(n);
	for (int i = 0; i < n; ++i){
		cin >> V[i];
		V[i]--;
	}

	if (!solve(n)){
		cout << 0 << endl;
		return 0;
	}

	int lo = 0;
	int hi = n;

	while (lo < hi - 1){
		int m = (lo + hi) / 2;
		if (solve(m)) hi = m;
		else lo = m;
	}

	cout << hi << endl;

	return 0;
}



Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, k; cin >> n >> k;
    int ar[n+5] = {};
    for(int i = 0; i < n; i++)
    {
        cin >> ar[i];
    }
    sort(ar, ar+n);
    int sum = 0;
    for(int i = 0; i < k; i++)
    {
        sum += ar[i];
    }
    cout << sum << endl;
}


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

const ll m=1000000007;




int main(){
    int n,k;
    cin>>n>>k;
    ll h[100005];
    for(int i=0;i<n;i++) cin>>h[i];
    sort(h,h+n);
    ll ans=1000000000;
    for(int i=0;i+k-1<n;i++){
        if(ans>h[i+k-1]-h[i]){
            ans=h[i+k-1]-h[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 1024
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int ans = 1001;
    for(int i=0;i<=s.size()-t.size();i++){
        string sub = s.substr(i,t.size());
        //cout << sub << endl;
        int ret = 0;
        for(int i=0;i<sub.size();i++){
            if(sub[i] != t[i]) ret++;
        }
        ans = min(ans,ret);
    }
    cout << ans << endl;
}

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

using namespace std; 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define forin(i, n) for ( int i = 0; i < (int)n; ++i )
typedef long long ll;

vector<bool> estado(101, false);
int main()
{
    //IOS
    
    int target, n;
    cin >> target >> n;
    forin ( i, n )
    {
        int aux; cin >> aux;
        estado[aux] = true;
    }

    int i, j;
    for ( i = target; i >= 0; --i )
    {
        if ( !estado[i] ) break;
    }

    for ( j = target; j <= 100; ++j )
    {
        if ( !estado[j] ) break;
    }
    
    int diff_i = abs(target - i), diff_j = abs(target - j);

    cout << ( diff_i <= diff_j ? i : j );

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#define llint long long

using namespace std;

llint n, r;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> r;
	if(n < 10) cout << r + 100*(10-n) << endl;
	else cout << r << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;


int main()
{
int a, b;
cin >> a >> b;
if (a <= 0 && b >= 0)
{
cout << "Zero" << endl;
return 0;
}
if ((a > 0 && b > 0) || (b - a + 1) % 2 == 0)
{
cout << "Positive" << endl;
return 0;
}
cout << "Negative" << endl;


}



Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
total = B - A + 1
num_C = B // C - (A-1)//C
num_D = B // D - (A-1)//D

from fractions import gcd
g = gcd(C, D)
l = C * D // g
num_CD = B//l - (A-1)//l
ans = total - (num_C + num_D - num_CD)
print(ans)


Measured memory_bytes: 5104
x, k, d = map(int, input().split())

x = abs(x)

a = x // d

if k <= a:
    ans = x - k * d
    print(abs(ans))
    exit()

x -= a * d
x = abs(x)
k -= a


if k % 2 == 0:
    print(abs(x))
else:
    print(abs(x - d))

Measured memory_bytes: 61876
#include <iostream>

using namespace std;

int main()
{
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;

	(x + r > w || x - r < 0 || y + r > h || y - r < 0) ? cout << "No" << endl : cout << "Yes" << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    string s;
    cin >> s;
    ll sum = 0;
    ll now = 0;
    n = s.size() + 1;
    vector<ll> v(n,-10);
    ll cnt = 0;
    bool flag = false;
    for(i=0;i<n-1;i++){
        if(s[i]=='>' && s[i+1]=='<'){
            v[i+1]=0;
        }
    }
    
    for(i=0;i<n;i++){
        if(v[i]==0){
            j=i-1;
            while(j>=0 && s[j]=='>'){
                v[j] = max(v[j+1]+1,v[j]);
                j--;
            }
            j = i+1;
            while(j<n && s[j-1]=='<'){
                v[j] = max(v[j-1]+1,v[j]);
                j++;
            }
        }
    }
    if(v[0]<0){
        i=0;
        v[0] = 0;
        while(i<n && s[i]=='<'){
            v[i+1] = max(v[i]+1,v[i+1]);
            i++;
        }
    }
    if(v[n-1]<0){
        i=n-1;
        v[i] = 0;
        while(i>0 && s[i-1]=='>'){
            v[i-1] = max(v[i]+1,v[i-1]);
            i--;
        }
    }
    sum = 0;
    for(i=0;i<n;i++){
        //cout << v[i] << " ";
        sum+=v[i];
    }
    //cout << endl;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Color(int a)
        {
            for (int i = 400; i <= 3200; i += 400)
            {
                if (a < i) { return i; }
            }
            return -1;
        }
        static IEnumerable<int> Solve(int[] A)
        {
            int reds = 0;
            var colors = new Dictionary<int, int>();
            foreach (int a in A)
            {
                int key = Color(a);
                if (key < 0)
                {
                    ++reds;
                }
                else
                {
                    if (!colors.ContainsKey(key)) { colors[key] = 0; }
                    ++colors[key];
                }
            }
            return new[] { Math.Max(colors.Count, 1), colors.Count + reds };
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] A = ReadInts();
            Console.WriteLine(string.Join(" ", Solve(A)));
        }
    }
}


Measured memory_bytes: 13152
#include<bits/stdc++.h>
using namespace std;
int main()
    {
    	cin.tie(0);
        ios::sync_with_stdio(0);
        string s,S;cin>>s;
    	for (int i = 0; i <s.length() ; ++i)
    	{
    		if(i%2==0){S+=s[i];}
 
    	}
        cout<<S;
    	return 0;
    }

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x = i * 1.08;
    if (x == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


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

class Combination:                                      # 計算量は O(n_max + log(mod))
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):                     # 階乗(= n_max !)の逆元を生成
            f = f * i % mod                             # 動的計画法による階乗の高速計算
            fac.append(f)                               # fac は階乗のリスト
        f = pow(f, mod-2, mod)                          # 階乗から階乗の逆元を計算。フェルマーの小定理より、　a^-1 = a^(p-2) (mod p) if p = prime number and p and a are coprime
                                                        # python の pow 関数は自動的に mod の下での高速累乗を行ってくれる
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):                   # 上記の階乗の逆元から階乗の逆元のリストを生成（＝ facinv ）
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()


    def __call__(self, n, r):  # self.C と同じ
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

############################################################################################################
from itertools import combinations

MOD = mod=10**9+7

N, K = map(int, input().split())
C = Combination(N)
A = list(map(int, input().split()))
if K == 1:
    print(0)
    exit()
A.sort()

res = 0
for i in range(K-1,N):
    res += C(i+1-1,K-1) * A[i]

for i in range(N-K+1):
    res -= C(N-i-1,K-1) * A[i]

print(res%MOD)


Measured memory_bytes: 94504
#include <stdio.h>
#include <inttypes.h>

int N;
int p[22222];

int64_t a[22222], b[22222];

int main(void) {
	int i;
	int64_t min;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &p[i]) != 1) return 1;
		a[p[i] - 1] = i;
		b[p[i] - 1] = 0;
	}
	for (i = 1; i < N; i++) {
		int64_t diff1 = a[i] - a[i - 1];
		int64_t diff2 = b[i - 1] - b[i];
		int64_t diff_min = diff1 < diff2 ? diff1 : diff2;
		if (diff_min <= 0) {
			a[i] += -diff_min + 1;
			b[i] -= -diff_min + 1;
		}
	}
	min = a[0];
	for (i = 0; i < N; i++) {
		if (a[i] < min) min = a[i];
	}
	for (i = 0; i < N; i++) {
		printf(" %" PRId64 + (i == 0), a[i] - min + 1);
	}
	putchar('\n');
	min = b[0];
	for (i = 0; i < N; i++) {
		if (b[i] < min) min = b[i];
	}
	for (i = 0; i < N; i++) {
		printf(" %" PRId64 + (i == 0), b[i] - min + 1);
	}
	putchar('\n');
}


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

int main(int argc, char** argv)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	/*
	"iostream 遅い"などと検索すると、cin.tie(0); ios::sync_with_stdio(false);の2つの記述を加えると速くなる、という情報が見つかります。
	これはそれぞれ、cinとcoutの同期を切るもの、iostreamとstdioの同期を切るものです
	https://qiita.com/blackcurrant/items/312ea2471900132fbd6a
	*/

	// https://atcoder.jp/contests/abc122/tasks/abc122_a を解くわよ！
	//はい！
	// ちゃんとコメントにしなさい！

		//笑った
	// AtCoder 星には四種類の塩基 A, C, G, T が存在し、A と T、C と G がそれぞれ対になります。
	//文字 b が入力されます。これは A,  C, G, T のいずれかです。塩基 b と対になる塩基を表す文字を出力するプログラムを書いてください。

	// 問題をコピペしてあげたわよ！ありがたく思いなさい！

	// ここに入力をかく
	// cin.tie()
	char b;
	cin >> b;

	// ↑ 入力部分書いてくれますこと？
	// 入力部分書き終わりました！！



	// ここで答えをけいさんする
	char ans;

	// 問題はA と T、C と G が対ってことらしいね！
	// そうですことよ
	// はやく解いていただけます？

	// これってA->T, C->Gだけでいいのでしょうか?
	// T->A必要?
	// 対ってことは対ってことでしょう
	// つまり必要ってことですわ。
	//  ほんとだ！入力例2がG->Cになってますね。。
	
	//愚直にやるなら
	//if (b == 'A') {
	//	ans = 'T';
	//}
	//else if (b == 'T') {
	//	ans = 'A';
	//}
	//else if (b == 'C') {
	//	ans = 'G';
	//}
	//else if (b == 'G') {
	//	ans = 'C';
	//}
	// 醜いプログラムですこと
	// では、お嬢様はこの問題をどのように解くのですか

	// map!!!!!!!
	// ここでしゅつりょく

	std::map<char, char> m = { {'A', 'T'}, {'T', 'A'}, {'C', 'G'}, {'G', 'C'} };
	ans = m[b];
	// すまーと！！
	cout << ans << endl;
	// OK
	// OK!
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)


def search(tree, visited, key):
    visited[key] = True
    sum = 1
    for i in range(len(tree[key])):
        if not visited[tree[key][i]]:
            sum += search(tree, visited, tree[key][i])
    return sum


def main(input, print):
    N, M = map(int, input().split())
    visited = [False] * N
    tree = [[] for _ in range(N)]
    for i in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        tree[A].append(B)
        tree[B].append(A)

    ans = 0
    for i in range(N):
        if visited[i]:
            continue
        ans = max(ans, search(tree, visited, i))

    print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 715776
n, m, c = map(int,input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for i in range(n):
    tm = 0
    for j in range(m):
        tm = tm + a[i][j] * b[j]
    if (tm + c > 0):
        ans += 1
print(ans)

Measured memory_bytes: 3064
# include <iostream>
# include <string>
using namespace std;
int main()
{
	int n,k;
	cin>>n;
	string s;
	k=0;
	cin>>s;
	for(int i=0; i<n; i++)
	{
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
		{
			k=k+1;
			i=i+2;
		}
	}
	cout<<k;
} 

Measured memory_bytes: 3624
#include<iostream>
#include<string>
using namespace std;
int main(){

  string S;
  cin>>S;
  if(S[0]!='A'){
  
    cout<<"WA";
    return 0;
  }
  bool Cflag=0;
  if('a'<=S[1]&&S[1]<='z'){
  }
  else{
  
    cout<<"WA";
    return 0;
  }
  for(size_t i=2;i<=S.length()-2;i++){
  
    if(S[i]=='C'){
    
      if(Cflag==1){
      
        cout<<"WA";
        return 0;
      }
      Cflag=1;
    }
    else if('a'<=S[i]&&S[i]<='z'){
    }
    else{
    
      cout<<"WA";
      return 0;
    }
  }
  if('a'<=S[S.length()-1]&&S[S.length()-1]<='z'&&Cflag==1){
  
  }
  else{
    cout<<"WA";
    return 0;
  }
  cout<<"AC";
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<map>
#define N 100000
#define LL long long int
using namespace std;
int fun(int x){
	int ans=0;
	while(x>0){
		ans+=x%10;
		x/=10; 
	}
	return ans;
}
int main(){
	int n;
	cin>>n;
	int L=1,R=n-1;
	int ans=100000;
	while(L<=R){
		ans=min(ans,fun(L)+fun(R));
		L++,R--;
	}
	cout<<ans<<endl;
} 

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

int main(){
  int i,j,k,l,m,n,x,y,h,w,sum;
  int ans;
 

  
  while(1){
    ans=0;
    sum=0;
    cin >> n;
    if(n == 0)break;

    for(i=0;i<n;i++){
      cin >> x >> y >> h >> w;
      sum = x + y + h;
      if(w<=2){
	if(sum<=60)ans+=600;
	else if(sum<=80)ans+=800;
	else if(sum<=100)ans+=1000;
	else if(sum<=120)ans+=1200;
	else if(sum<=140)ans+=1400;
	else if(sum<=160)ans+=1600;
	else ans+=0;
      }
      else if(w<=5){
        if(sum<=80)ans+=800;
	else if(sum<=100)ans+=1000;
	else if(sum<=120)ans+=1200;
	else if(sum<=140)ans+=1400;
	else if(sum<=160)ans+=1600;
	else ans+=0;
      }
      else if(w<=10){
	 if(sum<=100)ans+=1000;
	else if(sum<=120)ans+=1200;
	else if(sum<=140)ans+=1400;
	else if(sum<=160)ans+=1600;
	else ans+=0;
      }
 else if(w<=15){
	
	 if(sum<=120)ans+=1200;
	else if(sum<=140)ans+=1400;
	else if(sum<=160)ans+=1600;
	else ans+=0;
      }
 else if(w<=20){

	
	 if(sum<=140)ans+=1400;
	else if(sum<=160)ans+=1600;
	else ans+=0;
      }
 else if(w<=25){



	if(sum<=160)ans+=1600;
	else ans+=0;
      }




    }
    cout << ans << endl;



  }






}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int t,n,s,f,sum,i;
	while(1){
		cin>>t;
		if(t==0) break;
		cin>>n;
		sum=0;
		for(i=0;i<n;i++){
			cin>>s>>f;
			sum+=f-s;
		}
		if(sum>=t) cout<<"OK"<<endl;
		else cout<<t-sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int i;
			for(i=1;i<=n;i++) {
				int x=i;
				if(x%3 == 0) {
					System.out.printf(" "+i);
				}
				else {
				while(true) {
					if(x%10 == 3) {
						System.out.printf(" "+i);
						x=0;
					}
					x /= 10;
					if(x==0) break;
			}
			}
			}
			System.out.println();
			scan.close();
}
}


Measured memory_bytes: 30656
#include <cstdio>

template<typename T>
T gcd(T a, T b)
{
	if (a < b) return gcd(b, a);
	T r;
	while (r = a % b)
	{
		a = b;
		b = r;
	}
	return b;
}

int main()
{
  long long a, b;
  scanf("%lld%lld", &a, &b);
  printf("%lld\n", a * b / gcd(a, b));
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> A(M);
  rep (i, M) {
    int k;
    cin >> k;
    rep (j, k) {
      int s;
      cin >> s;
      s--;
      A[i].push_back(s);
    }
  }
  vector<int> P(M);
  rep (i, M) cin >> P[i];

  ll ans = 0;
  rep (i, 1 << N) {
    map<int, bool> mp;
    rep (j, N) {
      if (i & 1 << j) {
	mp[j] = true;
      }
    }

    bool ok = true;
    for (int l = 0; l < A.size(); l++) {
      int cnt = 0;
      for (auto v : A[l]) if (mp[v]) cnt++;
      if (cnt % 2 == P[l]) continue;
      ok = false;
    }
    if (ok) ans++;
  }

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


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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	for (int i=1; i<=9; i++) {
		for (int j=1; j<=9; j++) {
			if (i*j==n) {
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;

int main(){
	long long a;scanf("%lld",&a);
	int ret=0;
	while(a){
		ret++;
		a/=2;
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 2748
#include<bits/stdc++.h>
using namespace std;
///using ll=long long;
#define ll long long
const ll amx=100000;
int main()
{
	ll a[amx],b[amx];
	ll n,k;
	cin>>n>>k;
	vector<pair<ll,ll> >vec;
	for(int i=0;i<n;i++){
		int a2,b2;
		cin>>a2>>b2;
		vec.push_back(make_pair(a2,b2));
	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<n;i++){
		a[i]=vec[i].first;
		b[i]=vec[i].second;
	}
	for(int i=0;i<n;i++){
		if(b[i]>=k){
			cout<<a[i]<<endl;
			break;
		}else{
			k-=b[i];
		}
	}
	return 0;
}

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

int main(void){
    ll yen = 100;
    int count = 0;
    ll x;
    cin >> x;
    while(yen<x){
        yen *= 1.01;
        count++;
    }
    cout << count << endl;

}

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

using namespace std;

//#define FILE_IO

int N, L;
int p[100005];
int nxt[100005][20];

int caut(int val)
{
    int st = 1;
    int dr = N;
    int pos = 0;
    while(st <= dr)
    {
        int mid = st + (dr - st) / 2;
        if(p[mid] <= val)
        {
            pos = mid;
            st = mid + 1;
        }
        else
            dr = mid - 1;
    }
    return pos;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
        scanf("%d", &p[i]);
    scanf("%d", &L);

    for(int i = 0; i < 20; i++)
        nxt[N + 1][i] = N + 1;
    for(int i = N; i >= 1; i--)
    {
        int pos = caut(p[i] + L);
        if(pos == i)    pos = N + 1;
        nxt[i][0] = pos;
        for(int j = 1; j < 20; j++)
            nxt[i][j] = nxt[ nxt[i][j - 1] ][j - 1];
    }

    int Q;
    scanf("%d", &Q);
    while(Q--)
    {
        int st, dr;
        scanf("%d%d", &st, &dr);
        if(st > dr) swap(st, dr);

        int ans = 0;
        int pos = st;
        for(int b = 19; b >= 0; b--)
            if(nxt[pos][b] < dr)
            {
                ans ^= (1 << b);
                pos = nxt[pos][b];
            }
        ans++;
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 9088
S = input()
K = int(input())

if len(S)==1:
    print(S[0])
    quit()

if K == 1:
    print(S[0])
    quit()

n = 0
while n < len(S):
    if S[n] != '1':
        break
    else:
        n += 1

if K <= n:
    print(1)
else:
    print(S[n])

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
	ll n, d;
	cin >> n >> d;

	int ans = 0;
	for(int i = 0; i < n; i++){
		ll x, y;
		cin >> x >> y;

		ll dist = x*x + y*y;
		if(dist <= d*d) ans++;
	}

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


Measured memory_bytes: 3628
N = int(input())
ok = False

for i in range(1, 3501):
    for j in range(1, 3501):
        if N*(i+j) < 4*i*j:
            w = 1 / (4/N - 1/i - 1/j)
            if abs(int(w)-w) < 10**-7:
                print(i, j, int(w))
                ok = True
                break
    if ok:
        break

Measured memory_bytes: 74096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector <int> vec(5);
  for (int i = 0; i < 5; i++) {
  cin >> vec.at(i);
}
  int k;
  cin >> k;
  sort(vec.begin(), vec.end());
  int l;
  l = vec.at(4)-vec.at(0);
  if (k>=l){
  cout <<"Yay!";
  }else{
  cout <<":(";
  }
}



Measured memory_bytes: 256
s=input()
t=input()
sl=len(s)
tl=len(t)
a=''
ans=['']
for i in range(sl-tl+1):
  flg=0
  for j in range(tl):
    if s[i+j]!='?' and s[i+j]!=t[j]:
      flg=1
  if flg==0:
    a=s[:i]+t+s[tl+i:]
    a=a.replace('?','a')
    ans.append(a)
    a=''
ans.sort()
if len(ans)==1:
  print('UNRESTORABLE')
else:
  print(ans[1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
bool isOkmin(ll num,vector<int> v){
    rep(i,v.size()){
        num /= v[i];
        num *= v[i];
    }
    return num >= 2;
}
bool isOkmx(ll num,vector<int> v){
    rep(i,v.size()){
        num /= v[i];
        num *= v[i];
    }
    return num <= 2;
}
int main()
{
    int k;
    cin >> k;
    vector<int> a(k);
    rep(i,k){
        cin >> a[i];
    }
    ll l, r;
    ll ok = 1e18;
    ll ng = 1;
    while(abs(ok-ng) > 1){
        ll mid =(ok+ng)/2;
        if(isOkmin(mid, a)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    l = ok;
    ok = 1;
    ng = 1e18;
    while (abs(ok - ng) > 1)
    {
        ll mid = (ok + ng) / 2;
        if (isOkmx(mid, a))
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    r = ok;
    if(l<=r){
        cout << l << " " << r;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 1024
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353


n = int(input())
aaa = list(map(int, input().split()))
n2 = 1 << n
dp = [[a, 0] for a in aaa]

for j in range(n):
    b = 1 << j
    for i in range(n2):
        if not i & b:
            dpi, dpk = dp[i], dp[i | b]
            if dpk[0] < dpi[0]:
                dpk[1] = max(dpk[0], dpi[1])
                dpk[0] = dpi[0]
            elif dpk[1] < dpi[0]:
                dpk[1] = dpi[0]

ans = []
tmp = 0
for a in dp[1:]:
    tmp = max(tmp, a[0] + a[1])
    ans.append(tmp)
print(*ans)


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

#define ll long long

using namespace std;
int b[3][3];

int main(){
    int a[3][3];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin>>a[i][j];
        }
    }
    int n; cin>>n;
    int ele; 
    for(int i=0; i<n; i++){
        cin>>ele;
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(a[i][j]==ele)b[i][j]=1;
            }
        }
    } 
    // row
    for(int i=0; i<3; i++){
        bool f=true;
        for(int j=0; j<3; j++){
            if(!b[i][j]) f=false;
        }
        if(f){
            cout<<"Yes\n";
            return 0;
        }
    }
    // column
    for(int j=0; j<3; j++){
        bool f=true;
        for(int i=0; i<3; i++){
            if(!b[i][j]) f=false;
        }
        if(f){
            cout<<"Yes\n";
            return 0;
        }
    }
    // diag
    bool f=true;
    for(int i=0; i<3; i++){
        if(!b[i][i]) f=false;
    }
    if(f){
        cout<<"Yes\n";
        return 0;
    }

    f=true;
    for(int i=0; i<3; i++){
        if(!b[i][2-i]) f=false;
    }
    if(f){
        cout<<"Yes\n";
        return 0;
    }


    cout<<"No\n";
}

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

int main() {
  int N,X;
  cin >> N >> X;
  
  vector<int> m(N);
  int min=1001;
  for(int i=0; i<N; i++){
    cin >> m.at(i);
    if(min>m.at(i)) min = m.at(i);
    X -= m.at(i);
  }
  int cnt = X/min;
  cout << cnt+N << endl;
}

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

int main() {
  int s, w;
  cin >> s >> w;
  
  if(s <= w){
    cout << "unsafe" << endl;
  }else{
    cout << "safe" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3636
n = int(input())
if 1800 <= n <= 1999:
    print(1)
elif 1600 <= n <= 1799:
    print(2)
elif 1400 <= n <= 1599:
    print(3)
elif 1200 <= n <= 1399:
    print(4)
elif 1000 <= n <= 1199:
    print(5)
elif 800 <= n <= 999:
    print(6)
elif 600 <= n <= 799:
    print(7)
else:
    print(8)

Measured memory_bytes: 9180
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<# x "="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000
#define EPS 1e-10

double a[100], b[100], c[100], d[100];

#define EQ(x,y) fabs((x)-(y))<(EPS)

inline double dist(double x1,double y1,double x2,double y2){
  return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}


int main(){
  int n;
  int cnt=1;
  while(cin>>n, n){
    rep(i,n){
      scanf("%lf %lf %lf %lf", &a[i], &b[i], &c[i], &d[i]);
    }

    int res=1;
    rep(i,n){
      // new line idx=i
      vector<pair<double, double> > cross;
      int adds=1;
      rep(j,i){
        // check if i and j have intersection point
        // => not paralell and inner square

        // is paralell ?
        if(EQ((a[i]-c[i])*(b[j]-d[j]), (a[j]-c[j])*(b[i]-d[i]))) continue;

        // calc intersection point
        double nx;
        double ny;
        if( EQ(a[i],c[i]) ){
          double dj = (b[j]-d[j])/(a[j]-c[j]);
          nx = a[i];
          ny = dj*(nx-a[j])+b[j];
        } else if( EQ(a[j],c[j]) ){
          double di = (b[i]-d[i])/(a[i]-c[i]);
          nx = a[j];
          ny = di*(nx-a[i])+b[i];
        } else {
          double di = (b[i]-d[i])/(a[i]-c[i]);
          double dj = (b[j]-d[j])/(a[j]-c[j]);
          nx = (b[j]-dj*a[j]-(b[i]-di*a[i]))/(di-dj);
          ny = di*(nx-a[i])+b[i];
          assert(EQ(ny, dj*(nx-a[j])+b[j]));
        }
        //      dbg(nx);dbg(ny);

        if(fabs(nx)-100.0<=-EPS && fabs(ny)-100.0<=-EPS){
	//if(-100<nx && nx<100 && -100<ny && ny<100){
          int reps=cross.size();
          bool flg=true;
          rep(k,reps){
            // new point is already added or not
	    if(EQ(cross[k].first, nx) && EQ(cross[k].second, ny)){
	      //if( dist(cross[k].first,cross[k].second,nx,ny)<EPS ){
              flg=false; break;
            }
          }
          if(flg){
            cross.pb(mp(nx,ny));
            adds++;
          }
        }

      }// rep  j
      //      dbg(adds);
      res += adds;
    }//rep i

    cout<<res<<endl;

  }
  return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
#define mod 924844033
using namespace std;
int n,k;
int dp[4005][2005][2];
int d[4005],cnt,ans,fac[2005];

int main(){
    scanf("%d %d",&n,&k);
    for(int i=1;i<=k;i++){
        for(int j=0;j<2;j++) d[cnt+1]=1,cnt+=(n-i)/k+1;
    }
    dp[0][0][0]=1;
    for(int i=1;i<=cnt;i++){
        for(int j=0;j<=n;j++){
            dp[i][j][0]=(dp[i-1][j][0]+dp[i-1][j][1])%mod;
            if(!d[i]&&j+1<=n) dp[i][j+1][1]=dp[i-1][j][0];
        }
    }
    fac[0]=1;for(int i=1;i<=n;i++) fac[i]=1ll*i*fac[i-1]%mod;
    for(int j=0,v;j<=n;j++){
        v=1ll*(dp[cnt][j][0]+dp[cnt][j][1])*fac[n-j]%mod;
        if(j&1) (ans+=mod-v)%=mod;else (ans+=v)%=mod;
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 66416
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    x,y = map(int,input().split())
    print(x + y // 2)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int buff;
    vector<int>mochi;
    int n;  //餅の入力
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> buff;
        mochi.push_back(buff);
    }

    sort(mochi.begin(),mochi.end(),greater<int>());

    int ans = 1;    //重ねられる餅の数
    int maxmochi = mochi[0];   //一番上の餅の大きさ(これより小さければ良い)
    for (int j = 1; j < n; ++j) {
        if (maxmochi > mochi[j]){
            ans++;
            maxmochi = mochi[j];
        }
    }
    cout << ans;
    return 0;
}

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

#define N 300010 

using namespace std;

typedef long long ll;

const int mod = 1000000007 ;

char *p1, *p2, buf[100000];

#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1 ++ )

int rd() {
    int x = 0, f = 1;
    char c = nc();
    while (c < 48) {
        if (c == '-')
            f = -1;
        c = nc();
    }
    while (c > 47) {
        x = (((x << 2) + x) << 1) + (c ^ 48), c = nc();
    }
    return x * f;
}

int a[N], fac[N], fac2[N], bfr[N];

int qpow(int x, int y) {
    int ans = 1;
    while (y) {
        if (y & 1) {
            ans = (ll)ans * x % mod;
        }
        y >>= 1;
        x = (ll)x * x % mod;
    }
    return ans;
}

int main() {
    int n = rd();
    for (int i = 1; i <= n; i ++ ) {
        a[i] = rd();
    }

    // init
    fac[0] = 1;
    for (int i = 1; i <= n; i ++ ) {
        fac[i] = (ll)fac[i - 1] * i % mod;
    }
    for (int i = 1; i <= n; i ++ ) {
        fac2[i] = (ll)fac[n] * qpow(i, mod - 2) % mod;
        bfr[i] = (bfr[i - 1] + fac2[i]) % mod;
    }

    // for (int i = 1; i <= n; i ++ ) {
    //     printf("%d ", fac[i]);
    // }
    // puts("");
    // for (int i = 1; i <= n; i ++ ) {
    //     printf("%d ", fac2[i]);
    // }
    // puts("");

    int ans = 0;
    for (int i = 1; i <= n; i ++ ) {
        ans = (ans + (ll)a[i] * (
            (((ll)bfr[i] + bfr[n - i + 1]) % mod + mod - fac[n]) % mod
        )) % mod;
    }

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

Measured memory_bytes: 3200