akhauriyash/Code-Regression huggingface dataset:
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* 
   If you know what you’re worth, 
   then go out and get what you’re worth
   But you gotta be willing to take the hits, 
   and not pointing fingers saying you ain’t 
   where you wanna be because of him, or her, or anybody. 
   Cowards do that and that ain’t you. You’re better than that! 
*/

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define ld long double
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 2e5+5;

int h , n;
int dp[1001][10001];
int a[N];
int b[N];

int solve(int i ,int curr){

    if(curr <= 0) return 0;

    if(i == n){
        if(curr == 0)   return 0;
        return inf;
    }

    int &ans = dp[i][curr];
    if(ans != -1)   return ans;

    int one = solve(i+1,  curr);
    int two = b[i] + solve(i, curr - a[i]);
    int three = b[i] + solve(i+1 , curr - a[i]);    
    ans = min({one , two , three});
    return ans;
}   

int32_t main(){
    FAST;

    memset(dp , -1 , sizeof(dp));
    cin >> h >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    
    cout << solve(0,h) << endl;
    
    return 0;
}




Measured memory_bytes: 80512
s = int(input())
MOD = 10 ** 9 + 7

def comb_mod(n, k, p):
    if k < 0 or n < k:
        return 0
    k = min(k, n - k)
    return fact[n] * factinv[k] * factinv[n - k] % p

# 前処理
def make_fact(n, p):
    for k in range(2, n + 1):
        fact.append((fact[-1] * k) % p)
        inv.append((-inv[p % k]) * (p // k) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
    return

fact = [1, 1]
inv = [0, 1]
factinv = [1, 1]

MAXN = 2 * 10 ** 5 + 10 # 必要な数を設定

make_fact(MAXN, MOD) # O(N)

res = 0
MAX = s // 3
for k in range(1, MAX + 1):
    res += comb_mod(s - 2 * k - 1, k - 1, MOD)
    res %= MOD
print(res)

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

int main() {
 int n,a,b;
    cin>>n>>a>>b;
    
    string s;
    cin>>s;
    
    int counta=0;
    int countb=0;
    
    rep(i,n){
        if(s[i] == 'a' && counta+countb < a+b) {
         cout << "Yes" << endl;
            if(counta < a) {
             counta++;
            }else{
             countb++;
            }
        } else if(s[i] == 'a' && counta+countb >= a+b) {
         cout << "No"<<endl;
        }
        else if(s[i] == 'b' && counta+countb < a+b && countb <b){
         cout << "Yes"<<endl;
            countb++;
        } else if((s[i] == 'b' && counta+countb >= a+b) || (s[i] == 'b'  && countb >=b)) {
         cout << "No"<<endl;
        } else {
         cout << "No"<<endl;
        }
        
        
     }
    

}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
double pi=acos(-1);
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
double a,b,V;
bool judge(double mid)
{
	double x=sqrt(V*2*tan(mid)/a);
	double y=x/tan(mid);
	if(y<=a)
	{
		return x<=b;
	}
	x=V/a/a-a*tan(mid)/2;
	double sum=x+a*tan(mid);
	return sum<=b;
}
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	
	cin>>a>>b>>V;
	double l=0,r=pi/2,mid,ans;
	while(r-l>=1e-9)
	{
		mid=(l+r)/2;
		if(judge(mid)) ans=mid,l=mid;
		else r=mid;
	}
	printf("%.8lf\n",l/pi*180);
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx-sx,y = ty-sy;
    rep(_,x) cout << 'R';
    rep(_,y) cout << 'U';
    rep(_,x) cout << 'L';
    rep(_,y+1) cout << 'D';
    rep(_,x+1) cout << 'R';
    rep(_,y+1) cout << 'U';
    cout << "LU";
    rep(_,x+1) cout << 'L';
    rep(_,y+1) cout << 'D';
    cout << 'R' << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int arr[200000];
int put[200000];

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

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

	int cnt = 0;
	for (int i = n; i >= 1; i--) {
		int c = 0;
		for (int j = i-1; j < n; j += i) {
			c += put[j];
			c %= 2;
		}
		if (c != arr[i-1]) {
			put[i-1] = 1;
			cnt++;
		}
	}

	printf("%d\n", cnt);
	for (int i = 0; i < n; i++) {
		if (put[i]) printf("%d ", i+1);
	}
	printf("\n");
}


Measured memory_bytes: 2304
#include <cstdio>
#include <cstring>

using namespace std;

int n;
char s[109];

int go(int i, int k, int less) {
  if (n - i < k) {
    return 0;
  }
  if (k == 0) {
    return 1;
  }
  int res = 0;
  if (less == 1) {
    res = 1;
    for (int j = 0; j < k; ++j) {
      res *= n - i - j;
    }
    for (int j = 2; j <= k; ++j) {
      res /= j;
    }
    for (int j = 0; j < k; ++j) {
      res *= 9;
    }
  } else {
    int t = (int)(s[i] - '0');
    res += go(i + 1, k, t != 0);
    for (int j = 1; j < t; ++j) {
      res += go(i + 1, k - 1, 1);
    }
    if (t != 0) {
      res += go(i + 1, k - 1, 0);
    }
  }
  return res;
}

int main() {
  int k;
  scanf("%s%d", s, &k);
  n = (int)strlen(s);
  printf("%d\n", go(0, k, 0));
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;cin>>a>>b;
string s;
cin>>s;
int f=1;
for(int i=0;i<a+b+1;i++){
if(i==a){
if(s[i]!='-')f=0;
}else{
if(!isdigit(s[i]))f=0;
}
}
cout<<(f ? "Yes":"No")<<endl;
}


Measured memory_bytes: 256
// O(N log N) time
// O(N log N) memory
// yakusuu wo arakajime rekkyo suru

#include<cstdio>
#include<vector>

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

using namespace std;

const int N_MAX=300000;

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

	static vector<int> D[N_MAX]; // D[a] := ( a no yakusuu zentai )
	for(int a=1;a<=n;a++){
		for(int b=a;b<=n;b+=a){
			D[b].push_back(a);
		}
	}

	vector<int> ans(n),cnt(n+1);
	int now=w;
	for(int a=1;a<=w;a++){
		vector<int> &d=D[a];
		rep(j,d.size()) cnt[d[j]]++;
		cnt[a]+=2;
	}
	rep(i,n-w+1){
		ans[i]=now;

		if(i<n-w){
			// delete i+1
			{
				cnt[i+1]-=2;
				if(cnt[i+1]<2) now--;
				vector<int> &d=D[i+1];
				rep(j,d.size()){
					cnt[d[j]]--;
					if(cnt[d[j]]==1) now--;
				}
			}

			// add i+w+1
			{
				cnt[i+w+1]+=2;
				if(cnt[i+w+1]-2<2) now++;
				vector<int> &d=D[i+w+1];
				rep(j,d.size()){
					cnt[d[j]]++;
					if(cnt[d[j]]==2) now++;
				}
			}
		}
	}

	rep(i,n-w+1) printf("%d%c",ans[i],i<n-w?' ':'\n');

	return 0;
}

Measured memory_bytes: 16708
f = open(0)
N, M, L = map(int, f.readline().split())
A = [list(map(int, f.readline().split())) for i in range(N)]
B = [list(map(int, f.readline().split())) for i in range(M)]
C = [[0]*L for i in range(N)]
for i in range(N):
    for j in range(L):
        C[i][j] = str(sum(A[i][k]*B[k][j] for k in range(M)))
for line in C:
    print(*line)



Measured memory_bytes: 7276
N = int(input())
l = [0] * (N + 1)
s = 0
for i in range(1,N + 1):
    d = N // i
    n = 0
    for j in range(1,d + 1):
        n += i
        l[n] += 1
    s += l[i] * i
print(s)

Measured memory_bytes: 145800
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll gcd(ll a,ll b){
  ll r = a%b;
  while(r>0){
    a = b;
    b= r;
    r = a%b;
  }
  return b;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k;
  cin>>k;
  ll ans = 0;
  for(ll i=1;i<=k;i++){
    for(ll j=1;j<=k;j++){
      for(ll ii = 1;ii<=k;ii++){
	ans += gcd(i,gcd(j,ii));
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vpll flag, D; vll path;
//***********//
int main() {
	cin >> N >> M;
	vl X(N);
	vll A(M);
	for (i = 0; i < N; i++) {
		cin >> X[i];
		A[X[i] % M].push_back(X[i]);
	}
	vl Ae(M);
	for (i = 0; i < M; i++) {
		if (A[i].size() == 0) continue;
		sort(A[i].begin(), A[i].end());
		for (j = 0; j < A[i].size()-1; j++) {
			if (A[i][j] == A[i][j + 1]) {
				Ae[i]++;
				j++;
			}
		}
	}
	vl As(M);
	for (i = 0; i < M; i++) {
		As[i] = A[i].size();
	}
	for (i = 1; i <= M/2; i++) {
		if (M % 2 == 0 && i == M / 2) continue;
		ll pre = min(As[i], As[M - i]);
		ans += pre;
		As[i] -= pre; As[M - i] -= pre;
	}
	ans += As[0] / 2;
	if (M % 2 == 0) ans+=As[M / 2] / 2;
	for (i = 1; i < M; i++) {
		if (M % 2 == 0 && i == M / 2) continue;
		ans += min(As[i] / 2, Ae[i]);
	}
	cout << ans;
}

Measured memory_bytes: 10992
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
typedef pair<ll, ll> pll;
typedef vv<ll> vll;
typedef vv<pll> vpll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define LG(args...)                               \
	{                                             \
		string _s = #args;                        \
		replace(_s.begin(), _s.end(), ',', ' ');  \
		stringstream _ss(_s);                     \
		err(istream_iterator<string>(_ss), args); \
		cerr << endl;                             \
	}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;
// #define dbg

string s, t, ans;

void reconstruct(int i, int j, vv<vll>& dp) {
	if (i <= 0 || j <= 0)
		return;
	if (s[i] == t[j]) {
		ans.push_back(s[i]);
		reconstruct(i - 1, j - 1,dp);
	} else {
		if (dp[i - 1][j] > dp[i][j - 1])
			reconstruct(i - 1, j, dp);
		else
			reconstruct(i, j - 1, dp);
	}
}

int main() {
	fastio;
	cin >> s >> t;
	ll n, m;
	n = s.size(), m = t.size();
	s = '@' + s;
	t = '#' + t;
	/* s[i] == t[j]
		dp[i][j] = 1+dp[i-1][j-1];
		else
		dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
	*/

	// dp[i][j] is the length of maxsubsequence of strings
	// s(0...i) and t[0..j]

	vv<vll> dp(n + 1, vll(m + 1, 0));

	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= m; j++) {
			if (s[i] == t[j])
				dp[i][j] = 1 + dp[i - 1][j - 1];
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}

	// for(ll i=0; i<n; i++){
	// 	for(ll j=0; j<m; j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	// cout<<dp[0][0];
	// reconstruct(n,m,dp);
	ll i = n, j = m;
	while (i > 0 && j > 0) {
		if (s[i] == t[j]) {
			ans.push_back(s[i]);
			i--;
			j--;
		} else if (dp[i - 1][j] > dp[i][j - 1])
			i--;
		else
			j--;
	}
	
	// LG(ans)
	// if (ans.size() < dp[n - 1][m - 1]) {
	// 	if (i == 0) {
	// 		ans.push_back(s[0]);
	// 	} else if (j == 0)
	// 		ans.push_back(t[0]);
	// }
	reverse(all(ans));
	cout << ans << endl;
}

Measured memory_bytes: 73660
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int a[MAX_N];
vector<int> G[MAX_N];
int dp[MAX_N];

void dfs(int v)
{
	if(G[v].size()==0){
		dp[v] = 0;
	}else{
		vector<int> b;
		rep(i,G[v].size()){
			dfs(G[v][i]);
			b.push_back(dp[G[v][i]]);
		}
		sort(b.begin(),b.end(),greater<int>());
		rep(i,b.size()){
			b[i] += i+1;
		}
		sort(b.begin(),b.end(),greater<int>());
		dp[v] = b[0];
	}
}

int main()
{
	int n;
	cin >> n;
	rep(i,n-1){
		scanf("%d",&a[i+1]);
		a[i+1]--;
		G[a[i+1]].push_back(i+1);
	}
	dfs(0);
	cout << dp[0] << "\n";
}


Measured memory_bytes: 14336
S = str(input())
M = 753
min = 10000
for i in range(len(S)-2):
    a = 100*int(S[i]) + 10*int(S[i+1]) + int(S[i+2])
    b = abs(a - M)
    if b < min:
        min  = b

print(min)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int power[40];
int psum[41];
vector<int> g[40];
int n;
int ans;

void solve(int now, ll S, int sum) {
  if (sum + psum[now] < ans) return;
  if (now == n) {
    ans = max(ans, sum);
    // cout << bitset<14>(S) << " " << sum << endl;
    return;
  }
  bool ng = 0;
  FOR(it, g[now]) {
    if (S>>*it&1) {
      ng = 1;
      break;
    }
  }
  solve(now+1, S, sum);
  if (!ng) {
    solve(now+1, S|1LL<<now, sum + power[now]);
  }
}

int main() {
  while(cin>>n,n) {
    map<string,int> mp;
    REP(i,n) g[i].clear();
    vector<string> v[n];
    REP(i,n) {
      string s; cin >> s; mp[s] = i;
      cin >> power[i];
      int k;
      cin >> k;
      v[i].resize(k);
      REP(j,k) cin >> v[i][j];
    }
    REP(i,n) {
      FOR(it, v[i]) 
        g[i].push_back(mp[*it]);
    }

    // FOR(it, mp) cout << it->first << " " << it->second << endl;
    psum[n] = 0;
    for (int i=n-1; i>=0; --i) {
      psum[i] = psum[i+1] + power[i];
    }
    
    ans = 0;
    solve(1,1,power[0]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1368
while 1:
 n=int(input())
 if n==0:break
 d={}
 for _ in[0]*n:
  k,v=input().strip().split()
  d[k]=v
 a=''
 for _ in[0]*int(input()):
  e=input().strip()
  a+=d[e]if e in d else e
 print(a)


Measured memory_bytes: 6484
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;

int main(){
    int p,q,r;
    cin >> p >> q >> r;
    int ans = min(p+q,min(q+r,r+p));
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;

int main(){
    vector <int> intV;

    int N;
    cin >> N;

    intV.reserve(N+1);
    for(int i=0;i<N;i++){
        int temp =0;
        cin>>temp;
        intV.push_back(temp);
    }
    std::sort(intV.begin(), intV.end());

    double retval = double (intV[0]+intV[1])/2.0;
    for(int i=0;i<N-2;i++){
        retval =(retval + double(intV[i+2]))/2.0;
    }

    cout<< std::setprecision(10)<<retval<<endl;

}



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

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

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

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

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

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

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

  int N, L;
  cin >> N >> L;

  vector<string> vec(N);

  rep(i, N) cin >> vec[i];

  sort(vec.begin(), vec.end());

  rep(i, N){
    cout << vec[i];
  }  
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
line = readline
a = line.chomp.split(" ")[0].to_i
b = line.chomp.split(" ")[1].to_i

counter = 0
sum = 0

while counter < b
  if a == b
    sum = 1 
    break
  end

  if counter + 1 == b
    break
  end
  counter += a - 1
  sum += 1

end

p sum

Measured memory_bytes: 1788
#include<stdio.h>
#define heap_max 500000
int inHeap;
long heap[heap_max];

void maxHeapify(long A[],int i){
    int l,r,largest;
    long temp;
    l = i*2;
    r = i*2+1;
    if(inHeap>=l && A[l]>A[i]) largest = l;
    else largest = i;
    if(inHeap >= r && A[r] > A[largest]) largest = r;
    if(largest != i){
            temp = A[i];
            A[i] = A[largest];
            A[largest] = temp;
            maxHeapify(A,largest);
        }
    }
     
void buildMaxHeap(long A[]){
    int i;
    for(i=inHeap/2;i>=1;i--){
        maxHeapify(A,i);
        }
    }

	
int main(void){
    int i;
    
    scanf("%d",&inHeap);
    for(i=1;i<inHeap+1;i++) scanf("%ld",&heap[i]);
    buildMaxHeap(heap);
    for(i=1;i<inHeap+1;i++) printf(" %ld",heap[i]);
    printf("\n");
    return 0;
    }

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


// Useful container manipulation / traversal macros
#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(a,b)       ( (b).find(a) != (b).end())
#define tr(c,i)       for(auto i = (c).begin(); i != (c).end(); i++)
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define pb             push_back
#define fill(a,v)      memset(a, v, sizeof a)

typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }

    string s;
    cin>>s;

    int c1 = 0, c0 = 0;
    fori(i, 0, s.size()-1){
        if(s[i] == '0')
            c0++;

        else 
            c1++;
    }

    cout<<min(c0, c1) * 2;


}

Measured memory_bytes: 512
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------
long long modpow(long long a, long long n) {//a^n(MOD)を求める
    long long res = 1;
    while (n > 0) {
         if (n & 1) res = res * a % MOD;
         a= a * a % MOD;//次の準備
         n >>= 1;
      }
 return res;
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    vector<ll>c(n);
    for(ll i=0;i<n;i++)cin>>c[i];
    ll ans=0;
    sort(all(c));reverse(all(c));
    ll now=modpow(2,n-1)%MOD;
    ll change=modpow(2,n-2)%MOD;
    if(n==1)
        change=0;
    for(ll i=0;i<n;i++){
        ans+=now*c[i]%MOD;
        ans%=MOD;
        now+=change;
        now%=MOD;
    }
    for(ll i=0;i<n;i++){
        ans*=2;
        ans%=MOD;
    }
    cout<<ans%MOD<<Endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







Measured memory_bytes: 1920
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc126/tasks/abc126_a
 */
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();
		sc.close();

		char[] ans = S.toCharArray();
		ans[K - 1] = Character.toLowerCase(ans[K - 1]);

		System.out.println(String.valueOf(ans));
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
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;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    ll n, res = 0;
    rep(i, 10) {
        cin >> n;
        res += n;
    }
    cout << res << endl;
}


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

namespace ConsoleApp38
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] time = Console.ReadLine().Split(' ');
            int a = int.Parse(time[0]);
            int b = int.Parse(time[1]);
            int c = a + b;
            if (c<24)
            {
                Console.WriteLine(c);
            }
            else if(c >= 24){
                int d = c % 24;
                Console.WriteLine(d);
            }

        }
    }
}


Measured memory_bytes: 11092
mod = 1000000007


def frac_with_mod(a,m):
    outlist = [ 1 for i in range(a+1) ]
    for i in range(1,a+1):
        outlist[i] = (outlist[i-1] * i)% m
    return outlist

frac_list = frac_with_mod(4*10**5+10,10**9+7)

def comb_with_mod(a,b,c,m):
    return ( frac_list[a] * pow(frac_list[b],m-2,m) * pow(frac_list[c],m-2,m) ) % m

n, k = [ int(v) for v in input().split() ]


a = pow(frac_list[n - 1],mod-2,mod)

for i in range(2*n -1, n, -1):
    a *= i
    a %= mod

if (k >= n - 1):
    pass
else:
    for i in range(n-1, k,-1):
        j = n - i
        room = comb_with_mod(n, i, n - i, mod)
        person = comb_with_mod(n - 1, n - j, j - 1, mod)
        a -= ((room * person) % mod)
        a %= mod

print(a)


Measured memory_bytes: 67440
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  rep(i, n){
    int a;
    cin >> a;
    if(a % 2 == 0){
      if (a % 5 != 0 && a%3 != 0){
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

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

int main() {
  ll n, a, b; cin >> n >> a >> b;
  if(a == b && a == 0) cout << 0 << endl;
  else{
    ll x = n/(a+b);
    cout << a*x + min(a,n-(x*(a+b))) << endl;
  }
}


Measured memory_bytes: 3648
n=int(input())
a=list(map(int,input().split()))
l=[i-1 for i in range(n+1)]+[n]
r=[i+1 for i in range(n+1)]+[n+2]
ans=0
p=[0]*n
for i in range(n):p[a[i]-1]=i
for i in range(n-1,-1,-1):
  j=p[i]
  ans+=(i+1)*(j-l[j])*(r[j]-j)
  l[r[j]],r[l[j]]=l[j],r[j]
print(ans)

Measured memory_bytes: 35652
import math

n = int(input())

if n % 2 == 1 or n < 10:
	print(0)
	exit()

tmp = 1
idx = 0
while True:
	tmp *= 5
	if tmp >= n:
		break
	idx += 1

ans = 0
for i in range(idx):
	ans += (n // (5 ** (i + 1))) // 2

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
  public static void main(String[] args) {

    var m = 1000000000 + 7;

    var sc = new Scanner(System.in);

    var n = sc.nextInt();
    var a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt() % m;
    }

    long sum1 = 0;
    long sum2 = 0;
    for (int i = 0; i < n; i++) {
      sum1 += a[i];
      sum2 += (long)a[i] * a[i] % m;
    }
    sum1 = sum1 % m;
    sum2 = sum2 % m;

    long t = (sum1 * sum1 - sum2) % m;
    long answer;
    if (t % 2 == 0) {
      answer = t / 2;
    } else {
      answer = (t + m) / 2;
    }

    System.out.println(answer);
  }
}

Measured memory_bytes: 61252
#include <stdio.h>
int gcd(int p,int q){
    if(p%q==0) return q;
    return gcd(q,p%q);
}
int main(void){
    int n,i,j,k,tmp,sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            tmp=gcd(i,j);
            for(k=1;k<=n;k++){
                sum+=gcd(tmp,k);
            }
        }
    }
    printf("%d",sum);
    return 0;
}

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

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

    sort(a.begin(), a.end(), greater<ll>());

    list<ll> arrived;
    ll confort = 0;
    list<ll>::iterator it1, it2;
    for(ll i = 0; i < n; i++)
    {
        if(i == 0)
        {
            arrived.push_back(a[i]);
        }
        else if(i == 1)
        {
            arrived.push_back(a[i]);
            confort += *arrived.begin();

            it1 = arrived.begin();
            it2 = next(it1, 1);
        }
        else
        {
            confort += min(*it1, *it2);
            arrived.insert(it2, a[i]);

            it1 = it2;
            it2++;
            if(it2 == arrived.end())
            {
                it2 = arrived.begin();
            }
        }
    }

    cout << confort << endl;

    return 0;
}


Measured memory_bytes: 11168
import numpy as np
N = int(input())
HPs = np.array([int(i) for i in input().split()])
np.sort(HPs)
while len(HPs) > 1:
    HPs[1:] %= HPs[0]
    HPs[HPs==0] = HPs[0]
    HPs=np.unique(HPs)
print(HPs[0])

Measured memory_bytes: 23100
n = int(input())
a = list(map(int, input().split()))
ans = 0
flg = True

while flg:
    for i in range(n):
        if a[i] % 2 != 0:
            flg = False
            break
        else:
            a[i] >>= 1
        
    if flg:
        ans += 1
        
print(ans)
        
    


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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int  main(){
  int n, k;
  cin >> n >> k;
  vector<int> x(n);

  for(int i=0; i<n; ++i) cin >> x[i];

  int cnt = 0;

  for(int i=0; i<n; ++i){
    int a_dis = x[i] * 2;
    int b_dis = (k - x[i]) * 2;
    int mn = min(a_dis, b_dis);
    cnt += mn;
  }

  cout << cnt;

  return 0;
}

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

using namespace std;

int arr[51];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &arr[i]);

	for (int i = 1; i <= n; ++i)
		for (int j = i; j <= n; ++j) {
			swap(arr[i], arr[j]);

			bool chk = true;
			for (int k = 1; k <= n; ++k)
				if (arr[k] != k)
					chk = false;

			if (chk) {
				printf("YES");

				return 0;
			}

			swap(arr[i], arr[j]);
		}
	printf("NO");

	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  string s;cin>>s;
  string ans="";
  rep(i,0,s.size()){
    if(s[i]==','){
      cout<<ans<<" ";
      ans="";
      continue;
    }
    ans+=s[i];
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int a,b,x;
	cin>>a>>b>>x;
	if(a<=x&&x<=a+b)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

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

struct qer
{
    int x, y;
};

queue<qer> q;

int n, m;
int ans = 0;
char M[1050][1050];
int xx[5] = {0, 0, 0, 1, -1};
int yy[5] = {0, 1, -1, 0, 0};
bool used[1050][1050];
int d[1050][1050];

void bfs()
{
    memset(d, 0x3f, sizeof(d));
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (M[i][j] == '#')
                q.push((qer){i, j}), used[i][j] = 1, d[i][j] = 0;
        }
    }
    while (!q.empty())
    {
        qer u = q.front();
        q.pop();
        for (int i = 1; i <= 4; i++)
        {
            int lx = u.x + xx[i];
            int ly = u.y + yy[i];
            if (lx < 1 || lx > n || ly < 1 || ly > m || used[lx][ly])
                continue;
            q.push((qer){lx, ly});
            used[lx][ly] = 1;
            d[lx][ly] = min(d[lx][ly], d[u.x][u.y] + 1);
            ans = max(ans, d[lx][ly]);
        }
    }
}

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        scanf("%s", M[i] + 1);
    }
    bfs();
    cout << ans;
    return 0;
}

Measured memory_bytes: 14864
#include<stdio.h>
int main(){
  int A[101][101],n,u,k,i,x,j;
  
  for(i=0;i<101;i++){
    for(j=0;j<101;j++){
      A[i][j]=0;
    }
  }
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=1;j<=k;j++){
      scanf("%d",&x);
      A[i][x]=A[i][x]+1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j<=n-1)printf("%d ",A[i][j]);
      else printf("%d",A[i][j]);
    }
    printf("\n");
  } 
}



Measured memory_bytes: 2056
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()

using namespace std;

int main(){
  string a, b, c; cin >> a >> b >> c;
  char d, e, f;
  d=toupper(a[0]);
  e=toupper(b[0]);
  f=toupper(c[0]);
  cout << d << e << f << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
in n,m;
in bst=1e9;
VVI pm;
VI nxt;
VI act;
VI pct;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>n>>m;
  pm.resize(n,VI(m));
  nxt.resize(n,0);
  forn(i,n){
    forn(j,m){
      cin>>pm[i][j];
      --pm[i][j];
    }
  }
  act.resize(m,1);
  pct.resize(m,0);
  forn(i,n)
    ++pct[pm[i][0]];
  in mx=-1;
  in argmx=-1;
  forn(i,m){
    if(pct[i]>mx){
      mx=pct[i];
      argmx=i;
    }
  }
  bst=min(bst,mx);
  forn(z,m-1){
    act[argmx]=0;
    forn(i,n){
      while(!act[pm[i][nxt[i]]])
	++nxt[i];
    }
    forn(i,m)
      pct[i]=0;
    forn(i,n)
      ++pct[pm[i][nxt[i]]];
    mx=-1;
    argmx=-1;
    forn(i,m){
      if(pct[i]>mx){
	mx=pct[i];
	argmx=i;
      }
    }
    bst=min(bst,mx);
  }
  cout<<bst<<endl;
  return 0;
}


Measured memory_bytes: 1024
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define int ll
ll dp[212345],gg[212345];
vi vec;
main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
  	int n;
  	cin>>n;
  	int i,val;
  	int previ=-1;
  	rep(i,n){
  		cin>>val;
  		if(previ!=val)
  			vec.pb(val);
  		previ=val;
  	}
  	n=vec.size();
  	gg[vec[n-1]]=1;
  	fd(i,n-1,1){
  		dp[i]=gg[vec[i]];
  		dp[i]%=mod;
  		gg[vec[i-1]]+=dp[i];
  		gg[vec[i-1]]%=mod;
  	}
  	cout<<gg[vec[0]]<<endl;
    return 0;   
}


Measured memory_bytes: 5104
def main():
    n = int(input())
    a = input().split()
    if n%2: ans = a[n-1::-2] + a[1:n-1:2]
    else: ans = a[n-1:0:-2] + a[0:n-1:2]
    print(" ".join(ans))
if __name__=="__main__": main()

Measured memory_bytes: 26272
#include <iostream> 


int main(){
	int N, D, ans;
	std::cin >> N >> D;
	if(N%(2*D+1)!=0){
		ans = N/(2*D+1)+1;		
	}
	else{
		ans = N/(2*D+1);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    string s;
    cin>>n>>s;
    REPF(i,1,n) {
        if(s[i-1]==s[i] && s[i]=='x') {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 3300
s = input()
l = len(s)
import collections
s = collections.deque(s)
ans = collections.deque()
chk = 0
for i in range(l):
  c = s.popleft()
  if c == 'A' or c == 'T' or c == 'C' or c == 'G':
    chk += 1
  else:
    ans.append(chk)
    chk = 0
ans.append(chk)
print(max(ans))

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

int64_t intpow(int64_t n, int64_t k, int64_t INF=int64_t(1e18)){
    if(n == 0) return 0;
    int64_t ret = 1;
    while(k--){
        if(ret > INF/n) return INF;
        ret *= n;
    }
    return ret;
}

int main(){
    int X;
    cin >> X;
    for(int a=1; ; a++){
        int64_t b5 = intpow(a, 5) - X;
        int b = round(pow(abs(b5), 0.2));
        if(intpow(b, 5) == abs(b5)){
            cout << a << " " << (b5 > 0 ? b : -b) << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 4064
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);cerr<<fixed<<setprecision(5);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
/* VARIABLE DECLARATION START */
//int globe[int(1e6)];
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   int w,h,n;cin>>w>>h>>n;
   int xleft=0,xright=w,ydown=0,yup=h;
   for(int i=0,x,y,a;i<n;++i)
   {
     cin>>x>>y>>a;
     if(a==1)
     {
        xleft=max(xleft,x);
     }
     else if(a==2)
     {
       xright=min(xright,x);
     }
     else if(a==3)
     {
        ydown=max(ydown,y);
     }
     else if(a==4)
     {
       yup=min(yup,y);
     }
   }
   if(xright<xleft||yup<ydown)
    cout<<0<<endl;
   else
   cout<<(xright-xleft)*(yup-ydown)<<endl;
   
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
int main()
{
	pair<string,int> p1;
	pair<string,int> p2;
	string U;

	cin >>p1.first >>p2.first >>p1.second >>p2.second >>U;

	if(U==p1.first){
		cout <<p1.second-1 <<" " <<p2.second <<endl ;
	}
	else{
		cout <<p1.second <<" " <<p2.second-1 <<endl;
	}

}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [b, c] <- map strToInt . words <$> getLine
    -- 出力
    putStrLn $ if ((b `mod` 3) == 0 || (c `mod` 3) == 0 || ((b+c) `mod` 3) == 0) then "Possible" else "Impossible"


Measured memory_bytes: 508