akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define DBG(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll p = 1e9+7;
const ll INF = 1LL << 60;

vector<int> G[111111];
ll dp[111111][2];

ll rec(int nd,int hb,int par){
  //  DBG(nd);  DBG(hb);  DBG(par);
  if(dp[nd][hb]>0)return dp[nd][hb];
  
  dp[nd][hb]=1;
  
  if(hb){
    for(int i=0;i<G[nd].size();i++){
	 if(G[nd][i]==par)continue;
	 dp[nd][hb]*=rec(G[nd][i],0,nd);
	 dp[nd][hb]%=p;
    }
    return dp[nd][hb];
  }

  for(int i=0;i<G[nd].size();i++){
    if(G[nd][i]==par)continue;
    dp[nd][hb]*=(rec(G[nd][i],0,nd)+rec(G[nd][i],1,nd));
    dp[nd][hb]%=p;
  }
  return dp[nd][hb];
}


int main(){
  int n;
  cin>>n;
  for(int i=0;i<n-1;i++){
    int x,y;
    cin>>x>>y;
    G[x].PB(y);
    G[y].PB(x);
  }
  cout<<(rec(1,0,0)+rec(1,1,0))%p<<endl;
  /*
  for(int i=1;i<=n;i++){
    cout<<i<<" "<<dp[i][0]<<" "<<dp[i][1]<<endl;
  }
  */
  return 0;
}


Measured memory_bytes: 15872
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
	std::io::Read::read_to_string(
		&mut std::io::stdin(),
		&mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
	let mut get = || stdin.next().unwrap();
	macro_rules! get {
		() => (get().parse::<i64>().unwrap());
		($t:ty) => (get().parse::<$t>().unwrap());
	}
    
	let a = get!(usize);
	let b = get!(usize);
	let min = std::cmp::min(a, b);
	let xs = solve(min, a + b - min);
	let swap = b < a;
	show(&xs, swap);
}

fn solve(a: usize, b: usize) -> Vec<Vec<i32>> {
	let mut xs = vec![vec![0;100];100];
	let mut a = a - 1;
	let mut b = b;
	let mut c = 3;
	while a > 0 && b > 0 && c + 2 < 100 {
		let row = c;
		for dr in 0..3 {
			for col in 0..100 {
				xs[row + dr][col] = 1;
			}
		}
		c += 6;
        a -= 1;
        b -= 1;
	}
    fill(&mut xs, a, 3, 0);
    fill(&mut xs, b, 0, 1);
	xs
}

fn fill(xs: &mut Vec<Vec<i32>>, a: usize, p: usize, f: i32) {
	let mut a = a;
	for r in 0..30 {
		let row = r * 6 + p + 1;
		for c in 0..50 {
			if a == 0 { return; }
			let col = c * 2;
			xs[row][col] = f;
			a -= 1;
		}
	}
}

fn show(xs: &Vec<Vec<i32>>, swap: bool) {
	println!("100 100");
	for row in 0..100 {
		for col in 0..100 {
			let mut x = xs[row][col];
			if swap { x = 1 - x; }
			if x == 1 {
				print!("#");
			} else {
				print!(".");
			}
		}
		println!();
	}
}

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

int main() {
  ll x,y,k; cin>>x>>y>>k;
  
  if (k<=x) x-=k;
  else if ((k>x)&&(k<=y+x)) {
    y-=(k-x);
    x=0;
  }
  else {
    y=0;
    x=0;
  }
  cout<<x<<" "<<y<<endl; 
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<string> s(N);
  REP(i, N)
  cin >> s[i];
  int ans = 0;
  // 各s_iに含まれる'AB'をあらかじめ数えておく
  REP(i, N)
  {
    int len = s[i].size();
    int pos = 0;
    while (pos < len)
    {
      if (0 <= pos && pos < len - 1 && s[i][pos] == 'A' && s[i][pos + 1] == 'B')
      {
        ans++;
        pos += 2;
        continue;
      }
      pos++;
    }
  }
  int c1 = 0; // 先頭がB，末尾がA
  int c2 = 0; // 先頭がB, 末尾がA以外
  int c3 = 0; // 先頭がB以外，末尾がA
  REP(i, N)
  {
    int len = s[i].size();
    if (s[i][0] == 'B' && s[i][len - 1] == 'A')
      c1++;
    else if (s[i][0] == 'B')
      c2++;
    else if (s[i][len - 1] == 'A')
      c3++;
  }
  if (c1 == 0)
    ans += min(c2, c3);
  else
  {
    if (c2 + c3 == 0)
      ans += c1 - 1;
    else
      ans += c1 + min(c2, c3);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
l=[]
while True:
  e = list(map(int,input().split()))
  if e==[0, 0]:
    break
  l.append(e)

i = 0
while i < len(l):
  j = 0
  while j < l[i][0]:
    ans = ""
    if j == 0 or j == l[i][0]-1:
      for k in range(l[i][1]):
        ans += "#"
        k += 1
    else:
      ans += "#"
      for k in range (l[i][1]-2):
        ans += "."
        k += 1
      ans += "#"
    print(ans)
    j += 1
  i += 1
     
  print("")



Measured memory_bytes: 5620
#include<stdio.h>
#include<stdlib.h>

#define N 100005

typedef struct pp{
	
	char name[100];
	int y;
	
}P;

P Q[N+1];
int head,tail,n;

void enqueue(P x); //キュー末尾にヨウ素を追加
P dequeue();//キューの先頭から要素を取り出す
int min(int a,int b){
	int t;
	if(a>=b){t=b;}
	else {t=a;}
	
	return t;}

  /*／￣＼
○ ／￣￣￣＼ヘ
  /・   ・        ＼>
／￣￣￣＼   Ｖ|
｜ ――― ｜   ｜|
＼＿＿＿／   ∧|
    ＼                  ／〉
       ￣￣￣￣
    ヽ(´･w･)ﾉ
         |    /
         UU
うっせぇ、アンコウ投げんぞ!*/

int main(void){
	
	int n,c,q;
	int elaps = 0;
	P u;
	scanf("%d %d",&n, &q);
	
	for(int i=1;i<=n;i++){
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].y);
	}
	
	head =1;
	tail = n+1;
	
	while(head != tail){
		
		u = dequeue();
		c = min(q, u.y); //処理時間のどっちが短いか
		u.y -=c; //残り処理時間
		elaps += c;  //トータルの処理時間
		
			if(u.y>0){ enqueue(u);}
		else{
			printf("%s %d\n",u.name,elaps);
		}
				
	}
	
	
	return 0;
}

void enqueue(P x){
	Q[tail] = x;
	tail =( tail + 1) % N;
}

P dequeue(){
		P x = Q[head];
	head = (head + 1) % N;
	return x;
}



Measured memory_bytes: 11924
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif*/
}

int main()
{
	checkpoint1();
	string s,t;
	cin>>s>>t;
	ll n=s.length();
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		if(s[i]!=t[i])
			ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3828
N, M = map(int, input().split())
SC = [tuple(map(int, input().split())) for _ in range(M)]

for i in range(10**N):
    i = str(i)
    if len(i) != N:
        continue
    for s, c in SC:
        if len(i) < s:
            break
        if i[s - 1] != str(c):
            break
    else:
        print(i)
        exit()

print(-1)


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

const int MAX = 1000001; 

// structure to store queries 
struct Query { 
	int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) { 
	return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) { 
	for (; idx <= n; idx += idx & -idx) 
		bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) { 
	int sum = 0; 
	for (; idx > 0; idx -= idx & -idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) { 
	// initialising bit array 
	int bit[n + 1]; 
	memset(bit, 0, sizeof(bit)); 

	// holds the rightmost index of any number 
	// as numbers of a[i] are less than or equal to 10^6 
	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	// answer for each query 
	int ans[q]; 
	int query_counter = 0; 
	for (int i = 0; i < n; i++) { 
		// If last visit is not -1 update -1 at the 
		// idx equal to last_visit[arr[i]] 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		// Setting last_visit[arr[i]] as i and updating 
		// the bit array accordingly 
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		// If i is equal to r of any query store answer 
		// for that query in ans[] 
		while (query_counter < q && queries[query_counter].r == i) { 
			ans[queries[query_counter].idx] = query(queries[query_counter].r + 1, bit, n) - query(queries[query_counter].l, bit, n); 
			query_counter++;
		} 
	} 

	// print answer for each query 
	for (int i = 0; i < q; i++) 
		cout << ans[i] << '\n'; 
} 

// driver code 
int main() { 
	int n, q;
	cin >> n >> q;
	int a[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];

	Query queries[q];
	for (int i = 0; i < q; i++)  {
		int l, r;
		cin >> l >> r;
		l--, r--;
		queries[i].l = l;
		queries[i].r = r;
		queries[i].idx = i;
	}
	sort(queries, queries + q, cmp); 
	
	answeringQueries(a, n, queries, q); 
	
	return 0; 
} 


Measured memory_bytes: 19368
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return true;}return false;}

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,m);
  if (n >= 1 && m >= 2) {
    int qu = min(n, m/2);
    n -= qu;
    m -= qu*2;
    z += qu;
  }
  if (m >= 4) {
    int qu = m / 4;
    z += qu;
  }
  OUT(z);
}

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ll,ll> pll;

int x, y;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> x >> y;
    if ((y-2*x) % 2 != 0)
    {
        cout << "No\n";
        return 0;
    }
    int b = (y-2*x) / 2;
    int a = x-b;
    // cout << a << ' ' << b << '\n';
    cout << (b >= 0 && a >= 0 ? "Yes" : "No") << '\n';
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
bool isPrime(int);
int main(){
    int Q;
    int l[114514],r[114514];
    int Z[114514]={};
    cin >> Q;
    REP(i,Q){cin >> l[i] >> r[i];}
    REP(i,114514){
        if(isPrime(i+1)==true && isPrime((i+2)/2)==true){
            Z[i+1]=Z[i]+1;
        }else{
            Z[i+1]=Z[i];
        }
    }
    /*
    REP(i,30){
        cout << Z[i+1]-Z[i] << " ";
    }cout << endl;*/
    
    REP(i,Q){
        cout << Z[r[i]]-Z[l[i]-1] << endl;
    }
    
	return 0;
}

bool isPrime(int num) {
    if(num<2)return false;
    for(int i=2;i*i<=num;i++){
        if(num%i==0)return false;
    }
    return true;
}

Measured memory_bytes: 1920
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <forward_list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i]
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion

struct point {
    int x, y;

    point(int x = 0, int y = 0) : x(x), y(y) {}
};

int cross(const point &a, const point &b) {
    return a.x * b.y - a.y * b.x;
}

point vectorBy(const point &a, const point &b) {
    return {b.x - a.x, b.y - a.y};
}

point normal(const point &a) {
    return {a.y, -a.x};
}

vector<point> hull, vec;

void add_line(const point &a) {
    while (!vec.empty() && cross(vec.back(), normal(vectorBy(hull.back(), a))) >= 0) {
        hull.pop_back();
        vec.pop_back();
    }
    vec.push_back(normal(vectorBy(hull.back(), a)));
    hull.push_back(a);
}

int get_value(int x) {
    point p(x, 1);
    auto i = lower_bound(ALL(vec), p, [&](const point &a, const point &b) {
        return cross(a, b) < 0;
    }) - vec.begin();
    return hull[i].x * x + hull[i].y;
}

int32_t main() {
    hull.clear();
    vec.clear();
    make(int, n, c);
    makev(h, n);
    VI dp(n);
    hull.emplace_back(-2 * h[0], dp[0] + h[0] * h[0]);
    for (int i = 1; i < n; ++i) {
        dp[i] = get_value(h[i]) + h[i] * h[i] + c;
        add_line({-2 * h[i], dp[i] + h[i] * h[i]});
    }
    cout << dp.back();

    return 0;
}

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

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

    string s;
    cin >> s;
    if (s.back() == 's') s.push_back('e');
    cout << s << 's';
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define pb push_back
#define f first
#define s second
#define pi 3.141592653589793238
using namespace std;

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

ll power(ll a, ll b)	//a is base, b is exponent
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	if(b%2 == 1)
		return (power(a,b-1)*a)%mod;
	ll q = power(a,b/2);
	return (q*q)%mod;
}
ll h[300000];
ll a[300000];
ll n;
ll dp[300000];


int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n;

	for(int i =0;i<n;i++) cin >> h[i];
	for(int i =0;i<n;i++) cin >> a[i];
//	for(int i =0;i<300000;i++) dp[i] = -1;
//	cout << solve(1,0) << endl;	
	if(n==1) return cout << a[0] << endl,0;
	ll ma=0;
	set<ll> se;

	se.insert(-1);
//	dp[h[0]] = a[h[0]];
	for(int i =0;i<n;i++)
	{	
		auto it = se.lower_bound(h[i]);
		it--;
		dp[h[i]]= dp[*it]+a[i];
		if(dp[h[i]]>dp[*it])
		{
			while(!se.empty())
			{
				auto it =se.lower_bound(h[i]);
				if(it!=se.end()&&dp[h[i]]>dp[*it])
				{
					se.erase(*it);
				}
				else break;
			}
			se.insert(h[i]);
		}
		//dp[h[i]] = dp[*it]+a[i];
		ma =max(ma,dp[h[i]]);
	}
	cout << ma << endl;

	return 0;
}


//Hello, this is a snippet.


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



int main() {
    vector<int> x(32,1);
    x[3]=2;x[5]=2;x[7]=5;x[8]=2;x[9]=2;x[11]=5;x[13]=2;x[15]=14;x[17]=5;x[19]=5;x[20]=2;x[21]=2;x[23]=15;x[24]=2;x[25]=2;x[26]=5;x[27]=4;x[29]=4;x[31]=51;
    int n;
    cin>>n;
    n--;
    cout<<x[n]<<endl;
}

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

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

	switch (x) {
		case 7:
		case 5:
		case 3:
			cout << "YES" << endl;
			break;
		default:
			cout << "NO" << endl;
			break;	
	}


	return 0;
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main() {
	int X, F=0;
	cin >> X;
	int n = X;
	while (n > 0) {
		F += n % 10;
		n /= 10;
	}
	if (X%F == 0) {
		cout << "Yes" << endl;

	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct A{
	string s[6];
	void input(){
		for(int i=0;i<6;i++)cin>>s[i];
	}
	bool operator==(const A&a){
		for(int _=0;_<8;_++)
		{
			for(int __=0;__<4;__++)
			{
				bool flag=true;
				for(int i=0;i<6;i++)flag&=s[i]==a.s[i];
				if(flag)return true;
				string tmp=s[1];
				s[1]=s[2];
				s[2]=s[4];
				s[4]=s[3];
				s[3]=tmp;
			}
			if(_<4)
			{
				string tmp=s[0];
				s[0]=s[1];
				s[1]=s[5];
				s[5]=s[4];
				s[4]=tmp;
			}
			else
			{
				string tmp=s[0];
				s[0]=s[2];
				s[2]=s[5];
				s[5]=s[3];
				s[3]=tmp;
			}
		}
		return false;
	}
};
int N;
A a[30];
bool used[30];
main()
{
	while(cin>>N,N)
	{
		int ans=0;
		for(int i=0;i<N;i++)
		{
			a[i].input();
			used[i]=true;
			for(int j=0;j<i;j++)
			{
				if(used[j]&&a[j]==a[i])
				{
					used[i]=false;
					ans++;
					break;
				}
			}
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3160
#include<cstdio>
#include<iostream>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;

struct At{int u,v,w,next;}e[300004];

int g[100004],d[100004];
int n,m,tot=0;
bool vis[100004];

void input(){
	cin>>n;
	for(int i=1;i<n;i++){
		int u,v,w;
		cin>>u>>v>>w;
		e[++tot]=(At){u,v,w,g[u]};
		g[u]=tot;
		e[++tot]=(At){v,u,w,g[v]};
		g[v]=tot;
	}
}

int spfa(int st){
	queue<int>q;
	memset(d,127,sizeof(d));
	memset(vis,0,sizeof(vis));
	d[st]=0;
	q.push(st);
	vis[st]=1;
	while(!q.empty()){
		int x=q.front();
		q.pop();
		vis[x]=0;
		for(int i=g[x];i>0;i=e[i].next){
			int y=e[i].v,w=e[i].w;
			if(d[y]>d[x]+w){
				d[y]=d[x]+w;
				if(!vis[y]){
					vis[y]=1;
					q.push(y);
				}
			}
		}
	}
	int re=0,ba=st;
	for(int i=0;i<n;i++){
		if(d[i]>re){
			re=d[i];
			ba=i;
		}
	}
	return ba;
}

int main(){
	input();
	int ed1=spfa(0);
	int ed2=spfa(ed1);
	cout<<d[ed2]<<endl;
	return 0;
} 

Measured memory_bytes: 7156
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
using Graph = vector<vector<int>>;
using Graph_Wei = vector<vector<pair<int,int>>>;
using ll = long long;

vector<bool> seen;

Graph G;

int solve(ll a,ll b,ll c){

    for(int i=0;i < 1000;i++){

        if(a & 1) return i;
        if(b & 1) return i;
        if(c & 1) return i;

        ll ta,tb,tc;
        ta = (b + c)/2;
        tb = (a + c)/2;
        tc = (a + b)/2;

        a = ta;
        b = tb;
        c = tc;

    }
    return -1;
}


int main() {
    
    ll a,b,c;
    cin >> a >> b >> c;
    int res = 0;
    

    cout << solve(a,b,c) << endl;

    return 0;

}

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

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

void solve() {
    ll a, b, c; cin >> a >> b >> c;

    ll D = a + b - c;

    if(D > 0){
        cout << "No" << endl;
        return;
    }else{
        if( (4 * a * b) < (D * D) ){
            cout << "Yes" << endl;
            return;
        }else{
            cout << "No" << endl;
            return;
        }
    }
}

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

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

typedef long l;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int DX[] = {1, 0, -1, 0, 1, 1, -1, -1}, DY[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, d, x;
  cin >> n >> d >> x;

  int res = x;
  REP(i, n) {
    int a;
    cin >> a;
    for (int j = 1; j <= d; j += a) {
      res++;
    }
  }

  cout << res << endl;
}



Measured memory_bytes: 256
n = int(input())
monsters = list(map(int, input().split()))
heros = list(map(int, input().split()))

killed = 0
attack = 0
attack_l = [0, heros[0]]
for i in range(0, n+1):
  if i != n and i != 0:
    attack_l[1] = heros[i]
  attack = attack_l[0] + attack_l[1]
  if (monsters[i] - attack) < 0:
    killed += monsters[i]
    if (attack_l[0] - monsters[i]) < 0:
      attack_l[1] += (attack_l[0] - monsters[i])
    attack_l[0] = attack_l[1]
    attack_l[1] = 0
  elif (monsters[i] - attack) > 0:
    killed += attack
    attack_l[0] = 0
    attack_l[1] = 0
  elif (monsters[i] - attack) == 0:
    killed += monsters[i]
    attack_l[0] = 0
    attack_l[1] = 0

print(killed)

Measured memory_bytes: 19004
#include <bits/stdc++.h> 
#define pb push_back
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii; 
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int main() {

    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

    //int t; cin>>t; while(t--) 
	int n,k; cin>>k>>n;
	vi v(n);
	f(i,0,n) cin>>v[i];
	int x=abs(v[n-1]-v[0]);
	int mx=(x>k/2 ? k-x : x);
	f(i,1,n) {
		x=abs(v[i]-v[i-1]);
		x=(x>k/2 ? x=k-x: x );
		mx=max(x,mx);
	}
	cout<<k-mx;
	
    return 0 ;  
}

Measured memory_bytes: 1024
from scipy import special

S = int(input())
top = S // 3
if top == 0:
    print(0)
    exit()

ans = 1
mod = 10 ** 9 + 7
for i in range(2, top + 1):
    t = S - 3 * i
    i -= 1
    ans += special.comb(t+i, i, True)
print(ans % (mod))


Measured memory_bytes: 42320
// Danielxlr
// https://atcoder.jp/contests/abc055/tasks/arc069_a
// math
#include <iostream>
#include <algorithm>
using namespace std;

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

    if(m<2*n){
        cout<<min(n,m/2);
    }
    else{
        cout<<(2*n+m)/4;
    }
    return 0;
}

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

int main(){
	int n,a,b,c,x;
	while(cin >> n >> a >> b >> c >> x and !(n==0 and a==0 and b==0 and c==0 and x==0)){
		vector<int> y(n);
		for(int i=0;i<n;i++){
			cin >> y[i];
		}
		int cnt = 0, key = 0;
		while(cnt <= 10000){
			if(y[key]==x){
				key++;
			}
			if(key==n) break;
			x = (a*x + b) % c;
			cnt++;
		}
		if(key==n){
			cout << cnt << endl;
		}else{
			cout << -1 << endl;
		}
	}
}


Measured memory_bytes: 3040
loop do
  n,a,b,c,x = gets.split.map(&:to_i)
  break if n==0
  y = gets.split.map(&:to_i)

  res = 0
  pos = 0

  pos+=1 if x==y[pos]
  while res<10000 && pos<n
    x = (a*x + b)%c
    pos+=1 if x==y[pos]
    res+=1
  end

  if pos==n
    puts res
  else
    puts -1
  end
end

Measured memory_bytes: 8756
n = gets.to_i
ss = [100] * 26

1.upto(n) do
  tmp = [0] * 26
  gets.chomp.each_char do |c|
    tmp[c.ord - 97] += 1
  end

  0.upto(25) do |i|
    if tmp[i] < ss[i]
      ss[i] = tmp[i]
    end
  end
end

puts ss.each_with_index.map {|c, i|
  (97 + i).chr * c
}.join

Measured memory_bytes: 1788
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    	n:chars
    }
    let nn = n.into_iter().collect::<String>();
    
    println!("{}", match nn.trim() {
    "Sunny" => "Cloudy",
    "Cloudy" => "Rainy",
    "Rainy" => "Sunny",
    _ => "NOT"
    });
}

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

int n, m1 = INT_MIN, m2 = INT_MIN, n1 = INT_MAX, n2 = INT_MAX;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x, y; scanf("%d%d", &x, &y);
		m1 = max(m1, x + y);
		m2 = max(m2, x - y);
		n1 = min(n1, x + y);
		n2 = min(n2, x - y);
	}

	printf("%d\n", max(m1 - n1, m2 - n2));
	return 0;
}



Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=2e5+10;
const int mod=998244353;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,f[N][3][3],mx,p,fa[N],st[N],md[N],tp;
vi E[N];

void dfs(int u,int ff,int dis) {
	fa[u]=ff;
	if(dis>mx) mx=dis,p=u;
	for(auto v:E[u]) if(v!=ff) dfs(v,u,dis+1);
}

void dp(int u,int ff) {
	md[u]=0;
	for(auto v:E[u]) if(v!=ff) dp(v,u),md[u]=max(md[u],md[v]);
	if(md[u]==0) f[u][1][1]=1;
	else f[u][0][0]=1;
	for(auto v:E[u])
		if(v!=ff) {
			static int g[3][3];memset(g,0,sizeof(g));
			for(int i=0;i<3;i++)
				for(int j=0;j<3;j++)
					for(int k=0;k<3;k++)
						for(int l=0;l<3;l++) {
							int &t=g[min(i+(md[u]==md[v]?k:0),2)][min(j+(md[u]==md[v]?l:0),2)];
							t=(t+1ll*f[u][i][j]*f[v][k][l])%mod;
						}
			for(int i=0;i<3;i++)
				for(int j=0;j<3;j++) f[u][i][j]=g[i][j];
		}
	if(ff) {
		static int g[3][3];memset(g,0,sizeof(g));
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++) {
				g[0][0]=(g[0][0]+f[u][i][j])%mod;
				g[i][0]=(g[i][0]+f[u][i][j])%mod;
				g[0][j]=(g[0][j]+f[u][i][j])%mod;
			}
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++) f[u][i][j]=g[i][j];
		++md[u];
	}
}

int main() {
	cin>>n;
	for(int i=1,u,v;i<n;i++) u=gi(),v=gi(),E[u].pb(v),E[v].pb(u);
	dfs(1,0,0);mx=0;dfs(p,0,0);
	for(int i=p;i;i=fa[i]) st[++tp]=i;
	if(tp&1) {
		int x=st[(tp+1)/2];
		//cerr<<x<<'\n';
		dp(x,0);cout<<1ll*f[x][1][1]*((mod+1)>>1)%mod;
	}
	else {
		int x=st[tp/2],y=st[tp/2+1];
		dp(x,y);dp(y,x);cout<<1ll*f[x][0][1]*f[y][1][0]%mod;
	}
	return 0;
}


Measured memory_bytes: 28544
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;
#define PI 3.14159265358979323846

using namespace std;
typedef long long ll;

signed main() {
  int r;
  cin >> r;
  printf("%.20f\n", (double)2 * (double)r * PI);
  return 0;
}


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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

const int mod=1000000007;

int main(){
    string s;
    cin>>s;
    int ssz=s.size();
    if(s[0]==s[ssz-1]){
        if(ssz%2){
            cout<<"Second"<<endl;
        }
        else cout<<"First"<<endl;
    }
    else{
        if(ssz%2){
            cout<<"First"<<endl;
        }
        else cout<<"Second"<<endl;
    }
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}/*swap 交換*/
ll max2(ll a,ll b){return a>=b?a:b;}/*2つのうち大きい数を返す*/ 
ll min2(ll a,ll b){return a>=b?b:a;}/*2つのうち小さい数を返す*/ 
ll ABS(ll a){return a>=0?a:(-a);}/*絶対値*/ 
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

#define MAX_N (1 << 17)
ll seg[2*MAX_N-1];
void segmake(ll n, ll a[n] ,ll t){
    rep(i,0,t) seg[t-1+i]=i<n?a[i]:INF;
    while(t/=2) rep(i,0,t) seg[t+i-1]=min2(seg[2*(t+i)],seg[2*(t+i)-1]); 
}

ll segmin(ll from, ll to, ll a, ll l, ll r){
    return (l>=from && r<=to) ? seg[a] : (l>to || r<from) ? INF : min2(segmin(from,to,2*a+1,l,(l+r)/2),segmin(from,to,2*a+2,(l+r)/2+1,r));
}

void segupdate(ll a, ll b, ll t){
    ll c=t-1+a;
    seg[c]=b;
    while(c>0){
        c--; c/=2;
        seg[c]=min2(seg[2*(c+1)],seg[2*(c+1)-1]);
    }
    // a/=2; a--;
    // if(t==2){
    //     seg[a]=min2(seg[2*(a+1)],seg[2*(a+1)-1]);
    // }
    // if(t>3){
    //     while(a>0){
    //         a--; a/=2;
    //         seg[a]=min2(seg[2*(a+1)],seg[2*(a+1)-1]);
    //         a=(a-1)/2;
    //         if(a==0){
    //             seg[a]=min2(seg[2*(a+1)],seg[2*(a+1)-1]);
    //             break;   
    //         }
    //     }
    // }
}

int main(void){
    ll n,q;
    scanf("%lld%lld",&n,&q);
    ll b[n],query[q],t=1,x[q],y[q];
    while(t<n) t*=2;
    rep(i,0,n) b[i]=2147483647;
    segmake(n,b,t);
    rep(i,0,q) scanf("%lld%lld%lld",&query[i],&x[i],&y[i]);
    rep(i,0,q){
        if(query[i]==0){
            segupdate(x[i],y[i],t);
            // rep(j,0,2*t-1) printf("%lld ",seg[j]);
            // printf("\n");
        }else{
            printf("%lld\n",segmin(x[i],y[i],0,0,t-1) );
        }
    }
    return 0;
}



Measured memory_bytes: 6976
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> S(N);
  for(int i=0; i<N; i++){
    cin >> S.at(i);
  }
  for(int i=1; i<N; i++){
    int j = i,k;
    while(S.at(j)>S.at(j-1)){
      k=S.at(j);
      S.at(j)=S.at(j-1);
      S.at(j-1)=k;
      if(j==1) break;
      j--;
    }
  }
  int sum;
  for(int i=0; i<N; i+=2){
    if(N-i>=2) sum += S.at(i) - S.at(i+1);
    else sum += S.at(i);
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    int in[n] = {};
    rep(i, 0, m) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
        in[y]++;
    }

    int dist[n] = {};
    queue<int> que;
    rep(i, 0, n) {
        if (in[i] == 0) que.push(i);
    }
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (auto nv : g[v]) {
            in[nv]--;
            if (in[nv] == 0) {
                que.push(nv);
                dist[nv] = dist[v] + 1;
            }
        }
    }
    int ans = -1;
    rep(i, 0, n) ans = max(ans, dist[i]);
    cout << ans << endl;
    return 0;
}


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

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI 3.141592653589

using namespace std;

int main(void){
    int r;
    cin >> r;
    cout << r*r;
    
    return 0;
}

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

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI 3.141592653589793

using namespace std;

int main(void){
    int a, b;
    cin >> a >> b;

    if(a <= 9 && b <= 9) cout << a * b;
    else cout << "-1" ;

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(a,b)<<" "<<max((a+b)-n,0)<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;//でかい整数

int main(){
  double a,b,x;
  cin >>a>>b>>x;
  double th;
  if(a*b/2 <= x/a){
     th = atan(2*b/a - 2*x/(a*a*a));
  }else{
     th = atan(a*b*b/(2*x));
  }

  double ans = 180*th/3.14159265358979;
  cout << setprecision(10) << ans << endl;
  return 0;
}



Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
#print(a)
num=[]
num2=[]
count=0
m=a[0]
k=0
ans=0

for i in range(n):
    if a[i]==m:
        count=count+1
    else:
        num.append(m)
        num2.append(count)
        count=1
        m=a[i]
    if i==n-1:
        num.append(m)
        num2.append(count)

for i in range(len(num)):
    if num2[i]-num[i]>0:
        ans=ans+num2[i]-num[i]
    elif num2[i]-num[i]<0:
        ans=ans+num2[i]
#print(num,num2)
print(ans)

Measured memory_bytes: 14268
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <cstring>
#include <queue>
#include <unordered_map>
#include <vector>
#include <bitset>
#include <cstdio>
#include <climits>

#define eps 1e-6

#define MAXN 3010
#define INF 0x3f3f3f3f

#define MOD1 1000000009
#define MOD2 1000000007
#define MOD3 998244353
#define BASE1 304933
#define BASE2 4395853
const double PI = acos(-1);

using namespace std;
typedef long long ll;

ll S;
ll x1,x2,y_1,y2;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> S;
    x1 = y2 = sqrt(S);
    while(x1 * y2 < S)
    {
        x1++;
        y2++;
    }
    x2 = 1;
    y_1 = x1 * y2 - S;
    cout << 0 << " " << 0 << " " << x1 << " " << y_1 << " " << x2 << " " << y2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    REP(i, N) cin >> A[i] >> B[i];
    ll ans = 0;
    RREP(i, N){
        if(((A[i]+ans)%B[i])==0){
            continue;
        }else{
            ans += B[i]-((A[i]+ans)%B[i]);
        }
    }
    pr(ans);
}

Measured memory_bytes: 1792
from itertools import combinations


march = {'M':0,'A':0,'R':0,'C':0,'H':0}
n = int(input())
for _ in range(n):
    s = input()
    for cap in march:
        if s.startswith(cap):
            march[cap] +=1

trios = combinations(['M','A','R','C','H'],3)
ans = 0
for trio in trios:
    ans += march[trio[0]]*march[trio[1]]*march[trio[2]]

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int MOD = 1000000007;

int N, K, A[100], i, j;
long long int d[101][100001];

int main(){
	scanf("%d%d", &N, &K);
	for(i=0; i<N; i++){
		scanf("%d", A+i);
	}
	for(i=0; i<=N; i++){
		d[i][0] = 1;
	}
	for(i=0; i<N; i++){
		for(j=1; j<=K; j++){
			if(j-1-A[i] >= 0){
				d[i+1][j] = (d[i+1][j-1]+d[i][j]-d[i][j-1-A[i]]+MOD)%MOD;
			}else{
				d[i+1][j] = (d[i+1][j-1]+d[i][j])%MOD;
			}
		}
	}
	printf("%lld\n", d[N][K]);
}


Measured memory_bytes: 78336
import math
import collections
X,Y,A,B,C=  list(map(int,input().split(" ")))
Ps = list(map(int,input().split(" ")))
Qs = list(map(int,input().split(" ")))
Rs = list(map(int,input().split(" ")))
Ps.sort(reverse=True)
Qs.sort(reverse=True)
Ps = Ps[:X]
Qs = Qs[:Y]
ans = sum(Ps) + sum(Qs)
Ps.reverse()
Qs.reverse()
ind_p = 0
ind_q = 0
Rs.sort(reverse=True)
Ps.extend([10 ** 10] * (C -X) )
Qs.extend([10 ** 10] * (C -Y) )


for r in Rs:
    if r > Ps[ind_p] or  r > Qs[ind_q]:
        if Ps[ind_p]  > Qs[ind_q]:
            ans -= Qs[ind_q]
            ans += r
            ind_q += 1

        else:
            ans -= Ps[ind_p]
            ans += r
            ind_p += 1
print(ans)


Measured memory_bytes: 23740
// Problem : A - Sheep and Wolves
// Contest : AtCoder - AtCoder Beginner Contest 164
// URL : https://atcoder.jp/contests/abc164/tasks/abc164_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int a,b;
		cin>>a>>b;
		if(b>=a)
		{
			cout<<"unsafe";
		}
		else
		{
			cout<<"safe";
		}    	
    }
    return 0;
}



Measured memory_bytes: 3600
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip> 
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , a[N] , ans;
int main(){
fcin;
    cin >> n;
    for(int i = 1 ; i<= n ; i++){
        cin >> a[i];
        if(i%2!=0 && a[i]%2!=0) ans++;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3156
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var N = GetInt();
            var ans = N * N - GetInt();

            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
long long N;

void make(long long curr, int flag, vector<bool> flags, long long &ans) {
  if (curr > N) return;

  if (flag == 0) flags[0] = true;
  if (flag == 1) flags[1] = true;
  if (flag == 2) flags[2] = true;
  if (flags[0] && flags[1] && flags[2]) ans++;

  make(curr * 10 + 3, 0, flags, ans);
  make(curr * 10 + 5, 1, flags, ans);
  make(curr * 10 + 7, 2, flags, ans);
}

int main() {
  cin >> N;
  
  vector<bool> flags(3, false);
  long long ans = 0;
  make(0, -1, flags, ans);

  cout << ans << endl;
}


Measured memory_bytes: 256