akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>                                                                                           
    
    using namespace std;
    
    #define rep(i,n) for(int i=0;i<(n);++i)
    #define reps(i,n) for(int i=1;i<=(n);++i)
    #define all(x) (x).begin(),(x).end()
    #define int long long
    using pii = pair<int,int>;
    constexpr int INF  = 0x3f3f3f3f;
    constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
    
    char s[100][100];
    signed main(){
        int h,w;
        cin >> h >> w;
        reps(i,h){
            reps(j,w){
                cin >> s[i][j];
            }
        }
        pii now;
        now.first = 1;
        now.second = 1;
        while(!(now.first == h && now.second == w)){
            if(s[now.first][now.second + 1] != '#' && s[now.first + 1][now.second] != '#'){
                cout << "Impossible\n";
                return 0;
            }
            else if(s[now.first][now.second + 1] == '#' && s[now.first + 1][now.second] == '#'){
                cout << "Impossible\n";
                return 0;
            }
            else if(s[now.first][now.second-1] == '#'){
                cout << "Impossible\n";
                return 0;
            }
            else if(s[now.first -1][now.second] == '#'){
                cout << "Impossible\n";
                return 0;
            }
            else if(s[now.first][now.second + 1] == '#'){
                s[now.first][now.second] = '.';
                now.second++;
            }
            else{
                s[now.first][now.second] = '.';
                now.first++;
            }
        }
        if(s[h][w-1] == '#' || s[h-1][w] == '#') cout << "Impossible\n";
        else cout << "Possible\n";
        return 0;    
    }  

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = String.valueOf(n);
		char[] ch = s.toCharArray();
		if ((ch[0] == ch[1] && ch[0] == ch[2]) || (ch[1] == ch[2] && ch[1] == ch[3])) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

// Order statistics tree (if supported by judge!):
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

// template<class TK, class TM> using order_tree = tree<TK, TM, less<TK>, rb_tree_tag, tree_order_statistics_node_update>;
// iterator	find_by_order(int r) (zero based)
// int		order_of_key(TK v)
// template<class TV> using order_set = order_tree<TV, null_type>;

#define x first
#define y second
#define rs resize
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define rep(i,a,b) for(auto i=(a);i!=(b); ++i)
#define REP(i,n) rep(i,0,n)
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<ii> vii;
template<class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;

template<class T1, class T2>
ostream& operator<<(ostream &out, const pair<T1,T2> &a) { return out << '(' << a.x << ", " << a.y << ')'; }
template<class T1, class T2>
istream& operator>>(istream &in, pair<T1,T2> &a) { return in >> a.x >> a.y; }

template<class T> int sz(const vector<T> &v) { return (int) v.size(); }

template<class T> ostream& operator<<(ostream &os, vector<T> v) {
	os << "\n[";
	for(T &x : v) os << x << ',';
	return os << "]\n";
}

const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;

// lambda-expression: [] (args) -> retType { body }

void run() {
	string S;
	cin >> S;
	if (S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi")
		puts("Yes");
	else
		puts("No");
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr << boolalpha;
	(cout << fixed).precision(10);

	run();

	return 0;
}


Measured memory_bytes: 256
//************************
//** author  :  Alex Hu **
//************************

//  _______        __________         ________        __
//  \      \   ____\______   \ ____  /  _____/  _____/  |_
//  /   |   \ /  _ \|       _// __ \/   \  ____/ __ \   __\
// /    |    (  <_> )    |   \  ___/\    \_\  \  ___/|  |
// \____|__  /\____/|____|_  /\___  >\______  /\___  >__|
//         \/              \/     \/        \/     \/

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define fi first
#define se second
#define sqr(a) ((a)*(a))

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

int a,b;

int main()
{
	cin>>a>>b;
	if (a>=13) cout<<b<<endl;
	else if (a<=12 && a>=6) cout<<b/2<<endl;
	else cout<<0<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

int main(){
	int n; cin >> n;
	string s; cin >> s;
	if(n%2) cout << "No" <<endl;
	else{
		n /= 2;
		bool ok =true;
		rep(i,n){
			if(s[i]!=s[i+n]) ok = false;
		}
		cout << (ok ? "Yes" : "No");
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#define lowbit(i) (i&(-i))
typedef long long LL;
using namespace std;
const int maxn = 2e5+5;
int readint(){
	int x=0,f=1;char s=getchar();
	#define sc (s=getchar())
	while(s<'0'||s>'9'){
		if(s=='-')
			f=-1;
		sc;
	}
	while(s>='0'&&s<='9'){
		x=(x<<3)+(x<<1)+(s^48);
		sc;
	}
	#undef sc
	return x*f;
}
int a[maxn];
map<int,int> mp,mp1;
signed main (){
	int n=readint();
	LL ans=0;
	for(int i=1;i<=n;i++){
		a[i]=readint();
	}
	for(int i=n;i>=1;i--){
		mp[i-a[i]]++;
	}
	for(int i=1;i<=n;i++){
		mp1[i+a[i]]++;
		if(mp[i+a[i]]>0)
			ans+=mp[i+a[i]];
	}
	for(int i=n;i>=1;i--)
		if(mp1[i-a[i]]>0)
			ans+=mp1[i-a[i]];
	cout<<ans/2;
	return 0;
}


Measured memory_bytes: 38492
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define read(n) scanf("%d", &n);
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n;
  read(n);

  if ( n <= 999 ) 
    printf("ABC\n");
  else
    printf("ABD\n");
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int x = sc.nextInt(), y = sc.nextInt();
		
		for(int i = 0; i < n - 1; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(y < b){
				x = a;
				y = b;
			}
			if(y == b){
				if(x > a){
					x = a;
				}
			}
		}
		System.out.println(x + " " + y);
		
		sc.close();
	}
}

Measured memory_bytes: 17332
#include <stdio.h>

int main(void) {

    int W, H, x, y, r, f = 0;

    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if (x - r >= 0) {
    if (x + r <= W) {
    if (y - r >= 0) {
    if (y + r <= H) {
        f = 1;
    }
    }
    }
    }

    if (f == 1) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;

}

Measured memory_bytes: 584
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define deb(x) cout << #x << ' ' << x << '\n'
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define per(i,ini) for(int i=ini;i>=0;i--)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 1e5+2;

int n, ok = 0;
string s[N];
char ans[N];

void dfs(int a, int b, int c, int ind)
{
	if(ok)
	return;

	if(ind == n)
	{
		if(a >= 0 && b >=0 && c >=0)
		{
			ok = 1;
			printf("Yes\n");
			rep(i, 0, n)
			printf("%c\n", ans[i]);
		}
		return;
	}

	if(s[ind] == "AB")
	{
		if(b > 0)
		{
			ans[ind] = 'A';
			dfs(a+1, b-1, c, ind+1);
		}
		if(a > 0)
		{
			ans[ind] = 'B';
			dfs(a-1, b+1, c, ind+1);
		}
	}
	else if(s[ind] == "AC")
	{
		if(c > 0)
		{
			ans[ind] = 'A';
			dfs(a+1, b, c-1, ind+1);
		}
		if(a > 0)
		{
			ans[ind] = 'C';
			dfs(a-1, b, c+1, ind+1);
		}
	}
	else
	{
		if(c > 0)
		{
			ans[ind] = 'B';
			dfs(a, b+1, c-1, ind+1);
		}
		if(b > 0)
		{
			ans[ind] = 'C';
			dfs(a, b-1, c+1, ind+1);
		}
	}
}

int main()
{
	int a, b, c;
	scanf("%d%d%d%d", &n, &a, &b, &c);

	rep(i, 0, n)
	cin >> s[i];

	dfs(a, b, c, 0);

	if(!ok)
	printf("No\n");

	return 0;
}

Measured memory_bytes: 14772
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
const int INF = 1001001001;
int main(){
  int n;cin >>n;
  vector<long long int> a(n+1);
  vector<long long int> b(n);
  for(int i=0;i<n+1;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<n;i++){
    cin >> b.at(i);
  }
 long long int ans=0;
  for(int i=0;i<n;i++){
    ans+=min(a.at(n-i),b.at(n-1-i));
    b.at(n-1-i)-=min(a.at(n-i),b.at(n-1-i));
    a.at(n-i)-=min(a.at(n-i),b.at(n-1-i));
    
    ans+=min(a.at(n-1-i),b.at(n-1-i));
    a.at(n-1-i)-=min(a.at(n-1-i),b.at(n-1-i));
    
  }
  cout << ans;
}
  

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
char a[1000005];
int main(){
	scanf("%s",a+1);
	int s=0;
	for(int i=1;i<=strlen(a+1);i++){
		s+=a[i]-'0';
	}
	if(s%9==0) printf("Yes");
	else printf("No");
return 0;
} 

Measured memory_bytes: 3940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if((C*A) <= B)cout << C << endl;
    else cout << B/A << endl;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string S;
  IN(S);

  if(S[2]==S[3] && S[4]==S[5]){
    OUT("Yes\n");
  }else{
    OUT("No\n");
  }

  return 0;
}

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

using namespace std;

long long dp[1 << 16];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    long long a[n][n];
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j];
    for (int i = 0; i < (1 << n); i++) {
        vector<int> v;
        for (int j = 0; j < n; j++) if (i & (1 << j)) v.push_back(j);
        int n2 = v.size();
        dp[i] = 0;
        for (int j = 0; j < n2; j++) for (int k = j; k < n2; k++) dp[i] += a[v[j]][v[k]];
        for (int j = 0; j < (1 << n2); j++) {
            int i1 = 0;
            for (int k = 0; k < n2; k++) if (j & (1 << k)) i1 |= (1 << (v[k]));
            dp[i] = max(dp[i], dp[i1] + dp[i - i1]);
        }
    }
    cout << dp[(1 << n) - 1];
    return 0;
}


Measured memory_bytes: 768
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	queue<pair<string, int>> que;

	for (int i = 0; i < n; i++) {
		string s; int v;
		cin >> s >> v;

		que.push({ s,v });
	}

	int time = 0;
	while (!que.empty()) {
		pair<string, int> p;
		p = que.front(); que.pop();
		if (p.second > k) {
			time += k;
			p.second -= k;
			que.push({ p.first,p.second });
		}
		else {
			time += p.second;
			cout << p.first <<" "<< time << endl;
		}
	}
}


Measured memory_bytes: 6380
#Sが長いほう
S = input()
T = input()

mincnt = len(T)
for i in range(len(S)-len(T)+1): #i番目からチェック
  cnt = 0
  for j in range(len(T)):
    if S[i+j]!=T[j]:
      cnt += 1
  mincnt = min(mincnt, cnt)
print(mincnt)

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

ans = float("inf")
for i in range(N-1):
    # 右回りを実現
    if i == 0:
        ans = min(ans, A[N-1]-A[i])
    else:
        ans = min(ans, (K-A[i])+A[i-1])

    # 左回りを実現
    if i == 0:
        ans = min(ans, A[i]+(K-A[i+1]))
    else:
        ans = min(ans, A[i]+(K-A[i+1]))

# # 最後の家を考える
# 左回り
ans = min(ans, A[N-1]-A[0])
# 右回り
ans = min(ans, K-A[N-1]+A[N-2])
print(ans)


Measured memory_bytes: 26444
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	std::cin >> N;

	vector<vll> dp(N + 1, vll(3, 0));
	ll a[3];
	repeq(i, 1, N) {
		std::cin >> a[0] >> a[1] >> a[2];
		rep(j, 0, 3) {
			dp[i][j] = max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + a[j];
		}
	}

	std::cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
	return 0;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
 
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
 
int n;
vector<int> g[202020];
bool fav[202020];
int far[202020];
int second_farthest[202020];
int closest[202020];
bool in_fav[202020];
long long ans = 0;
 
static const int INF = 0x3f3f3f3f;
 
void dfs1(int v, int prev) {
        if (fav[v]) in_fav[v] = true;
        for (auto u : g[v]) if (u != prev) {
                dfs1(u, v);
                in_fav[v] |= in_fav[u];
                far[v] = max(far[v], far[u] + 1);
        }
}
 
void dfs2(int v, int ma, bool par_fav, int prev) {
        vector<pair<pii, bool>> children;
        children.push_back(mp(mp(0, -1), false));
        for (auto u : g[v]) {
                if (u == prev) children.emplace_back(mp(ma + 1, u), par_fav);
                else children.emplace_back(mp(far[u] + 1, u), in_fav[u]);
        }
        vector<int> fav_children;
        for (auto c : children) if (c.second) fav_children.emplace_back(c.first.first);
        closest[v] = INF;
        for (int i = 0; i < fav_children.size(); i ++) closest[v] = min(closest[v], fav_children[i]);
        int one = -1, two = -1, onei, onenode;
        for (int i = 0; i < children.size(); i ++) if (one < children[i].first.first) {
                one = children[i].first.first;
                onei = i;
                onenode = children[i].first.second;
        }
        for (int i = 0; i < children.size(); i ++) if (i != onei) if (two < children[i].first.first) {
                two = children[i].first.first;
        }
        second_farthest[v] = two;
        for (auto u : g[v]) if (u != prev) { 
                int maa = (u == onenode ? two : one);
                bool par_f = fav[v] || par_fav;
                if (!in_fav[u]) par_f |= !fav_children.empty();
                else par_f |= fav_children.size() > 1;
                ans += (maa < far[u] && par_f) || (maa > far[u] && in_fav[u]) || (maa == far[u] && (par_f || in_fav[u]));
                dfs2(u, maa, par_f, v);
        }
}
 
int main() {
        cin >> n;
        for (int i = 0; i < n - 1; i ++) {
                int a, b;
                cin >> a >> b;
                a --, b --;
                g[a].emplace_back(b);
                g[b].emplace_back(a);
        }
        string s;
        cin >> s;                                            
        for (int i = 0; i < n; i ++) fav[i] = s[i] == '1' ? true : false;
        dfs1(0, -1);
        dfs2(0, 0, fav[0], -1); for (int i = 0; i < n; i ++) {
                if (fav[i]) ans += 1 + second_farthest[i];
                else ans += max(0, 1 + (second_farthest[i] - closest[i]));
        }
        cout << ans << endl;
        return 0;
}


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

#define ll long long
#define pb push_back
#define vb vector<bool>
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll, ll>
#define MOD 1000000007
#define MAX_TIME 1e9
#define nl "\n"
#define sp " "
#define gcd __gcd
#define pf printf
#define sf scanf
#define se(a) a.begin(),a.end()
#define fill(a,n) for(int i = 0; i < n; i++)cin>>a[i]


int main()
{
    int n;
    cin>>n;
    vi a(n,0);
    fill(a,n);
    ll ans = 0;
    for(int i = 1; i < n; i++){
        if(a[i-1] > a[i]){
            ans+= (a[i-1] - a[i]);
            a[i] = a[i-1];
        }
    }
    cout<<ans<<nl;
}

Measured memory_bytes: 4028
using System;
using System.Linq;

namespace ABC098
{
    class C
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            int[] WS = new int[N + 1];
            int[] ES = new int[N + 1];

            WS[0] = 0;
            ES[0] = 0;
            for (int i = 1; i < N + 1; i++)
            {
                if (S[i - 1] == 'W') { WS[i] = WS[i - 1] + 1; ES[i] = ES[i - 1]; }
                if (S[i - 1] == 'E') { ES[i] = ES[i - 1] + 1; WS[i] = WS[i - 1]; }
            }

            int[] res = new int[N + 1];

            for (int i = 0; i < N + 1; i++)
            {

                //Console.WriteLine("ES : " + ES[i]);
                //Console.WriteLine("WS : " + WS[i]);

                res[i] = WS[i] + ES[N] - ES[i];

                //Console.WriteLine(res[i]);
            }

            Console.WriteLine(res.Min());
        }
    }
}


Measured memory_bytes: 15712
#include<cstdio>
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	long long int d[10][10]={};
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			scanf("%lld",&d[i][j]);
		}
	}
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			for(int k=0;k<10;k++){
				if(i!=k && d[j][k]>d[j][i]+d[i][k]){
					d[j][k]=d[j][i]+d[i][k];
				}
			}
		}
	}
	long long int ans=0;
	int t;
	for(int i=0;i<n*m;i++){
		scanf("%d",&t);
		if(t!=-1)ans+=d[t][1];
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main()
{
  int a, b, c, n;
  while(cin >> a){
  cin >> b;
  c = a + b;
  n = 0;
  while(c != 0){
    n++;
    c /= 10;
  }
  cout << n << "\n";
}

return 0;
}

Measured memory_bytes: 3060
//code by PARTH_4399 for competitive programming
#include<bits/stdc++.h>

using namespace std;

#define l long // -2^31 to +2^31-1 (upper limit ~ 2*(10^9))
#define ul unsigned long // 0 to +2^32-1
#define ll long long // -2^63 to +2^63-1 (upper limit ~ 9*(10^18))
#define ull unsigned long long // 0 to +2^64-1
#define mod(x, m) ((((x)%(m))+(m))%(m))
#define vi vector<int>
#define pi pair<int,int>
#define vl vector<ll int>
#define pl pair<ll int,ll int>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll MOD = 1e9 + 7;
const double pie = 3.141592653589793;

#define setcount(x) __builtin_popcount(x) // counts set bits
#define parity(x) __builtin_parity(x) // checks parity of the number
#define lzcount(x) __builtin_clz(x) // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x) // count trailing zeros in binary representation of number

template<typename T> T inf() { return (T)__builtin_inf();} // syntax for use inf<datatype>();
template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return (a*b)/gcd(a,b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
ll add(ll a,ll b,ll M) { return ( mod(a,M ) + mod(b,M ))%M; }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M; }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

/************************** main program **************************/

int main()
{
	FASTIO
	//code
	ll int n,i,s=0,count=0;
	cin>>n;
	ll int a[n];
	cin>>a[0];
	for(i=1;i<n;i++)
	{
		cin>>a[i];
			if(a[i-1]>=a[i])
			{
				count++;
			}
			else
			{
				count=0;
			}
			if(s<count)
				{
					s=count;
				}
		//cout<<count<<" ";
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    int n, y;

    scanf("%d%d", &n, &y);

    int res_a = -1, res_b = -1, res_c = -1;
    int k = 0;
    for(int i = 0; i <= n; ++i){
        for(int j = 0; j + i <= n; ++j){
            k = n - i - j;
            if((10000 * i + 5000 * j + 1000 * k) == y){
                res_a = i;
                res_b = j;
                res_c = k;
                break;
            }
        }
    }

    printf("%d %d %d\n", res_a, res_b, res_c);

    return 0;
}


Measured memory_bytes: 1688
S = list(input())
F = [0] * (len(S)-1)

ans = 0
def rec(i):
    global ans
    if i == len(F):
        string = S[0]
        tmp = []
        for i in range(len(F)):
            if F[i] == 0:
                string += S[i+1]
            else:
                tmp.append(string)
                string = S[i+1]
        
            if i == len(F) - 1:
                tmp.append(string)
        
        tmp = list(map(int, tmp))
        ans = ans + sum(tmp)
        return
        
    rec(i+1)
    F[i] = 1
    rec(i+1)
    F[i] = 0

if len(S) == 1:
    print(S[0])
else:
    rec(0)
    print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		long k = Integer.parseInt(br.readLine());
		br.close();

		long ans = 0;
		boolean first = true;
		boolean odd1 = false;
		boolean oddn = false;
		int cnt = 1;
		for (int i = 1; i < s.length(); i++) {
			if (s.charAt(i - 1) == s.charAt(i)) {
				cnt++;
			} else {
				if (first) {
					odd1 = cnt % 2 == 1;
					first = false;
				}
				ans += cnt / 2;
				cnt = 1;
			}
		}
		oddn = cnt % 2 == 1;
		ans += cnt / 2;
		ans *= k;
		if (odd1 && oddn && s.charAt(0) == s.charAt(s.length() - 1)) {
			ans += k - 1;
		}
		if (first) {
			System.out.println(k * s.length() / 2);
		} else {
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 21076
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string.h>
using namespace std;
#define sz(x) int(x.size())
#define pb push_back
#define ff first
#define ss second
typedef long long ll;

const int N=1e5+100;
int f[N];

int main(){
	int n;cin>>n;
	map<int,int>M;
	vector<int>vec1;
	vector<int>vec2;
	for(int i=0;i<n;i++){
		int val;cin>>val;
		M[val]++;
		if(i&1)vec2.pb(val);
		else vec1.pb(val);
	}
	if(sz(M)==1){
		cout<<n/2<<endl;
		return 0;
	}
	int mx=0,id=-1;
	for(int i=0;i<sz(vec1);i++){
		f[vec1[i]]++;
		if(f[vec1[i]]>mx){
			mx=f[vec1[i]];
			id=vec1[i];
		}
	}
	memset(f,0,sizeof(f));
	int mx2=0,id2=-1;
	for(int i=0;i<sz(vec2);i++){
		f[vec2[i]]++;
		if(f[vec2[i]]>mx2){
			mx2=f[vec2[i]];
			id2=vec2[i];
		}
	}
	if(id!=id2)cout<<sz(vec1)-mx+sz(vec2)-mx2<<endl;
	else{
		int ans=N;
		for(int g=0;g<2;g++){
			memset(f,0,sizeof(f));
			int x=0;
			for(int i=0;i<sz(vec2);i++)if(vec2[i]!=id2){
				f[vec2[i]]++;
				if(f[vec2[i]]>x)x=f[vec2[i]];
			}
			ans=min(ans,sz(vec1)-mx+sz(vec2)-x);
			swap(vec1,vec2);
			swap(id,id2);
			swap(mx,mx2);
		}
		cout<<ans<<endl;

	}
	
	return 0;
}


Measured memory_bytes: 8848
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
#define foreach(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

inline int read() {
	int x = 0, f = 1, c = getchar();
	for (;!isdigit(c);c = getchar()) if (c == '-') f ^= 1;
	for (; isdigit(c);c = getchar()) x = x * 10 + c - '0';
	return f ? x : -x;
}

int n, m;
vector <pii> nodes;
vi g[300005];
vector <pii> e;
map <pii, int> nodeid;
queue <int> que;
vi dis;

int main() {
	n = read(), m = read();
	rep(i, m) {
		int u = read() - 1, v = read() - 1;
		e.pb(mp(u, v));
	}
	rep(i, n) rep(j, 3) nodes.pb(mp(i, j)), nodeid[mp(i, j)] = nodes.size() - 1;
	rep(i, m) {
		int u = e[i].first, v = e[i].second;
		g[nodeid[mp(u, 0)]].pb(nodeid[mp(v, 1)]);
		g[nodeid[mp(u, 1)]].pb(nodeid[mp(v, 2)]);
		g[nodeid[mp(u, 2)]].pb(nodeid[mp(v, 0)]);
	}
	dis.resize(nodes.size());
	rep(i, nodes.size()) dis[i] = -1;
	int S = read() - 1, T = read() - 1;
	S = nodeid[mp(S, 0)], T = nodeid[mp(T, 0)];
	dis[S] = 0; que.push(S);
	while (!que.empty()) {
		int u = que.front(); que.pop();
		rep(i, g[u].size()) {
			int v = g[u][i];
			if (!~dis[v]) {
				dis[v] = dis[u] + 1;
				que.push(v);
			}
		}
	}
	if (!~dis[T]) puts("-1");
	else printf("%d\n", dis[T] / 3);
	return 0;
}


Measured memory_bytes: 40300
N,K = map(int,input().split())
ans = 0
for b in range(K+1, N+1):
	# a=K, K+b, K+2b, ...
	n = N // b
	r = N % b
	c = b - K
	ans += n * c
	if r >= K:
		if K > 0:
			ans += r - K + 1
		else:
			ans += r - K
print(ans)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  bool flag = false;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == '7') flag = true;
  }
  
  if (flag) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int n = obj.nextInt();
        System.out.println((n/2+n%2));
    }
}


Measured memory_bytes: 21076
#include<iostream>
#include<cstdlib>

using namespace std;

typedef pair<int,int> P;

int dis(P p1, P p2){
  return abs(p1.first-p2.first)+abs(p1.second-p2.second);
}

int main(){
  int n,t[4];
  cin >> n >> t[0] >> t[1] >> t[2] >> t[3];

  int ans = (1<<25);

  for(int w = 1; w <= n; w++){
    P p[4];
    int nowx = 0,nowy = 1;
    for(int i = 1; i <= n; i++){
      for(int j = 0; j < 4; j++)
	if(t[j] == i) p[j] = P(nowx,nowy);
    
      nowx++;  
      if(nowx == w){
	nowy++;
	nowx=0;
      }
    }
    // cout << dis(p[0],p[1])+dis(p[2],p[3]) << endl;
    ans = min(ans,dis(p[0],p[1])+dis(p[2],p[3]));
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
#include <chrono>
#include <random>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXBIT=17;

int nbit,a,b;

int ans[1<<MAXBIT],nans;

void gen(int a,int b,int done) {
	int idx=-1; REP(i,nbit) { bool same=((a>>i)&1)==((b>>i)&1); if(done&(1<<i)) assert(same); else if(idx==-1&&!same) idx=i; } assert(idx!=-1);
	if((done|(1<<idx))==(1<<nbit)-1) { ans[nans++]=a; ans[nans++]=b; return; }
	int otheridx=-1; REP(i,nbit) if(otheridx==-1&&i!=idx&&(done&(1<<i))==0) otheridx=i;
	gen(a,a^(1<<otheridx),done|(1<<idx));
	gen(a^(1<<otheridx)^(1<<idx),b,done|(1<<idx));
}

bool solve() {
	int c=a^b; int cnt=0; REP(i,nbit) if(c&(1<<i)) ++cnt; if(cnt%2==0) return false;
	nans=0; gen(a,b,0);
	return true;
}

void run() {
	scanf("%d%d%d",&nbit,&a,&b);
	if(!solve()) { printf("NO\n"); return; }
	printf("YES\n");
	REP(i,1<<nbit) { if(i!=0) printf(" "); printf("%d",ans[i]); } puts("");
}

void stress() {
	std::mt19937 rnd(12398);
	int mxn=MAXBIT;
	REP(rep,1000) {
		nbit=rnd()%mxn+1;
		a=rnd()%(1<<nbit);
		b=rnd()%(1<<nbit);
		printf("%d %d %d\n",nbit,a,b);
		bool have=solve();
		if(have) {
			//REP(i,1<<nbit) { if(i!=0) printf(" "); printf("%d",ans[i]); } puts("");
			assert(ans[0]==a&&ans[(1<<nbit)-1]==b);
			vector<bool> seen(1<<nbit,false);
			REP(i,1<<nbit) { assert(0<=ans[i]&&ans[i]<(1<<nbit)&&!seen[ans[i]]); seen[ans[i]]=true; }
			FOR(i,1,1<<nbit) { int cnt=0; REP(j,nbit) if(((ans[i-1]>>j)&1)!=((ans[i]>>j)&1)) ++cnt; assert(cnt==1); }
		}
		printf(".");
	}
}

int main() {
	run();
	//stress();
	return 0;
}


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

cums = [0]
cums_p = [0]
for a in A:
    cums.append(cums[-1] + a)
    cums_p.append(cums_p[-1] + max(0,a))

ans = -float('inf')
for l in range(N-K+1):
    free = cums_p[l] + cums_p[-1] - cums_p[l+K]
    cont = cums[l+K] - cums[l]
    ans = max(ans, free, free+cont)
print(ans)

Measured memory_bytes: 17532
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


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


  
 int A;
  cin>>A;
  if(A<1200){
    cout<<"ABC"<<endl;
  }else{
    cout<<"ARC"<<endl;
  }
  
  
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;
using LL = long long;

int main(){
    int n;
    string si;
    cin >> n;
    int max = 0;
    map<string, int> m;
    vector<string> ans = {};
    for(int i=0;i <n; i++){
        cin >> si;
        if(m.find(si)!=end(m)){
            m.at(si) += 1;
        }else{
            m.insert(make_pair(si, 1));
        }
        if(m.at(si)>max){
            ans = {si};
            max = m.at(si);
        }else if(m.at(si)==max){
            ans.push_back(si);
        }
    }

    sort(begin(ans), end(ans));
    for(int i=0; i<ans.size(); i++){
        cout << ans[i] << endl;
    }

}

Measured memory_bytes: 26736
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		while (true)
		{
			try
			{
				double v = sc.nextDouble();
				int i = 1;
				while (i * 5 * 2 * 9.8 < v * v)
					i++;
				System.out.println(i+1);
			}
			catch (Exception e)
			{
				break;
			}
		}
	}
}

Measured memory_bytes: 12000
import math
import sys
input = sys.stdin.readline

def main():
    num, k = map(int, input().split())
    data = list(map(int, input().split()))

    count_list = [0 for i in range(40)]

    for i in range(num):
        now_bin = bin(data[i])[2:]
        now_bin = now_bin.zfill(40)
        for j in range(40):
            if now_bin[j] == '1':
                count_list[j] += 1

    ans_bin = ''
    max_bin = bin(k)[2:]
    max_bin = max_bin.zfill(40)
    large_flg = 0



    for i in range(40):
        if count_list[i] >= math.ceil(num / 2):
            if max_bin[i] == '1':
                large_flg = 1
            ans_bin += '0'
        else:
            if max_bin[i] == '1' or large_flg:
                ans_bin += '1'
            else:
                ans_bin += '0'

    ans_int = int(ans_bin, 2)
    # print(ans_int)
    ans = 0
    for i in range(num):
        ans += ans_int ^ data[i]

    print(ans)





if __name__ == '__main__':
    main()


Measured memory_bytes: 63320
# coding: utf-8
# Your code here!

from collections import defaultdict

R, G, B, N = map(int, input().rstrip().split(' '))
A = [R, G, B]

dp = defaultdict(lambda: defaultdict(lambda: -1))
def rec(i, n):
    if dp[i][n] != -1:
        return dp[i][n]
    if n == 0:
        return 1
    if i == 2:
        return n % A[2] == 0
       
    temp = 0
    for j in range(n // A[i] + 1):
        temp += rec(i + 1, n - j * A[i])
        
    dp[i][n] = temp
    
    return temp
    
print(rec(0, N))

Measured memory_bytes: 4132
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[] org = new boolean[n + 1];
		for (int i = 1; i <= n; i++) {
		    org[i] = (sc.nextInt() == 1);
		}
		boolean[] counts = new boolean[n + 1];
		boolean[] ans = new boolean[n + 1];
		for (int i = n; i >= 1; i--) {
		    if (counts[i] != org[i]) {
		        ans[i] = true;
		        counts[1] ^= true;
		        for (int j = 2; j <= Math.sqrt(i); j++) {
		            if (i % j == 0) {
    		            counts[j] ^= true;
    		            if (j * j != i) {
    		                counts[i / j] ^= true;
    		            }
		            }
		        }
		    }
		}
		boolean isFirst = true;
		StringBuilder sb = new StringBuilder();
		int count = 0;
		for (int i = 1; i <= n; i++) {
		    if (ans[i]) {
		        count++;
		        if (!isFirst) {
		            sb.append(" ");
		        } else {
		            isFirst = false;
		        }
		        sb.append(i);
		    }
		}
		System.out.println(count);
		if (count > 0) {
		    System.out.println(sb);
		}
   }
}


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

int main(){
  string S,newS;
  int N;
  
  cin>>N;
  cin>>S;
  
  for(int i=0;i<S.length();++i){
    if(S[i]+N>90){
      S[i]=S[i]+N-26;
    }else{
      S[i]=S[i]+N;
    }
  }
  cout<<S<<endl;
}

Measured memory_bytes: 256
M(int*a){return*1[&a]-*a;}n[];main(){qsort(n,scanf("%d%d%d%d%d",n,n+1,n+2,n+3,n+4,n+5),4,M);exit(!printf("%d %d %d %d %d\n",*n,n[1],n[2],n[3],n[4]));}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int upper = 100000;
const int Mod = 1e9 + 7;
vector<int> primes;
bitset<10000010>bs;
int num[1005];
void sieve (){
	bs.set();
	bs[0] = bs[1] = 0;
	for(ll i = 2 ; i <= upper ; ++i)if(bs[i]){
		for(ll j = i * i ; j <= upper ; j += i)bs[j] = 0;
		primes.push_back(int(i));
	}
}
void numdiv (int n){
	int ind = 0  , pf = primes[ind];
	while(n >= pf){
		while(n % pf == 0){
			num[pf]++;
			n /= pf;
		}
		pf = primes[++ind];
	}
}
int main() {
	sieve();
	int n ;
	cin>>n;
	ll res = 1;
	for(int i = 2 ; i <= n ; ++i)numdiv(i);
	for(int i = 2 ; i <= n ; ++i)res = (res * (num[i] + 1)) % Mod;
	cout<<res;
	return 0;
}

Measured memory_bytes: 1536
<?php
fscanf(STDIN,"%d %d",$N,$M);
for ($i = 0; $i < $N; ++$i) $cities[] = 0;
for ($i = 0; $i < $M; ++$i) {
    fscanf(STDIN,"%d %d",$f,$t);
    $cities[$f-1]++;
    $cities[$t-1]++;
}
for ($i = 0; $i < $N; ++$i) echo $cities[$i]."\n";
?>

Measured memory_bytes: 4728
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<map>
#define llong long long
#define ldouble long double
#define uint unsigned int
#define ullong unsigned long long
#define udouble unsigned double
#define uldouble unsigned long double
#define modinc(x) {if(x>=P) x-=P;}
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define piiii pair<pair<int,int>,pair<int,int> >
#define pli pair<llong,int>
#define pll pair<llong,llong>
#define Memset(a,x) {memset(a,x,sizeof(a));}
using namespace std;

const int N = 2e5;
const int LGN = 31;
llong a[N+3];
map<llong,int> mp;
int n;

bool cmp(llong x,llong y)
{
	return x>y;
}

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1,cmp); int ans = 0;
	for(int i=1; i<=n; i++)
	{
		bool found = false;
		for(int j=LGN; j>=1 && (1ll<<j)-a[i]>0; j--)
		{
			llong tmp = (1ll<<j)-a[i];
//			printf("%lld %lld\n",a[i],tmp-a[i]);
			if(mp[tmp]>0)
			{
				mp[tmp]--; ans++; found = true; break;
			}
		}
		if(found==false)
		{
			mp[a[i]]++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 52736
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B, H, M] = input[0].map(Number);

  const hAngle = ((H * 60 + M) / 720) * Math.PI * 2;
  const mAngle = (M / 60) * Math.PI * 2;

  const hX = A * Math.cos(hAngle);
  const hY = A * Math.sin(hAngle);
  const mX = B * Math.cos(mAngle);
  const mY = B * Math.sin(mAngle);

  const dX = mX - hX;
  const dY = mY - hY;

  return Math.sqrt(dX ** 2 + dY ** 2);
};

console.log(main(read()));


Measured memory_bytes: 29824
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 1000;

ll x[N],y[N],z[N],s[N];

int main() {
	int n,m;cin>>n>>m;
	rep(i,n) cin>>x[i]>>y[i]>>z[i];
	ll dx[]={1,-1, 1, 1,-1, 1,-1,-1};
	ll dy[]={1, 1,-1, 1,-1,-1, 1,-1};
	ll dz[]={1, 1, 1,-1, 1,-1,-1,-1};
	ll ans=0LL;
	rep(i,8){
		ll t_ans=0LL;
		rep(j,n) s[j]=dx[i]*x[j]+dy[i]*y[j]+dz[i]*z[j];
		sort(s,s+n,greater<ll>());
		rep(j,m) t_ans+=s[j];
		ans=max(ans,t_ans);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <math.h>
#include <list>

using namespace std;

int sum_digit(int n) {
	if (n == 0) return 0;
	else return n % 10 + sum_digit(n / 10);
}
int absolute(int a) {
	if (a < 0) return -a;
	else return a;
}

int main()
{
  string s; cin >> s;
  
  int red = 0 , blue = 0;
  for(int i = 0 ; i < s.size(); i++){
  	if(s.at(i) == '0') red++;
    else blue++;
  }
  
  int ans = 2 * min(red,blue);
  
  cout << ans << endl;
}

Measured memory_bytes: 512
n = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
 
ans = 1
hats = [0, 0, 0]
 
for a in A:
    count = hats.count(a)
    if count == 0:
        print(0)
        exit()
 
    idx = hats.index(a)
    hats[idx] += 1
    ans *= count
    ans %= mod
 
print(ans)

Measured memory_bytes: 13964
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,a,n)for(int (i) = (a);i<(n);i++)
#define INF 1e9
using namespace std;
int main(){
    using i64 = long long;
    #define int long long
    int N;
    cin >> N;
    vector<int> num;
    num.push_back(1);
    num.push_back(2);
    num.pop_back();
    for(int i =2;i<=N;i++){
        num.push_back(i);
        num.pop_back();
        if(num[i-2]+i>N)break;
        num.push_back(num[i - 2] + i);
    }
    num.push_back(num[num.size()-1]+num.size()+1);
    int MAX = num.size();
    //
    if(num[num.size()-2]==N)MAX--;
    if(num[num.size() - 2] == N) num.pop_back();
    //
    for(int i = MAX;N>0;i--){
        if(i > N) continue;
        int ei1333 =1333;
        //
        break;
        return 0;
    }
    for(int i = MAX;N>0;i--){
        if(i > N) continue;
        int ei1333 = 1333;
        cout<<i<<endl;
        N -= i;
        //
    }
    return 0;
} 

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>
#include <stdlib.h>
# include <map>

using namespace std;

int main(){
int k;
cin >> k;
if (k%2 == 0){
   cout << (k/2)*(k/2) << endl;
}

else{
    cout << ((k-1)/2)*(((k-1)/2)+1) << endl;
}
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }




// ***************************************


int main() {

    int K;
    cin >> K;
    ll ans = 0;
    REP(i, K) {
        REP(j, K) {
            int tmp = gcd(i + 1, j + 1);
            REP(k, K) {
                ans += (gcd(tmp, k + 1));
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636