akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
  string s;
  cin >> s;
  int n=s.size();
  string ans;
  for(int i=0;i<n;i+=2)ans+=s[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 576
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>

using namespace std;

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    set<int> S;
    rep(i, 3) {
        int A;
        cin >> A;
        S.insert(A);
    }
    cout << S.size() << endl;
}



Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
aa=[]
ans=0
for i in a:
    ans^=i
anss=int(ans)
for i in range(n):
    anss^=a[i]
    aa.append(anss)
    anss=int(ans)
print(" ".join(map(str,aa)))

Measured memory_bytes: 111712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll lcm(ll a,ll b){
  ll c;
  for(int i=1;;i++){
    if(a*i%b==0){
      c=a*i;
      break;
    }
  }
  return c;
}
int main(){
  int n;cin>>n;
  vector<ll> T(n);
  for(int i=0;i<n;i++) cin>>T[i];
  sort(T.begin(),T.end(),greater<ll>());
  if(n==1) cout<<T[0]<<endl;
  else{
    ll a=lcm(T[0],T[1]);
    for(int i=2;i<n;i++){
      a=lcm(a,T[i]);
    }
    cout<<a<<endl;
  }
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		int ans = 0;
		for(long i = x ; i <= y ; i *= 2) {
			ans ++;
		}
		System.out.println(ans);
	}
}


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

using namespace std;

int main(void){
	long long int a, b, c, x, y;

	cin >> a >> b >> c >> x >> y;

	long long int m = 5000*200000;
	for (long long int i = 0; i < 200001; i++){
		long long int t = a*max((long long int)0, (x - i/2)) + b*max((long long int)0, (y - i/2)) + c*i;
		m = min(t, m);
	}

	cout << m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,x;
vector<int> a;
vector<int> b;
vector<int> c;
long long s=0;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x);
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x);
		b.push_back(x);
	}
	sort(b.begin(),b.end());
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x);
		c.push_back(x);
	}
	sort(c.begin(),c.end());
	for(int i=0;i<n;i++)
	{
		int it=lower_bound(a.begin(),a.end(),b[i])-a.begin();
		int itt=upper_bound(c.begin(),c.end(),b[i])-c.begin();
		s+=1LL*it*(n-itt);
	}
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 1912
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const long long MAX = 1000000000;

ll S, _x1, _y1, _x2 = 1, _y2 = MAX, _x3 = 0, _y3 = 0;

/*
S = x1y2 - x2y1
y2 = 1e9, x2 = 1

x1 * 1e9 - y1 = S

*/

int main(void) {
    cin >> S;
    ll q = S/MAX, r = S%MAX;
    if (r!=0){
        _x1 = q+1;
        _y1 = MAX-r;
    } else {
        _x1 = q;
        _y1 = r;
    }

    //cout << _x1*_y2 - _x2*_y1 << endl;
    printf("%lld %lld %lld %lld %lld %lld\n", _x1, _y1, _x2, _y2, _x3, _y3);

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC166E();

#if 1
int main()
{
	ABC166E();
	fflush(stdout);
	return 0;
}
#endif


static void ABC166E()
{
	int N;
	getint(N);

	std::vector<std::pair<int, int>> ai(N);
	std::map<int, std::set<int>> amn;
	for (int i = 0; i < N; i++) {
		ai[i].first = i + 1;
		getint(ai[i].second);
		
		int aminusn = ai[i].first - ai[i].second;
		if (aminusn > 0) {
			amn[aminusn].insert(ai[i].first);
		}
	}
	
	LLONG ans = 0;
	for (int i = 0; i < N; i++) {
		int aplusn = ai[i].first + ai[i].second;
		ans += amn[aplusn].size();
	}
	printf("%lld\n", ans);
}


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

using namespace std;

int n, m, d;
long double ans;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m >> d;
    ans = (n - d);
    if (d != 0) {
        ans *= 2;
    }
    ans /= n;
    ans *= (m - 1);
    ans /= n;
    cout.precision(20);
    cout << fixed << ans << endl;
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  var array = input.split(' ');
  var a = parseInt(array[0]);
  var b = parseInt(array[1]);
  var ab = parseInt(array[2]);
  var x = parseInt(array[3]);
  var y = parseInt(array[4]);

  var a_min = Math.min(a, ab * 2);
  var b_min = Math.min(b, ab * 2);
  var pair_min = Math.min((a + b), ab * 2);

  var pair_num = Math.min(x, y);
  var remained_x = x - pair_num;
  var remained_y = y - pair_num;

  return pair_num * pair_min + remained_x * a_min + remained_y * b_min;
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
console.log(Main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    ll A, B;
    cin >> A >> B;
    if(A == B) {cout << 1 << endl; return 0;}
    int j = 60;
    rep3(i, 59, 0){
        j--;
        if((A>>i) == (B>>i)) A &= (1LL<<i)-1, B &= (1LL<<i)-1;
        else break;
    }
    ll a = A, b = B^(1LL<<j), ans = (1LL<<j)-a;
    rep3(i, j, 0){
        if(b & (1LL<<i)){
            b |= (1LL<<i)-1;
            break;
        } 
    }
    if(b >= a) ans += 1LL<<j;
    else ans += (1LL<<j)-a+b+1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int d;
	cin >> d;
	if (d == 25) cout << "Christmas" << endl;
	else if (d == 24) cout << "Christmas Eve" << endl;
	else if (d == 23) cout << "Christmas Eve Eve" << endl;
	else cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
using namespace std;
typedef long long int ll;

// K: 連結要素の数（=木の数）
ll N, M, K;
vector<ll> edges[200000];
ll a[200000];
ll col[200000];
vector<ll> trees[200000];

void dfs(ll i) {
  if (col[i] != -1)
    return;
  col[i] = K;
  for (auto j : edges[i])
    dfs(j);
}

int main() {
  rep(i, 200000)
    col[i] = -1;
  cin >> N >> M;
  rep(i, N) {
    cin >> a[i];
  }
  if (M == N - 1) { // 木が1つしかない
    cout << 0 << endl;
    return 0;
  }
  rep(i, M) {
    ll x, y;
    cin >> x >> y;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }
  rep(i, N) {
    if (col[i] != -1)
      continue;
    dfs(i);
    K++;
  }
  rep(i, N) {
    trees[col[i]].push_back(a[i]);
  }
  // cout << "K=" << K << endl;
  rep(c, K) {
    sort(begin(trees[c]), end(trees[c]));
    // cout << c << ": ";
    // for (auto i : trees[c])
    //   cout << i << " ";
    // cout << endl;
  }

  ll ans = 0;
  vector<ll> p;
  // まずすべての木から1頂点を選ぶ (計K個）
  rep(c, K) {
    auto it = trees[c].begin();
    ans += *it;
    trees[c].erase(it);
    p.insert(p.end(), trees[c].begin(), trees[c].end());
  }
  // 残りからK-2個選ぶ
  sort(begin(p), end(p));
  if (p.size() < K-2) {
    cout << "Impossible" << endl;
    return 0;
  }
  rep(i, K-2)
    ans += p[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 18808
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<ll,ll,ll> tll;
const ll MOD = 1000000007LL;
using vll = vector<ll>;
const ll INF = 1LL << 60;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  ll cu=0;
  rep(i,n){
    ll a,b;
    cin>>a>>b;
    if(a==b) cu++;
    else cu=0;
    if(cu==3){
      COUT("Yes");
      return 0;
    }
  }
  COUT("No");
}
      


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

int n, m, a, b, sv;
long long fp;
vector<int> v[100005];
multiset<int> sms;
multiset<int>::iterator it;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; ++i) {
		cin >> a >> b;
		v[a].push_back(b);
	}
	for(int i = m; i >= 1; --i) {
		/*if(v[i].size() == 0) {
			++sv;
			continue;
		}*/
		//sort(v[i].begin(), v[i].end());
		//fp += v[i][(int)v[i].size() - 1];
		++sv;
		for(int j = 0; j < v[i].size(); ++j) {
			sms.insert(v[i][j]);
		}
		while(sms.size() > sv) {
			sms.erase(sms.begin());
		}
	}
	if(sms.size())
	for(it = sms.begin(); it != sms.end(); ++it) {
		fp += (*it);
	}
	cout << fp << endl;
	return 0;
}


Measured memory_bytes: 10112
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

int main()
{
	int N;
	string S, T;
	cin >> N;
	cin >> S >> T;

	string ret;

	for (int i = 0; i < N; ++i) {
		ret.push_back(S[i]);
		ret.push_back(T[i]);
	}

	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 3656
# coding=utf-8
import math


N = int(input())
for i in range(N):
    length_list = list(map(int, input().split()))
    length_list.sort()
    if math.pow(length_list[0], 2) + math.pow(length_list[1], 2) == math.pow(length_list[2], 2):
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 5672
#include<stdio.h>
int main(){
        int i,t,u,H[100],W[100];
        for(i=0;;i+=1){
            scanf("%d %d",&H[i],&W[i]);
            if(H[i]==0&&W[i]==0){
                break;
            }
            for(t=1;t<=H[i];t+=1){
                if(t==1||t==H[i]){
                    for(u=1;u<=W[i];u+=1){
                        if(u<W[i]){
                            printf("#");
                        }
                        else if(u==W[i]){
                            printf("#\n");
                        }
                    }
                }
                else{
                    for(u=1;u<=W[i];u+=1){
                        if(u==1){
                            printf("#");
                        }
                        else if(u==W[i]){
                            printf("#\n");
                        }
                        else{
                            printf(".");
                        }
                    }
                }
            }
            printf("\n");
        }
                return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
struct SegTree {
    vector<pair<int, int>> A;
    int N;
    SegTree(int n) {
        N = 1;
        while (N < n) N *= 2;
        A.resize(N*2);
        for (int i = 0; i < N; i++) A[N+i].second = i;
    }
    void add(int idx, int val) {
        idx += N;
        A[idx].first += val;
        idx /= 2;
        while (idx > 0) {
            auto s = A[idx*2+0], t = A[idx*2+1];
            A[idx] = min(s, t);
            if (s.first == 0) A[idx] = t;
            if (t.first == 0) A[idx] = s;
            idx /= 2;
        }
    }
    pair<int, int> get() {
        return A[1];
    }
};
int main()
{
    int N; cin >> N;
    vector<int> A(N-1), B(N-1), C(N);
    vector<vector<int>> G(N);
    for (int i = 0; i < N-1; i++) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    for (auto &c : C) cin >> c;
    sort(begin(C), end(C));
    vector<int> count(N), ans(N);
    for (int i = 0; i < N-1; i++) {
        count[A[i]]++;
        count[B[i]]++;
    }
    SegTree S(N);
    for (int i = 0; i < N; i++) {
        S.add(i, count[i]);
    }
    for (int i = 0; i < N; i++) {
        auto p = S.get();
        for (auto t : G[p.second]) {
            if (count[t] > 0) {
                count[p.second]--;
                count[t]--;
                S.add(p.second, -1);
                S.add(t, -1);
                ans[p.second] = C[i];
                break;
            }
        }
    }
    cout << accumulate(begin(C), end(C), 0) - C[N-1] << '\n';
    for (auto d : ans) cout << (d != 0 ? d : C[N-1]) << ' ';
    cout << '\n';
    return 0;
}

Measured memory_bytes: 1280
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;


#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 1e5 + 120;



int main(){FAST;   
      
int n ,k ,res = INT_MAX ,a[maxn];
    cin >> n >> k;
    forp(i ,1 ,n + 1)    cin >> a[i];
    for(int i = 1 ;i + k - 1 <= n; i++) res = min(res ,a[i + k - 1] - a[i] + min(abs(a[i]) ,abs(a[i + k - 1]) ) );
        out(res);
return 0;
}
 










Measured memory_bytes: 640
N = int(input())
S = str(input())
#N = 3
#S = "#.#"
stone_list = []
tmp = 1
for i in range(N):
    if i == N-1:
        stone_list.append(tmp)
        break
    if S[i+1] != S[i]:
        stone_list.append(tmp)
        tmp = 1
    else:
        tmp += 1
        
# whiteから初めてwhiteで終わらせる
if S[0] == '#':
    stone_list = [0] + stone_list
if S[N-1] == '#':
    stone_list = stone_list + [0]

tmp = sum(stone_list[2::2])
ans = tmp
for i in range(1,len(stone_list)-1,2):
    tmp = tmp + stone_list[i] - stone_list[i+1]
    if tmp < ans:
        ans = tmp
print(ans)
    

Measured memory_bytes: 6628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};


void solve(int ca){
    int X,Y;
    cin>>X>>Y;
    for (int i = 0; i <= X; ++i) {
        if(i*4+(X-i)*2==Y){
            cout<<"Yes"<<endl;
            return;
        }
    }
    cout<<"No"<<endl;
}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int A[200005];
ll psum[200005];
 
map<ll,int> mp;
 
int main()
{
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        cin>>A[i];
        psum[i]=psum[i-1]+1LL*A[i];
        if(psum[i]==0)ans++;
    }
    for(int i=1;i<=n;i++){
        mp[psum[i]]++;
    }
 
    for(auto it=mp.begin();it!=mp.end();it++){
        int val=it->second;
        ans+=1LL*val*(val-1)/2;
    }
    cout<<ans;
 
}

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

using namespace std;

const int inf = 0x3f3f3f3f;

int vetor[100010], pd[100010];
int n, k;

int solve(int x){
  if(pd[x] != inf) return pd[x];
  if(x >= n) return inf;
  if(x == n-1) return 0;

  for(int i=1 ; i<=k ; i++)
    pd[x] = min(pd[x], solve(x+i) + abs(vetor[x]-vetor[x+i]));

  return pd[x];
}

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

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

  memset(pd, inf, sizeof pd);

  cout<<solve(0)<<endl;
}

Measured memory_bytes: 5760
#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
using namespace  std;
int main() {
	double r;
	cin >> r;
	cout << fixed << setprecision(6)<< r * r * M_PI << ' ' << r * 2 * M_PI << endl;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << "A" << s2[0] << "C" << endl;

}

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

int main(int argc, char const *argv[])
{
    char num[3];
    int ans = 0;
    cin >> num[0] >> num[1] >> num[2] >> num[3];

    if (num[0] == '2')
    {
        ans++;
    }

    if (num[1] == '2')
    {
        ans++;
    }

    if (num[2] == '2')
    {
        ans++;
    }
    
    if (num[3]=='2') {
        ans++;
    }
    cout<<ans<<endl;
    

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

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

int h,w;
int ans;
int flg[10],t[10][10000];

int count(void){
	int i,j;
	int tmp,res=0;

	rep(j,w){
		//1の数を数える
		tmp=0;
		rep(i,h)if(flg[i] && !t[i][j] || !flg[i] && t[i][j]) tmp++;
		if(tmp<h-tmp)
			//j列目を裏返した方がいい
			res+=h-tmp;
		else 
			//j列目を裏返さない方がいい
			res+=tmp;
		}

	return res;
}

void solve(int idx){
	int res;
	if(idx==h){
		res=count();
		if(ans<res)ans=res;
		return;
	}
	//idx行目を裏返さない
  	flg[idx]=0;
	solve(idx+1);
	//idx行目を裏返す
	flg[idx]=1;
	solve(idx+1);
}

int main(void){
	int i,j;
	while(scanf("%d%d",&h,&w) && (h||w)){
		rep(i,h)rep(j,w)scanf("%d",&t[i][j]);
    		ans=0;
		solve(0);
		printf("%d\n",ans);
		}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
 
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    string s,t;
    cin>>s>>t;
    string tmp;
    ll flg=0;
    for(char c='a';c<='z';c++){
        tmp=s+c;
        // cout<<c<<" "<<tmp<<endl;
        if(tmp==t){
            flg=1;
            break;
        }
    }
    if(flg) cout<<"Yes";
    else cout<<"No";
    return 0;   
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
const int dx4[4] = {1,0,-1,0};
const int dy4[4] = {0,1,0,-1};
const int dx8[8] = {-1,0,1,1,1,0,-1,-1};
const int dy8[8] = {1,1,1,0,-1,-1,-1,0};
typedef long long ll;
const int mod = 1e9+7;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> field(h);
  rep(i,h) cin >> field[i];
  vector<vector<int>> dis(h, vector<int>(w, -1));
  dis[0][0] = 0;
  queue<P> que;
  que.push(make_pair(0,0));
  while(!que.empty()){
    int vy = que.front().first;
    int vx = que.front().second;
    que.pop();
    rep(i,4){
      int ny = vy + dy4[i];
      int nx = vx + dx4[i];
      if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
      if(dis[ny][nx] == -1 && field[ny][nx] == '.'){
        dis[ny][nx] = dis[vy][vx] + 1;
        que.push(make_pair(ny, nx));
      }
    }
  }
  int ans = h*w - (dis[h-1][w-1] + 1);
  int bluck = 0;
  rep(i,h)rep(j,w){
    if(field[i][j] == '#') bluck++;
  }
  ans -= bluck;
  if(dis[h-1][w-1] == -1) cout << -1 << endl;
  else cout << ans << endl;
}

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

using namespace std;

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as(n);
  std::vector<int> bs(n);
  int i = 0;
  for (; i < n; i++) {
    int a, b;
    std::cin >> a >> b;
    as[i] = a;
    bs[i] = b;
  }
  int64_t ret = 0;
  i--;
  for (; i >= 0; i--) {
    auto const a = as[i];
    auto const b = bs[i];
    ret += (b - (a + ret) % b) % b;
  }
  std::cout << ret << std::endl;
  return 0;
}

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

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

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N, R; cin >> N >> R;
    cout << R + 100*max(10-N,0) << endl;
    return 0;
}


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

#define ll long long

using namespace std;

ll n;

int main(){
cin>>n;
vector< pair<int,int> > p(n);
for(int i=0;i<n;++i){
 int ai;
 cin>>ai;
 p.at(i)=make_pair(ai,i+1); 
}

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

for(int i=0;i<n;++i){
  pair<int,int> t;
  t=p.at(i);
  cout<<t.second;
  if(i<n-1) cout<<" ";
  else cout<<endl;
}

return 0;

}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int dp[1100][11000];
const int INF = 1001001001;
int main()
{
    int a,b;
    int h,n;
    cin >> h >> n;
    rep(i,n+3)rep(j,h+1)dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i,n){
        
        cin >> a >> b;
        rep(j,h+1){
            dp[i][min(j+a,h)] = min(dp[i][min(j+a,h)],dp[i][j]+b);
            dp[i+1][j] = min(dp[i][j],dp[i+1][j]);
            
        }
    }
    rep(j,h+1)dp[n][min(j+a,h)] = min(dp[n][min(j+a,h)],dp[n][j]+b);
    
    cout << dp[n][h] << endl;
    return 0;
}

Measured memory_bytes: 45312
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 105, INF = 0x7f7f7f7f;
struct Edges { int to, next, dis; } e[MAXN * MAXN * MAXN];
int head[MAXN * MAXN * MAXN], tot = 1;
int In[MAXN][MAXN], Out[MAXN][MAXN], cnt, S, T, Row[MAXN], Line[MAXN];
int dep[MAXN * MAXN * MAXN], cur[MAXN * MAXN * MAXN];
char s[MAXN][MAXN];
queue <int> q;

inline void addedge(int from, int to, int dis) {
  e[++tot] = (Edges){to, head[from], dis};
  head[from] = tot;
  e[++tot] = (Edges){from, head[to], 0};
  head[to] = tot;
}

bool Bfs() {
  memset(dep, 0, sizeof(dep));
  dep[S] = 1;
  q.push(S);
  while (!q.empty()) {
    int t = q.front(); q.pop();
    for (RI i = head[t]; i; i = e[i].next)
      if (!dep[e[i].to] && e[i].dis)
        dep[e[i].to] = dep[t] + 1, q.push(e[i].to);
  }
  if (!dep[T]) return 0;
  for (RI i = 1; i <= cnt; ++i) cur[i] = head[i];
  return 1;
}

int Dfs(int now, int res) {
  if (now == T || !res) return res;
  int sum = 0;
  for (RI i = cur[now]; i; i = e[i].next) {
    cur[now] = i;
    if (dep[e[i].to] == dep[now] + 1) {
      int d = Dfs(e[i].to, min(res, e[i].dis));
      if (d) {
        sum += d;
        res -= d;
        e[i].dis -= d;
        e[i ^ 1].dis += d;
      }
    }
  }
  return sum;
}

int Dinic() {
  int Maxflow = 0;
  while (Bfs())
    Maxflow += Dfs(S, INF);
  return Maxflow;
}

int main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n, m; scanf("%d %d", &n, &m);
  for (RI i = 1; i <= n; ++i)
    scanf("%s", s[i] + 1);
  for (RI i = 1; i <= n; ++i) Row[i] = ++cnt;
  for (RI i = 1; i <= m; ++i) Line[i] = ++cnt;
  for (RI i = 1; i <= n; ++i)
    for (RI j = 1; j <= m; ++j) {
      if (s[i][j] == 'o') {
        In[i][j] = ++cnt, Out[i][j] = ++cnt;
        addedge(Out[i][j], Row[i], INF);
        addedge(Out[i][j], Line[j], INF);
        addedge(Row[i], In[i][j], INF);
        addedge(Line[j], In[i][j], INF);
        addedge(In[i][j], Out[i][j], 1);
      }
      if (s[i][j] == 'S') {
        S = ++cnt;
        addedge(S, Row[i], INF);
        addedge(S, Line[j], INF);  
      }
      if (s[i][j] == 'T') {
        T = ++cnt;
        addedge(Row[i], T, INF);
        addedge(Line[j], T, INF);
      }
    }
  int Maxflow = Dinic();
  if (Maxflow > n * m) puts("-1");
  else printf("%d\n", Maxflow);

  return 0;
}

Measured memory_bytes: 10624
N, K = map(int,input().split())
A = list(map(int,input().split()))
import itertools

min_cost = float('inf')
for Buildings in itertools.combinations(range(N),K):
    min_height = 0
    cost = 0
    for i in range(N):
        if i in Buildings:
            h = A[i]
            if h>min_height:
                min_height = h
                continue
            cost+=(min_height+1) - h
            min_height += 1
            continue
        min_height = max(min_height,A[i])

    min_cost=min(min_cost,cost)

print(min_cost)


Measured memory_bytes: 9024
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;


int main() {
	cout << fixed << setprecision(18);

	long long int N,M,K,A[200005];
	cin>>N>>M;
	if(N==M){cout<<"Yes";}
	else{cout<<"No";}
} 

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

using namespace std;

#define int long long

#define rep(i,x) for(int i=0;i<x;++i)
#define all(a) begin(a),end(a)

const int inf = 3e17;

int dp[155][15][100];
int stone[155][15];
int X[155][15];

signed main()
{
    int n, m;
    
    while (cin >> n >> m, n) {
        rep(i, n+5) rep(j, 15) stone[i][j] = inf, X[i][j] = inf;
        rep(i, n+5) rep(j, 15) rep(k, 100) dp[i][j][k] = inf;

        rep(i, n) {
            int k; cin >> k;
            rep(j, k) {
                int x, d; cin >> x >> d;

                X[i][j] = x;

                stone[i][j] = d;
                if (i == 0) dp[0][j][0] = 0;
                if (i == 1) dp[1][j][1] = 0;
            }
        }

        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < 11; ++j) {
                if (stone[i][j] == inf) continue;

                for (int k = 0; k <= m; ++k) {
                    if (k < m) {
                        rep(l, 11) {
                            if (stone[i + 2][l] == inf) continue;

                            dp[i + 2][l][k + 1] = min(
                                    dp[i + 2][l][k + 1],
                                    dp[i][j][k] + (stone[i][j] + stone[i + 2][l]) * abs(X[i][j] - X[i + 2][l])
                                    );
                        }
                    }

                    rep(l, 11) {
                        if (stone[i + 1][l] == inf) continue;

                        dp[i + 1][l][k] = min(
                                dp[i + 1][l][k],
                                dp[i][j][k] + (stone[i][j] + stone[i + 1][l]) * abs(X[i][j] - X[i + 1][l])
                                );
                    }
                }
            }
        }

        int mi = inf;

        for (int i = 0; i < 11; ++i) {
            for (int j = 0; j <= m; ++j) {
                mi = min(mi, dp[n - 1][i][j]);
            }
        }

        for (int i = 0; i < 11; ++i) {
            for (int j = 0; j <= m - 1; ++j) {
                mi = min(mi, dp[n - 2][i][j]);
            }
        }

        cout << mi << endl;
    }
}

Measured memory_bytes: 4940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		String ans = "";
		for(int i = 0; i < str.length(); i++) {
			if(str.charAt(i) =='B') {
				if(ans.length() > 0)
				ans = ans.substring(0,ans.length()-1);
			}else{
				ans += str.charAt(i);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 38980
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

int N;
string s;

bool exist(int l){
    if(l==0) return false;
    for(int i=0;i<N;i++){
        if(N-(i+l) < l) return false;
        string p = s.substr(i,l);
        string q = s.substr(i+l);
        if(q.find(p) != string::npos) return true;
    }
    return false;
}

int main(void){
    cin >> N;
    cin >> s;
    int left = 0, right = N/2;

    while(abs(right-left) > 1){
        int m = (right+left)/2;
        if(exist(m)) left = m;
        else right = m;
    }
    if(exist(right)) cout << right << endl;
    else cout << left << endl;

    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
vector<pair<char,int> >A,B,C;
main()
{
	char c;
	while(cin>>c,c!='$')
	{
		int a;cin>>a;
		A.push_back(make_pair(c,a));
	}
	while(cin>>c,c!='$')
	{
		int a;cin>>a;
		B.push_back(make_pair(c,a));
	}
	while(cin>>c,c!='$')
	{
		int a;cin>>a;
		C.push_back(make_pair(c,a));
	}
	int id=-1;
	for(int i=0;i<A.size();i++)
	{
		if(A[i].first==B[0].first&&A[i].second>=B[0].second)
		{
			bool flag=1;
			for(int j=1;j+1<B.size();j++)flag&=i+j<A.size()&&A[i+j]==B[j];
			if(B.size()>1)flag&=i+B.size()<=A.size()&&A[i+B.size()-1].first==B[B.size()-1].first&&A[i+B.size()-1].second>=B[B.size()-1].second;
			if(flag)
			{
				id=i;
				break;
			}
		}
	}
	vector<pair<char,int> >ans;
	if(id<0)
	{
		ans=A;
	}
	else
	{
		for(int i=0;i<id;i++)ans.push_back(A[i]);
		if(B.size()>1)
		{
			if(A[id].second>B[0].second)ans.push_back(make_pair(A[id].first,A[id].second-B[0].second));
			for(int i=0;i<C.size();i++)ans.push_back(C[i]);
			int next=id+B.size()-1;
			if(A[next].second>B[next-id].second)
				ans.push_back(make_pair(A[next].first,A[next].second-B[next-id].second));
			id=next+1;
		}
		else
		{
			for(int i=0;i<C.size();i++)ans.push_back(C[i]);
			if(A[id].second>B[0].second)
			{
				ans.push_back(make_pair(A[id].first,A[id].second-B[0].second));
			}
			id++;
		}
		for(;id<A.size();id++)ans.push_back(A[id]);
	}
	for(int i=0;i<ans.size();i++)
	{
		while(i+1<ans.size()&&ans[i].first==ans[i+1].first)
		{
			ans[i+1].second+=ans[i].second;
			i++;
		}
		cout<<ans[i].first<<" "<<ans[i].second<<" ";
	}
	cout<<"$"<<endl;
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;

signed main(){
    int n,m;
    cin >> n >> m;
    int MIN = 0;
    int MAX = INF;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        MIN = max(MIN,a);
        MAX = min(MAX,b);
    }
    if(MAX - MIN >= 0) cout << MAX - MIN + 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> V(N), C(N);
    for(int i=0;i<N;i++){
        cin >> V[i];
    }
    for(int i=0;i<N;i++){
        cin >> C[i];
    }

    int cost = 0;
    for(int i=0;i<N;i++){
        if((V[i] >= C[i])) cost += (V[i] - C[i]);
    }

    cout << cost << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
  
typedef long long int ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef priority_queue <ll> pqb;
typedef priority_queue <ll, vector<ll>, greater<ll>> pqs;
double EPS = 1e-9; 
long long INF = 1000000000000000005ll; 
double PI = acos(-1); 
#define M 1000000007ll
#define D 998244353ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound  
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a))
#define GCD(a,b) __gcd(a,b)
#define setbits(x)   __builtin_popcountll(x)
#define zerobits(x)  __builtin_ctzll(x) 
#define ps(x,y)  fixed<<setprecision(y)<<x
#define endl '\n'
#define ff first 
#define ss second 
#define mp make_pair  
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
  
inline string IntToString(ll a) 
{ 
    char x[100]; 
    sprintf(x, "%lld", a); 
    string s = x; 
    return s; 
} 
  
inline ll StringToInt(string a) 
{ 
    char x[100]; 
    ll res; 
    strcpy(x, a.c_str()); 
    sscanf(x, "%lld", &res); 
    return res; 
} 
  
 
inline string uppercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'a' && s[i] <= 'z') 
        s[i] = s[i] - 'a' + 'A'; 
    return s; 
} 
  
inline string lowercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'A' && s[i] <= 'Z') 
        s[i] = s[i] - 'A' + 'a'; 
    return s; 
}

bool cmp(pll a,pll b)
{
  ll as=a.ff-a.ss;
  ll bs=b.ff-b.ss;
    return (as>bs);
}

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

vl v[100005];
bool vis[100005];

int main() {
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   	ll n,W;
   	cin>>n>>W;
   	ll w[n],v[n];
   	for(ll i=0;i<n;i++){
   		cin>>w[i]>>v[i];
   	}
   	ll dp[n+1][W+1];
   	memset(dp,0,sizeof dp);
   	for(ll i=1;i<=n;i++){
   		for(ll j=1;j<=W;j++){
   			if(w[i-1]<=j){
   				dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1],dp[i-1][j]);
   			}
   			else{
   				dp[i][j]=dp[i-1][j];
   			}
   		}
   	}
   	cout<<dp[n][W]<<endl;
    return 0; 
}

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

#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector< pi > 
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL)
const int N=200003;
vi v[N];
ll c[N],a[N],val[N],res[N],sub[N];
int dfs(int x,int p)
{
    for(int y:v[x])
        if(y!=p)
            sub[x]+=dfs(y,x);
    sub[x]+=1;
    return sub[x];
}
void solv(int x,int p)
{
    ll n=val[c[x]];
    ll add=(n-sub[x]+1)*sub[x],sm=0;
    for(int y:v[x])
    {
        if(y==p) continue;
        add+=1ll*sub[y]*sm;
        sm+=sub[y];
    }
    res[c[x]]+=add;
    //val[c[x]]=sub[x]-1;
    for(int y:v[x])
    {
        if(y==p) continue;
        val[c[x]]=sub[y];
        solv(y,x);
    }
    val[c[x]]=n-sub[x];
}
int main()
{
    int n,x,y;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>c[i];
        val[i]=n;
    }
    for(int i=1;i<n;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(1,0);
    solv(1,0);
    for(int i=1;i<=n;i++)
    {
        cout<<res[i]<<'\n';
    }
    return 0;
}

Measured memory_bytes: 36384
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int n, t, a;
  cin >> n >> t >> a;
  
  float min_e = -1, x;
  int temp, index;
  
  
  for(int i =0; i< n; ++i)
  {
    cin >> temp;
    x = (float)temp*0.006;
    if(min_e == -1)
    {
      index = i;
      min_e = t-x;
    }
    else if(abs(a-(t-x)) < abs(a-min_e))
    {
      index = i;
      min_e = t-x;
    }
  }
  cout << index+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int ans1=n*2,ans2=n*4;
	if(m>=ans1&&m<=ans2&&m%2==0)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 3636
def even_count(N):
    if N == 0:
        return 0
    elif N == 1:
        return 0
    else:
        return N * (N-1) // 2

def odd_count(M):
    if M == 0:
        return 0
    elif M == 1:
        return 0
    else:
        return M * (M-1) // 2

N, M = map(int, input().split())

num_even = even_count(N)
num_odd = odd_count(M)
amount = num_even + num_odd
print(amount)


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

using namespace std;
int a, b, cnt[10];
int main(){
    while(cin >> a >> b, a | b){
	fill(cnt, cnt + 10, 0);
	int hit = 0, blow = 0;
	for(int i = 0;i < 4;i++){
	    cnt[a%10]++;
	    cnt[b%10]++;
	    if(cnt[a%10] == 2)blow++;
	    if(cnt[b%10] == 2)blow++;
	    if(a%10 == b%10)hit++,blow--;
	    a/=10,b/=10;
	}
	cout << hit << " " << blow - hit << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import java.io.*;
import java.util.*;


public class Main {

    private static InputStreamReader isr = new InputStreamReader(System.in);
    private static BufferedReader br = new BufferedReader(isr);

    private static int minCost(int[] height, int[] dp, int i) {
        if (i == height.length - 1) return 0;

        if (dp[i] != -1) return dp[i];

        if (i + 1 >= height.length) {
            dp[i] = minCost(height, dp, i);
            return dp[i];
        }

        if (i + 2 >= height.length) {
            dp[i] = Math.abs(height[i] - height[i+1]) + minCost(height, dp, i+1);
            return dp[i];
        }

        int oneStep = Math.abs(height[i] - height[i+1]) + minCost(height, dp, i+1);
        int twoStep = Math.abs(height[i] - height[i+2]) + minCost(height, dp, i+2);
        dp[i] = Math.min(oneStep, twoStep);
        return dp[i];
    }

    public static void main(String[] argv) throws IOException {
        int n = Integer.parseInt(br.readLine());
        int height[] = Arrays.stream(br.readLine().split(" "))
            .mapToInt(Integer::parseInt).toArray();
        int[] dp = new int[n];
        Arrays.fill(dp, -1);
        System.out.println(minCost(height, dp, 0));
    }
}


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

int main()
{

int n,k;
cin>>n>>k;
bool arr[n];
for(int index =0 ;index<n;index++)
    arr[index]=false;
for(int index = 0;index<k;index++)
{
    int t;
    cin>>t;
    for(int i = 0;i<t;i++)
    {
        int pos;
        cin>>pos;
        arr[pos-1] = true;
    }

}
int ans = 0;
for(int index = 0;index<n;index++)
    if(!arr[index])
    ans++;

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


Measured memory_bytes: 3632
#include<cstdio>
using namespace std;
int a[5];
inline bool judge( int x )
{
	int s=0;
	for ( int i=1; i<=4; i++ )
	  if ( a[i]==x ) s=1;
	if ( s==1 ) return true;
	else return false;
}
int main()
{
	
	scanf ( "%d%d%d%d", &a[1], &a[2], &a[3], &a[4] ); 
	if ( !judge(1) ) { printf( "NO" ); return 0; }
	if ( !judge(9) ) { printf( "NO" ); return 0; }
	if ( !judge(7) ) { printf( "NO" ); return 0; }
	if ( !judge(4) ) { printf( "NO" ); return 0; }
	printf( "YES" );
	return 0;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

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

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

int n, a[400];
int memo[401][401];
int sum[401];

int dfs(int l, int r){
  if(r <= l) return 0;

  int &res = memo[l][r];
  if(res >= 0) return res;

  res = inf;
  rep(m, l, r){
    chmin(res, dfs(l, m)+dfs(m+1, r)+sum[r+1]-sum[l]);
  }

  return res;
}

signed main(){
  cin >> n;
  rep(i, 0, n) cin >> a[i];

  rep(i, 0, n) sum[i+1] = sum[i] + a[i];
  memset(memo, -1, sizeof(memo));
  int ans = dfs(0, n-1);
  cout << ans << endl;

  return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1001001001;

int dist[1000005][3];

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> to(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
    }
    int sv, tv;
    cin >> sv >> tv;
    sv--;
    tv--;

    rep(i, n)rep(j, 3) dist[i][j] = INF;

    queue<P> q;
    q.push(P(sv, 0));
    dist[sv][0] = 0;

    while (!q.empty()) {
        int v = q.front().first;
        int l = q.front().second;
        q.pop();
        for (int u : to[v]) {
            int nl = (l + 1) % 3;
            if (dist[u][nl] != INF)continue;
            dist[u][nl] = dist[v][l] + 1;
            q.push(P(u, nl));
        }
    }
    int ans = dist[tv][0];
    if (ans == INF) ans = -1;
    else ans /= 3;
    cout << ans << endl;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		if (x & 1 && i & 1)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3648
import java.util.Scanner;

//2018-04-08
public class Main {
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        String ans = null;

        if (N%500 !=0 && (N%500)>A){
            ans ="No";
        }else {
            ans ="Yes";
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21204
import collections
import sys
input = sys.stdin.readline
num = int(input())
word_list = []
for i in range(num):
    word_list.append(input())
word_dict = collections.Counter(word_list)
most_common = word_dict.most_common()[0][1]
word_list = [k for k,v in word_dict.items() if v == most_common]
word_list.sort()
for word in word_list:
    print(word)

Measured memory_bytes: 45420
h, w = map(int, input().split())
A = [input() for _ in range(h)]
mod = 10**9 + 7
memo = [[0] * w for _ in range(h)]
for i in range(h):
    if A[i][0] == '.':
        memo[i][0] = 1
    else:
        break
for j in range(w):
    if A[0][j] == '.':
        memo[0][j] = 1
    else:
        break
for i in range(1, h):
    for j in range(1, w):
        if A[i][j] == '#':
            memo[i][j] = 0
        else:
            memo[i][j] = (memo[i-1][j] + memo[i][j-1]) % mod
print(memo[-1][-1])

Measured memory_bytes: 49424
N, M, C = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for i in range(N):
    s = 0
    a = list(map(int, input().split()))
    for j in range(M):
        s += a[j] * b[j]
    if s + C > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060