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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    ll N; cin >> N;
    vector<ll> A(N); REP(i,N) cin >> A[i];
    ll mn = LL_INF, t = -1;
    REP(i,N){
        if(chmin(mn, abs(A[i]))) t = i;
    }
    REP(i,t){
        if(A[i] < 0){
            A[i] *= -1;
            A[i+1] *= -1;
        }
    }
    RFOR(i,N-1,t){
        if(A[i+1] < 0){
            A[i+1] *= -1;
            A[i] *= -1;
        }
    }
    ll ans = 0;
    REP(i,N) ans += A[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;
void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}



// class menu{ll s, ll e, ll val}

int main(){
    ll n,t; cin >> n >> t;
    vector<ll> a(n),b(n);
    vvl dp(2, vector<ll>(t+10,0));
    vector<vector<vector<bool>>> ok(2,vector<vector<bool>>(t+10,vector<bool>(n,false)));
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    rep(i,n){
        rep(j,t+1){
            if(j < a[i]){
                dp[(i+1)%2][j] = dp[i%2][j];
                ok[(i+1)%2][j] = ok[i%2][j];
            }
            else {
                if(dp[i%2][j] < dp[i%2][j-a[i]] + b[i]){
                    dp[(i+1)%2][j] = dp[i%2][j-a[i]] + b[i];
                    ok[(i+1)%2][j] = ok[i%2][j-a[i]];
                    ok[(i+1)%2][j][i] = true;
                }
                else{
                    dp[(i+1)%2][j] = dp[i%2][j];
                    ok[(i+1)%2][j] = ok[i%2][j];
                }
                // dp[i+1][j] = max(dp[i][j],dp[i][j-a[i]] + b[i]);
            }
        }
        
    }
    // print(dp);
    ll res = dp[n%2][t-1];
    // print(res);
    // rep(i,n){
    //     cout << int(ok[n][t-1][i]) << " ";
    // }
    // cout << endl;
    rep(i,n){
        if(ok[n%2][t-1][i])continue;
        res = max(res,dp[n%2][t-1] + b[i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <limits>
#include <cmath>
using namespace std;
 
int main() {
  long double a, b, c; cin >> a >> b >> c;
  long double epsilon = numeric_limits<long double>::epsilon();
  cout << (a + b + 2.0 * sqrt(a * b) + epsilon < c ? "Yes" : "No") << "\n"s;
  return 0;
}

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

ll n;
ll a, b, c, d, g;

ll gcd(ll x, ll y){
	return y == 0 ? x : gcd(y, x % y);
}

int main(){

cin >> n;

while (n--){
    cin >> a >> b >> c >> d;
    if (a < b || d < b) cout << "No\n";
    else if (c >= b) cout << "Yes\n";
    else {
        g = gcd(b, d);
        if (b - g + a % g > c) cout << "No\n";
        else cout << "Yes\n";
    }
}

return 0;
} 

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

cnt = {}
for i in range(n):
    s = input()
    s = sorted(list(s))
    s = str(s)
    if s not in cnt:
        cnt[s] = 0
    else:
        cnt[s] += 1

ans = 0
for c in cnt.values():
    ans += c * (c+1) // 2

print(ans)


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<int> wcnt(n, 0);
    int sum = 0, acs = 0;
    for (int i = 0; i < m; i++) {
        int p; string s; cin >> p >> s;
        if (s == "AC") {
            if (wcnt[p] >= 0) acs++, sum += wcnt[p];
            wcnt[p] = -1;
        } else {
            if (wcnt[p] >= 0) wcnt[p]++;
        }
    }
    cout << acs << " " << sum << "\n";
    return 0;
}

Measured memory_bytes: 640
INF = 10010
N_MAX = 100010

n = gets.to_i
hs = gets.chomp.split(' ').map(&:to_i)

h = {}
dp = {}
N_MAX.times do |i|
  h[i] = hs[i]
  dp[i] = INF
end

dp[0] = 0
(1...n).each do |i|
  dp[i] = dp[i-1] + (h[i] - h[i-1]).abs
  next if i == 1

  diff = dp[i-2] + (h[i] - h[i-2]).abs
  dp[i] = diff if dp[i] > diff
end

print(dp[n-1])

Measured memory_bytes: 28288
#pragma region Template
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <stack>
#include <set>
#include <algorithm>
#include <bitset>
#include <functional>
#include <ctime>
#include <cassert>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <complex>
#pragma comment(linker, "/STACK:167772160")

using namespace std;
#define mp make_pair
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define print_var(x) cerr << #x << " : " << (x) << endl
#define print_array(arr, len) {cerr << #arr << " : "; for(int i = 0; i < len; ++i) cerr << arr[i] << ' '; cerr << endl;}
#define print_2d_array(arr, len1, len2) {cerr << #arr << endl; for(int i = 0; i < len1; ++i, cerr << endl) for(int j = 0; j < len2; ++j) cerr << arr[i][j] << ' ';}
#define print_iterable(i) {cerr << #i << " : "; for(auto e : i) cerr << e << ' '; cerr << endl;}
#define print_new_line() cerr << endl
#else
#define eprintf(...) (void)0
#define print_var(x) (void)0
#define print_array(arr, len) {}
#define print_2d_array(arr, len1, len2) {}
#define print_iterable(i) {}
#define print_new_line() (void)0
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int INF = 1e9 + 10;
const ll LINF = ll(2e18) + 10;
const double PI = acosl(-1);
const double eps = 1e-8;
const ld EPS = 1e-11;
#pragma endregion

const int N = 1e5 + 10;
int n;
pii a[N];
ll ans[N];

void solve()
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i].first);
		a[i].second = i;
	}
	sort(a, a + n);
	reverse(a, a + n);
	ll sum = 0;
	int lastid = n;
	for (int i = 0; i < n; ++i)
	{
		if (a[i].second < lastid)
		{
			ll d = sum - (ll) i * a[i].first;
			sum -= d;
			ans[lastid] = d;
			lastid = a[i].second;
		}
		sum += a[i].first;
	}
	ans[lastid] = sum;
	for (int i = 0; i < n; ++i)
		printf("%lld\n", ans[i]);
}

int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#ifdef NOERR
	freopen("err.txt", "w", stderr);
#endif
#else
	//freopen("alter.in", "r", stdin);
	//freopen("alter.out", "w", stdout);
#endif

#ifdef ST
	while(true)
		solve();
#endif
#ifdef CASES
#define MULTITEST
#endif
#ifdef MULTITEST
	int t;
	scanf("%d", &t);
	for (int i = 0; i < t; ++i)
	{
#ifdef CASES
		printf("Case #%d: ", i + 1);
#endif
		solve();
#ifdef CASES
		//eprintf("Passed case #%d:\n", i + 1);
#endif
	}
#else
		solve();
#endif

	eprintf("\n\nTime: %.3lf", double(clock()) / CLOCKS_PER_SEC);
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    N=N%10 ;
    switch (N) {
            case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout<<"hon"<<endl;
            break;
        case 0:
            case 1:
                 case 6:
                 case 8:
                     cout<<"pon"<<endl;
                     break;
            case 3:
                               cout<<"bon"<<endl;
                               break;
            
        default:
            break;
    }
    
return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>  
 
using namespace std;
 
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
 
const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};
 
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int fact[100005];

int elePow(int a, int b) {
	int num = 1;
	while(b != 0) {
		if(b & 1) num = 1ll * num * a % MOD;
		b /= 2;
		a = 1ll * a * a % MOD;
	}
	return num;
}

int nCr(int n, int r) {
	if(r > n) return 0;
	if(r == 0) return 1;
	int a = fact[n], b = 1ll * fact[r] * fact[n - r] % MOD;
	int res = 1ll * a * elePow(b, MOD - 2) % MOD;
	return res;
}
 
int a[100005];
map<int, bool> went;

int main() {
	int n;
	scanf("%d", &n);
	int l, d, r;
	rep(i, n + 1) {
		scanf("%d", &a[i]);
		if(!went[a[i]]) went[a[i]] = true;
		else {
			r = i;
			d = a[i];
		}
	}
	rep(i, n + 1) if(a[i] == d) {
			l = i;
			break;
	}
	fact[0] = 1;
	FOR(i, 1, n + 2) {
		fact[i] = 1ll * fact[i - 1] * i % MOD;
		//cout << fact[i] << endl;
	}
	printf("%d\n", n);
	FOR(i, 2, n + 2) {
		printf("%d\n", (nCr(n + 1, i) - nCr(l + n - r, i - 1) + MOD) % MOD);
	}
	return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include <string>

using namespace std;

// 入力
string s;

int main(void) {
    cin >> s;

    bool success = true;
    while (s.length() != 0) {
//        cout << s << endl;
        if (s.substr(s.length() - 5) == "dream") {
            s = s.substr(0, s.length() - 5);
            continue;
        }
        if (s.substr(s.length() - 5) == "erase") {
            s = s.substr(0, s.length() - 5);
            continue;
        }
        if (s.substr(s.length() - 6) == "eraser") {
            s = s.substr(0, s.length() - 6);
            continue;
        }
        if (s.substr(s.length() - 7) == "dreamer") {
            s = s.substr(0, s.length() - 7);
            continue;
        }
        success = false;
        break;
    }

    if (success) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>

int main(void){
	
	char ango[1000],ttt[100];
	int leng,b;

	while(gets(ango)!=0){
		leng=strlen(ango);
		b=1;

		while(b){

			for(int i=leng-1;i>=0;i--){
				if(ango[i]>=97&&ango[i]<=122){
					ango[i]=ango[i]-1;
					if(ango[i]==96){
						ango[i]=122;
					}
				}
			}

			for(int i=0,j=0;i<=leng;i++,j++){
				if(ango[i]>=97&&ango[i]<=122&&i!=leng){
					ttt[j]=ango[i];
				}
				else{
					if((ttt[0]=='t'&&ttt[1]=='h'&&ttt[2]=='e'&&j==3)||(ttt[0]=='t'&&ttt[1]=='h'&&ttt[2]=='i'&&ttt[3]=='s'&&j==4)||(ttt[0]=='t'&&ttt[1]=='h'&&ttt[2]=='a'&&ttt[3]=='t'&&j==4)){
						b=0;
						break;
					}
					j=-1;
				}
			}
		}
		printf("%s\n",ango);
	}
	return 0;
}

Measured memory_bytes: 920
/**
     *    author:  shashank_hire
    **/
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define ld long double
#define MOD 1000000007

bool f(string s)
{
    cout<<s<<"\n";
    ll n = s.size(), i;
    for(i=0;i<n/2;i++)
        if(s[i]!=s[n-1-i])
            return 0;
    return 1;
}

// main function
int main()
{
    double n;
    cin>>n;
    cout<<setprecision(12)<<(n*n*n)/27<<"\n";
	return 0;
}

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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)


int main(){
    int a,b;
    cin>>a>>b;
    cout<<(b-a-1)*(b-a)/2-a<<endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;

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

  ll h, w;
  cin >> h >> w;
  vector < string > s(h);
  for(int i = 0; i < h; i++) cin >> s[i];

  vector < vector < bool > > used(h, vector < bool > (w, false));
  ll ans = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(!used[i][j]){
        queue < pair < ll, ll > > q;
        q.push({i, j});
        ll cnt0 = 0, cnt1 = 0;
        while(!q.empty()){
          ll x = q.front().first, y = q.front().second; q.pop();
          if(x - 1 >= 0 && s[x - 1][y] != s[x][y] && !used[x - 1][y]){
            used[x - 1][y] = true;
            q.push({x - 1, y});
            if(s[x - 1][y] == '.') cnt0++;
            else cnt1++;
          }
          if(x + 1 < h && s[x + 1][y] != s[x][y] && !used[x + 1][y]){
            used[x + 1][y] = true;
            q.push({x + 1, y});
            if(s[x + 1][y] == '.') cnt0++;
            else cnt1++;
          }
          if(y - 1 >= 0 && s[x][y - 1] != s[x][y] && !used[x][y - 1]){
            used[x][y - 1] = true;
            q.push({x, y - 1});
            if(s[x][y - 1] == '.') cnt0++;
            else cnt1++;
          }
          if(y + 1 < w && s[x][y + 1] != s[x][y] && !used[x][y + 1]){
            used[x][y + 1] = true;
            q.push({x, y + 1});
            if(s[x][y + 1] == '.') cnt0++;
            else cnt1++;
          }
        }
        ans += cnt0 * cnt1;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios()              \
  ios::sync_with_stdio(0); \
  cin.tie(0);              \
  cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in()
{
  int x;
  cin >> x;
  return x;
}
template <typename T>
inline void out(const T &x) { cout << x << endl; }
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool *isPrime, int max)
{
  fill(isPrime, isPrime + max, true);
  isPrime[0] = false;
  isPrime[1] = false;
  for (int i = 2; i <= max / i; ++i)
    if (isPrime[i])
      for (int j = 2; j <= max / i; ++j)
        isPrime[i * j] = false;
}

signed main()
{
  ios();
  int m;
  cin >> m;
  string s;
  for (int i = 0; i < m; i++)
  {
    cin >> s;
    int sz = s.size();
    set<string> train;
    for (int i = 1; i < sz; i++)
    {
      string left = s.substr(0, i);
      string right = s.substr(i);
      // cout << "degub:" << left << ' ' << right << endl;
      string r_left = left;
      string r_right = right;
      reverse(r_left.begin(), r_left.end());
      reverse(r_right.begin(), r_right.end());
      train.insert(left + right);
      train.insert(right + left);

      train.insert(left + r_right);
      train.insert(r_right + left);

      train.insert(r_left + right);
      train.insert(right + r_left);

      train.insert(r_left + r_right);
      train.insert(r_right + r_left);
    }
    // for (auto itr = train.begin(); itr != train.end(); itr++)
    // {
    //   cout << *itr << endl;
    // }
    int ans = train.size();
    cout << ans << endl;
  }
}



Measured memory_bytes: 3304
#include<cstdio>

const int maxn=1e5+5;

const int INF=1<<30;

int cost[maxn];

int dp[maxn];

int min(int a,int b) { return a>b?b:a; }

int get_value(int,int);

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

	for(int i=1;i<=n;i++){

		scanf("%d",&cost[i]);
	}
	
	for(int i=0;i<=maxn-3;i++){
	
		dp[i]=INF;
	}

	dp[1]=0; dp[2]=get_value(1,2);

	for(int i=3;i<=n;i++){
	
		dp[i]=min(dp[i-1]+get_value(i,i-1),dp[i-2]+get_value(i,i-2));
	}

	printf("%d\n",dp[n]);

	return 0;
}

int get_value(int a,int b){
	
	int value=cost[a]-cost[b];

	return value>0?value:((-1)*value);
}



Measured memory_bytes: 896
#include <iostream>
#include <cstdlib>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <utility>
using namespace std;


int main(){
    int a;
    int min = 100000;
    string s;
    cin >> s;

    for(int i=0;i<s.length()-2;i++){
        a = atoi(s.substr(i, 3).c_str());
        if(abs(a - 753) < min) min = abs(a - 753);
    }
	cout << min << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    long M = 1_000_000_007;
    int n = scanner.nextInt();
    int k = scanner.nextInt();

    long[] chooseN = chooseForN(n, M);
    long[] chooseN1 = chooseForN(n - 1, M);
    long res = 0;
    for (int i = Math.max(n - k, 1); i <= n; i++) {
      long c = chooseN[i];
      c *= chooseN1[i - 1];
      c %= M;
      res += c;
      if (res >= M) res -= M;
    }
    System.out.println(res);
  }

  private static long inverse(long a, long mod) {
    return modpow(a, mod - 2, mod);
  }

  private static long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
      if (n % 2 == 1) res = (res * a) % mod;
      a = (a * a) % mod;
      n >>= 1;
    }
    return res % mod;
  }

  public static long[] chooseForN(int n, long mod) {
    long[] C = new long[n + 1];
    long[] fact = new long[n + 1];
    long[] factinv = new long[n + 1];

    fact[0] = 1;
    for (int i = 0; i < n; i++) fact[i + 1] = fact[i] * (n - i) % mod;
    factinv[0] = 1;
    for (int i = 1; i <= n; i++) factinv[i] = factinv[i - 1] * inverse(i, mod) % mod;

    for (int i = 0; i <= n; i++) C[i] = fact[i] * factinv[i] % mod;

    return C;
  }
}


Measured memory_bytes: 34388
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True

def f(x, y, z):
    return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x

def main():
    N = I()
    ans = defaultdict(int)

    for x in range(1, int(N ** 0.5)+1):
        for y in range(1, int(N ** 0.5)+1):
            for z in range(1, int(N ** 0.5)+1):
                ans[f(x, y, z)] += 1

    for i in range(1, N+1):
        print(ans[i])
    # print(dic)

if __name__ == '__main__':
    main()


Measured memory_bytes: 76344
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

K, N = lr()
A = np.array(lr())
A = np.append(A, A[0] + K)
diff = np.diff(A)
answer = K - diff.max()
print(answer)


Measured memory_bytes: 34168
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

struct data{
	string team;
	int win, lose, order;
};

bool cmp(data d1, data d2){
	if(d1.win != d2.win) return d1.win > d2.win;
	if(d1.lose != d2.lose) return d1.lose < d2.lose;
	return d1.order < d2.order;
}

signed main() {
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		vector<data> d(n);
		string s;
		int a, win, lose;
		rep(i, 0, n){
			cin >> s;
			win = 0;
			lose = 0;
			rep(j, 0, n - 1){
				cin >> a;
				if(a == 0) win++;
				else if(a == 1) lose++;
			}
			d[i].team = s;
			d[i].win = win;
			d[i].lose = lose;
			d[i].order = i;
		}
		sort(all(d), cmp);
		rep(i, 0, n){
			cout << d[i].team <<endl;
		}
	}
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n;
    cin >> n;
    string tmp;
    map<string, int> mp;
    int max_num = 0;
    REP(i,n){
        cin >> tmp;
        mp[tmp]++;
        max_num = max(max_num, mp[tmp]);
    }
    for(auto x:mp){
        if(x.second==max_num){
            cout << x.first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 18304
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int a;
    cin >> a;
    string s;
    cin >> s;

    if(a >= 3200){
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int a[] = new int[n];
    int count[] = new int[n + 1];
    Combination[] combinations = new Combination[n + 1];
    for (int i = 0; i < n; i++) {
      int ai = Integer.parseInt(sc.next());
      a[i] = ai;
      count[ai]++;
    }
    for (int i = 1; i < n + 1; i++) {
      int countI = count[i];
      if (countI == 0) {
        continue;
      }
      Combination c = new Combination();
      combinations[i] = c;
      if (countI == 1) {
        continue;
      }
      c.full = (long) countI * (countI - 1) / 2;
      if (countI == 2) {
        continue;
      }
      c.matchK = ((long) countI - 1) * (countI - 2) / 2;
    }
    long total = Arrays.stream(combinations)
      .filter(Objects::nonNull)
      .mapToLong(c -> c.full)
      .sum();
    for (int i = 0; i < n; i++) {
      int ak = a[i];
      Combination c = combinations[ak];
      pw.println(total - (c.full - c.matchK));
    }
  }

  static class Combination {

    long full;
    long matchK;
  }
}


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

int a[200000+50];
int c[200000+50];

vector <int> tc[200000+50];

int poww(int x,int k,int mod){
    if(k==0){
        return 1;
    }

    int xx=poww(x,k/2,mod);
    xx=(xx*xx)%mod;
    if(k%2==1){
        xx=(xx*x)%mod;
    }
    return xx;
}

signed main(){
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    map <int,int> mp;
    mp[0]++;
    int val=0,p=1;
    long long ans=0;
    for(int i=s.size()-1;i>=0;i--){
        val=val+p*(s[i]-'0');
        p=(p*10)%2019;
        val=val%2019;
        ans+=(long long)mp[val];
        mp[val]++;
    }
    cout<<ans;
}
/*
Mistakes to take care of-
1. For string s, s+=a is similar to appending to s. s = s + a takes O|s| + O|a| time. 
Relevant problem where I made mistake - https://codeforces.com/contest/1326/problem/D2
2. Try using constant value of N to declare arrays, etc. Else you might get hacked / FST.
Relevant problem where I made a mistake - https://codeforces.com/contest/1307/problem/D
3. While exponentiation, avoid modding the exponent. Or mod with mod-1.
Relevant problem where I made a mistake - https://codeforces.com/contest/1332/problem/E
*/

Measured memory_bytes: 8444
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)1e5+100;


int main(void) {
   ll N;
   cin>>N;
   vector<ll> A(N);
   rep(i,0,N) cin>>A[i];
   ll id[2] = {min_element(A.begin(),A.end()) - A.begin(),max_element(A.begin(),A.end()) - A.begin()};
   // cout<<id[0]<<" "<<id[1]<<endl;
   if (id[1]==id[0]) {
      id[0] = 0;
      id[1] = N-1;
   }
   vector<pair<ll,ll>> va;
   rep(i,0,N) {
      if (i==id[0]) continue;
      if (i==id[1]) continue;
      if (A[i]<=0) {
         // cout<<A[id[1]]<<" "<<A[i]<<endl;
         va.push_back(make_pair(A[id[1]],A[i]));
         A[id[1]] -= A[i];
      } else {
         // cout<<A[id[0]]<<" "<<A[i]<<endl;
         va.push_back(make_pair(A[id[0]],A[i]));
         A[id[0]] -= A[i];
      }
   }
   // cout<<A[id[1]]<<" "<<A[id[0]]<<endl;
   va.push_back(make_pair(A[id[1]],A[id[0]]));
   cout<<A[id[1]] - A[id[0]]<<endl;
   for (auto el: va) {
      cout<<el.first<<" "<<el.second<<endl;
   }




   return 0;
}

Measured memory_bytes: 4336
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int min = sc.nextInt();
    int max = sc.nextInt();
        
    int count = 0;
        
    for(int i=min; i<=max; i++) {
        String val = String.valueOf(i);
        String reverseVal = (new StringBuilder(val)).reverse().toString();

        if(val.equals(reverseVal)) {
        	count++;
    	}
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 38612
#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int maxn=1e6+20;

int a[10005],b[10005];

int main()
{
	int n;
    ll c1=0,c2=0;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    for(int i=1;i<=n;i++){
        if(a[i]>b[i]) c1=c1+a[i]-b[i];
        else if(a[i]<b[i]){
            if((b[i]-a[i])%2==0) c2=c2+(b[i]-a[i])/2;
            else {c1++;c2=c2+(b[i]-a[i]+1)/2;}
        }
    }
    
    if(c2>=c1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}//Good luck,mate!^_^

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;

int main(void)
{
    LL H, W, K;
    cin >> H >> W >> K;
    LL s[H][W];
    LL c = 1;
    for (LL i = 0; i < H; i++) {
        for (LL j = 0; j < W; j++) {
            char t;
            cin >> t;
            if (t == '#') s[i][j] = c++;
            else s[i][j] = 0;
        }
    }

    for (LL i = 0; i < H; i++) {
        LL f = 0;
        for (LL j = 0; j < W; j++) {
            if (s[i][j] == 0) s[i][j] = f;
            else f = s[i][j];
        }
    }
    for (LL i = H-1; i >= 0; i--) {
        LL f = 0;
        for (LL j = W-1; j >= 0; j--) {
            if (s[i][j] == 0) s[i][j] = f;
            else f = s[i][j];
        }
    }
    for (LL i = 1; i < H; i++) {
        if (s[i][0] == 0) {
            for (LL j = 0; j < W; j++) {
                s[i][j] = s[i-1][j];
            }
        }
    }
    for (LL i = H-1; i >= 0; i--) {
        if (s[i][0] == 0) {
            for (LL j = 0; j < W; j++) {
                s[i][j] = s[i+1][j];
            }
        }
    }

    for (LL i = 0; i < H; i++) {
        for (LL j = 0; j < W; j++) {
            cout << s[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 1408
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)
const long double PI = (acos(-1));

int main() {

	int d;
	cin >> d;
	string s = "Christmas", t = "Eve";

	cout << s;
	int n = 25 - d;
	rep(i, 0, n) cout << " " << t;

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;

 
const int MAX_N = int(1e6) + 10;
long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()




//s.reserve(32768); //updated !
//s.max_load_factor(0.25);

ll fun(ll &x){
    ll low=1;
    ll high=100;
    ll ans=-1;
    while(low<=high){
        ll mid=(low+high)/2LL;if(mid*(mid+1)/2LL<=x){ans=mid;low=mid+1;}else{high=mid-1;}
    }
    return ans;
}



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

   map<ll,ll> mp;

   for(ll i=2;i*i<=n;i++){
    if(n%i==0){
        ll cnt=0;
        while(n%i==0){
            mp[i]++;
            n=n/i;
        }
    }
   }

   if(n>1){
    mp[n]++;
   }

   ll ans=0;


   for(auto it:mp){
    ans+=fun(it.second);
   }

   cout<<ans<<endl;

   
   
    
}


 
    



    



    
    
    




    


    

    






    
    

    
 
    
 

 
 
    
 
 


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
// #define mp make_pair
#define S second
#define F first
// ll mod=1e9+7 ;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono; 

int main(){                fastIO
  // input_from_file
  ll n,k;cin>>n>>k;vector<ll> vec(n,0),dp(n,1e12);
  for(int i=0;i<n;i++) cin>>vec[i];
  dp[0]=0;
  for(int i=1;i<n;i++){
    for(int j=i-1;j>=0 && j>=i-k;j--)
      dp[i]=min(dp[i],dp[j]+abs(vec[i]-vec[j]));
  }
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 4700
//177 a 不要迟到 
#include <bits/stdc++.h>
using namespace std;
int main(){
	int d,t,s;
	cin>>d>>t>>s;
	if (t*s>=d) {
		cout<<"Yes\n";
	} else {
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	static long fact[] = new long[300000];
	static long factInv[] = new long[300000];

	public static void main(String[] args) {
		final int MOD = 1_000_000_000 + 7;

		fact[0] = 1;
		factInv[0] = 1;
		for(int i = 0; i < fact.length - 1; i++){
			fact[i+1] = fact[i]*(i+1) % MOD; // n!(mod M)
	        factInv[i+1] = (int)(factInv[i]*repeatablePow(i+1, MOD-2, MOD) % MOD);
		}

		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		boolean broken[] = new boolean[n + 1];

		for(int i = 0; i < m; i++){
			broken[sc.nextInt()] = true;
		}

		//2連続で壊れていたらたどり着けない
		for(int i = 1; i < n; i++){
			if(broken[i] && broken[i - 1]){
				System.out.println(0);
				return;
			}
		}

		long result[] = new long[n + 1];
		result[0] = 1;

		if(!broken[1]){
			result[1] = 1;
		}
		for(int i = 2; i <= n; i++){
			if(broken[i]){
				result[i] = 0;
			}
			else {
				result[i] = (result[i - 1] + result[i - 2])%MOD;
			}
		}

		System.out.println(result[n]);
	}
	static long repeatablePow(int x, int n, int mod){
		if(n == 0){
			return 1;
		}
		long result = repeatablePow((int)((long)x*x%mod), n/2, mod);
		if(n % 2 == 1){
			result = result*x%mod;
		}
		return result;
	}


	//今回はnが大きすぎるがa,b<=2*10^5なのでこちらを使う
//	static long combination2(int n, int b, int mod){
//		if(b == 1){
//			return n;
//		}
//
//		long result = 1;
//
//		for(int i = 1; i <= b ; i++){
//			result *= (n - i + 1);
//			result %= mod;
//		}
//
//		result *= factInv[b];
//
//		return result % mod;
//	}
	static long combination(int a, int b, int mod){ //aCbをmod計算
	    if(a == 0 && b == 0)return 1;
	    if(a < b || a < 0)return 0;

	    long tmp = factInv[a - b]* factInv[b] % mod;
	    return tmp * fact[a] % mod;
	}
}


Measured memory_bytes: 53284
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(n-2):
  if p[i]<p[i+1] and p[i+1]<p[i+2] or p[i]>p[i+1] and p[i+1]>p[i+2]:
    ans=ans+1
print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  long long count1 = 0;
  long long sum = 0;
  for (int i = 0; i < n; i++){
    if (i % 2){
      if (sum + a.at(i) > 0){
        sum += a.at(i);
      }
      else{
        count1 += 1 - (sum + a.at(i));
        sum = 1;
      }
    }
    else{
      if (sum + a.at(i) < 0){
        sum += a.at(i);
      }
      else{
        count1 += 1 + (sum + a.at(i));
        sum = -1;
      }
    }
  }
  
  long long count2 = 0;
  sum = 0;
  for (int i = 0; i < n; i++){
    if (!(i % 2)){
      if (sum + a.at(i) > 0){
        sum += a.at(i);
      }
      else{
        count2 += 1 - (sum + a.at(i));
        sum = 1;
      }
    }
    else{
      if (sum + a.at(i) < 0){
        sum += a.at(i);
      }
      else{
        count2 += 1 + (sum + a.at(i));
        sum = -1;
      }
    }
  }
  
  cout << min(count1, count2) << endl;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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



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

    int ans=0;
   int m,d;
   cin>>m>>d;

   
   for(int i=1;i<=m;i++)
   {
     for(int j=2;j<=9;j++)
     {
       for(int k=2;k<=9;k++)
       {
         int x=j+k*10;
         if(x>d)break;
         if(j*k==i)ans++;    
       }
     }
   }
   cout<<ans<<"\n";

}



Measured memory_bytes: 256
#include<stdio.h>

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

  if(x==2){
    if(y==2){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }else if(x==4 ||x==6||x==9||x==11){
    if(y==4 ||y==6||y==9||y==11){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }else{
    if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    A,B,K=MI()
    
    for i in range(K):
        if i%2==0:
            A=A//2
            B+=A
        else:
            B=B//2
            A+=B
            
    print(A,B)

main()


Measured memory_bytes: 38384
from collections import defaultdict
 
n = int(input())
raw_numbers = list(map(int, input().split()))
q = int(input())
 
total = sum(raw_numbers)
 
numbers = defaultdict(int)
 
for item in raw_numbers:
    numbers[item] += 1

for i in range(q):
    b, c = map(int, input().split())
    taken = numbers[b]
    total -= numbers[b]*b
    numbers[c] += numbers[b]
    numbers[b] = 0
    total += taken*c
    print(total)

Measured memory_bytes: 89812
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

vector<string> a = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };

int main() {
  string s;
  cin >> s;
  int k;
  for (k = 0; k < 7; ++k) {
    if (s == a[k]) break;
  }
  k = 7 - k;
  cout << k << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    long long ans = 0;

    for (int i = 0; i < n; i++) {
        const long long pairsi = a[i] / 2;
        ans += pairsi;
        a[i] -= pairsi * 2;

        if (i == n - 1) continue;

        const long long pairsij = min(a[i], a[i + 1]);
        ans += pairsij;
        a[i] -= pairsij;
        a[i + 1] -= pairsij;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

string s;

int main() {
	cin >> s;
	rep(i, s.size()) {
		if (i % 2 == 0)cout << s[i];
	}
	cout << endl;
}

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

int main() {
    int n;
    cin >> n;
    int x[n], y[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    int ans = n;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int p = x[j] - x[i], q = y[j] - y[i];
            //cout << p << ' ' << q << endl;
            int left = i, right = j;
            int cost = 1;
            bool used[n];
            fill(used, used + n, false);
            used[i] = used[j] = true;
            for (int k = 2; k < n; k++) {
                int l;
                for (l = 0; l < n; l++) {
                    if (used[l])
                        continue;
                    if (x[l] - x[right] == p && y[l] - y[right] == q) {
                        right = l;
                        used[l] = true;
                        break;
                    }
                    if (x[l] - x[left] == -p && y[l] - y[left] == -q) {
                        left = l;
                        used[l] = true;
                        break;
                    }
                }
                if (l == n) {
                    cost++;
                    for (l = 0; l < n; l++) {
                        if (used[l])
                            continue;
                        left = right = l;
                        used[l] = true;
                        break;
                    }
                }
            }
            ans = min(cost, ans);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
long long dp[10][1005],i,j,k,s,n;
int main()
{
	dp[0][0]=1;
	for(i=0;i<101;i++)
		for(j=1000;j>=0;j--)
			for(k=9;k>0;k--)
				if(j-i>=0)
					dp[k][j]+=dp[k-1][j-i];
	for(;scanf("%d%d",&n,&s),n;)
		printf("%lld\n",dp[n][s]);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  if(N == 1) {
    cout << 1 << endl;
  } else {
    int temp = 2;
    while(temp <= N) temp <<= 1;
    cout << (temp >> 1) << endl;
  }
  return 0;
}


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

int n;
int x[11][2], y[11][2];
vector<int> id;

bool used[11];
int ans[11], cnt;

void dfs(int left, int bottom) {
  for(int i : id) {
    if(used[i]) continue;
    if(left < x[i][1] || bottom < y[i][1]) continue;    
    //cout<<i<<" "<<x[i][0]<<" "<<y[i][0]<<" "<<left<<" "<<bottom << endl;
    used[i] = true;
    ans[i] = ++cnt;
    int ll = left;
    for(int j = 0; j < n; j++) {
      if(i == j) continue;
      if(y[j][0] < y[i][1] && y[i][1] < y[j][1]) {
	ll = min(ll, x[j][0]);
      }
    }
    dfs(ll, y[i][1]);
  }
}

signed main(){
  for(int t = 0; cin >> n, n != 0; t++) {
    if(t) cout << endl;
    int left = 0, bottom = 0;
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < 2; j++) {
	cin >> x[i][j] >> y[i][j];
	left = max(left, x[i][j]);
	bottom = max(bottom, y[i][j]);
      }
    }
    id.clear();
    for(int i = 0; i < n; i++) id.push_back(i);
    sort(id.begin(), id.end(), [&](int i, int j) -> bool{
	return x[i][0] != x[j][0] ? x[i][0] < x[j][0] : y[i][0] < y[j][0];
      });
    //for(int i = 0; i < n; i++) cout << id[i]<<endl;
    memset(used, false, sizeof(used));
    memset(ans, -1, sizeof(ans));
    cnt = 0;
    dfs(left, bottom);
    for(int i = 0; i < n; i++) cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// 素因数分解 O(√n)
// たとえば 60 = 2^2 x 3 x 5 だったら {(2, 2), (3, 1), (5, 1)} を返す
// 素因数の個数はlogn
vector<pair<ll,ll>> prime_factorize(ll n){
    vector<pair<ll,ll>> res;
    for(ll p=2;p*p<=n;p++){
        if(n%p!=0) continue;
        int num=0; // 指数
        while(n%p==0){
            num++;
            n/=p;
        }
        res.push_back({p,num});
    }
    if(n!=1) res.push_back({n,1});
    return res;
}

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

    auto pf=prime_factorize(n);
    cout<<n<<": ";
    int l=pf.size();
    for(int i=0;i<l;i++){
        int cnt=pf[i].second;
        rep(j,cnt){
            if(i==l-1 && j==cnt-1){
                cout<<pf[i].first<<endl;
            }
            else{
                cout<<pf[i].first<<" ";
            }
        }
    }

    return 0;
}

 


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vector<double> V(N);
    REP(i,0,N) {
        ll v;
        cin >> v;
        V[i] = (double)v;
    }

    DESC(V);
    REP(i,0,N-1) {
        double x = V.back(); V.pop_back();
        double y = V.back(); V.pop_back();
        V.push_back((x+y)/2.0);
    }

    PR(V[0]);

    return 0;
}

/*



*/

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main() {
    FAST
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a+b>=k){
        if(k>=a) cout<<a<<endl;
        else cout<<k<<endl;
    }
    else cout<<a-(k-a-b);
}

Measured memory_bytes: 3664
# 整数の入力
N = int(input())
# 計算1
p = 1
temp = 10**9 + 7
 
for num in range(1,N+1):
    p = p * num
    if p > (10**9 + 7):
        p = p % temp
    
# 計算2
ans = p % temp
 
# 出力
print(ans)

Measured memory_bytes: 2940