akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

vector<int> graph[1000];

int main(void){
  int N, M, Q;                  // 頂点の数N，辺の数M，インプットの数Q
  cin>>N>>M;
  int cnt=0;

  FORQ(i,1,N){
    graph[i].push_back(0);
  }

  FOR(i,0,M){
    int a,b;
    cin>>a>>b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }


  int loop3SucFlag=0;
  int loop2FailFlag=0;
  vector<int> v(N+1);
  FORQ(i,1,N){
    v[i]=i;
  }

  do{
    FORQ( i,1,v.size()-2 ) { 
      FOR ( j,0,graph[v[i]].size() ) {
        if(graph[v[i]][j]==v[i+1]){
          loop3SucFlag=1;
          break;
        }else{
        }
      }

      if(loop3SucFlag==0){
        loop2FailFlag=1;
        break;
      }
      loop3SucFlag=0;
    }

    if(loop2FailFlag==0){
      cnt++;
    }
    loop2FailFlag=0;
    
  }while(   next_permutation(  v.begin()+1,v.end()  )   &&  v[1]==1);

  cout<<cnt<<endl;
  return 0;
}


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

int main()
{
  string s;
  cin>>s;
  int n=s.length();
  if(s[n-1]=='s')
  {
    s.append(1,'e');
    s.append(1,'s');
    cout<<s;
  }
  else
  {
     s.append(1,'s');
    cout<<s;
  }
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,m,i;
  cin>>n>>m;
  vector<int> a(m);
  for(i=0;i<m;i++) {
    cin>>a.at(i);
    n-=a.at(i);
  }
  if (n>=0) cout<<n<<endl;
  else cout<<-1<<endl;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

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

  vector<std::array<ll, 2>> dp(l.size());
  dp[0][0] = 2;
  dp[0][1] = 1;
  for (size_t i = 1; i < l.size(); ++i) {
    char c = l[i];
    if (c == '0') {
      dp[i][0] = dp[i-1][0];
      dp[i][1] = dp[i-1][1] * 3;
      dp[i][1] %= MOD;
    }
    else if (c == '1') {
      dp[i][0] = dp[i-1][0] * 2;
      dp[i][0] %= MOD;

      dp[i][1] = dp[i-1][0] + dp[i-1][1] * 3;
      dp[i][1] %= MOD;
    }
    else {
      assert(false);
    }
  }
  auto ans = dp[l.size()-1][0] + dp[l.size()-1][1];
  ans %= MOD;
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 2000
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 500005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int N,dp[MAXN],pre[MAXN];
char s[MAXN];
void Solve() {
	read(N);
	scanf("%s",s + 1);
	for(int i = 1 ; i <= N ; ++i) {
		if(s[i] == '0') pre[i] = i;
		else pre[i] = pre[i - 1];
	}
	for(int i = 1 ; i <= N ; ++i) {
		dp[i] = dp[i - 1];
		if(s[i] == '1') {
			if(pre[i] == 0) continue;
			int a = pre[i],b = pre[a - 1];
			if(b == a - 1) continue;
			dp[i] = max(dp[a - 2] + i - a,dp[i]);
			if(i - a == 1) {
				for(int j = b ; j <= a - 2 ; ++j) {
					dp[i] = max(dp[j] + a - j - 1,dp[i]);
				}
			}
		}
	}
	out(dp[N]);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 4608
#define _CRT_SECURE_NO_WARNINGS
 #define _USE_MATH_DEFINES
 #include <iostream>
 #include <list>
 #include <cstdio>
 #include <cmath>
 #include <cstring>
 #include <string>
 #include <vector>
 #include <algorithm>
 #include <utility>
 #include <queue>
 #include <iomanip>
 #define INF 2147483647
  
 using namespace std;


 int prime[10000];


bool isprime(int x)
{
	if (x == 2) return (true);
	if (x <= 1 || x % 2 == 0) return (false);

	for (int i = 3; i <= sqrt(x) + 1; i += 2) {
		if (x % i == 0) return (false); 
	}
	return (true); 
}

 int main(void)
 {
	 int n, x, cnt;

	 cnt = 0;
	 cin >> n;

	 for (int i = 0; i < n; i++) {
		 cin >> x;
		 if (isprime(x)) cnt++; 
	 }
	 cout << cnt << endl;

	 return (0);
 }

Measured memory_bytes: 1168
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

int main(){
    string s;
    cin>>s;
    rep(i,0,1){
        if(s[i]!=s[i+1]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N, 0);
    rep(i, K) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            A[a - 1] = 1;
        }
    }
    
    int ans = 0;
    rep(i, N) {
        if (A[i] == 0) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
typedef struct{
    int cost;
    int deadline;
}task;
int compare(const void *a,const void *b){
    task x=*(task*)a,y=*(task*)b;
    int tmp1=x.deadline,tmp2=y.deadline;
    if(tmp1>tmp2)return 1;
    return -1;
}
int main()
{   int n;
    scanf("%d",&n);
    task a[n];
    for(int i=0;i<n;i++)
    scanf("%d%d",&a[i].cost,&a[i].deadline);
    qsort(a,n,sizeof(task),compare);
    int TIME=0;
    for(int i=0;i<n;i++){
        TIME+=a[i].cost;
        if(TIME>a[i].deadline){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 3324
#include <iostream>

int search_combination(int from, int n, int s)
{
    if (n == 1) {
        if (from <= s && s <= 9) return 1;
        else return 0;
    }
    else {
        int cnt = 0;
        for (int i = from; i <= 10 - n; ++i)
            cnt += search_combination(i + 1, n - 1, s - i);
        return cnt;
    }
}

int main()
{
    while (true) {
        int n, s;
        std::cin >> n >> s;
        if (n == 0 && s == 0) break;

        if (s < n * (n - 1) / 2) std::cout << 0 << std::endl;
        else if (n * (19 - n) / 2 < s) std::cout << 0 << std::endl;
        else std::cout << search_combination(0, n, s) << std::endl;
    }
}

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


#define MOD 1000000007

using namespace std;

long long int modpow(long long int a, long long int n) {
	if (n == 0)return 1;
	if (n == 1)return (a % MOD);

	long long int hanbun = n / 2;
	long long int amari = n % 2;

	long long int ans = (a * a) % MOD;
	ans = modpow(ans, hanbun);

	if (amari == 1)ans *= a;

	ans %= MOD;

	return ans;

}

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}

	long long int amari = a % b;

	if (amari == 0)return b;

	return gcd(b, amari);
}

long long int lcm(long long int a, long long int b) {
	long long int ans = (a * b) % MOD;
	long long int wari = modpow(gcd(a, b), MOD - 2);
	ans = (ans * wari) % MOD;
	return ans;
}

long long int factElement[10000] = { 0 };

long long int factrial(int n) {

	if (factElement[n] != 0)return factElement[n];

	if (n == 0) {
		factElement[0] = 1;
		return factElement[n];
	}

	long long int ans = n * factrial(n - 1);
	factElement[n] = ans;
	return factElement[n];

}


int main()
{

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

	int ans = 0;
	while (n > 0) {
		ans++;
		n /= k;
	}

	cout << ans << endl;

	return 0;

}



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

int main(void){
  string S, answer;
  
  answer = "Good";
  cin >> S;
  
  for(int i = 0;i < 3;i++){
    if(S.at(i) == S.at(i + 1)){
      answer = "Bad";
    }
  }
  
  cout << answer << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main (){
  int n,a,b,max,min;
  cin >> n >> a >> b;
  if(a > b){
    max = b;
  } else {
    max = a;
  }
  min = a + b - n;
  if(min < 0){
    min = 0;
  }
  cout << max << " " << min << endl;
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <map>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    string s; cin >> s;
    map<char, int> mp;
    for(auto& c : s)
    {
        mp[c]++;
    }
    bool ok = true;
    for(auto& x : mp)
    {
        if(x.second != 2) ok = false;
    }
    if(mp.size() != 2) ok = false;
    cout << (ok ? "Yes" : "No") << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
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; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin>>n;
    vector<double> p(n);
    rep(i,n) cin>>p[i];
    auto dp=make_vec<double>(n+10,n+10);
    //dp[i][j]->i枚目までみてj枚表の確率
    //dp[i+1][j]=dp[i][j]*(1-p[i)+dp[i][j-1]*p[i];
    dp[0][0]=1;
    rep(i,n) {
        rep(j,n+1) {
            dp[i+1][j]+=dp[i][j]*(1-p[i]);
            if(j>0) dp[i+1][j]+=dp[i][j-1]*p[i];
        }
    }
    
    double ans=0;
    FOR(j,n/2+1,n) ans+=dp[n][j];
    cout<<fixed<<setprecision(10)<<ans<<endl;
}


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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

vector<int> V;

void printv()
{
	FOR(i, 0, V.size()){
		cout << i << " : " << V[i] << endl;
	}
}

int num(int n)
{
	return count_if(ALL(V), [n](int x){ return x >= n - 1; });
}

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

	V.resize(N+1);
	fill(ALL(V), 0);

	for(int i = 2; i <= N; i++){
		int n = i;
		for(int k = 2; k <= i; k++){
			if(n % k == 0){
				do {
					V[k]++;
					n /= k;
				}while(n % k == 0);
			}
		}
	}

//	printv();

//	printf("num(75)=%d\n", num(75));
//	printf("num(25)=%d\n", num(25));
//	printf("num(15)=%d\n", num(15));
//	printf("num(5)=%d\n", num(5));
//	printf("num(3)=%d\n", num(3));

	int ans = num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) / 2;

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s;
  string t;
  cin >> s >> t;
  mat dp(s.size()+1,vec(t.size()+1,inf));
  dp[0][0]=0;
  for(ll i=0;i<=s.size();i++) {
    for(ll j=0;j<=t.size();j++) {
      if(i>0&&j>0) {
        if(s[i-1]==t[j-1]) {
          dp[i][j]=min(dp[i][j],dp[i-1][j-1]);
        }
        else {
          dp[i][j]=min(dp[i][j],dp[i-1][j-1]+1);
        }
      }
      if(i>0) dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
      if(j>0) dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
    }
  }
  cout << dp[s.size()][t.size()] << endl;
}


Measured memory_bytes: 10792
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
//#define LOCAL
using namespace std;
typedef long long ll;
const int mx=15;

int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL
ll n;
cin>>n;
vector<bitset<64> >v(mx);
for(int i=0;i<n;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
        int sub;
        cin>>sub;
        v[i][sub]=1;
    }
}
ll q;
cin>>q;
bitset<64>a(0);
for(ll t=0;t<q;t++){
    ll com, i;
    cin>>com>>i;
    switch(com){
        case 0:
        (a.test(i))?puts("1"):puts("0");
        break;

        case 1:
        a=a|v[i];
        break;

        case 2:
        a=a&(~v[i]);
        break;

        case 3:
        a=a^v[i];
        break;

        case 4:((a&v[i])==v[i])?puts("1"):puts("0");
        break;

        case 5:((a&v[i]).any())?puts("1"):puts("0");
        break;

        case 6:((a&v[i]).none())?puts("1"):puts("0");
        break;

        case 7:cout<<(a&v[i]).count()<<endl;
        break;

        case 8:cout<<(a&v[i]).to_ulong()<<endl;
        break;
    }
}

#ifdef LOCAL
fin.close();
#endif // LOCAL
}



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


int main() {
    string s; cin >> s;
    bool ok = s[0] != s[1] && s[1] != s[2] && s[0]!=s[2];
    if(ok){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<cmath>
#define ll long long
#define pb push_back
#define vi vector<int>
#define si set<int>
#define msi multiset<int>
#define vll vector<ll>
#define ff first
#define ss second
#define pii pair<int,int>
#define mp make_pair
#define all(a) a.begin(),a.end()
#define f(i,x,n) for(int i=x;i<n;i++)
#define fd(i,n,x) for (int i=n;i>=x;i--)
#define itr :: iterator it
#define endl '\n'
#define INF 1e9
#define mod 1e9+7

using namespace std;
int step(int i,int j,int n,int a[],int b[],int c[],vector<vector<int> >&dp)
{
    if(i==n||j>3)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
        if(j==0)
        {
            int x=a[i]+step(i+1,1,n,a,b,c,dp);
            int y=b[i]+step(i+1,2,n,a,b,c,dp);
            int z=c[i]+step(i+1,3,n,a,b,c,dp);
            return dp[i][j]=max(x,max(y,z));
        }

        if(j==1)
            {
                int y=b[i]+step(i+1,2,n,a,b,c,dp);
                int z=c[i]+step(i+1,3,n,a,b,c,dp);
                return dp[i][j]=max(y,z);
            }
        if(j==2)
        {
                int x=a[i]+step(i+1,1,n,a,b,c,dp);
                int z=c[i]+step(i+1,3,n,a,b,c,dp);
                return dp[i][j]=max(x,z);
        }
        if(j==3)
        {
                int x=a[i]+step(i+1,1,n,a,b,c,dp);
                int y=b[i]+step(i+1,2,n,a,b,c,dp);
                return dp[i][j]=max(x,y);
        }

}
int main()
{
    int n;
    cin>>n;
    int a[100005],b[100005],c[100005];
    vector<vector<int> >dp(n,vector<int>(4,-1));
    for(int k=0;k<n;k++)
    {
        cin>>a[k]>>b[k]>>c[k];
    }
    cout<<step(0,0,n,a,b,c,dp);
}


Measured memory_bytes: 22444
A, B = [int(x) for x in input().split()]

# 0 xor 1 xor .... xor x
def xor_upto(x):
    b = int(x % 4 == 1 or x % 4 == 2)
    div = 2
    r = x % div
    q = x // div
    while q > 0:
        xor = int(q % 2 == 1 and r % 2 == 0)  # ビットをXORした結果
        b += xor * div
        div *= 2
        r = x % div
        q = x // div

    return b

if A == 0:
    ans = xor_upto(B)
else:
    ans = xor_upto(B) ^ xor_upto(A - 1)

print(ans)


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<string>
#include<utility>
#include<cmath>

using namespace std;

int main(){
    int n;
    cin >> n;
    pair<int, string> dp[n+1][64];
    int mod = 1000000007;
    string s = "ACGT";
    for(int i = 0; i < n+1; i++){
        int idx = 0;
        for(int j = 0; j < 4; j++){
            for(int k = 0; k < 4; k++){
                for(int l = 0; l < 4; l++){
                    string t = "";
                    t.push_back(s[j]);
                    t.push_back(s[k]);
                    t.push_back(s[l]);
                    dp[i][idx].second = t;
                    idx++;
                }
            }
        }
    }
//    for(int i = 0; i < 64; i++){
//        cout << dp[0][i].second << '\n';
//    }
	for(int i = 0; i <= n; i++){
		for(int j = 0; j < 64; j++){
			dp[i][j].first = 0;		
		}
	}
	for(int i = 0; i < 64; i++){
		dp[2][i].first = 1;
		if(dp[2][i].second == "AGC" || dp[2][i].second == "GAC" || dp[2][i].second == "ACG"){
			dp[2][i].first = 0;
		}
	}
	
	
    for(int i = 3; i <= n; i++){
    	for(int j = 0; j < 64; j++){
    		string u = dp[i][j].second;
    		if(u != "AGC" && u != "GAC" & u != "ACG"){
	    		for(int k = 0; k < 64; k++){
	    			string v = dp[i][k].second;
	    			if(u[0] == v[1] && u[1] == v[2]){
	    				if(!(v[0] == 'A' && v[2] =='G' && u[2] == 'C') && !(v[0] == 'A' && v[1] =='G' && u[2] == 'C')){
	    					dp[i][j].first += dp[i-1][k].first;
	    					dp[i][j].first %= mod;
	    				}
	    			}
	    		}	
    		}
    	}
    }
	int ans = 0;
    for(int i = 0; i < 64; i++){
    	// cout << dp[n-1][i].first << ' '<< dp[n-1][i].second     << '\n';	
    	ans += dp[n-1][i].first;
    	ans %= mod;
    }
    cout << ans << '\n';
}

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

int N;
long long A[101010], B[101010];
int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) scanf("%lld%lld", A+i, B+i);

	vector<pair<long long, long long>> st;
	for(int i = 0; i < N; ++i) st.push_back({A[i]+B[i],A[i]});
	sort(st.begin(),st.end());
	reverse(st.begin(),st.end());

	long long ret = 0;
	for(int i = 0; i < N; ++i){
		if(i % 2 == 0) ret += st[i].second;
		else ret += st[i].second - st[i].first;
	}

	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 3956
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Globalization;
namespace ant
{
    class MainClass
    {
        
        public static void Main(string[] args)
        {
            new MainClass().solve();
        }

        Scanner cin;

        //1<=|s|<=100
        string s;
        int ans = 0;
        void solve()
        {
            cin = new Scanner();
            s = cin.next();
            int min = 101;
            for (char c = 'a'; c <= 'z';c++)
              min = Math.Min(min, callRec(c));
            Console.WriteLine(min);
         }
        int ret = 0;
        int callRec(char c){
            for (int i = 0; i < s.Length;i++){
                if(s[i]!=c){
                    ret = 0;
                    ans = rec(c, s)+1;
                    return ans;
                }
            }
            ans = 0;
            return ans;
        }
        int rec(char c,string str){
			bool flag = true;
            string t = "";
            for (int i = 0; i < str.Length-1;i++){
                if(str[i]!=c&&str[i+1]==c)
                    t += str[i + 1];
                else
                    t += str[i];
            }
            for (int i = 0; i < t.Length;i++){
                if(t[i]!=c){
                    flag = false;
                    break;
                }
            }
            if (!flag)
                ret = rec(c, t) + 1;
                return ret;
        }
    }

    class Scanner{
        string[] nextBuffer;
        int BufferCnt;
        char[] cs = new char[] { ' ' };
        public Scanner(){
            nextBuffer = new string[0];
            BufferCnt = 0;
        }
        public string next()
        {
            if (BufferCnt < nextBuffer.Length)
                return nextBuffer[BufferCnt++];
            string st = Console.ReadLine();
            while (st == "")
                st = Console.ReadLine();
            nextBuffer= st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            BufferCnt=0;
            return nextBuffer[BufferCnt++];
        }
        public int nextInt(){
            return int.Parse(next());
        }
        public long nextLong(){
            return long.Parse(next());
        }
        public double nextDouble(){
            return double.Parse(next());
        }

    }
	class Printer : StreamWriter{
		public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
		public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
		public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { }
	}
   
}


Measured memory_bytes: 17228
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    G = [[] for _ in range(N)] 
    for _ in range(N - 1):
        a, b, c = LI()
        G[a-1].append((b - 1, c))
        G[b-1].append((a - 1, c))
    Q, K = LI()
    K -= 1

    dist = [-1] * N
    dist[K] = 0
    que = collections.deque()
    que.append(K)
    while que:
        c = que.popleft()
        for n, l in G[c]:
            if dist[n] == -1:
                dist[n] = dist[c] + l
                que.append(n)

    for _ in range(Q):
        x, y = LI_()
        ans = dist[x] + dist[y]
        print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 48096
x, k, d = (int(each) for each in input().split())

ideal_k = x // d
ideal_result = x - (ideal_k * d)

ideal_result_list = [ideal_result-d, ideal_result, ideal_result+d]
diff = [abs(each) for each in ideal_result_list]
i =  diff.index(min(diff))

ideal_result -= ((-i+1) * d)
ideal_k = abs((x - ideal_result) // d)

# print('ideal_k', ideal_k)
# print('ideal_result', ideal_result)

x = abs(x)

if k - ideal_k < 0:
    result = x - (k * d)
    result = x - (k * d)
elif (k - ideal_k) % 2 == 0:
    result = ideal_result
else:
    if ideal_result < 0:
        result = ideal_result + d
    else:
        result = ideal_result - d

print(abs(result))

Measured memory_bytes: 9220
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N);
        Console.WriteLine(A.Max() - A.Min());
    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

int main(){
  int n,i;
  cin >> n;
  for( i=0;i<n;i++){
    int k;
    cin >> k;
    if(k%2==0){
      if(k%3!=0 && k%5!=0){
        cout << "DENIED";
        break;
      }
    }
  }
  if(i==n){
    cout << "APPROVED";
  }
  return 0;
}
        

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

using namespace std;

using ll = long long;

int mp[100];

int main()
{
	mp['A'] = 1;
	mp['T'] = 1;
	mp['G'] = 1;
	mp['C'] = 1;
	string s;
	cin >> s;
	int f = 0, ans = 0;
	for (int i = 0; i < (int)s.length(); ++i)
	{
		if (mp[(int)s[i]])
		{
			f++;
		}
		else
		{
			ans = max(f, ans);
			f = 0;
		}
	}
	ans = max(f, ans);
	cout << ans << endl;
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int n;
	cin >> n;
	int ans = 0;
	int cnt = 0;
	int now = -1;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		if (x == now) {
			++cnt;
		}
		else {
			if (cnt > 1) {
				ans += cnt / 2;
			}
			now = x;
			cnt = 1;
		}
	}
	if (cnt > 1)
		ans += cnt / 2;
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, d int64

	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&d)

	var w = []int64{a, b}
	var h = []int64{c, d}

	var m int64 = math.MinInt64
	for _, x := range w {
		for _, y := range h {
			m = max(m, x*y)
		}
	}

	fmt.Println(m)
}

func max(a, b int64) int64 {
	if a > b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 1776
#include <stdio.h>
#include <math.h>

int main(void) {
  int n;
  while (scanf("%d", &n), n!=0) {
    int arr[n];
    double sum=0, m;
    for (int i=0; i<n; i++) {
      scanf("%d", &arr[i]);
      sum+=arr[i];
    }
    m=sum/n;

    double t=0;
    for (int i=0; i<n; i++) {
      t+=pow(arr[i]-m, 2);
    }

    printf("%lf\n", sqrt(t/n));
  }
  return 0;
}


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

int N,M;
int s[5],c[5];

string solve(){

    for(int i=0; i<=999; i++){
        bool flag = true;
        string check;
        check = to_string(i);

        if(check.size() != N) flag = false;

        for(int j=0; j<M; j++){
            if(check[s[j]] != char(c[j]+'0')) flag = false;
        }

        if(flag) return check;
    }

    return "-1";
}

int main(){
    cin>>N>>M;

    for(int i=0; i<M; i++){
        cin>>s[i]>>c[i];
        s[i]--;
    }

    cout<<(solve())<<endl;

    return 0;
}

Measured memory_bytes: 256
# 標準入力
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))

# 0 - indexed 化
for i in range(n):
    p[i] -= 1

ans = -12345678901234567

# 全ての場所からスタートを試す
for st in range(n):
    score = 0
    now = st

    # ループするまで or kまでスコアを計算しans更新
    for i in range(1,k+1):
        now = p[now]
        score += c[now]
        ans = max(ans,score)

        # ループしたら
        if now == st:
            # k回までに何回ループできるか計算
            # 最後の一回のループは愚直に計算する（どこに最適があるかわからないため）
            # 最後の一回のループ以外は最適になり得ないので省略しておｋ
            cnt = k//i - 1
            if cnt > 1:
                score *= cnt
                i *= cnt
                ans = max(ans,score)
            break

    # 最後のループ分を愚直に計算
    for j in range(i+1,k+1):
        now = p[now]
        score += c[now]
        ans = max(ans,score)
print(ans)

Measured memory_bytes: 74144
#include <iostream>

using namespace std;

int main()
{
    double x1, y1, x2, y2, x3, y3, xp, yp;
    double a, b, c;
    while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp)
    {
        a = (x3 - x2)*(yp - y2) - (y3 - y2)*(xp - x2);
        b = (x1 - x3)*(yp - y3) - (y1 - y3)*(xp - x3);
        c = (x2 - x1)*(yp - y1) - (y2 - y1)*(xp - x1);
        if((a >= 0 && b  >= 0 && c >= 0) || (a <= 0 && b <= 0 && c <= 0))
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 1224
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
int main()
{
    int N,D; cin >> N >> D;
    int val,int_sum,c=0;
    double sum=0;
    int X[N][D];
    rep(i,N) rep(j,D) cin >> X[i][j];
    for (int i1=0;i1<N;i1++){
        for (int i2=0;i2<N;i2++){
            if((i1==i2)||(i1<i2)) continue;
            sum=0;
            for (int j=0;j<D;j++){
                int val = (X[i1][j] - X[i2][j]);
                sum+=val*val;
            }
            int_sum=(int)sqrt(sum);
            if(int_sum*int_sum==sum){
                c++;
            }
        }
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

cnt = 10 ** 9
W = s.count(".")
w = 0
b = 0
for i, j in enumerate(s):
    cnt = min(cnt, b + W - w)
    if j == "#":
        b += 1
    else:
        w += 1
print(min(cnt, b + W - w))

Measured memory_bytes: 3500
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL n;
    cin >> n;
    vector<LL> a(n);
    LL sum_m=0;
    LL sum_p=0;
    LL ans_m=0;
    LL ans_p=0;
    LL ans;
    for(LL i=0; i<n; i++){
        cin >> a[i];
    }

    for(LL i=0; i<n; i++){
        sum_m+=a[i];
        if(i%2==0){
            if(sum_m>=0){
                ans_m=ans_m+1+sum_m;
                sum_m=-1;
            }
        }else{
            if(sum_m<=0){
                ans_m=ans_m+1-sum_m;
                sum_m=1;
            }
        }
        //cout << ans_m << " " << sum_m << endl;
    }

    //cout << "test" << endl;

    for(LL i=0; i<n; i++){
        sum_p+=a[i];
        if(i%2==0){
            if(sum_p<=0){
                ans_p=ans_p+1-sum_p;
                sum_p=1;
            }
        }else{
            if(sum_p>=0){
                ans_p=ans_p+1+sum_p;
                sum_p=-1;
            }
        }
        //cout << ans_p << " " << sum_p << endl;
    }

    ans=min(ans_p, ans_m);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;
#define out(i) cout<<(i)<<endl

ll gcd(ll a,ll b){
    if(a%b==0){return b;}
    else{return gcd(b,a%b);}
}

int main() {
  int a,b;
  cin>>a>>b;
  cout<<gcd(a,b)<<endl;
}



Measured memory_bytes: 3092
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d %d", &a,&b);

    if(a<b){
        printf("a < b\n");
    }
    else if(a>b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }

    return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int n,m,a[30],b[30],count=0,ans=0;
bool visited[8];

int dfs(v){
    visited[v]=true;
    count++;
    if (count==n){
        ans++;
    }
    for (int i=0; i<m; i++){
        if (a[i]==v){
            int v2=b[i];
            if (visited [v2]==true){
            continue;
            }
            dfs(v2);
            visited[v2]=false;
            count--;
        } else if (b[i]==v){
            int v2=a[i];
            if (visited [v2]==true){
            continue;
            }
            dfs(v2);
            visited[v2]=false;
            count--;
        }
    }
    return 0;
}


int main(void){
    scanf("%d%d",&n,&m);
    for (int i=0; i<n; i++){
        visited[i]=false;
    }
    for (int i=0; i<m; i++){
        scanf("%d%d",&a[i],&b[i]);
    }
    
    dfs(1);
    printf ("%d\n",ans);
	return 0 ;
}

Measured memory_bytes: 128
X, N = map(int, input().split())

if N == 0:
  print(X)
  exit()

import numpy as np
p = np.array(list(map(int, input().split())))
p = p-X

for i in range(100):
  if i in p and -1*i in p:
    continue
  if -1*i not in p:
    print(X-i)
    break
  else:
    print(X+i)
    break

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

// #define DEBUG

using namespace std;

const int N = 50+7;
const int M = 20+7;
const int MOD = 1e9+7;
const double eps = 1e-11;
typedef pair<int, int> pii;

int n, m;
long long res;
int f[N], d[N];
long long pt[N];
list<int> e[N];
pii a[N];

void build_tree(const int &u = 1, const int &fa = 0)
{
    f[u] = fa;
    d[u] = d[fa]+1;
    for (int v : e[u]) if (v != fa)
        build_tree(v, u);
}

// edge u is the edge bewteen u and f[u]
inline void get_path(const int &i)
{
    int u = a[i].first, v = a[i].second;
    if (d[u] < d[v]) swap(u, v);
    while (d[u] > d[v]) pt[i] |= 1ll<<u, u = f[u];
    while (u != v) {
        pt[i] |= 1ll<<u; u = f[u];
        pt[i] |= 1ll<<v; v = f[v];
    }
}

void dfs(const int &id, const int &num, const long long &val)
{
    if (id > m) {
        if (num) res += (num&1 ? 1 : -1)*1ll<<(n-1-__builtin_popcountll(val));
        return;
    }
    dfs(id+1, num, val);
    dfs(id+1, num+1, val|pt[id]);
}

inline void solve()
{
    cin >> n;
    for (int i = 1, u, v; i < n; ++i) {
        cin >> u >> v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    cin >> m;
    for (int i = 1, u, v; i <= m; ++i) {
        cin >> u >> v;
        a[i] = {u, v};
    }

    build_tree(1, 0);
    for (int i = 1; i <= m; ++i)
        get_path(i);
    dfs(1, 0, 0);
    #ifdef DEBUG
    for (int i = 1; i <= m; ++i)
        cout << bitset<64>(pt[i]) << endl;
    cout << res << endl;
    #endif
    res = (1ll<<(n-1))-res;
    cout << res << endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int T = 1;
    while (T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N; cin >> N;
    map<string,int> mp;

    for(int i=0; i<N; i++){
        string S; cin >> S;
        mp[S] += 1;
    }

    cout << mp.size() << endl;

}

Measured memory_bytes: 19176
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int n, m = 0;
    cin >> n;

    vector<int> a(n+1), b(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    int tmp;
    for (int i = n; i > 0; i--) {
        tmp = a[i];
        for (int j = i*2; j <= n; j+=i) {
            tmp ^= b[j];
        }
        b[i] = tmp;
        if (b[i] == 1) m++; 
    }

    cout << m << endl; 
    for (int i = 1; i <= n; i++) {
        if (b[i] == 1)
            cout << i << " ";
    }

    return 0;
}

Measured memory_bytes: 2432
import sys
INPUT = sys.stdin.readline

def SINGLE_INT(): return int(INPUT())
def MULTIPLE_INT_LIST(): return list(map(int, INPUT().split()))
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())
def SINGLE_STRING(): return INPUT()
def MULTIPLE_STRING(): return INPUT().split()

MOD = 10 ** 9 + 7

N, M = MULTIPLE_INT_MAP()

floors = [0] * (N + 1)
floors[0] = 1
floors[1] = 1

for _ in range(M):
    floors[SINGLE_INT()] = -1

for i in range(2, N+1):

    if floors[i] == -1:
        continue

    if floors[i-2] == floors[i-1] == -1:
        floors[-1] = 0
        break

    if floors[i-2] > 0:
        floors[i] += floors[i-2]
    if floors[i-1] > 0:
        floors[i] += floors[i-1]

    floors[i] %= MOD

print(floors[-1])


Measured memory_bytes: 6964
#include "bits/stdc++.h" 
using namespace std;

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

typedef int64_t ll;

ll k, n;
ll b[100000 + 100] = {0};

int main(){
  cin >> n >> k;
  rep(i, n){
    ll ai, bi;
    cin >> ai >> bi;
    b[ai] += bi;
  }
  int i = 0;
  while(k > 0){
    //cout << k << ":" << i << endl;
    k -= b[i++];
  }
  cout << i - 1 << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <vector>
#include <sstream>
#include <algorithm>
 
using namespace std;

bool compare_by_b(pair<long long, long long> a, pair<long long, long long> b) {
	return a.second < b.second;
}
 
int main(void) {
	long long n;
	cin >> n;
	vector<pair<long long, long long>> data(n);
	for(long long i = 0; i < n; i++){
		long long a, b;
		cin >> a >> b;
		data[i] = {a,b};
	}
	sort(data.begin(), data.end(), compare_by_b);
	int count = 0;
	long long sum = 0;
	for(long long i = 0; i < n; i++){
		pair<long long, long long> d;
		d = data[i];
		sum = sum + d.first;
		if(sum > d.second){
			count++;
		}
	}
	if(count == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(int &x){
    x=0;static char ch;static bool flag;flag = false;
    while(ch=getchar(),ch<'!');if(ch=='-') ch=getchar(),flag = true;
    while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
const int maxn = 100010;
int a[maxn];
int main(){
    int n,m;read(n);read(m);
    int u,v;
    rep(i,1,m){
	read(u);read(v);
	if(u != 1) ++ a[u];
	if(v != 1) ++ a[v];
    }
    bool flag = false;
    rep(i,2,n) if(a[i] & 1) {flag = true;break;}
puts(flag ? "NO" : "YES");
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    char s[7] = {};
    cin >> s;

    int r = 0;
    for (int i = 0; i < 6; i++) {
        if (s[i] == '1') r++;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn push(ncandidate: &mut Vec<i32>, a: i32, b: i32) {
    if 5000 < a {
        return;
    }
    ncandidate[a as usize] = std::cmp::min(ncandidate[a as usize], b);
}

fn main() {
    let n: usize = read();
    let mut ps = vec![0 as usize; n];
    let mut childs = vec![vec![]; n];
    let mut xs = vec![0 as i32; n];
    for i in 1..n {
        ps[i] = read();
        ps[i] -= 1;
        childs[ps[i]].push(i);
    }
    for i in 0..n {
        xs[i] = read();
    }
    let mut min_value = vec![1 << 30; n];
    for i in (0..n).rev() {
        if childs[i].len() == 0 {
            min_value[i] = 0;
            continue;
        }
        let mut candidate = vec![1 << 30; 5001];
        candidate[0] = 0;
        for &c in childs[i].iter() {
            let mut ncandidate = vec![1 << 30; 5001];
            for w in 0..5001 {
                if candidate[w as usize] == 1 << 30 {
                    continue;
                }
                push(
                    &mut ncandidate,
                    w + xs[c],
                    candidate[w as usize] + min_value[c],
                );
                push(
                    &mut ncandidate,
                    w + min_value[c],
                    candidate[w as usize] + xs[c],
                );
                push(
                    &mut ncandidate,
                    candidate[w as usize] + xs[c],
                    w + min_value[c],
                );
                push(
                    &mut ncandidate,
                    candidate[w as usize] + min_value[c],
                    w + xs[c],
                );
            }
            candidate = ncandidate;
        }
        for w in 0..5001 {
            if candidate[w] == 1 << 30 {
                continue;
            }
            if w as i32 <= xs[i] {
                min_value[i] = std::cmp::min(min_value[i], candidate[w]);
            }
            if candidate[w] <= xs[i] {
                min_value[i] = std::cmp::min(min_value[i], w as i32);
            }
        }
    }
    if min_value[0] != 1 << 30 {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
    int H, W, i, j;

    while (1) {
        scanf("%d %d", &H, &W);

        if (H == 0 && W == 0)
            break;

        for (i = 0; i < H; i++) {
            for (j = 0; j < W; j++)
                putchar('#');
            putchar('\n');
        }
        putchar('\n');
    }

    return 0;
}


Measured memory_bytes: 2132
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	int g[] = { 0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };
	int x, y;
	cin >> x >> y;
	cout << (g[x] == g[y] ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256