akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    set<string> st;
    string pre;
    bool isok = true;
    for(int i=0; i<n; i++){
        string str;
        cin >> str;
        st.insert(str);
        if(i!=0 && str[0]!=pre[pre.size()-1]){
            isok = false;
        }
        pre = str;
    }
    if(st.size()!=n){
        isok = false;
    }
    if(isok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int n,temp;
  cin>>n;
  int ar[n+1]={0};
  for(int i=0;i<n-1;i++)
  {
    cin>>temp;
    ar[temp]++;
  }
for(int i=1;i<=n;i++)
{cout<<ar[i]<<endl;
}
 
 
   return 0;
}


Measured memory_bytes: 4420
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll mod_pow(ll x, ll n, ll mod) {
	ll bit = 1;
	while (n) {
		if (n & 1)bit = bit * x % mod;
		x = x * x % mod;
		n /= 2;
	}
	return bit;
}
signed main() {
	ll n, k;
	cin >> n >> k;
	if (n * (2 * k + 5 * n - 1) < 2 * n * (2 * k + 2 * n - 1))puts("-1");
	else {
		ll a[114514], b[114514], c[114514];
		for (int i = 0; i < n; i += 2) {
			a[i] = k; k++;
		}
		for (int i = 1; i < n; i += 2) {
			a[i] = k; k++;
		}
		for (int i = 1; i < n; i += 2) {
			b[i] = k; k++;
		}
		for (int i = 0; i < n; i += 2) {
			b[i] = k; k++;
		}
		for (int i = 0; i < n; i++) {
			c[i] = k; k++;
		}
		for (int i = 0; i < n; i++) {
			cout << a[i] << ' ' << b[i] << ' ' << c[i] << endl;
		}
	}
	ggr
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20

typedef long long ll;
using namespace std;

ll n,y;
int p[] = {10000,5000,1000};
int main() {
    scanf("%lld%lld",&n,&y);
    for(ll i = 0; i<n+1; i++){
        for(ll j = 0; j<n+1; j++){
            if(i+j>n) break;
            ll k = n-i-j;
            if(y == p[0]*i+p[1]*j+p[2]*k){
                printf("%lld %lld %lld\n",i,j,k);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,d;
    while(cin>>a>>b>>c>>d)
    {
        long long  c1=0,d1=0,c1d1=0;
        long long lcm=0;
        lcm=(c*d)/(__gcd(c,d));
        //cout<<"lcm="<<lcm<<endl;
        c1=(b/c)-((a-1)/c);
        //cout<<"c1="<<c1<<endl;
        d1=(b/d)-((a-1)/d);
        //cout<<"d1="<<d1<<endl;
        c1d1=(b/(lcm))-((a-1)/(lcm));
        //cout<<"c1d1="<<c1d1<<endl;

        cout<<(b-a+1)-(c1+d1-c1d1)<<endl;
    }
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    string s;
    cin >> s;

    char now = s[0];
    int ans=0;
    for (int i = 0; i < (int)s.length(); i++) {
        if (now != s[i]) {
            ans++;
            now = s[i];
        }
    }

    cout << ans << endl;
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

int main(int argc, const char * argv[]) {
    
    int N, K;
    char S[52];
    
    cin >> N >> K;
    cin >> S;
    
    S[K-1] = tolower(S[K-1]);
    
    for(int i=0; i< N; i++){
        cout << S[i];
    }
    
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
root = [[False]*n for _ in range(2)]

for i in range(m):
    a, b = map(int, input().split())
    if a==1:
        root[0][b-1] = True
    if b==n:
        root[1][a-1] = True
for j in range(n):
    if root[0][j]:
        if root[1][j]:
            print('POSSIBLE')
            exit(0)
print('IMPOSSIBLE')


Measured memory_bytes: 6132
#include <bits/stdc++.h>
 
#define A_MAX 1000000
#define A_MAX_HALF 500000
 
using namespace std;
 
int scanint() { 
	char c = getchar_unlocked();
    int x = 0;
    for(; (c<48)||(c>57);c = getchar_unlocked());
    for(; (c>47)&&(c<58);c = getchar_unlocked())
        x = 10 * x + c - 48;
    return x;
} 
 
int min_factor[A_MAX + 1];
int q[A_MAX + 1];
int a[A_MAX + 1];
 
int main() {
 
    vector<int> primes;
    for (int i = 2; i <= A_MAX_HALF; ++i) {
        if (!min_factor[i]) {
            min_factor[i] = i;
            primes.push_back(i);
        }
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
    for (int i = A_MAX_HALF + 1; i <= A_MAX; ++i) {
        if (!min_factor[i]) {
            min_factor[i] = i;
            primes.push_back(i);
        }
    }
 
    int N = scanint();
    for (int i = 0; i < N; ++i) {
        ++a[scanint()];
    }
 
    bool is_pairwise_coprime = true;
    for (int n = A_MAX; n > 1; --n) {
        int an = a[n];
        if (an) {
            if (an > 1) {
                if (an == N) {
                    printf("not coprime\n");
                    return 0;
                }
                is_pairwise_coprime = false;
            }
            a[min_factor[n]] += an;
            a[q[n]] += an;
        }
    }
    if (is_pairwise_coprime) {
        printf("pairwise coprime\n");
    } else {
        printf("setwise coprime\n");
    }
 
    return 0;
}

Measured memory_bytes: 15468
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

dp = [False] * N

for i in range(N):
    if i >= K and dp[i - K] and T[i] == T[i - K]:
        continue
    dp[i] = True
    
ans = 0
for i in range(N):
    if not dp[i]:
        continue
        
    if T[i] == "r":
        ans += P
    elif T[i] == "s":
        ans += R
    else:
        ans += S
        
print(ans)


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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  std::string s;
  std::cin >> s;
  if (s == "A") {
    s = "T";
  } else if (s == "C") {
    s = "G";
  } else if (s == "T") {
    s = "A";
  } else if (s == "G") {
    s = "C";
  }

  std::cout << s << std::endl;
  return 0;
}
//
// A, C, G, T が存在し、A と T、C と G がそれぞれ


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    int X = 0;
    int A = 0;
    cin >> X >> A;

    const char* out = NULL;
    if(X < A) {
        out = "0";
    } else {
        out = "10";
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

class ABC121_C
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int M = int.Parse(input[1]);

        Pair[] p = new Pair[N];

        for (int i = 0; i < N; i++)
        {
            input = Console.ReadLine().Split(' ');
            p[i] = new Pair();
            p[i].A = long.Parse(input[0]);
            p[i].B = int.Parse(input[1]);
        }

        Array.Sort(p);

        long sum = 0;
        int count = 0;

        for (int i = 0; i < N; i++)
        {
            int buy = Math.Min(p[i].B, M - count);

            sum += p[i].A * buy;
            count += buy;

            if (count >= M) break;
        }

        Console.WriteLine(sum);
    }

    class Pair : IComparable
    {
        public long A;
        public int B;

        public int CompareTo(object x)
        {
            return this.A.CompareTo(((Pair)x).A);
        }
    }
}


Measured memory_bytes: 22720
#include <iostream>
#include <vector>
#include <functional>

int main() {
  int N,M;
  std::cin >> N >> M;
  std::vector<int> K(M);
  std::vector<std::vector<int>> S(M);
  for(int i=0;i<M;i++){
    std::cin >> K[i];
    for(int k=0;k<K[i];k++){
      int s;
      std::cin >> s;
      S[i].push_back(s);
    }
  }
  std::vector<int> P(M);
  for(auto &p:P)
    std::cin >> p;
  int cnt=0;
  for(int i=0;i< (1<<N) ;i++){
    bool all_on = true;
    for(int m=0;m<M;m++){
      int on_num=0;
      for(int k=0;k<K[m];k++){
        on_num += (i>>(S[m][k]-1))&1;
      }
      if((on_num&1) != P[m]){
        all_on = false;
        break;
      }
    }
    if(all_on)
      cnt++;
  }
  std::cout << cnt << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<vector>
using namespace std;
const int MAXN=1e5+10;
int A[MAXN],deg[MAXN]={0};
typedef long long LL;
LL cntfa[MAXN];
vector<int> ed[MAXN];
bool flag=true;
int root=0;
void dfs(int x,int fa=0)
{
    if(deg[x]==1)
    {
        cntfa[x]=A[x];
        return;
    }
    LL sum=0;
    for(int i=0;i<ed[x].size();i++) if(ed[x][i]!=fa)
    {
        dfs(ed[x][i],x);
        if(cntfa[ed[x][i]]>A[x]) flag=false;
        sum+=cntfa[ed[x][i]];
    }
    if(x!=root)
    {
        cntfa[x]=2*A[x]-sum;
        if(cntfa[x]<0||cntfa[x]>A[x]) flag=false;
    }
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&A[i]);
    for(int i=1;i<n;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        ed[u].push_back(v);
        ed[v].push_back(u);
        deg[u]++;deg[v]++;
    }
    if(n==2)
    {
        if(A[1]==A[2]) puts("YES");else puts("NO");
        return 0;
    }
    for(int i=1;i<=n;i++) if(deg[i]>1) root=i;
    dfs(root);
    LL sum=0;
    for(int i=0;i<ed[root].size();i++) sum+=cntfa[ed[root][i]];
    if(sum!=2*A[root]) flag=false;
    for(int i=0;i<ed[root].size();i++) if(cntfa[ed[root][i]]>A[root]) flag=false;
    if(flag) puts("YES");else puts("NO");
    return 0;
}


Measured memory_bytes: 14464
#include <bits/stdc++.h>
#define endl '\n'
#define _USE_MATH_DEFINES
using namespace std;

int main() {
	
	ios::sync_with_stdio(false);
    cin.tie(0);
    
    string ans = "";
    long long int n;
    int i,k = 1;
    cin>>n;
    while(n>pow(26,k)){
    	n -= pow(26,k);
    	k++;
	}
    n--;
    for(i = k-1;i>=0;i--){
    	long long int tmp = pow(26,i),tmp2;
    	tmp2 = n/tmp;
    	char ch = 'a'+tmp2;
    	ans += ch;
    	n -= tmp2*tmp;
	}
	cout<<ans;
    
	return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG



int main() {
  char S;
  cin >> S;
  int tmp = int(S) +  1;
  cout << char(tmp) << endl;

  return 0;
}


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

int main()
{
  double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
  while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
    if (xa1 <= xb2 && xb1 <= xa2 && ya1 <= yb2 && yb1 <= ya2)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
// ACM-ICPCアジア地区予選2014 F. There is No Alternative

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int root[500];
int getRoot(int v){ return root[v]==-1 ? v : root[v] = getRoot(root[v]); }

int getMst(const vector<pair<int, pair<int, int> > >& vp, int N, int nouse){
	int cnt = 0, res = 0;
	memset(root, -1, sizeof(root));
	for(int i=0;i<vp.size();i++){
		if(i == nouse) continue;
		int p = getRoot(vp[i].second.first);
		int q = getRoot(vp[i].second.second);
		if(p != q){
			root[q] = p;
			cnt++;
			res += vp[i].first;
		}
	}
	if(cnt < N-1) return -1;
	return res;
}

int main(){
	int N, m;
	while(cin >> N >> m){
		vector< pair<int, pair<int, int> > > vp(m);
		for(int i=0;i<m;i++){
			cin >> vp[i].second.first >> vp[i].second.second >> vp[i].first;
			vp[i].second.first--;
			vp[i].second.second--;
		}
		sort(vp.begin(), vp.end());
		int minCost = 0;
		vector<int> idx;
		memset(root, -1, sizeof(root));
		for(int i=0;i<vp.size();i++){
			int p = getRoot(vp[i].second.first);
			int q = getRoot(vp[i].second.second);
			if(p != q){
				root[q] = p;
				minCost += vp[i].first;
				idx.push_back(i);
			}
		}
		int res = 0, sum = 0;
		for(int i=0;i<idx.size();i++){
			if(minCost != getMst(vp, N, idx[i])){
				res++;
				sum += vp[idx[i]].first;
			}
		}
		cout << res << " " << sum << endl;
	}
}

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

# C - When I hit my pocket...
def get_max_biscuits():
	
	if K < A + 1:
		return K + 1
	else:
		count = K - (A+1)
		
		return B + (B-A)*(count//2) + count%2


K, A, B = map(int, input().split())

if B - A >= 2:
	print(get_max_biscuits())
else:
	print(K + 1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll k; cin >> k;
    ll sum = 3*n*(k-1) + 3*n*(3*n+1)/2;
    ll usum= n*(k+2*n-1) + n*(n+1)/2;
    if (usum*2 < sum){
        cout << -1 << endl;
        return 0;
    }
    dump(usum)
    dump(sum)
    ll top;
    ll mid;
    ll low;
    set <ll> q;
    //for(ll i=k; i<k+3*n; i++){
    //    q.insert(i);
    //}
    ll lefttop;
    ll leftbottom;
    for(ll i=0; i<(n+1)/2; i++) {
        top = k + 3 * n - 1 - 2 * i;
        mid = k + 2 * n - 1 - i;
        low = top - mid;
        if (i == 0) {
            lefttop = low;
        }
        if (i ==(n+1)/2 - 1){
            leftbottom = low;
        }
        //q.erase(top); q.erase(mid); q.erase(low);
        cout << low << " " << mid << " " << top << endl;
    }
    for(ll i=0; i<n/2; i++){
        top = k + 3*n - 2 - 2*i;
        mid = k + 2*n - (n+1)/2 - 1 - i;
        //q.erase(top); q.erase(mid);
    }
    bool kirikae = false;
    for(ll i=0; i<n/2; i++){
        top = k + 3*n - 2 - 2*i;
        mid = k + 2*n - (n+1)/2 - 1 - i;
        //low = *max_element(q.begin(), q.end());
        //q.erase(low);
        low = mid -  (2*n +1- (n+1)/2 -(n+1)/2)/2;
        if (low == lefttop){
            kirikae = true;
        }
        if (kirikae){
            leftbottom--;
            low = leftbottom;
        }
        cout << low << " " << mid << " " << top << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
H,W = (int(i) for i in input().split())
s = [[-1] * (W + 2) for i in range(H+2)]
t = [[-1] * (W + 2) for i in range(H+2)]

for i in range(1, H+1):
    SS = input()
    for j in range(W):
        if SS[j] == "#":
            s[i][j+1] = -1
            t[i][j+1] = -1
        else:
            s[i][j+1] = 0
            t[i][j+1] = 0

tmp = []
num = 0
for i in range(1, H+1):
    for j in range(1, W+2):
        if s[i][j] == -1 :
            if num != 0:
                for tp in tmp:
                    s[i][tp] = num
                tmp = []
                num =0
        else:
            tmp.append(j)
            num += 1

tmp = []
num = 0
for j in range(1, W+1):
    for i in range(1, H+2):
        if t[i][j] == -1 :
            if num != 0:
                for tp in tmp:
                    t[tp][j] = num
                tmp = []
                num =0
        else:
            tmp.append(i)
            num += 1

ref = 0
for i in range(H+2):
    for j in range(W+2):
        ref = max(s[i][j] + t[i][j], ref)

print(ref-1)

Measured memory_bytes: 113116
a=int(input())
b=int(input())
c=int(input())
y=int(input())
count=0
for i in range(a+1):
    x=y-500*i
    for j in range(b+1):
        z=x-100*j
        for k in range(c+1):
            if z==50*k:
                count +=1
                break
print(count)

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  string s;
  int count[2] = {};
  cin >> s;
  int sz = s.size();

  REP(i,sz){
      if(s[i] == '0') count[0]++;
      else count[1]++;
    }

    cout << (min(count[0],count[1]) * 2) << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
ll const mod=998244353;
//ll const mod=1e9+7;
const ll MAX=300000;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////


int main(){
    int n;
    cin>>n;
    vi a(n),b(n),c(n-1);
    rep(i,n){
      cin>>a[i];
      a[i]--;
    }
    rep(i,n)cin>>b[i];
    rep(i,n-1)cin>>c[i];
    int ans=0;
    rep(i,n){
      ans+=b[a[i]];
      if(i>0&&a[i]==a[i-1]+1)ans+=c[a[i-1]];

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

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {

    int n, m; cin >> n >> m;
    out(pow(2,m) * (1900*m + 100 * (n - m)));



    return 0;
}









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

int main(){
  char str[210];
  scanf("%s", str);
  int n = strlen(str);
  for(int i = n-2; i; i-=2){
    if(strncmp(str, str+i/2, i/2)==0){
      printf("%d\n", i);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input().strip()
S1 = S
cur = 0
for i in range(len(S)):
    if S[i]=="(":
        cur += 1
    else:
        cur -= 1
    if cur<0:
        S1 = "("+S1
        cur += 1
S1 = S1+")"*cur
print(S1)

Measured memory_bytes: 38256
n=int(input())
d,x = list(map(int, input().split()))

a=[]
for i in range(n):
    a.append(int(input()))

m=[]
for i in range(n):
    if d%a[i]==0:
        m.append(int(d/a[i]))
    else:
        m.append(int(d/a[i]+1))

s=0
for i in range(n):
    s += m[i]
s += x

print(s)

Measured memory_bytes: 3064
import bisect

A, B, Q = map(int, input().split())
INF = 10 ** 18
S = sorted([-INF] + [int(input()) for i in range(A)] + [INF])
T = sorted([-INF] + [int(input()) for i in range(B)] + [INF])

for _ in range(Q):
    x = int(input())
    si = bisect.bisect_right(S, x)
    ti = bisect.bisect_right(T, x)
    d = INF
    for s in [S[si-1], S[si]]:
        for t in [T[ti-1], T[ti]]:
            d1 = abs(s-x) + abs(t-s)
            d2 = abs(t-x) + abs(s-t)
            d = min(d, d1, d2)
    print(d)

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct Maybe {
   T x;
   bool valid;
   Maybe() : valid(false) {}
   Maybe(T x_) : x(x_), valid(true) {}
   operator T() const {
      assert( valid );
      return x;
   }
};


struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int n, m; scan(n, m);
      std::string field[112];
      for(Int i = 0; i < n; ++i) {
         scan(field[i]);
      }
      Int count[128] = {};
      for(Int i = 0; i < n; ++i) {
         for(Int k = 0; k < m; ++k) {
            count[field[i][k]] += 1;
         }
      }
      Int p4 = 0, p2 = 0, p1 = 0;
      for(Int i = 0; i < 128; ++i) {
         while( count[i] >= 4 ) {
            p4 += 4;
            count[i] -= 4;
         }
         while( count[i] >= 2 ) {
            p2 += 2;
            count[i] -= 2;
         }
         p1 += count[i] % 2;
      }
      Int ts[4] = {4 * (n/2) * (m/2), 2 * (n/2) * (m%2),2 * (n%2) * (m/2),(n%2) * (m%2)};
      bool res = p4 >= ts[0] and p4 + p2 >= ts[0] + ts[1] + ts[2] and p4 + p2 + p1 >= ts[0] + ts[1] + ts[2] + ts[3];
      puts(res ? "Yes" : "No");
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




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

int main(){
  string s;
  cin>>s;
  if(s[0]!='A'){
    cout<<"WA";
    return 0;
  }
  int i,cnt=0;
  if(s[1]=='C' || s[s.size()-1]=='C'){
    cout<<"WA";
    return 0;
  }
  for(i=2;i<s.size()-1;i++){
    if(s[i]=='C')cnt++;
    if(cnt==2){
      cout<<"WA";
      return 0;
    }
  }
  if(cnt==0){
    cout<<"WA";
    return 0;
  }
  for(i=1;i<s.size();i++){
    if((s[i]<'a' || s[i]>'z') && s[i]!='C'){
      cout<<"WA";
      return 0;
    }
  }
  cout<<"AC";
}

Measured memory_bytes: 256
#include <iostream>

int n, s;
int answer;
int arr[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

void dfs(int i, int sum, int k){
	if(k==n && sum==s){
		answer++;
	}
	if(i>9 || k==n || sum > s){
		return;
	}
	dfs(i+1, sum+arr[i], k+1);
	dfs(i+1, sum, k);
}

int main(void){
	while(std::cin >> n >> s){
		if(n==0 && s==0) break;
		answer = 0;
		dfs(0,0,0);
		std::cout << answer << std::endl;
	}
	return 0;
}



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

typedef long long ll;

const int N = 1e5+1;
const ll INF = 1e18L+5;


void min_val(ll &a, ll b)
{
	a = min(a, b);
}

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

	vector<int> weight(n), value(n);

	for(int i = 0; i < n; ++i)
	{
		cin >> weight[i] >> value[i];
	}
	ll sum_value = 0;
	for(auto z : value)
	{
		sum_value += z;
	}

	std::vector<ll> dp(sum_value + 1, INF);
	dp[0] = 0;
	for(int item = 0; item < n; ++item)
	{
		for(int value_already = sum_value - value[item]; value_already >= 0; --value_already)
		{
			min_val(dp[value_already+value[item]], weight[item] + dp[value_already]);
		}
	}

	ll ans = 0;
	for(int i = 0; i <= sum_value; ++i)
	{
		if(dp[i] <= w)
			ans = max(ans, (ll)i);
	}
	cout << ans;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15); 
    int n, m; 
    cin >> n >> m;
    vector<int> a(m);
    vector<bool> b(10, 0); 
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
        b[a[i]] = 1; 
    }
    for (int i = n; ; ++i) {
        int x = i;
        bool flag = 1; 
        while (x) {
            if (b[x % 10]) {
                flag = 0; 
                break; 
            }
            x = x / 10; 
        }
        if (flag) {
            cout << i << endl; 
            break; 
        }
    }
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

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

    if(R < 1200){
        cout << "ABC" << endl;
    }else if(R < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
n = gets.to_i
h = gets.split.map(&:to_i)
dp = []
dp[0] = 0
dp[1] = (h[1] - h[0]).abs
(2...n).each do |k|
  dp[k] = [dp[k-2] + (h[k] - h[k-2]).abs,dp[k-1] + (h[k] - h[k-1]).abs].min
end
p dp[n-1]


Measured memory_bytes: 21176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,T,b;
  cin>>a;
  cin>>T;
  cin>>b;
  
  if (a*T < b){
    cout<< a*T <<endl;
  }
  else{
    cout<< b <<endl;
  }
}

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

int main(){
    int a,b;
    cin>>a>>b;
    if(a>b) cout<<"a"<<" > "<<"b"<<endl;
    else if(a<b) cout<<"a"<<" < "<<"b"<<endl;
    else cout<<"a"<<" == "<<"b"<<endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ll = long long;
using ii = pair<int, int>;

int32_t main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<ll> vs(n);
	for(auto &x:vs) cin >> x;
	sort(all(vs), greater<ll>());
	priority_queue<ll> pq;
	ll ans = vs[0];
	pq.push({vs[1]});
	pq.push({vs[1]});
	int i = 2;
	while(i<n){
		ans += pq.top(); pq.pop();
		pq.push(vs[i]);
		pq.push(vs[i]);
		++i;
	}
	cout << ans << endl;
}


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

int main() {
    int n;
    ll count=0;
    cin>>n;
    vector<int> a(n+1),b(n);
    rep(i,n+1) cin>>a.at(i);
    rep(i,n) cin>>b.at(i);

    rep(i,n) {
        if (a.at(i)+a.at(i+1) <= b.at(i)) {
            count+=a.at(i)+a.at(i+1);
            a.at(i+1)=0;
        } else if(a.at(i)<b.at(i)){
            count+=b.at(i);
            a.at(i+1)-=b.at(i)-a.at(i);
        } else {
            count+=b.at(i);
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pub push_back
#define pob pop_back
#define M 1000000007
#define pii pair<ll,ll>
#define mp make_pair
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    ll n,i,a[200006],z[200006],ans[200006]={0};
    cin>>n;
    for(i=0;i<200005;i++)z[i]=-1;
    for(i=0;i<n;i++)cin>>a[i];
    for(i=n-1;i>=0;i--)
    {
    	if(z[a[i]]!=-1 && z[a[i]]>i+1)
    	{
    		ans[i]=ans[z[a[i]]]+1;
    	}
    	ans[i]+=ans[i+1];
    	ans[i]%=M;
    	z[a[i]]=i;
    }
    cout<<ans[0]+1;

    return 0;
}

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

double eps = 1e-7;
double g=9.8;

double Sqrt(double x){
  if(x<0)return 0;
  return sqrt(x);
}

bool check(double a,double b,double c,double d){
  if(a>b)swap(a,b);
  if(c>d)swap(c,d);
  if( b-eps < c )return false;
  if( d-eps < a )return false;
  return true;
}

#define MAX_N 50
int N;
double V,X,Y;
double L[MAX_N],B[MAX_N],R[MAX_N],T[MAX_N];

double calcpy(double t,double vy){
  return (vy+vy-g*t)*t*0.5;
}

bool check(double t,double px,double py){
  double vx = px/t;
  double vy = Sqrt(V*V-vx*vx);

  if( vy < eps ) return false;
  
  for(int i=0;i<N;i++){
    if( X <= L[i] )continue;

    double ft = L[i] / vx;
    double st = R[i] / vx;
    double zt = vy / g;
    
    double fh = calcpy(ft,vy);
    double sh = calcpy(st,vy);
    double zh = calcpy(zt ,vy);
    
    if( check( B[i], T[i], fh, sh ) )return false;

    if( ft<= zt && zt <= st ){
      if( check( B[i], T[i], fh, zh ) )return false;
      if( check( B[i], T[i], zh, sh ) )return false;
    }
    
  }


  double lastT=X/vx;
  double lastY=calcpy(lastT,vy);

  if( lastY < Y - eps )return false;
  
  for(int i=0;i<N;i++){
    if( X < L[i]+eps ) continue;
    if( R[i]-eps < X ) continue;
    if( check(B[i],T[i],Y,lastY) )return false;
  }

  return true;
}

bool solve(double px,double py){
  double R=2*py;
  double A=g*g;
  double B=2*R*g-4.0*V*V;
  double C=R*R+4.0*px*px;
  if( B*B - 4.0*A*C < 0 )return false;
  if( abs(A) < eps ) return false;
  
  double t0 = (-B+Sqrt(B*B-4.0*A*C))/(2.0*A);
  double t1 = (-B-Sqrt(B*B-4.0*A*C))/(2.0*A);

  t0=Sqrt(t0);
  t1=Sqrt(t1);
  
  if(t0>eps && check(t0,px,py) )return true;
  if(t1>eps && check(t1,px,py) )return true;

  return false;
}

int main(){
  cin>>N>>V>>X>>Y;

  if( V < eps ){
    cout<<"No"<<endl;
    return 0;
  }
  
  for(int i=0;i<N;i++){
    cin>>L[i]>>B[i]>>R[i]>>T[i];
    if( X+1.0<R[i])R[i]=X+1.0;
    if( X+1.0<L[i])L[i]=X+1.0;
  }
  
  bool ans= solve(X,Y) ;
  for(int i=0;i<N;i++){
    if( solve(L[i],B[i]) )ans=true;
    if(ans)break;
    if( solve(L[i],T[i]) )ans=true;
    if(ans)break;
    
    if( solve(R[i],B[i]) )ans=true;
    if(ans)break;
    if( solve(R[i],T[i]) )ans=true;
    if(ans)break;
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

ll N, A, B;

int main() {
	cin >> N >> A >> B;
	ll ma = B * (N-1) + A;
	ll mi = A * (N-1) + B;
	if (A > B || (N == 1 && A != B)) {
		puts("0");
	} else {
		cout << ma - mi + 1 << endl;
	}
	return 0;
}

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

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

  vector<int> b(n - 1), a(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> b.at(i);
  }
  for (int i = 0; i < n - 1; i++) {
    if (i == 0 || b.at(i - 1) > b.at(i)) a.at(i) = b.at(i);
    a.at(i + 1) = b.at(i);
  }

  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a.at(i);
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,Q,a[2005],ans=1e9;
priority_queue<int>que;
vector<int>E;
void update(){
	while(!que.empty()){
		if(que.size()>=k)E.push_back(-que.top());
		que.pop();
	}
}
int main(){
	scanf("%d%d%d",&n,&k,&Q);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		int Min=a[i];
		for(int j=1;j<=n;j++){
			if(a[j]>=Min)que.push(-a[j]);
			else update();
		}
		update();
		if(E.size()>=1)sort(E.begin(),E.end());
		if(E.size()>=Q&&E[0]==Min)ans=min(ans,E[Q-1]-Min);
		E.clear();
	}
	printf("%d",ans);
	return 0;
}

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

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

    vector<int> p(n);
    vector<int> p_org(n);

    for ( int i = 0; i < n; i++ ) {
        cin >> p[i];
        p_org[i] = p[i];
    }

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

    int cnt = 0;
    for ( int i = 0; i < n; i++ ) {
//        cout << p[i] << endl;
        if ( p[i] != p_org[i] ) {
            cnt++;
        }
    }

    if ( cnt >= 3 ) {
        cout << "NO" << endl;
    }
    else {
        cout << "YES" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,T; cin >> N >> T;
    vector<vector<int>> c(N,vector<int> (2));
    for(int i = 0; i < N; i++)
    {
        cin >> c.at(i).at(0) >> c.at(i).at(1);
    }
    int ans = 1001;
    for(int i = 0; i < N; i++)
    {
        if(c.at(i).at(1) <= T)
        {
            if(ans > c.at(i).at(0))
            {
                ans = c.at(i).at(0);
            }
        }
    }
    if(ans == 1001)
    {
        cout << "TLE" << endl;
    }
    else
    {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    string s,t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    vector<vector<int> >is(26);
    for(int i=0;i<n;i++){
        is[s[i]-'a'].push_back(i);
    }
    for(int i=0;i<n;i++){
        is[s[i]-'a'].push_back(i+n);
    }
    ll ans=0;
    int p=0;
    for(int i=0;i<m;i++){
        int c=t[i]-'a';
        if(is[c].size()==0){
            cout<<"-1"<<endl;
            return 0;
        }
        p=*lower_bound(is[c].begin(),is[c].end(),p)+1;//p以上の最小の値

        if(p>=n){
            p-=n;
            ans+=n;
        }
    }
    ans+=p;
    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 1724
import sys
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
n, q = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

cnt = [0 for i in range(n)]
for _ in range(q):
    p, x = map(int, input().split())
    cnt[p-1] += x

def dfs(frm, cur):
    if cur > 0:
        cnt[cur] += cnt[frm]
    for to in edges[cur]:
        if frm != to:
            dfs(cur, to)

dfs(-1, 0)
print(*cnt)

Measured memory_bytes: 230920
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int n = sc.nextInt();
      if (n == 0) {
        break;
      }
      int sum = 0;
      int[] stu = new int[n];
      for(int i = 0; i < n; i++) {
        stu[i] = sc.nextInt();
        sum += stu[i];
      }
      double ave = sum / (double) n;
      double dveSum = 0.0;
      for(int i = 0; i < n; i++) {
        dveSum += Math.pow(stu[i] - ave, 2);
      }
      double dve = Math.sqrt(dveSum / (double) n);
      System.out.println(dve);
    }
  }
}



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

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

    int a = 0, b;
    for (int i = 0; i < n; i++) {
        cin >> b;
        if (b > a) b--;
        else if (b < a) {
            cout << "No" << endl;
            return 0;
        }
        a = b;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string S;
    cin >> S;
    S[3] = '8';
    cout << S << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	auto vs = vector<int>(v.begin(), v.end() - 1);
	int sum_vs = accumulate(vs.begin(), vs.end(), 0);
	int max_v = v[n -1];
	if (sum_vs > max_v) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
		
	int n;
	scanf("%d",&n);
	vector<double> dp(n+1);
	dp[0]=1;
	double p_heads;
	for (int coin=0; coin<n; ++coin){
		scanf("%lf",&p_heads);
		for (int i = coin+1; i>=0; --i){
			dp[i]= (i==0?0:dp[i-1]*p_heads)+dp[i]*(1-p_heads);
		}
	}
	double ans = 0;
	for (int heads=0;heads<=n;++heads){
		int tails = n- heads;
		if(heads >tails){
			ans += dp[heads];
		}
	}
	printf("%.10f",ans);
	
	return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  int maxValue = 0;
  int sum = 0;
  int L;
  for (int i = 0; i < N; ++i) {
    cin >> L;
    sum += L;
    maxValue = max(maxValue, L);
  }

  sum -= maxValue;
  if (maxValue < sum) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#define MAX (1000000)
using namespace std;

bool mon_sat[MAX + 1];

int div(int n, int i)
{
	printf("_%d %d\n", n, i);
	
	if (n % i != 0){
		return (n);
	}
	return (div(n / i, i));
}

int main()
{
	for (int i = 7; i <= MAX - 1; i += 7){
		mon_sat[i - 1] = true;
		mon_sat[i + 1] = true;
	}
	
	for (int i = 6; i * i <= MAX; i++){
		if (mon_sat[i]){
			for (int j = i * 2; j <= MAX; j += i){
//				printf("%d\n", j);
				mon_sat[j] = false;
			}
		}
	}
	
	int n;
	while (scanf("%d", &n), n != 1){
		printf("%d:", n);
		for (int i = 0; i <= n; i++){
			if (mon_sat[i] && n % i == 0){
				printf(" %d", i);
			}
		}
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 2012
#include <iostream>
#include <bitset>
#include <math.h>
#include <algorithm>
#include <vector>;
using namespace std;

vector<int> r;

int root(int x) {
	if (r[x] < 0) return x;
	return r[x] = root(r[x]);
}

bool unite(int x, int y) {
	x = root(x);
	y = root(y);
	if (x == y) return false;

	if (r[x] < r[y]) swap(x, y);
	r[y] += r[x];
	r[x] = y;
	return true;
}

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

	r = vector<int>(n,-1);

	for (int i = 0;i < m;i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		unite(a, b);
	}

	int ans = -1;
	for (int i = 0;i < n;i++) {
		ans = max(ans, -r[root(i)]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3940
#include<bits/stdc++.h>
using namespace std;
vector<int>vec;
//map<int,int>mp;
int main()
{

  int i,j,n,t,a,b,c;
  string s;
  cin>>a>>b>>c;
  int ara[3];
  ara[0]=a;
  ara[1]=b;
  ara[2]=c;
  sort(ara,ara+3);
  cout<<ara[0]+ara[1]<<"\n";


    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto ABC = RDR.ARR;
	auto K = RD;
	ABC.sort();
	ABC[2] = ABC[2] * 2^^K;

	writeln(ABC.sum);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public void exec() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int menseki = a*b;
		int shuu = (a+b)*2;
		System.out.println(menseki+" "+shuu);
	}

	public static void main(String[] args)  {
		new Main().exec();
	}
}

Measured memory_bytes: 25780
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

vector<int> G[100010];
int dp[100010];

int dfs(int n){
  if(!dp[n]){
    for(int i=0; i<G[n].size(); i++){
      dp[n]=max(dp[n],dfs(G[n][i])+1);
    }
    return dp[n];
  }
  else return dp[n];
}

int main(){
  int ans=0;
  int N, M;
  cin >> N >> M;
  int x[100010];
  int y[100010];
  for(int i=0; i<M; i++) cin >> x[i] >> y[i];
  for(int i=0; i<M; i++) G[x[i]].push_back(y[i]);
  for(int i=1; i<=N; i++) dp[i]=0;
  for(int i=1; i<=N; i++) dfs(i);
  for(int i=1; i<=N; i++) ans=max(ans,dp[i]);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(ll i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define LESEN std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;

const int MAX_V = 128;
const ll INF_F = 1e16;

struct Edge {int to; ll cap ; int rev;};

struct Dinic {
	vector <Edge> G[MAX_V];
	int level[MAX_V], iter[MAX_V];

	void add_edge(int from, int to, ll cap) {
		Edge e1 = {to, cap, (int)G[to].size()}, e2 = {from, 0, (int)G[from].size()-1};
		G[from].pb(e1), G[to].pb(e2);
	}

	void bfs(int s) {
		memset(level, -1, sizeof(level));
		queue <int> q;
		level[s] = 0;
		q.push(s);
		while(!q.empty()) {
			int v = q.front();
			q.pop();
			for (auto &e : G[v]) {
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}

	ll dfs(int v, int t, ll f) {
		if (v == t) return f;
		for (int &i = iter[v]; i < (int)G[v].size(); i++) {
			Edge &e = G[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	ll max_flow(int s, int t) {
		ll flow = 0;
		while (1) {
			bfs(s);
			if (level[t] < 0) return flow;
			memset(iter, 0, sizeof(iter));
			ll f;
			while ((f = dfs(s, t, INF_F)) > 0) {
				flow += f;
			}
		}
	}

};

void solve(void){
	LESEN;
	ll N;
	cin >> N;
	vector <ll> as(N);
	rep(N ,i) cin >> as[i];
	Dinic dinic;
	ll sum = 0LL;
	Rep(1, N, i) {
		if (as[i-1] >= 0LL) {
			dinic.add_edge(0, i, as[i-1]);
			sum += as[i-1];
		}
		else {
			dinic.add_edge(i, N+1, -as[i-1]);
		}
		ll j = 2;
		while (j * i <= N) {
			dinic.add_edge(i*j, i, INF_F);
			j++;
		}
	}
	cout << sum - dinic.max_flow(0, N+1) << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <list>
#include <algorithm>

using namespace std;

long long lcm(long long a, long long b){
  long long t_a = a, t_b = b;;
  if(b > a) swap(a, b);

  long long r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }
  return t_a / b * t_b;
}

int main(){
  int n;
  list<long long> l;

  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    long long t;
    scanf("%lld", &t);
    l.push_back(t);
  }

  while(l.size() != 1){
    long long t1 = *l.begin(); l.pop_front();
    long long t2 = *l.begin(); l.pop_front();
    l.push_back(lcm(t1, t2));
  }

  printf("%lld\n", *l.begin());

  return 0;
}


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

int n;
int p[20];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> p[i];
	
	int ans = 0;
	for (i = 1; i < n - 1; i++) {
		if (p[i] != max({p[i-1], p[i], p[i+1]}) && p[i] != min({p[i-1], p[i], p[i+1]})) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256