akhauriyash/Code-Regression huggingface dataset:
/*
                ____________    ______________       __
               / _________  /\ /_____   _____/\     / /\
              / /\       / /  \\    /  /\    \ \   / /  \
             / /  \_____/ /   / \__/  /  \____\/  / /   /
            / /   /    / /   /    /  /   /       / /   /
           / /   /    / /   /    /  /   /       / /   /
          / /   /    / /   /    /  /   /       / /   /
         / /___/____/ /   /    /  /   /       / /___/________
        /____________/   /    /__/   /       /______________/\
        \            \  /     \  \  /        \              \ \
         \____________\/       \__\/          \______________\/
           ___       ___               ___    __________
          /  /\     /  /\             /  /\  /_______  /\
         /  /__\___/  /  \           /  /  \ \      /  /  \
        /____    ____/   /          /  /   /  \____/  /   /
        \   /   /\   \  /          /  /   /       /  /   /
         \_/   /  \___\/ ___      /  /   /       /  /   /
          /   /   /     /  /\    /  /   /       /  /   /
         /   /   /     /  /__\__/  /   /       /  /___/____
        /___/   /     /___________/   /       /___________/\
        \   \  /      \           \  /        \           \ \
         \___\/        \___________\/          \___________\/
       
          A FAN OF FIZZYDAVID
           
*/

#include<bits/stdc++.h>

#define HEAP priority_queue
#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,n) for(int i=(n)-1;i>=0;i--)
#define forn(i,l,r) for(int i=(l);i<=(r);i++)
#define nrof(i,r,l) for(int i=(r);i>=(l);i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-20
#define pi 3.1415926535897932384626433832795
#define orz int
#define yjz main
#define fizzydavid return
#define ak 0
#define la ;
#define debug puts("OK");
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(),x.end()

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int iinf=1e9+7;
const LL linf=1ll<<60;
const flt dinf=1e10;

template <typename T>
inline void scf(T &x)
{
	bool f=0; x=0; char c=getchar();
	while((c<'0' || c>'9') && c!='-') c=getchar();
	if(c=='-') { f=1; c=getchar(); }
	while(c>='0' && c<='9') { x=x*10+c-'0'; c=getchar(); }
	if(f) x=-x; return;
}

template <typename T1,typename T2>
void scf(T1 &x,T2 &y) { scf(x); return scf(y); }

template <typename T1,typename T2,typename T3>
void scf(T1 &x,T2 &y,T3 &z) { scf(x); scf(y); return scf(z); }

//---------------------------head----------------------------

const int N=2e5+100;

int n,x;
int a[N];
bool used[N];

orz yjz()
{
	scf(n,x);
	if(x==1 || x==2*n-1){ puts("No"); fizzydavid ak la }
	a[n]=x;
	a[n-1]=x-1; a[n+1]=x+1;
	used[x-1]=used[x]=used[x+1]=1;
	int j=1;
	forn(i,1,2*n-1)
	{
		if(a[i]) continue;
		while(used[j]) j++;
		a[i]=j; used[j]=1;
	}
	puts("Yes");
	forn(i,1,2*n-1) printf("%d\n",a[i]);
	fizzydavid ak la
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define SQ(a) (a)*(a)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long
#define m 1000000007



int32_t main()
{
IOS
//#ifndef ONLINE_JUDGE
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
//#endif


string s;
cin>>s;
int ans=0;

for(int i=0;i<s.length();i++)
{
	if(s[i]=='+')
	{
		ans++;
	}
	else if(s[i]=='-')
	{
		ans--;
	}
}




cout<<ans;



//#ifndef ONLINE_JUDGE
	//cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n\n";
//#endif

return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int a,b,c,d;
	cin>>s;
	a=s[0]-48; b=s[1]-48; c=s[2]-48; d=s[3]-48;
	if(a+b+c+d==7) cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<'='<<7;
	else if(a+b+c-d==7) cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<'='<<7;
	else if(a+b-c+d==7) cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<'='<<7;
	else if(a+b-c-d==7) cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<'='<<7;
	else if(a-b+c+d==7) cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<'='<<7;
	else if(a-b+c-d==7) cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<'='<<7;
	else if(a-b-c+d==7) cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<'='<<7;
	else if(a-b-c-d==7) cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<'='<<7;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define NUM 100

int main(){

  int x,y,a,b,r,d;
  
  //入力
  scanf("%d%d",&x,&y);

  if(x<1 && x>1000000000) exit(1);
  if(y<1 && x>1000000000) exit(1);
  
  //処理

  a=x;
  b=y;
  if(x<y){
    a=y;
    b=x;
  }

  r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  d=b;

  //出力

  printf("%d\n",d);

  return 0;
  
}



Measured memory_bytes: 2068
import sys

N = int(sys.stdin.readline())
As = [int(x) for x in sys.stdin.readline().split(" ")]
Bs = [int(x) for x in sys.stdin.readline().split(" ")]

result = 0
for i in range(0, N):
    i = (N - 1) - i
    B = Bs[i]

    right = As[i + 1]
    right_result = min(B, right)
    result += right_result
    As[i + 1] -= right_result
    B -= right_result

    left = As[i]
    left_result = min(B, left)
    result += left_result
    As[i] -= left_result
    B -= left_result

print(result)


Measured memory_bytes: 24484
#include <stdio.h>

using namespace std;

int main(){
	char str[20001];
	int m,tmp,length;
	while(true){
		scanf("%s",str);
		if(str[0] == '-') break;
		length = 0;
		for(int k = 0; str[k] != '\0';k++) length++;
		scanf("%d",&m);
		int index = 0;
		for(int i = 0; i < m; i++){
			scanf("%d",&tmp);
			for(int j = 0; j < tmp; j++){
				str[index+length] = str[index];
				index++;
			}
		}
		for(int p = 0; p < length; p++){
			printf("%c",str[index+p]);
		}
		printf("\n");
	}
}



Measured memory_bytes: 2704
program shift
  implicit none
  integer(8), parameter :: modu = 998244353
  character(301) :: s
  integer :: k, n, a(302) = 0, m = 1, x = 0, h = 0, r, d, w, c, b, i, j
  integer(8) :: dp(0:300, 0:301) = 0
  read(*,*) s, k
  n = len_trim(s)
  s(n + 1:n + 1) = '0'
  do i = 1, n + 1
    if (s(i:i) == '0') then
      m = m + 1
      a(m) = x
    else
      x = x + 1
    end if
  end do
  k = min(k, x)
  dp(0, 0) = 1
  do i = 1, m - 1
    do j = h, 0, -1
      r = min(k - j, a(i + 1) - a(i))
      do d = 1, r
        w = j + d
        b = a(m) - a(i + 1) + d
        do c = 0, a(m) - a(i + 1)
          b = c + d
          dp(w, c) = dp(w, c) + dp(j, b)
          if (dp(w, c) > modu) dp(w, c) = dp(w, c) - modu
        end do
      end do
      do c = 1, a(m) - a(i + 1)
        dp(j, c) = dp(j, c) + dp(j, c - 1)
        if (dp(j, c) > modu) dp(j, c) = dp(j, c) - modu
      end do
    end do
    h = min(k, h + a(i + 1) - a(i))
  end do
  write(*,'(i0)') mod(sum(dp(0:h, 0)), modu)
end program shift

Measured memory_bytes: 3384
D, N = map(int,input().split())
if D == 2:
  if N < 100:
    print(N*10000)
  else:
    print(1010000)
elif D == 1:
  if N < 100:
    print(N*100)
  else:
    print(10100)
else:
  if N < 100:
    print(N)
  else:
    print(101)


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
string S;

signed main(){
    cin>>S;
    N=S.size();

    int base=-N;
    base+=count(all(S),'g');
    cout<<base+N/2<<endl;
    return 0;
}


Measured memory_bytes: 512
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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() {
	string S;
	cin >> S;
	int N = (int)S.size();

	vector<int> A(N, 0);
	for (int i = 1; i < N; i++) {
		if (S.at(i - 1) == 'R' && S.at(i) == 'L') {
			A.at(i - 1) = 1;
			A.at(i) = 1;
		}
	}

	int basyo = -1;
	int rcnt = 0;
	int lcnt = 0;
	for (int i = 0; i < N; i++) {
		if (A.at(i) > 0 && S.at(i) == 'R') {
			if (basyo != -1) {
				A.at(basyo) += lcnt / 2 + lcnt % 2;
				A.at(basyo + 1) += lcnt / 2;
				lcnt = 0;
			}
			A.at(i) += rcnt / 2;
			A.at(i + 1) += rcnt / 2 + rcnt % 2;
			rcnt = 0;
			basyo = i;
		}
		else if (A.at(i) == 0) {
			if (S.at(i) == 'R') rcnt++;
			else lcnt++;
		}
	}
	A.at(basyo) += lcnt / 2 + lcnt % 2;
	A.at(basyo + 1) += lcnt / 2;

	for (int i = 0; i < N; i++) cout << A.at(i) << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int h, w;
string s[20];

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

int calc(int sy, int sx) {
	typedef pair<int, int> P;
	queue<P> que;
	int dist[20][20];
	int i, j;
	
	rep(i, h) rep(j, w) dist[i][j] = -1;
	dist[sy][sx] = 0;
	
	que.push(P(sy, sx));
	while (!que.empty()) {
		P now = que.front();
		que.pop();
		int y = now.first;
		int x = now.second;
		rep(i, 4) {
			int ny = y + dy[i];
			int nx = x + dx[i];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
			if (s[ny][nx] == '#') continue;
			if (dist[ny][nx] == -1) {
				que.push(P(ny, nx));
				dist[ny][nx] = dist[y][x] + 1;
			}
		}
	}
	
	int ret = 0;
	rep(i, h) {
		rep(j, w) {
			ret = max(ret, dist[i][j]);
		}
	}
	return ret;
}

signed main() {
	int i, j;
	
	cin >> h >> w;
	rep(i, h) { cin >> s[i]; }
	
	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == '#') continue;
			int res = calc(i, j);
			ans = max(ans, res);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

const int N = 3010;
const int MOD = 1e9 + 7;

int n, m;
int f[N][N][2];
//取了 i 次，当前序列中有 j 个白球，是否经历过没有白球的状态

signed main()
{
	scanf("%lld %lld", &n, &m);

	for(register int k = 1; k <= n; k++)
		f[0][k][0] = 1;
	f[0][0][1] = 1;

	for(register int k = 0; k < m; k++)
		for(register int i = 0; i <= n; i++)
		{
			f[k][i][0] %= MOD, f[k][i][1] %= MOD;

			if(i - 1 >= 0)
			{
				if(i == 1) f[k + 1][i - 1][1] += f[k][i][0];
				else f[k + 1][i - 1][0] += f[k][i][0];
				f[k + 1][i - 1][1] += f[k][i][1];

				if(i == 1) f[k + 1][i][1] += f[k][i][0];
				else f[k + 1][i][0] += f[k][i][0];
				f[k + 1][i][1] += f[k][i][1];
			}
			if(i + 1 <= n)
			{
				f[k + 1][i + 1][0] += f[k][i][0];
				f[k + 1][i + 1][1] += f[k][i][1];

				f[k + 1][i][0] += f[k][i][0];
				f[k + 1][i][1] += f[k][i][1];
			}
		}

	int answ = 0;
	for(register int k = 0; k <= n; k++)
		answ += f[m][k][1], answ %= MOD;

	printf("%lld", answ);

	return 0;
}

Measured memory_bytes: 141568
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

#define repo(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main(){
    int N;
    cin >> N;
    ll ans = 1000000000;
//     int x = 0;
    vector<int> X(N);
    repo(i,N){
        cin >> X[i];
    }
    for(int p = 1; p <= *max_element(X.begin(),X.end()); p++){
        ll kari = 0;
        for(int i = 0; i < N; i++){
//              if(kari > ans) continue;

             kari += pow(X[i]-p,2);
        }      
        ans = min(kari, ans);
    }

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



Measured memory_bytes: 256
n,x = map(int ,input().split())
l = list(map(int ,input().split()))
old_d = 0
count = 1
for i in range(1 ,n+1):
    new_d =old_d +l[i-1]
    old_d = new_d
    if new_d <= x:
        count +=1
print(count)

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

int main() {
    uint N; cin >> N;
    vector<int> A(N, 0);
    for (auto &a: A) cin >> a;

    int cnt = 0;
    bool exist = false;
    while (!exist) {
        for (size_t i=0; i<A.size(); ++i) {
            if (A[i] % 2 != 0) {
                exist = true;
                break;
            }
            A[i] /= 2;
        }
        if (!exist) ++cnt;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3632
N,M = map(int, input().split())
minMax = N
maxMin = 0
for i in range(M):
    L,R = map(int, input().split())
    if L > maxMin:
        maxMin = L
    if R < minMax:
        minMax = R

print(0) if minMax - maxMin + 1 <= 0 else print(minMax - maxMin + 1) 




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

typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<pair<ll, ll> > v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
  }
  ll t = v[0].first, a = v[0].second;
  for (int i = 1; i < n; i++) {
    ll n = (t + v[i].first - 1)/v[i].first;
    ll m = (a + v[i].second - 1)/v[i].second;
    ll tmp = max(n, m);
    t = tmp*v[i].first;
    a = tmp*v[i].second;
  }
  ll ans = t + a;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef unsigned __int128 Hash;

vector<Hash> p;
const Hash w = 8999;

void init() {
    p.resize(2000050);
    p[0] = 1;
    for (int i = 1; i < p.size(); i++) {
        p[i] = p[i - 1] * w;
    }
}

template<class T>
class RollingHash {
public:
    T src;
    vector<Hash> harr;

    vector<int> suffixArray;

    RollingHash(T src) : src(src) {
        Hash sum = 0;
        for (int i = 0; i < src.size(); i++) {
            sum = sum * w + src[i];
            harr.push_back(sum);
        }
    }

    // [l,r)
    Hash sub(int l, int r) const {
        assert(l <= r);
        if (l == r) return 0;
        return harr[r - 1] - (l ? harr[l - 1] * p[r - l] : 0);
    }
};

struct String {
    Hash h;
    int l;

    String concat(const String &s) {
        return {
                h * p[s.l] + s.h,
                s.l + l
        };
    }
};

//tabata
int main() {
    init();
    int n;
    cin >> n;
    string s;
    cin >> s;
    if( count(s.begin(), s.end(), s[0]) == s.size() ){
        cout << 2 << endl;
        return 0;
    }
    RollingHash<string> rh(s);
    reverse(s.begin(), s.end());
    RollingHash<string> rv(s);
    auto calc_rev = [&](int a, int b) {
        int L = s.size() - b;
        int R = s.size() - a;
        return rv.sub(L, R);
    };


    auto f = [&](int l) {
        String le = {rh.sub(1, l), l - 1};
        String ri = {calc_rev(0, l-1), l-1};
        String repeat = le.concat(ri);
        String cur = {rh.sub(0, 1), 1};
        int i = 1;
        for (; i + repeat.l <= s.size(); i += repeat.l) {
            cur = cur.concat(repeat);
        }
        // tabata tab
        // t (abat) (abat)(abat)(abat)(abat)(abat)(abat)

        int rem = s.size() - i;

        if (rem <= l - 1) {
            cur = cur.concat({rh.sub(1, 1 + rem), rem});
        } else {
            rem -= l - 1;
            cur = cur.concat({rh.sub(1, l), l - 1});
            cur = cur.concat({calc_rev(l - rem - 1, l - 1), rem});
        }
        return cur.h;
    };


    for (int l = 2; l <= s.size(); l++) {
        if( f(l) == rh.sub(0, s.size())){
            cout << l << endl;
            break;
        }
    }
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int Price;
  if (A <= 5) {
    Price = 0;
  } else if (A <= 12) {
    Price = B / 2;
  } else {
    Price = B;
  }
  cout << Price << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int result[45];

int fib(int n){
    if(n==0||n==1)
      return result[n] = 1;
    if(result[n] != -1)
      return result[n];
    return result[n]=fib(n-1)+fib(n-2);
}

int main(){
  int n,i;
    for(i=0;i<45;++i){
        result[i]=-1;
    }
    scanf("%d",&n);
    printf("%d\n",fib(n));
    return 0;
}



Measured memory_bytes: 2108
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(list[K-1])

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

int main(){
  int n,count;
  cin >> n;
  vector<int> a(n),b(n);
  for(int i; i < n; i++){
    cin >> a.at(i);
  }
  for(int j; j < n; j++){
    b.at(j) = j+1;
  }
  count = 0;
  for(int p; p < n; p++){
    if(a.at(p) == b.at(p))
      continue;
    else
      count++;
  }
  if(count == 0 || count ==2)
    cout << "YES" <<endl;
  else
    cout << "NO" << endl;
}
             
            
          
      
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    string s,t; cin>>s>>t;
    int cnt=0;
    rep(i,3){
    if(s[i]==t[i]) cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict

if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    bc = [list(map(int, input().split())) for _ in range(m)]

    card = defaultdict(int)
    for aa in a:
        card[aa] += 1

    for c in bc:
        card[c[1]] += c[0]

    card_sort = sorted(card.items(), key=lambda x: x[0], reverse=True)

    ans = 0
    res = n
    for c in card_sort:
        if c[1] >= res:
            ans += res * c[0]
            break
        else:
            ans += c[0] * c[1]
            res -= c[1]

    print(ans)


Measured memory_bytes: 64556
import math
A, B, H, M = map(int,input().split())


ha = 6 * (5 * H + (M/60 * 5))
ma = 6 * M
angle = min(360 - abs(ha - ma), abs(ha - ma))

cos = math.cos(math.radians(angle))
c = B**2 + A**2 - 2*A*B * cos
res = math.sqrt(c)
print(res)

Measured memory_bytes: 9516
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
#include <functional>

using namespace std;


int main() {
	string s;
	cin >> s;
	s[5] =  ' ';
	s[13] = ' ';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
array = [int(a) for a in input().split()]
for i in range(n):
    j = i
    while j < n:
        if j != 0 and array[j-1] > array[j]:
            array[j-1], array[j] = array[j], array[j-1]
            j -= 1
            continue
        else:
            break
    for k in range(n):
        if k != n-1:
            print(array[k], end=' ')
        else:
            print(array[k])

Measured memory_bytes: 8032
#include<stdio.h>

int main(void)
{
   int n, k, l[50], i, f, a, x, s;

   scanf("%d%d",&n,&k);
   for(i=0;i<n;i++)
      scanf("%d",&l[i]);

   for(i=0;i<n-1;i++)
      for(f=i;f<n;f++)
         if(l[i]<l[f]){
            a=l[i];
            l[i]=l[f];
            l[f]=a;
         }

   for(i=0,a=0;i<k;i++)
      a+=l[i];

   printf("%d\n",a);
   return 0;
}

Measured memory_bytes: 1700
#include<stdio.h>
int main(void){
int N,M,i;
int no = 0;
scanf("%d %d",&N,&M);
int a[200000]={0},b[200000]={0},tmpa,tmpb;
for(i=0;i<M;i++){
scanf("%d %d",&tmpa,&tmpb);
if(tmpa==1)a[tmpb]=1;
if(tmpb==N)b[tmpa]=1;
}
for(i=0;i<N;i++){
if(a[i]==1 && b[i]==1){
no = 1;
}
}
if(no == 1) printf("POSSIBLE");
if(no == 0) printf("IMPOSSIBLE");
return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main()
{
	int n,a,b;
	cin >>n>> a >> b;
	if(a<b) cout <<a;
	else cout <<b;
	cout <<" ";
	if(n<a+b) cout <<a+b-n;
	else cout <<"0";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int s[200],pre[100],back[100];
int main()
{
	long long n;
	cin >> n;
	int tmp = 100,r = 1,l = 1;
	while(n)
	{
		if(n & 1)
		{
			n >>= 1;
			back[r ++] = tmp --;
		}
		else
		{
			n --;
			pre[l ++] = tmp --;
		}
	}
	cout << 2 * (100 - tmp) << endl;
	for(int i = 1;i < l;i ++)
		printf("%d ",pre[i]);
	for(int i = r - 1;i > 0;i --)
		printf("%d ",back[i]);
	for(int i = tmp + 1;i < 100;i ++)
		printf("%d ",i);
	cout << 100 << endl;
	return 0;
}

Measured memory_bytes: 256
import math
S=input()
N=len(S)
S1=S[0:math.floor((N-1)/2)]
S2=S[math.floor((N+3)/2)-1:N]
if S1==S1[::-1]:
  if S2==S2[::-1]:
    if S==S[::-1]:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 3064
"""
まず、最大値と最小値は出せる。
その範囲外のYであれば不可

愚直にやる場合、
N(N-2) / 2
通りあると思うので、O(N*N)
動的計画法使うんかな？？？
どうやって使うっけ


"""

import sys

N, Y = list(map(lambda x: int(x), input().split()))

# ここNだとnoguchi = Nの時を数え忘れる
for n in range(N+1):
  for hi in range(N - n + 1):
    if n + hi >= N:
      hu = 0
    else:
      hu = N - n - hi

    if n * 1000 + hi * 5000 + hu * 10000 == Y:
      print(' '.join([str(hu), str(hi), str(n)]))
      sys.exit()
    
print('-1 -1 -1')
      

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int m, nmin, nmax;
    while(cin>>m>>nmin>>nmax, m) {
        vi v(m);
        rep(i,m) cin>>v[i];
        sort(v);
        int tmp = 0;
        int ans = 0;
        REPI(i,nmin,nmax) {
            if(v[m-i]-v[m-i-1]>=tmp) {
                tmp = v[m-i]-v[m-i-1];
                ans = i;
            }
        }
        P(ans);
    }
    return 0;
}

Measured memory_bytes: 3052
#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <string>
#include <string.h>
#include <limits>
#include <utility>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <chrono>

using namespace std;

namespace
{
	struct Node
	{
		vector<int> nexts;
		int arrowedCount = 0;
	};
	vector<int> answer;

	vector<Node> nodes;

	void Process(int target, int beforeTarget)
	{
		answer[target] = beforeTarget;

		deque<int> que;
		for (int i = 0; i < nodes[target].nexts.size(); i++)
		{
			int nextNode = nodes[target].nexts[i];
			nodes[nextNode].arrowedCount--;
			if (nodes[nextNode].arrowedCount == 0)
			{
				que.push_back(nextNode);
			}
		}

		while (!que.empty())
		{
			int t = que.front();
			que.pop_front();

			Process(t, target);
		}
	}
}

#if 1
int main()
{
	int n, m;
	cin >> n;
	cin >> m;

	vector<bool> isArrowed;
	isArrowed.resize(n + 1, false);

	nodes.resize(n + 1);

	for (int i = 0; i < n + m; i++)
	{
		int a, b;
		cin >> a >> b;
		nodes[a].nexts.push_back(b);
		nodes[b].arrowedCount++;
		isArrowed[b] = true;
	}

	int beforeTarget = 0;
	int target = -1;
	for (int i = 1; i <= n; i++)
	{
		if (!isArrowed[i])
		{
			target = i;
			break;
		}
	}
	
	answer.resize(n + 1, 0);
	answer[target] = 0;

	Process(target, beforeTarget);

	for (int i = 1; i <= n; i++)
	{
		printf("%d\n", answer[i]);
	}
}
#endif


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

int main(){

ll n; cin>>n;
ll sum=0;
for(int i=1;i<=n;i++){
	for(int j=1;j<=n;j++){
		for(int k=1;k<=n;k++){
			sum+=__gcd(i,__gcd(j,k));
		}
	}
}
cout<<sum<<"\n";
return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)
 

 
signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif 
    int a,maxi;
    cin>>a>>maxi;

    int b[a];
    rep(i,0, a){
        cin>>b[i];
    }
    vector<bool> dp(maxi+1);
    dp[0]=false;
    //dp[i] is true if first player using those stones wins
    for(int i=1;i<=maxi;i++){
        for(int x:b){
            if(i>=x&&(!dp[i-x])){
                dp[i]= true;
            }

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


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define rank AAAAAA
#define MAX 114514
using namespace std;
int par[MAX];
int rank[MAX];
 
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    rank[i]=0;
  }
}
int find(int x){
  if(par[x]==x)return x;
  else return par[x]=find(par[x]);
}
void unit(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
 
  if(rank[x]<rank[y]){
    par[x]=y;
  }
  else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}
 
map<int,int> mm;
 
int main(){
  int n,m,k,a,b,c;
  cin>>n>>m>>k;
  init(n+1);
  for(int i=1;i<=k;i++){
    cin>>c>>a>>b;
    if(c==1){
      int p1=find(a),p2=find(b);
      if(mm[p1]&&mm[p2]&&mm[p2]!=mm[p1]){
        cout<<i<<endl;
        break;
      }
      unit(a,b);
      if(mm[p1])mm[p2]=mm[p1];
      if(mm[p2])mm[p1]=mm[p2];
    }
    else{
      int p=find(a);
      if(mm[p]&&mm[p]!=b){
    cout<<i<<endl;
    break;
      }
      mm[p]=b;
    }
    if(i==k)cout<<0<<endl;
  }
}

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

typedef long long ll;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m, k;
    cin >> n >> m >> k;
    ll a[n], b[m];
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<m; i++) cin >> b[i];

    ll ans=0, sum=0, temp;
    for(ll i=0; i<n; i++){
        sum+=a[i];
        if(sum>k){
            temp=i-1;
            sum-=a[i];
            break;
        }else{
            ans++;
            temp=i;
        }
    }

    ll ans2=ans;
    for(ll i=0; i<m; i++){
        sum+=b[i];
        if(sum>k){
            while(sum>k && temp>=0){
                ans2--;
                sum-=a[temp];
                temp--;
            }
            if(sum>k){
                sum-=b[i];
                break;
            }
            ans2++;
            ans=max(ans,ans2);
        }else{
            ans2++;
            ans=max(ans,ans2);
        }
    }

    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 6732
A=[]#元の値
for i in range(5):
    a=int(input())
    A.append(a) 
    def key_func(x):
        one_keta=x%10
        if one_keta==0:
            return 10
        else:
            return x%10
    A.sort(reverse=True,key=key_func)
    
    #1の位に着目して小さい順にソートしたい
#print(A)

t=0
for i in range(4):
    if A[i]%10==0:
        t+=A[i]
    else:
        for j in range(10):
            if A[i]%10==j:
                t+=A[i]+10-j
                break

t=t+A[4]
print(t)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int ans = 0;
  REP(i, 6){
    if(S[i] == '1') ans++;
  }
  cout << ans << endl;
}


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

#define forn(i,m,n) for(int i=m;i<n;i++)
#define vv vector
#define vi vv<int>
#define ii pair<int,int>
#define vii vv<ii>
#define mp make_pair
#define pb push_back
#define PI 3.141592653589
#define ll long long
#define pll pair<ll,ll>
#define vl vv<ll>
#define ff first
#define ss second
#define MOD 1000000007


bool is_prime[1000001];
vi prime;
void sieve(int n)
{
	memset(is_prime,true,sizeof(is_prime));
	for(int i=2;i*i<=n;i++)
	{
		if(is_prime[i])
		{
			for(int j=i*i;j<=n;j+=i)
			{
				is_prime[j]=false;
			}
		}
	}
	forn(i,2,n+1)
	{
		if(is_prime[i])
			prime.pb(i);
	}
}

ll ex(ll a,ll b)
{
    ll res=1;
    a=a%MOD;
    while(b)
    {
        if(b%2){res=(res*a)%MOD;b--;}
        b/=2;
        a=(a*a)%MOD;
    }
    return res;
}

ll fermat_inv(ll a){ return ex(a,MOD-2); }
ll max(ll a,ll b){ return a>b?a:b; }
ll min(ll a,ll b){ return a<b?a:b; }

int gcd(int a,int b) { return (a%b==0)?b:gcd(b,a%b); }


int main()
{
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        /*#ifndef ONLINE_JUDGE
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        #endif*/
    //sieve(1000000);

    int te=1;
    //cin>>te;
    while(te--)
    {
        int n;
        cin>>n;
        int d[n][2];
        forn(i,0,n)
        {
            cin>>d[i][0]>>d[i][1];
        }
        forn(i,0,n-2)
        {
            if(d[i][0]==d[i][1] && d[i+1][0]==d[i+1][1] && d[i+2][0]==d[i+2][1]){
                cout<<"Yes";
                exit(0);
            }
        }
        cout<<"No";
    }
}


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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

int main(){
    double N, T, A;
    double min = 100000;
    int num;

    cin >> N >> T >> A;
    rep(i,N) {
        double a;
        cin >> a;

        double deg = abs(A - (T - a * 0.006));
        if(min > deg) {
            min = deg; 
            num = i + 1;
        }
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int dp[200005],a[100005];
int main(void){
	int n,k,i;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
	int j;
	for(i=0;i<=k;i++)
	{
	    if(dp[i]==0)
	    {
	        for(j=1;j<=n;j++)
	        dp[i+a[j]] = 1;
	    }
	}
	if(dp[k])printf("First\n");
	else printf("Second\n");
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define MOD 1000000007

using namespace std;
typedef long long int ll;

int main(void){
	// #ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// #endif
	fast;
	int n; cin >> n;
	int m; cin >> m;
	vector<array<int, 3>> v;
	for (int i = 0; i < m; ++i){
		int a, b; cin >> a >> b;
		v.pb({a, 1, i});
		v.pb({b, 0, i});
	}
	bool mark[m]; memset(mark, 0, sizeof mark);
	sort(v.begin(), v.end());
	int ans = 0;
	stack<int> s;
	for (auto it : v){
		if (it[1] == 1){
			s.push(it[2]);
		}
		else{
			if (mark[it[2]]) continue;
			ans += 1;
			while(!s.empty()){
				int t = s.top();
				s.pop();
				mark[t] = 1;
			}
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n ;
  vector<int>a1(n);
  vector<int>a2(n);
  for(int i = 0;i<n;i++){
    cin >> a1.at(i);
    if( i != 0){
    a1.at(i) += a1.at(i-1);
    }
  }
  for(int i = 0;i<n;i++){
    cin >> a2.at(i);
    if( i != 0){
    a2.at(i) += a2.at(i-1);
    }
  }
  int ans =0;
  for( int i = 0; i<n;i++){
    int sum ;
    if( i !=0){
      sum = a1.at(i) + a2.at(n-1) - a2.at(i - 1);
    }
    else {
      sum = a1.at(i) + a2.at(n-1) - 0;
    }
    if( ans < sum ) {
      ans = sum;
    }
  }
  cout << ans << endl;   
}

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

int main() {
  set<int> abc;
  int a;
  for(int i=0; i<3; i++){
    cin >> a;
    abc.insert(a);
  }
  if(abc.size() == 2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	

int max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int n;

	int a[22];
	int b[22];
	int c[22];

	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n - 1) cin >> c[i];

	int sum = 0;
	rep(i, n) {
		sum += b[a[i]-1];
		if (a[i] == a[i+1] - 1) {
			sum += c[a[i]-1];
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int mod = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const int maxa = 2000 + 10;
const int maxn = 200000 + 10;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

LL fpm(LL base, LL exp) {
    LL res = 1;
    for(base %= mod; exp > 0; exp >>= 1) {
        if(exp & 1)
            res = res * base % mod;
        base = base * base % mod;
    }
    return res;
}

LL fac[maxn], ifac[maxn];
LL C(int n, int k) { return fac[n] * ifac[k] % mod * ifac[n-k] % mod; }

void init() {
    fac[0] = ifac[0] = 1;
    for(int i = 1; i < maxn; ++i) fac[i] = fac[i-1] * i % mod; 

    ifac[maxn-1] = fpm(fac[maxn-1], mod-2);
    for(int i = maxn-1; i >= 1; --i) ifac[i-1] = ifac[i] * i % mod;
}

int a[maxn], b[maxn], n;
int dp[maxa << 1][maxa << 1];

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    init();
    n = read<int>();
    for(int i = 1; i <= n; ++i) {
        a[i] = read<int>(), b[i] = read<int>();
        dp[maxa - a[i]][maxa - b[i]] ++;
    }

    for(int i = 1; i < (maxa << 1); ++i) 
        for(int j = 1; j < (maxa << 1); ++j) {
            dp[i][j] = (dp[i][j] + (dp[i-1][j] + dp[i][j-1]) % mod) % mod;
        }

    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        ans = (ans + dp[maxa + a[i]][maxa + b[i]]) % mod;
        ans = (ans - C(2*a[i] + 2*b[i], 2*a[i])) % mod;
    }
    ans = ans * fpm(2, mod-2) % mod;
    printf("%d\n", (ans % mod + mod) % mod);

    return 0;
}


Measured memory_bytes: 68096
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

/*
[$ s_i \neq t_i]の場合: 
上下で別々のドミノなので前はなにもないか or 1つの縦ドミノ。
なにもない場合は3 x 2 で１つの縦ドミノの場合は2 x 1
次の文字は読み飛ばし。
[$ s_i = t_i]の場合:
上下で１つのドミノなので、前は
i) なにもない 3
ii) １つのドミノ 2
ii) ２つの横ドミノ 1
*/
const ll MOD = 1000000007;
int main() {
  int n; cin >> n;
  string s, t; cin >> s >> t;
  n = s.size();
  ll ans = 1;
  int prev = -1; // -1: 何もなし, 1: １つのドミノ, 2: ２のドミノ
  loop(i,0,n) {
    if (s[i] != t[i]) {
      // --
      // --
      if (prev == -1) ans *= 3 * 2;
      // |--
      // |--
      else if (prev == 1) ans *= 2;
      // -- --
      // -- --
      else ans *= 3;
      ans %= MOD;
      prev = 2;
      i++;
      continue;
    }
    
    // |
    // |
    if (prev == -1) ans *= 3;
    // | |
    // | |
    else if (prev == 1) ans *= 2;
    // --|
    // --|
    else ans *= 1;
    ans %= MOD;
    prev = 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>

int c[100001];

int main(void) {
	int n;
	scanf("%d", &n);
	int a[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		c[a[i]] += 1;
	}
	int max = 0;
	for (int i = 0; i < 100001 - 2; i++) {
		int temp = c[i] + c[i + 1] + c[i + 2];
		if (temp > max) max = temp;
	}
	printf("%d", max);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
#define REP(i,M) for(int i=0;i<M;i++)
 
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 gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  
  ll X = input();
  
  ll answer = 0;
  ll val = 100;

  while(val < X){
    val += val/100;
    answer++;
  }

  output(answer);
  
  return 0;
}

Measured memory_bytes: 3616
/** omgursocute **/
#include <bits/stdc++.h>
 
using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
 
	int n;
	cin >> n;
 
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
 
	bool ok = 1;
	for(int i = n-1; i > 0; i--) {
		if(a[i-1] <= a[i]) continue;
		else {
			a[i-1]--;
			if(a[i-1] ^ a[i]) ok = 0;
		}
	}
 
	cout << ((ok) ? "Yes" : "No");
 
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
}
 
// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long long int (i) = 0; (i) < (int) (n); (i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;

int main(int argc, char const *argv[])
{
    int a, b, c;
    cin >> a >> b;
    c = a * b / 2;
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100
#define INFTY 2001
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,A[MAX][MAX];
int prim(void);

int main(){
  int i,j;

  scanf("%d",&n);

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

  printf("%d\n",prim());

  return 0;
}

int prim(){
  int i,u,v,mincost,sum = 0,d[MAX],pi[MAX],color[MAX];

  for(i=0; i<n; i++){
    d[i] = INFTY;
    pi[i] = NIL;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    mincost = INFTY;
    for(i=0; i<n; i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
    if(mincost == INFTY)
      break;
    color[u] = BLACK;
    for(v=0; v<n; v++){
      if(color[v] != BLACK && A[u][v]  != INFTY){
	if(A[u][v] < d[v]){
	  pi[v] = u;
	  d[v] = A[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }

  for(i=0; i<n; i++){
    if(pi[i] != NIL)
      sum += A[i][pi[i]];
  }

  return sum;
}

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

#define loop(i,n) for(int i=1;i<=n;i++)
typedef pair<char,int> P;
vector<P> v;

int main(){
  char c;
  while(cin>>c){
    if(!v.empty()&&v.back().first==c){
      v.back().second++;
    }else{
      v.push_back(P(c,1));
    }
  }
  int m=0;
  if(v.size()>=3)loop(p,v.size()-2){
    if(v[p-1].first=='J'&&v[p].first=='O'&&v[p+1].first=='I'){
      int j=v[p-1].second;
      int o=v[p].second;
      int i=v[p+1].second;
      if(j>=o&&o<=i){
        m=max(m,o);
      }
    }
  }
  cout<<m<<endl;
  return 0;
}

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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;


const int S = 1e5+5;
ll occ[S] = {0};
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	vector<int> nums(n);
	ll ans = 0;
	for (int &it: nums){
		cin>>it;
		occ[it]++;
		ans += it;
	}
	int q;
	cin>>q;
	for (int i = 0; i < q; i++){
		ll b,c;
		cin>>b>>c;
		ans += (c-b)*occ[b];
		occ[c] += occ[b];
		occ[b] = 0;
		cout<<ans<<'\n';
	}
	return 0;
}

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

int main(){
    int N,M,m,n;
    int a=100000;
    cin >> N;
    for(int i=1; i<N; i++){
        M=N-i;
        m=M/100000+(M/10000)%10+(M/1000)%10+(M/100)%10+(M/10)%10+M%10;
        n=i/100000+(i/10000)%10+(i/1000)%10+(i/100)%10+(i/10)%10+i%10;
        if(m+n<a)
        a=m+n;
    }
    cout << a << endl;
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;

int main() {
    cin >> N;

    double p = 0;
    double a;

    for (int i = 0; i < N; i++) {
        cin >> a;
        p += 1 / a;
    }

    cout << 1 / p << endl;
    return 0;
}


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

int N;
int a[210000];
vector<vector<int>> G;
int dp[210000], res[210000];
int const INF = 1001001001;

void dfs(int v, int par, int pos, int prev) {
    res[v] = lower_bound(dp, dp + N, INF) - dp;
    for(int child : G[v]) {
        if(child == par) continue;
        auto it = lower_bound(dp, dp + N, a[child]);
        int npos = it - dp, nprev = *it;
        *it = a[child];
        dfs(child, v, npos, nprev);
    }
    dp[pos] = prev;
}

int main() {
    cin >> N; G.resize(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < N-1; i++)
    {
        int u, v; cin >> u >> v;
        --u; --v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    dp[0] = a[0];
    for(int i=1; i<N; ++i) dp[i] = INF;
    dfs(0, -1, 0, INF);

    for (int i = 0; i < N; i++)
    {
        cout << res[i] << '\n';
    }
}

Measured memory_bytes: 30880
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;


    vector<int> W;
    vector<int> S;

    for (int i = 0; i * a * 100 <= f; ++i) {
        for (int j = 0; j * b * 100 + i * a * 100 <= f; ++j) {
            W.emplace_back(i * a *100 + j * b * 100);
        }
    }
    for (int i = 0; i * c <= f; ++i) {
        for (int j = 0; j * d + i * c <= f; ++j) {
            S.emplace_back(i * c + j * d);
        }
    }

    sort(W.begin(), W.end());
    W.resize(unique(W.begin(), W.end()) - W.begin());
    sort(S.begin(), S.end());
    S.resize(unique(S.begin(), S.end()) - S.begin());

    int n = W.size(), m = S.size();

    int w = 0, s = 0;
    for (int i = 0; i < n; ++i) {
        int x = W[i];

        int l = 0, r = m - 1;
        while (l < r) {
            auto mi = (l + r + 1) / 2;
            if (x / 100 * e >= S[mi] && x + S[mi] <= f) {
                l = mi;
            } else {
                r = mi - 1;
            }
        }
        if (l >= 0 && l < m) {
            if (w == 0 || S[l] * (w + s) > (S[l] + x) * s) {
                w = x;
                s = S[l];
            }
        }
    }

    cout << (w + s) << ' ' << s << '\n';

    return 0;
}

Measured memory_bytes: 4180
from sys import stdin, setrecursionlimit
from collections import deque

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


MOD = 1000000007
N = int(stdin.buffer.readline())
m = map(int, stdin.buffer.read().split())
AB = zip(m, m)
G = [[] for _ in range(N)]
for a, b in AB:
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)

pow2 = [1] * (N + 1)
for i in range(N):
    pow2[i + 1] = pow2[i] * 2 % MOD

order = []
parent = [-1] * N

stack = deque([0])
while stack:
    v = stack.pop()
    order.append(v)
    for nv in G[v]:
        if parent[v] != nv:
            parent[nv] = v
            stack.append(nv)

numer = 0
nums = [0] * N

for v in reversed(order):
    tmp = 1
    for nv in G[v]:
        if parent[v] != nv:
            nums[v] += nums[nv] + 1
            tmp += pow2[nums[nv] + 1] - 1
    tmp += pow2[N - nums[v] - 1] - 1
    numer = (numer + pow2[N - 1] - tmp) % MOD

denom = pow2[N]
ans = numer * pow(denom, MOD - 2, MOD) % MOD
print(ans)


Measured memory_bytes: 59080
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n<1200)cout<<"ABC"<<endl;
    else if (1200<=n and n<2800)cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
}

Measured memory_bytes: 256