akhauriyash/Code-Regression huggingface dataset:
X,N = map(int,input().split())
P = list(map(int,input().split()))
if X not in P:
    print(X)
else:
    d = 1
    while True:
        if X-d not in P:
            print(X-d)
            break
        if X+d not in P:
            print(X+d)
            break
        d += 1

Measured memory_bytes: 61864
#include<iostream>
using namespace std;
int n,a[100010];
bool vis[100010]={false};
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];a[i]--;
	}
	int ans=0,pnt=0;
	while(true){
		if(pnt==1)break;
		if(vis[pnt]){
			ans=-1;
			break;
		}
		vis[pnt]=true;
		pnt=a[pnt];
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 768
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n; cin>>n;
    ll ans=n*(n+1)/2,cnt=0;
    ll l=0,r=0;
    vector<ll> a(n,0);
    rep(i,n) cin>>a[i];
    ll sum=a[0],xsum=a[0];
    while(r<n){
        if(sum==xsum){
            r++;
            if(r<n){
                sum+=a[r]; xsum^=a[r];
            }
        }
        else{
            cnt+=n-r;
            sum-=a[l]; xsum^=a[l];
            l++;
        }
    }
    cout<<ans-cnt<<endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    def c(x):
        return 1 <= x <= 9
    if c(a) and c(b):
        print(a * b)
        return
    print(-1)
    return

#B
def B():
    a = set()
    for i in range(10):
        for k in range(10):
            a.add(i * k)
    x = II()
    if x in a:
        print("Yes")
    else:
        print("No")
    return

#C
def C():
    n = II()
    factlize = []
    ans = inf
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            ans = min(ans, n // i + i - 2)
    print(ans)
    return

#D
def D():
    a, b, x = LI()
    from math import atan, pi
    if a * a * b / 2 <= x:
        print(atan(2 * (a * a * b - x) / (a * a * a)) * 180 / pi)
    else:
        print((pi / 2 - atan(2 * x / (a * b * b))) * 180 / pi)
    return

#E
def E():
    def solve(m):
        a1 = a[::-1]
        f1 = f[::1]
        res = 0
        for i in range(n):
            if a1[i] * f1[i] <= m:
                continue
            k = m // f1[i]
            res += a1[i] - k
            if res > K:
                return False
        return True

    n, K = LI()
    a = LI()
    a.sort()
    f = LI()
    f.sort()
    ok = max(a) * max(f)
    ng = -1
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if solve(mid):
            ok = mid
        else:
            ng = mid
    print(ok)
    return

#F
def F():
    return


#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 40304
x,y =map(int,input().split())
p=0
for i in range(x+1):
    t=i
    k=x-t
    tashi=2*t
    kashi=4*k
    if tashi+kashi==y:
        p=1
        print('Yes')
        break
if p==0:
    print('No')



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

int main() {
  double R;
  cin >> R;
  
  printf("%0.10f", 2*R * M_PI);
  return 0;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    int n;
    cin >> n;
    int r= n%1000;
    if(r>0){
        cout << 1000-r << endl;
        return 0;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
    int main(){
    string O, E;
    cin >> O >> E;
    for(int i=0;i<O.size()+E.size();i++){
    if(i%2==0){
        cout<<O.at(i/2);
    }else{
        cout<<E.at(i/2);
    }
    }
    return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  ll i,j;
  ll ans = 0;
  string s; cin >> s;
  if(s=="SUN"){cout << 7 << endl; return 0;}
  if(s=="MON"){cout << 6 << endl; return 0;}
  if(s=="TUE"){cout << 5 << endl; return 0;}
  if(s=="WED"){cout << 4 << endl; return 0;}
  if(s=="THU"){cout << 3 << endl; return 0;}
  if(s=="FRI"){cout << 2 << endl; return 0;}
  if(s=="SAT"){cout << 1 << endl; return 0;}

  return 0;
}


Measured memory_bytes: 256
# seishin.py
N = int(input())
*A, = map(int, input().split())
S = sum(A)

b = 1
for a in A:
    b |= b << a
b >>= (S + 1) // 2
print((b & -b).bit_length() - 1 + (S + 1) // 2)

Measured memory_bytes: 5460
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N;
	cin>>N;
	vector < int> vect;
	int k=3;
	int product=1,j=1,a,b,c,i=1;
	while(product<=10*N)
	{
		product=j*j;
		vect.push_back(product);
		j++;
	}
//	cout<<vect.size()<<"\n";
	
	vector <int> vect1(N,0);
	
	
	for(i=0;i<vect.size();i++)
	{
		for(a=1;a<=i+1;a++)
		{
			for(b=1;b<=i+1;b++)
			{
				c=i+1-(a+b);
				if(c>0)
				{
					j=vect[i]-(a*b+b*c+c*a)-1;
					if((j<N)&&(j>0))
					vect1[j]++;
				}
			}
		}
	}
	for(i=0;i<N;i++)
	cout<<vect1[i]<<"\n";
	return 0;
}

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

int main(){
    const int i = 3;
    char S[i];

    for(int j=0; j<i; j++){
        cin >> S[j];
    }

    if(S[0] == 'A' && S[1] == 'A' && S[2] == 'A' ){
        cout << "No" << endl;
    }else if(S[0] == 'B' && S[1] == 'B' && S[2] == 'B'){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
n,k = gets.split.map(&:to_i)

cnt = Array.new(k, 0)
1.upto(n) do |i|
  cnt[i % k] += 1
end

ans = 0
k.times do |i|
  a = i
  b = (k - a) % k
  c = (k - a) % k
  next unless (b + c) % k == 0
  ans += cnt[a] * cnt[b] * cnt[c]
end

puts ans


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

int main(){
  int a,b;
  cin >> a >> b;
  int ans = 0, i = 0;
  while(i<2){
    if(a>b){
      ans += a;
      a--;
    }
    else{
      ans += b;
      b--;
    }
    i++;
  }
  cout << ans << endl;
}

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

typedef long long ll;

int main() {
  set<int> st;
  int q; cin >> q;
  for(int i=0; i<q; i++){
    int query, x;
    cin >> query >> x;
    if(query==0){
      st.insert(x);
      cout << st.size() << endl;
    }
    else if(query==1){
      auto itr = st.find(x);
      if(itr != st.end()) cout << 1 << endl;
      else cout << 0 << endl;
    }
    else {
      st.erase(x);
    }
  }
}


Measured memory_bytes: 12412
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n,k;cin>>n>>k;
    vector<double> p(n);
    rep(i,n)cin>>p[i];

    double e=0.0;
    rep(i,k){
        e += (1.0+p[i])/2.0;
    }
    
    double ans=e;
    rep(i,n-k){
        e = e - p[i]/2.0 + p[i+k]/2.0;
        ans=max(ans,e);
    }

    cout<<fixed<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	scanf("%d",&n);
	int arr[n+1];
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&arr[i]);
	}
	int ans[n+1];
	int p=1;
	if(n%2==0)
	{
		for(int i=n;i>=1;i-=2)
		{
			ans[p]=arr[i];
			p++;
		}
		for(int i=1;i<=n;i+=2)
		{
			ans[p]=arr[i];
			p++;
		}
	}
	else
	{
		for(int i=n;i>=1;i-=2)
		{
			ans[p]=arr[i];
			p++;
		}
		for(int i=2;i<=n;i+=2)
		{
			ans[p]=arr[i];
			p++;
		}
	}
	for(int i=1;i<=n;i++)
		printf("%d ",ans[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 3712
S = list(input())
c = 0
ans = [0]*(len(S))
l = len(S)

for i in range(l-1):
    if S[i] == "R" and S[i+1] == "R":
        c += 1
    if S[i] == "R" and S[i+1] == "L":
        if c % 2 == 0:
            ans[i] += c//2 + 1
            ans[i+1] += c//2 + 1
        else:
            ans[i] += c//2 + 1
            ans[i+1] += c//2 + 2
        c = 0

for j in range(-1,-l,-1):
    if S[j] == "L" and S[j-1] == "L":
        c += 1
    if S[j] == "L" and S[j-1] == "R":
        if c % 2 == 0:
            ans[j] += c//2
            ans[j-1] += c//2
        else:
            ans[j] += c//2
            ans[j-1] += c//2 + 1
        c = 0

for i in ans:
    print(i,end=" ")

Measured memory_bytes: 55672
N=int(input())
A=[]
A=list(map(int,list(input().split())))
S=[0]*201

C=10**7
for k in range(0,201):
    for i in range(N):
        B=(k-100)-A[i]
        S[k]+=B*B
    if C>S[k]:
        C=S[k]
print(C)

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

typedef long long ll;
static const int INF = 1e9+7;

int main(){
    int data[32] = {
        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
    };

    int K;
    cin>>K;

    cout<<data[K-1]<<endl;    

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100
#define Wh 0
#define Gr 1
#define Bl 2

int n;
int M[N][N];
int color[N],d[N],f[N],tt;

void dv(int u);
void dfs();

int main(void)
{
  int u,v,k;
  int i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  M[i][j]=0;
	}
    }

  for(i=0;i<n;i++)
    {
      scanf("%d%d",&u,&k);

      u--;

      for(j=0;j<k;j++)
	{
	  scanf("%d",&v);

	  v--;

	  M[u][v]=1;
	}
      
    }

  dfs();

  return 0;
}

void dv(int u)
{
  int v;

  color[u]=Gr;

  d[u]=++tt;

  for(v=0;v<n;v++)
    {
      if(M[u][v]==0)
	{
	  continue;
	}

      if(color[v]==Wh)
	{
	  dv(v);
	}

    }

  color[u]=Bl;

  f[u]=++tt;
}

void dfs()
{
  int u;

  for(u=0;u<n;u++)
    {
      color[u]=Wh;
    }
  
  tt=0;

  for(u=0;u<n;u++)
    {
      if(color[u]==Wh)
	{
	  dv(u);
	}

    }

  for(u=0;u<n;u++)
    {
      printf("%d %d %d\n",u+1,d[u],f[u]);
    }
  
}



Measured memory_bytes: 2104
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
	string S;
	cin >> S;
	ll an=0,c=0;
	
	
	for (int i = 0; i < S.size(); i++) {
		if (S.at(i) == 'A' || S.at(i) == 'G' || S.at(i) == 'C' || S.at(i) == 'T')
		{
			c++;
		}
		else {
			c = 0;
		}
		an = max(an, c);
	}


	cout << an << endl;

	
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
ans = 0

for i in range(1, n-1):
  if min(p[i-1], p[i], p[i+1]) < p[i] < max(p[i-1], p[i], p[i+1]):
    ans += 1

print(ans)  

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

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

using namespace std;

int main()
{
    int n,m,p;
    while(cin >> n >> m >> p) {
        if(n == 0 && m == 0 && p == 0) break;
        
        vector<int> X(n);
        int sum = 0;
        rep(i,n) { 
            cin >> X[i];
            sum += X[i];
        }

        sum *= (100 - p);
        if(X[m-1] == 0) cout << 0 << endl;
        else {
            sum /= X[m-1];

            cout << sum << endl;
        }
    }
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N,A;
	cin >> N;
	vector<int> v;
	for (int i = 0; i < N; i++) {
		cin >> A;
		v.push_back(A);
	}
	sort(v.begin(),v.end());
	for (int i = 1; i < N; i++) {
		if (v[i] == v[i - 1]) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 1400
def find_index_by_value(a, val):
    for i, items in enumerate(a):
        if val in items:
            return i
    return -1


def num_reachable(n):
    return n * (n - 1) // 2


n, m = map(int, input().split())
edges = []

for _ in range(m):
    a, b = map(int, input().split())
    edges.append((a, b))

size = [1 for _ in range(n + 1)]
group = [i for i in range(n + 1)]


def find_group(x):
    c = []
    p = x
    while True:
        pp = group[p]
        if pp == p:
            break
        else:
            c.append(p)
            p = pp
    for i in c:
        group[i] = pp
    return pp

# find_group = lambda x: x if x == group[x] else find_group(group[x])

ans = []
not_reachable = n * (n - 1) // 2
reachable_node = []
ans.append(not_reachable)

count = not_reachable
reachable = 0
for _ in range(m - 1):
    a, b = edges.pop()
    if count > 0:
        ra = find_group(a)
        rb = find_group(b)
        if rb != ra:
            s_ra = size[ra]
            s_rb = size[rb]
            new_size = s_ra + s_rb
            reachable += num_reachable(new_size) - num_reachable(s_ra) - num_reachable(s_rb)
            size[ra] = new_size
            group[rb] = ra
        count = not_reachable - reachable
    ans.append(count)

for _ in range(len(ans)):
    print(ans.pop())

Measured memory_bytes: 21864
while True:
	arr = list(map(int, input().split()))
	n = arr[0]
	x = arr[1]

	if n == 0 and x == 0:
		break
	ans = 0
	for i in range(1, n + 1):
		for j in range(i + 1, n + 1):
			for k in range(j + 1, n + 1):
				if i + j + k == x:
					ans += 1
	print(ans)



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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        string s;
        cin>>s;
        
        int n=s.length();
        int mini=INT_MAX;
        int x;
        for(int i=0;i<=n-3;i++){
        	string ans;
            for(int j=i;j<i+3;j++){
                ans+=s[j];
                x=stoi(ans);
                x=abs(x-753);
                
            }
            // cout<<ans<<" ";
            // cout<<x<<endl;
            mini=min(x,mini);
        }
        cout<<mini<<endl;
    }   
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  int n,y;
  cin >> n >> y;
  int p = y/10000;
  int r = y/5000;
  rep(i,p+1)rep(j,r+1){
    int q = y-10000*i-5000*j;
    if(q<0) continue;
    if(q%1000==0 && q/1000+i+j==n){
      cout << i << " " << j << " " << q/1000 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}




Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 
 
void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
 
double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}
 
ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}
 
ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
 
vec modncrlistp,modncrlistm;
 
ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}
 
ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}
 
ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}
 
ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  ll i,N,x=inf,id=0;
  cin>>N;
  set<ll> se;
  rep(i,N){
    cin>>x;
    se.insert(x);
  }
  cout<<se.size()<<endl;
  return 0;
}


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

using namespace std;

const int base = -2;

int n;

void solve(){
    string ans = "";
    if (n == 0) {
        printf("0");
        return;
    }

    while (n != 0) {
        int rem = n % base;
        n /= base;

        if (rem < 0) {
            rem += 2;
            n++;
        }

        ans = (char)(rem + '0') + ans;
    }

    cout << ans;
}

int main(){
    scanf("%d", &n);
    solve();
    return 0;
}


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

int main() {
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int A,B,C,D;
	A=0;
	for(int i=0;i<a;i++){
		if(i<b){
			A=A+c;
		}else if(i<a){
			A=A+d;
		}
	}
	cout << A << endl;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc155/tasks/abc155_d
// AtCoder Beginner Contest 155
// D - Pairs
// tutorial AC

/*
Problem.
数列A(-10^9 <= A[i] <= 10^9)が与えられて、
各要素のペアの積で、k番目に小さい値?

Point.
k番目の値xについて二分探索を行う。
  各要素について、
    積がx未満となるペアを二分探索で探す。
    ペア数を集計
決定したxを出力すれば良い。
*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

using namespace std;

using ll = long long;
const ll INF = ll(1e18) + 1;

int main(){
  long long n, k; cin >> n >> k;
  vector<long long> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll l = -INF, r = INF;
  while(l + 1 < r){
    ll x = (l+r)/2;
    bool ok = [&]{
      ll tot = 0;
      for(int i = 0; i < n; i++){
        int l = -1, r = n;
        if(a[i] < 0){ //負の時
          while(l+1 < r){
            int c = (l+r)/2;
            if(a[c]*a[i] < x) r = c;
            else l = c;
          }
          tot += n-r;
        }else{        //正の時
          while(l+1 < r){
            int c = (l+r)/2;
            if(a[c]*a[i] < x) l = c;
            else r = c;
          }
          tot += r;
        }
        if(a[i] * a[i] < x) tot--;
      }
      tot /= 2;
      return tot < k;
    }();
    if(ok) l = x;
    else r = x;
  }
  cout << l << endl;
}


Measured memory_bytes: 1792
import sys
from itertools import accumulate


def main():
    input = sys.stdin.readline
    n, q = [int(i) for i in input().split()]
    s = input().strip()
    qs = [[int(i) for i in input().split()] for _ in range(q)]
    hoges = [0] + [1 if s[i : i + 2] == "AC" else 0 for i in range(n - 1)]
    hoges = list(accumulate(hoges))
    for (l, r) in qs:
        print(hoges[r - 1] - hoges[l - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 27392
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int matrix[1000][1000] = {};
class UnionFind
{
public:
	UnionFind(int min, int max)
		: elems_(max - min + 1)
		, min_(min)
		, rank_(max - min + 1)
	{
		for (int i = min; i <= max; i++) {
			Elem& elem = this->elems_[i - min];
			elem.i = i;
			elem.num = 1;
		}
	}

	int find(int i) {
		int idx = i - this->min_;
		if (this->elems_[idx].i == i) return i;

		int root = this->find(this->elems_[idx].i);
		this->elems_[idx].i = root; // 簡略化
		return root;
	}

	int size(int i) {
		int root = this->find(i);
		int idx = root - this->min_;
		return this->elems_[idx].num;
	}

	int rank() {
		return rank_;
	}

	void merge(int i, int j) {
		int i_root = this->find(i);
		int j_root = this->find(j);
		if (i_root == j_root) return;

		int i_idx = i_root - this->min_;
		int j_idx = j_root - this->min_;

		int i_size = this->elems_[i_idx].num;
		int j_size = this->elems_[j_idx].num;

		if (i_size < j_size) {
			this->elems_[i_idx].i = j_root;
			this->elems_[j_idx].num += this->elems_[i_idx].num;
		}
		else {
			this->elems_[j_idx].i = i_root;
			this->elems_[i_idx].num += this->elems_[j_idx].num;
		}
		this->rank_--;
	}

private:
	struct Elem {
		int i;
		int num; // root 以外は無効
	};

	vector<Elem> elems_;
	int          min_;
	int          rank_;
};

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

	int n, k; cin >> n >> k;

	vector<int> vals(n + 1);
	FOR_LT(i, 0, n) {
		cin >> vals[i];
	}

	UnionFind uf = UnionFind(0, n - k);

	vector<int> mina(n);
	{
		deque<int> cont;
		FOR_LT(i, 0, n) {
			while (!cont.empty() && cont.back() > vals[i]) cont.pop_back();
			cont.push_back(vals[i]);
			if (i < k - 1) continue;

			mina[i - (k - 1)] = cont.front();
			if (cont.front() == vals[i - (k - 1)]) cont.pop_front();
		}
	}

	vector<int> maxa(n);
	{
		deque<int> cont;
		FOR_LT(i, 0, n) {
			while (!cont.empty() && cont.back() < vals[i]) cont.pop_back();
			cont.push_back(vals[i]);
			if (i < k) continue;

			maxa[i - k] = cont.front();
			if (cont.front() == vals[i - k]) cont.pop_front();
		}
	}

	FOR_LT(i, 0, n - k) {
		if (mina[i] == vals[i] && maxa[i] == vals[i + k]) {
			uf.merge(i, i + 1);
		}
	}


	int prev = -1;
	int count = 0;
	FOR_LT(i, 0, n - 1) {
		if (vals[i] < vals[i + 1]) {
			count++;
		}
		else {
			count = 0;
		}
		if (k - 1 <= count) {
			if (prev != -1) {
				uf.merge(prev, i - (k - 2));
			}
			prev = i - (k - 2);
		}
	}

	cout << uf.rank() << endl;

	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class H> void rsz(V<T> &v, H h) { v.resize(h); }
template<class T, class H, class... R> void rsz(V<T> &v, H h, R... r) { v.resize(h); for (auto&& i : v) rsz(i, r...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int r; cin >> r;
  if (r < 1200) return cout << "ABC" << '\n', 0;
  if (r < 2800) return cout << "ARC" << '\n', 0;
  cout << "AGC" << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
#define     mod            (int)1e9+7
#define     MOD             998244353
#define     ll              long long
#define     mp              make_pair
#define     F               first
#define     S               second
#define     t()             int test;cin>>test;while(test--)
#define     ii              pair<int,int>
#define     que_max         priority_queue <int>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n"
#define     sz(x)           (int)(x).size()
#define     grid            vector<vector<int> >
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;
  //use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

int const maxm = 1e5 + 5;

std::vector<int> dp(maxm, 0), adj[maxm];


int cdp(int node)
{
  int &ans = dp[node];

  if (!ans)
  {
    for (auto v : adj[node])
      ans = max(ans, cdp(v));

    ++ans;
  }

  return ans;
}


int main()
{
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif

  IOS;

  int n, m;

  cin >> n >> m;

  while (m--)
  {
    int u, v;

    cin >> u >> v;

    u--, v--;

    adj[u].push_back(v);
  }

  int ans = 0;

  for (int i = 0; i < n; i++)
  {
    ans = max(cdp(i), ans);
  }

  cout << ans - 1 << endl;










}

Measured memory_bytes: 10544
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main() {
	ll lu[87];
	lu[0]=2,lu[1]=1;
	for(int i=2;i<87;i++){
		lu[i]=lu[i-1]+lu[i-2];
	}
	int n;
	cin>>n;
	cout<<lu[n];
	return 0;
}

Measured memory_bytes: 3608
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h,n=LI()
  l=LI()

  if h<=sum(l):
    return 'Yes'
  return 'No'

# main()
print(main())


Measured memory_bytes: 16308
N,Y = map(int,input().split())
for i in range(N+1):
  for j in range(N-i+1):
      if 10000*i + 5000*j + 1000*(N-i-j) == Y:
        print(i,j,N-i-j)
        exit()
      elif i == N:
        print("-1 -1 -1")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)

int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//CODE TONOY
	    string s;
        cin>>s;
        int a;
        for(int i=0;i<s.size();i++){
            a^=s[i];
        }
        if(a==0){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char vet[10];

    scanf("%s",vet);

    if (strcmp(vet,"SUN")==0){
        printf("7\n");
    }
    if (strcmp(vet,"MON")==0){
        printf("6\n");
    }
    if (strcmp(vet,"TUE")==0){
        printf("5\n");
    }
    if (strcmp(vet,"WED")==0){
        printf("4\n");
    }
    if (strcmp(vet,"THU")==0){
        printf("3\n");
    }
    if (strcmp(vet,"FRI")==0){
        printf("2\n");
    }
    if (strcmp(vet,"SAT")==0){
        printf("1\n");
    }


    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 100010
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

class UnionFind{
    private:
        int par_[MAX_N];
        int rank_[MAX_N];
        int groups_;
    
    public:
        void init(int n){ // initializes the tree 
            for(int i=0; i<n; i++){
                par_[i] = i;
                rank_[i] = 0;
            }
            groups_ = n;
        } 
        int rootOf(int x){ // returns the root of x 
            if(par_[x] == x){
                return x;
            }
            else{
                return par_[x] = rootOf(par_[x]);
            }
        } 
        void unite(int x, int y){ // unites x and y 
            x = rootOf(x);
            y = rootOf(y);
            if(x == y) return;
            if(rank_[x] < rank_[y]){
                par_[x] = y;
                groups_--;
            }
            else{
                par_[y] = x;
                groups_--;
                if(rank_[x] == rank_[y]) rank_[x]++;
            }
        }
        bool isSameGroupe(int x, int y){ // whether x and y are united
            return rootOf(x) == rootOf(y);
        }
        int countGroups(){ // returns the number of groups
            return groups_;
        }
};

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

    UnionFind tree;
    tree.init(n);

    
    for(int i=0; i<m; i++){
        int x,y,z;
        cin >> x >> y >> z;
        tree.unite(x-1, y-1);
    }

    cout << tree.countGroups();

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

ll cnt(string s) {
    ll res = 0;

    rep(i, s.size() - 1) {
        if (s[i] == s[i + 1]) {
            s[i + 1] = '0';
            res++;
        }
    }
    return res;
}

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

    string s;
    cin >> s;
    ll k;
    cin >> k;
    bool one_letter = true;

    rep(i, s.size()) {
        if (s[i] != s[0]) one_letter = false;
    }

    if (one_letter) {
        cout << (ll) s.size() * k / 2 << endl;
        return 0;
    }

    string t = s + s;
    ll a1 = cnt(s);
    ll a2 = cnt(t);
    ll p = a2 - a1, q = a1 - p;
    cout << p * k + q << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,c,p=0;
cin>>n>>k;
if(k>=1&&n>=k&&n<=1000){
int x[n];
for(int i=0;i<n;i++){
    while(true){
    cin>>x[i];
    if(x[i]>=1&&x[i]<=1000)
        break;
    }
}
for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
        if(x[i]>x[j]){
            c = x[i];
            x[i] = x[j];
            x[j] = c;
        }}}
for(int i=0;i<k;i++)
    p+=x[i];
cout<<p<<endl;}

return 0;}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=2e5+100;
const int M=4e5+100;
const int mod=1e9+7;
int a[N];
int tmp[N];
int tot;
map<int,int>MM1;
map<int,int>MM2;
int main()
{
	int n;
	while(cin>>n)
	{
		MM1.clear();
		MM2.clear();
		for(int i=1;i<=n;i++)cin>>a[i];
		tot=0;
		LL ans=0;
		for(int i=1;i<=n;i++)tmp[++tot]=abs(n-i-i+1),MM1[tmp[tot]]++;
		int f=0;
		for(int i=1;i<=n;i++)
		{
			int kk=lower_bound(tmp+1,tmp+1+tot,a[i])-tmp;
			if(!(kk>=1&&kk<=tot))
			{
				f=1;
				break;
			}
			MM2[a[i]]++;
		}
		for(int i=1;i<=tot;i++)
		{
			if(MM1[tmp[i]]!=MM2[tmp[i]])
			{
				f=1;
				break;
			}
		}
		if(f)
		{
			cout<<"0"<<endl;
		}
		else
		{
			ans=1;
			for(int i=1;i<=tot;i++)
			{
				if(MM1[tmp[i]]==2||tmp[i]==0)
				{
					ans=ans%mod*(LL)MM1[tmp[i]]%mod;
					ans%=mod;
					MM1[tmp[i]]--;
				}
			}
			cout<<ans<<endl;
		}		
	}
	return 0;
}

Measured memory_bytes: 6400
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int a[35][100005],b[100005];

int main()
{ios_base::sync_with_stdio(false);
int n,cc;
cin>>n>>cc;
while(n--)
{
	int s,t,c;
	cin>>s>>t>>c;
	a[c][s]++;
	a[c][t+1]--;
}

rep(i,1,30)
{
	rep(j,1,100004)
	{
		a[i][j]+=a[i][j-1];
		if(a[i][j]>0)
		{
			b[j]++;
		}
	}
}
int ans=0;
rep(i,1,100004)ans=max(ans,b[i]);
ol(ans);
return 0;
}



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

bool A[222][222];
bool Kf[222][222];
bool Kg[222][222];
bool Lf[222][222];
bool Lg[222][222];
bool Op[222][222];

bool Ek[222][222];
bool El[222][222];
bool Ep[222][222];


bool Exp[222][222];

int N,M,S,T;


typedef pair<int,int> P;

bool update( int i, int k, int j ){
  bool f = false;
  if( !Ep[i][j] && Exp[i][k] && Op[k][j] ) Ep[i][j] = f = true;
  
  if( !Exp[i][j] && Ep[i][k] && Exp[k][j] ) Exp[i][j] = f = true;
  
  if( !Ek[i][j] && Exp[i][k] && Kg[k][j] ) Ek[i][j] = f = true;
  if( !El[i][j] && Exp[i][k] && Lg[k][j] ) El[i][j] = f = true;
  
  if( !Exp[i][j] && Kf[i][k] && Ek[k][j] ) Exp[i][j] = f = true;
  if( !Exp[i][j] && Lf[i][k] && El[k][j] ) Exp[i][j] = f = true;
  return f;
}

int main(){
  while( cin >> N >> M >> S >> T && (N|M|S|T) ){
    --S;--T;
    memset(A,0,sizeof(A));
    memset(Kf,0,sizeof(Kf));
    memset(Kg,0,sizeof(Kg));
    memset(Lf,0,sizeof(Lf));
    memset(Lg,0,sizeof(Lg));
    memset(Op,0,sizeof(Op));
    
    memset(Ek,0,sizeof(Ek));
    memset(El,0,sizeof(El));   
    memset(Ep,0,sizeof(Ep));
 
    memset(Exp,0,sizeof(Exp));


    queue<P> q;
 
    for(int i=0;i<M;i++){
      int a,b;char c;
      cin >> a >> b >> c;
      a--; b--;
      if( c == 'a' ) Exp[a][b] = true;
      if( c == '+' || c == '*' ) Op[a][b] = true;
      if( c == '(' ) Kf[a][b] = true;
      if( c == ')' ) Kg[a][b] = true;
      if( c == '[' ) Lf[a][b] = true;
      if( c == ']' ) Lg[a][b] = true;

      q.push( P(a,b) );
    }

    while( !q.empty() ){      
      P p = q.front(); q.pop();
      for(int i=0;i<N;i++){
        if( update( i, p.first, p.second ) ) q.push( P(i, p.second) );
        if( update( p.first, p.second , i) ) q.push( P(p.first, i ) );
      }          
    }
 
    if( Exp[S][T] ) cout << "Yes" << endl;
    else cout << "No" << endl;
 
  }
 
}

Measured memory_bytes: 3136
#include "bits/stdc++.h"
using namespace std;
int main(void){
  char a[10],b[10],c[10],r[3];
  cin >> a >> b >> c;
  r[0] = a[0];
  r[1] = b[0];
  r[2] = c[0];
  for (int i = 0;i < 3;i++){
    r[i] = toupper(r[i]);
  }
  cout << r << endl;
}

Measured memory_bytes: 256
N, M = [int(i) for i in input().split()]

S, G = set(), set()
for _ in range(M):
    a, b = [int(i) for i in input().split()]
    if a == 1:
        S.add(b)
    if b == N:
        G.add(a)

if any(s in G for s in S):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 19136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
/* 一括cin */
template<class H>
void CIN(H& h){cin>>h;}
template<class H, class... T>
void CIN(H &h, T&... t){cin>>h;CIN(t...);}
/* デバッグ */
namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}
using vi = vector<int>;
using vvi = vector<vi>;
#define pb push_back
#define all(v) (v).begin(), (v).end()

int main(){
  int n,m;CIN(n,m);
  vvi S(m);
  rep(i,m){
    int k;cin>>k;
    rep(j,k){
      int s;cin>>s;s--;
      S[i].push_back(s);
    }
  }
  vi P;
  rep(i,m){
    int p;cin>>p;P.push_back(p);
  }

  int ans = 0;
  for(int onoff = 0; onoff<(1<<n); onoff++){
    //全てのonoffパターンについてbit全探索
    int rec = 0;//ついてるlamp
    for(int lamp = 0; lamp<m; lamp++){
      int num = 0;//on
      for(int x: S[lamp]){
        //lampの各スイッチ設定について
        if(1<<x & onoff)num++;
      }
      if(num%2 == P[lamp]){
        rec++;
        //DEBUG(onoff,lamp);
      }
    }
    if(rec == m)ans++;
  }
  debug(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
int a[3];
int b[3];
long long n;
bool is = false;
long long memo[25000003];
long long dp(int val){
    for (int i=0; i<=val; i++){
        memo[i] = max(memo[i], (long long)i);
        //cout << memo[i] << " ";
        if (is){
            for (int j=0; j<3; j++){
                if (i+b[j] <= val){
                    memo[i+b[j]] = max(memo[i+b[j]], memo[i]+a[j]);
                }
            }
        }else{
            for (int j=0; j<3; j++){
                if (i+a[j] <= val){
                    memo[i+a[j]] = max(memo[i+a[j]], memo[i]+b[j]);
                }
            }
            
        }
    }

    return memo[val];
}
int main ()
{
  prep();

  cin >> n;

  for (int i=0; i<3; i++){
      cin >> a[i];
  }
  for (int i=0; i<3; i++){
      cin >> b[i];
  }
  //iota(memo, memo+5001, 0);
  n = dp(n);
  is = true;
  memset(memo, 0, sizeof(long long)*5001);
  n = dp(n);
  cout << n;
  return 0; 
}


Measured memory_bytes: 195584
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string odd, even;
  	cin >> odd >> even;
  	for (int i = 0; i < even.length(); i++){
    	cout << odd[i] << even[i];
    }
  	if (odd.length() - even.length() == 1){
    	cout << odd[odd.length() - 1];
    }
}

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

int main(){
	int h,w;

	cin >>h >>w;
	string array[h];
	for(int i=0;i<h;i++){
		cin >>array[i];
	}
	for(int i=0;i<h;i++){
		cout<<array[i]<<endl;
		cout<<array[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

bool isPalin(string &s) {
	int wsk = 0;
	while (wsk < s.size()) {
		if (s[wsk] != s[s.size() - 1 - wsk]) return false;
		++wsk;
	}
	return true;
}
int main() {
	ios_base::sync_with_stdio(false);

	string s;
	cin >> s;
	int n = s.size();
	string l1 = s.substr(0, (n - 1) /2);
	string l2 = s.substr((n + 3) / 2  - 1);
	// cout << l1 << ' ' << l2 << endl;
	bool ok = isPalin(s) && isPalin(l1) && isPalin(l2);
	cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

int main() {
  std::cout << std::fixed << std::setprecision(10);
  ll n, k;
  scanf("%lld %lld", &n, &k);

  vector<ll> p(n);
  for (ll i = 0; i < n; i++) {
    ll v;
    scanf("%lld", &v);
    ll k = (v - 1);
    p[i] = k;
  }

  ll current = 0;
  ll width = 0;

  ll maxValue = 0;
  for (ll i = 0; i < n; i++) {
    if (width < k) {
      current += p[i];
      width += 1;
    } else {
      current += p[i];
      current -= p[i - k];
    }

    maxValue = max(maxValue, current);
  }

  // cout << maxValue << endl;

  float ans = width + (maxValue * 0.5);
  cout << ans << endl;
}


Measured memory_bytes: 1792