akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.printf("%d %d%n", Math.min(a, b), Math.max(a + b - n, 0));
    }
}


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


int main() {
    int N, M, C;
  	cin >> N >> M >> C ;
    vector<int> b(M); vector<int> a(M);
    rep(i,M){
        cin >>  b[i];
    }
    int ans =0;
    for(int i=0;i<N;i++){
        int sum = C;
        for(int j=0;j<M;j++){
            int k;cin>>k;
            a[j] = k;
            sum += a[j]*b[j] ;
            
        }
        if(sum>0)ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
/*input
1 5
*/
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define input(str) freopen(str,"r",stdin);
#define output(str) freopen(str,"w",stdout);
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF  3e16+1
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld\n",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define modd 1000000007
#define len(x) x.size()
#define all(v) (v.begin(),v.end())
#define ll int
#define pi 3.1415926535897932384626
#define ld double
const int N =6e5+5;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
int powmod(int base,int exp,int mod)
{
	int res=1LL;
	while(exp>0)
	{
		if(exp&1LL)
			res=(res*base)%mod;
		exp/=2LL;
		base=(base*base)%mod;
	}
	return res%mod;
}
int dp[105][100500];
int pre[105][100500];
signed main()
{
	speed
	int n,k;
	cin>>n>>k;
	int a[n+1];
	Rep(i,n)
	{
		cin>>a[i];
	}
	a[0]=0;
	Rep(i,n)
	{
		dp[i][0]=1;
		pre[i][0]=1;
	}
	for(int i=1;i<=k;i++)
	{
		if(i<=a[1])
		{
			dp[1][i]=1;
		}
		pre[1][i]=(pre[1][i-1]+dp[1][i])%modd;
	}
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			dp[i][j]=pre[i-1][j];
			if(j-a[i]-1<0){
			}
			else
			{
				dp[i][j]-=pre[i-1][j-a[i]-1];
			}
			//dp[i][j]=max(0LL,dp[i][j]);
			dp[i][j]+=modd;
			dp[i][j]%=modd;
			pre[i][j]=(pre[i][j-1]+dp[i][j])%modd;
			pre[i][j]%=modd;
		}
	}
	cout<<dp[n][k]%modd<<endl;
	return 0;
}

Measured memory_bytes: 159232
n = int(input())
li = []
for i in range(9):
  li_2 = []
  for j in range(9):
    li_2.append(0)
  li.append(li_2)

ans = 0
for i in range(1,n+1):
  i = str(i)
  t = int(i[0])
  f = int(i[-1])
  if f != 0:
    li[t-1][f-1] += 1
for i in range(9):
  for j in range(9):
    cnt =  li[i][j]*li[j][i]
    ans += cnt
print(ans)
  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define debug(x) cerr << #x << ": " << x << endl
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

string s;
void gen(int rem, int tail) {
  if (rem == 0) {
    cout << s << '\n';
  } else {
    for (int x = 0; x < tail; ++x) {
      s += (char)('a' + x);
      gen(rem - 1, tail);
      s.pop_back();
    }
    s += (char)('a' + tail);
    gen(rem - 1, tail + 1);
    s.pop_back();
  }
}

signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef DEBUG
  freopen("in", "r", stdin);
#endif

  int n;
  cin >> n;
  s += 'a';
  gen(n - 1, 1);

  return 0;
}




Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define IO() freopen("palindrome.in","rw",stdin)
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long ll;
const int N = 1e6+9, M = 1e2+9, OO = 0x3f3f3f3f,MOD = 1e9 + 7;
vector<pair<int,int>> adj[N];
int dis[N],vis[N];
int n;
int dfs(int p)
{
  vis[p]=1;
  for(auto ch : adj[p])
  {
    if(vis[ch.first])
    {
      if(dis[ch.first]!=dis[p]+ch.second) return 1;
    }
    else
    {
      vis[ch.first]=1;
      dis[ch.first]=dis[p]+ch.second;
      if(dfs(ch.first)) return 1;
    }
  }
  return 0;
}
int main()
{
  int m;
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;++i)
  {
    int u,v,c;
    scanf("%d%d%d",&u,&v,&c);
    adj[u].push_back({v,-c});
    adj[v].push_back({u,c});
  }
  bool f=1;
  for(int i=1;i<=n;++i)
  {
    if(!vis[i] && dfs(i))
    {
      f=0;
      break;
    }
  }
  if(f) printf("Yes");
  else  printf("No");

  #ifdef _LOCAL_DEFINE  
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}



Measured memory_bytes: 37888
n = int(raw_input())



graph = [[] for i in range(n)]
for i in range(n):
    entry = map(int,raw_input().strip().split(' '))
    u = entry[0]-1
    for v in entry[2:]:
        v -= 1
        graph[u].append(v)

d = [-1 for i in range(n)]
d[0] = 0
t = 1
q = []
q.append(0)
while len(q) > 0:
    u = q[0]
    for v in graph[u]:
        if d[v] == -1:
            q.append(v)
            d[v] = d[u]+1
    del q[0]

for i in range(n):
    print i+1,d[i]

Measured memory_bytes: 6472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
  string str;
  cin >> str;

  if (str.size() % 2 == 1) {
    cout << "No" << endl;
  } else {
    string ans = "Yes";
    bool is_one = true;
    for (int i = 0; i < str.size(); ++i) {
      if ((is_one && str[i] != 'h') || (!is_one && str[i] != 'i')) {
        ans = "No";
        break;
      }
      is_one = !is_one;
    }

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
int n, m;

int main(){
	int i, j;
	string s;
	cin >> s;
	ll ans=0, c=0;
	n = s.length();
	for(i=0;i<n;i++){
		if(s[i] == 'W'){
			c++;
			ans += i-c+1;
		}
	}
	cout << ans;
}


Measured memory_bytes: 3676
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if(H == 0 && W == 0){
				scan.close();
				break;
			}
			for(int i=0; i<H; i++){

				for(int s=0; s<W; s++){
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.print("\n");
		}
	}
}

Measured memory_bytes: 26176
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  int n;
  int m;
  cin >> n;
  cin >> m;
  
  for(int i = 0; i <= n; ++i)
    for(int j = 0; j <= n; ++j) {
      int k = n - i - j;
      if(k < 0) continue;
      if(10000 * i + 5000 * j + 1000 * k == m) {
        cout << i << " " << j << " " << k;
        return 0;
      }
    }

  // cout << ans << endl;
  cout << "-1 -1 -1";
  return 0;
}



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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if(n <= 3) {
    cout << 0 << endl;
    return 0;
  }
  ll r = 0;
  ll g = 0;
  ll b = 0;
  rep(i,n){
    if(s[i] == 'R'){
      r++;
    }else if(s[i] == 'G'){
      g++;
    }else {
      b++;
    }
  }
  ll ans = r * g * b;
  for (int i = 0; i < n; i++){
    for (int j = i + 1; j < n; j++){
      if(s[i] == s[j]) continue;
      int k = j + j - i;
      if(k >= n || s[k] == s[i] || s[k] == s[j]){
        continue;
      }
      ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
# /user/bin/python
# -*- coding: utf-8 -*-


N,M = map(int, input().split())
ABn = [[0 for j in range(2)] for i in range(N)]
for i in range(N):
  ABn[i] = list(map(int, input().split()))

ABn = sorted(ABn)

num,i = M,0
ans = 0
while(num > 0):
  if num >= ABn[i][1]:
    ans += ABn[i][0] * ABn[i][1]
    num -= ABn[i][1]
  else:
    ans += ABn[i][0] * num
    num = 0
  i += 1
print(ans)

Measured memory_bytes: 28204
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int calc500(double record){
	if(record < 35.50){
		return 7;
	}else if(record < 37.50){
		return 6;
	}else if(record < 40.0){
		return 5;
	}else if(record < 43.0){
		return 4;
	}else if(record < 50.0){
		return 3;
	}else if(record < 55.0){
		return 2;
	}else if(record < 70.0){
		return 1;
	}else{
		return 0;
	}
}

int calc1000(double record){
	if(record < 71.0){
		return 7;
	}else if(record < 77.0){
		return 6;
	}else if(record < 83.0){
		return 5;
	}else if(record < 89.0){
		return 4;
	}else if(record < 105.0){
		return 3;
	}else if(record < 116.0){
		return 2;
	}else if(record < 148.0){
		return 1;
	}else{
		return 0;
	}
}

int main(){

	double t_500,t_1000;
	int rank500,rank1000,rank;

	while(scanf("%lf %lf",&t_500,&t_1000)!=EOF){
		rank500 = calc500(t_500);
		rank1000 = calc1000(t_1000);
		rank = min(rank500,rank1000);

		switch(rank){
		case 7:
			printf("AAA\n");
			break;
		case 6:
			printf("AA\n");
			break;
		case 5:
			printf("A\n");
			break;
		case 4:
			printf("B\n");
			break;
		case 3:
			printf("C\n");
			break;
		case 2:
			printf("D\n");
			break;
		case 1:
			printf("E\n");
			break;
		case 0:
			printf("NA\n");
			break;
		}
	}

    return 0;
}

Measured memory_bytes: 2508
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N, K;
vector<ll> A, B;

ll solve(ll x) {
    ll res = 0;
    REP(i, N) if((A[i]|x)==x) res += B[i];
    return res;
}

int main() {
    cin >> N >> K;
    A.resize(N);
    B.resize(N);
    REP(i, N) cin >> A[i] >> B[i];
    ll ans = solve(K);
    ll k, d=0;
    while(k=K>>d) {
        if(k&1) {
            k--;
            k<<=d;
            k|=(1<<d)-1;
            ans = max(ans, solve(k));
        }
        d++;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================





int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================
	



	int N, A, B;
	cin >> N >> A >> B;

	vint P(N);
	for (int i = 0; i < N; i++)
	{
		cin >> P[i];
	}


	int easy = 0;
	int mid = 0;
	int hard = 0;

	for (int i = 0; i < N; i++)
	{
		if (P[i] <= A)
		{
			easy++;
		}
		else if (P[i] <= B)
		{
			mid++;
		}
		else
		{
			hard++;
		}
	}

	cout << min(easy, min(mid, hard)) << endl;








}





Measured memory_bytes: 256
C=[];D=[];cost=1001;num=-1
N,T=map(int,input().split())
for i in range(N):
  c,t=map(int,input().split())
  C.append(c)
  D.append(t)
for i in range(N):
  if D[i]<=T:
    if C[i]<cost:
      cost=C[i]
      num=i
      #print(i,cost)
print(C[num] if num!=-1 else "TLE")

Measured memory_bytes: 3064
#include <set>
#include <cstdio>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

typedef long long ll;

using namespace std;

int e[1000];
ll dp[1000];
int cycle[1000];
int flag[1000];
int in[1000];

int n, m;

const int mod = 1000000007;

int check(int i){
  if(flag[i] == 2) return -1;
  if(flag[i] == 1){
    flag[i] = 2;
    return i;
  }

  flag[i] = 1;

  if(e[i] != -1){
    int c = check(e[i]);
    if(c != -1){
      flag[i] = 2;
      cycle[i] = c;
      if(c == i) return -1;
      else return c;
    }
  }
  flag[i] = 2;

  return -1;
}

int main(){
  n = getInt();
  m = getInt();

  REP(i,n){
    e[i] = -1;
    cycle[i] = i;
    dp[i] = 1;
  }

  REP(i,m){
    int s = getInt() - 1;
    int d = getInt() - 1;
    e[s] = d;
  }

  REP(i,n) if(!flag[i])
    check(i);

  REP(i,n) if(cycle[i] == i && e[i] != -1 && cycle[e[i]] != i)
    in[cycle[e[i]]]++;

  queue<int> que;
  ll ans = 1;

  REP(i,n) if(cycle[i] == i){
    if(in[i] == 0) que.push(i);
  }

  while(que.size()){
    int pos = que.front(); que.pop();
    flag[pos] = 5;

    if(e[pos] == -1 || cycle[e[pos]] == pos){
      ans = ans * (1 + dp[pos]) % mod;
    }else{
      int next = cycle[e[pos]];
      dp[next] = dp[next] * (1 + dp[pos]) % mod;
      if(--in[next] == 0)
        que.push(next);
    }
  }

  printf("%d\n", (int)ans);

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int, int> SEG;
typedef pair<SEG, int> S;
int main(){
  int N;
  while(cin>>N && N){
    vector<S> data;
    data.push_back(S(SEG(-1, 0), -1));
    REP(time, N){
      string cmd; cin>>cmd;
      if(cmd == "W"){
        int l, s; cin>>l>>s;
        vector<S> add;
        REP(i, data.size()-1){
          if(s == 0) break;
          if(data[i].first.second < data[i+1].first.first){
            int fst = data[i].first.second;
            int len = min(s, data[i+1].first.first - fst);
            add.push_back(S(SEG(fst, fst + len), l));
            s -= len;
          }
        }
        if(s > 0){
          int fst = data.back().first.second;
          int len = s;
          add.push_back(S(SEG(fst, fst + len), l));
        }
        REP(i, add.size()) data.push_back(add[i]);
        sort(data.begin(), data.end());
      }else if(cmd == "D"){
        int l; cin>>l;
        vector<S>::iterator it = data.begin();
        while(it != data.end()){
          if(it->second == l){
            it = data.erase(it);
          }else{
            it++;
          }
        }
      }else if(cmd == "R"){
        int P; cin>>P;
        int res = -1;
        REP(i, data.size())if(data[i].first.first <= P && P < data[i].first.second){
          res = data[i].second;
          break;
        }
        cout<< res << endl;
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1016
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a >= d) {
		cout << d << endl;
	}
	else if (a + b > d) {
		cout << a << endl;
	}
	else {
		cout << a - d + a + b << endl;
	}
}

Measured memory_bytes: 3636
from fractions import gcd

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

a = As[0]
k = 0
while a % 2 == 0:
  a //= 2
  k += 1
lst = [As[0]//2]

for i in range(1,N):
  j = 0
  a = As[i]
  while a % 2 == 0:
    a //= 2
    j += 1
  if k != j:
    print(0)
    exit()
  lst.append(As[i]//2)
  
lcm = lst[0]
for i in range(1,N):
  t = gcd(lcm, lst[i])
  lcm *= lst[i]//t
  if lcm > M:
    print(0)
    exit()
  
rlt = M //lcm
if rlt % 2 == 0:
  print(rlt//2)
else:
  print(rlt//2+1)

Measured memory_bytes: 96652
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int cnt[4];

void solve() {
	rep(i, 0, 3) {
		int a, b; cin >> a >> b; a--; b--;
		cnt[a]++; cnt[b]++;
	}
	bool ok = true;
	rep(i, 0, 4) {
		if(cnt[i] >= 3) ok = false;
	}
	if(ok) cout << "YES\n";
	else cout << "NO\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void){
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;
    return 0;
}

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

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

  string s;
  cin >> s;

  for (auto &c : s) c = (c == ',' ? ' ' : c);
  cout << s << '\n';

  return (0);
}


Measured memory_bytes: 3572
n = int(input())

s = []
for i in range(n):
    s.append(input())

out = {"AC":0,"WA":0,"TLE":0,"RE":0}

for i in range(n):
    out[s[i]] += 1
for i in ["AC","WA","TLE","RE"]:
    print(f"{i} x {out[i]}") 


Measured memory_bytes: 16332
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] l = new long[N];
		long[] r = new long[N];
		long[] len = new long[N];
		long ans = 0;
		for (int i = 0; i < N; ++i) {
			l[i] = sc.nextLong() - 1;
			r[i] = sc.nextLong() - 1;
			len[i] = r[i] - l[i];
		}

		PriorityQueue<Long> pqL = new PriorityQueue<>(new Comparator<Long>() {
			@Override
			public int compare(Long o1, Long o2) {
				return -Long.compare(o1, o2);
			}
		});
		PriorityQueue<Long> pqR = new PriorityQueue<>();

		long slideR = 0, slideL = 0;
		pqL.add(l[0]);
		pqR.add(l[0]);
		for (int i = 1; i < N; ++i) {
			slideL -= len[i];
			slideR += len[i - 1];
			long L = pqL.peek() + slideL;
			long R = pqR.peek() + slideR;
			if (L <= l[i] && l[i] <= R) {
				pqL.add(l[i] - slideL);
				pqR.add(l[i] - slideR);
			} else {
				if (l[i] < L) {
					pqL.poll();
					pqL.add(l[i] - slideL);
					pqL.add(l[i] - slideL);
					pqR.add(L - slideR);
					L = pqL.peek() + slideL;
					R = pqR.peek() + slideR;
					ans += (R - l[i]);
				} else {
					pqR.poll();
					pqR.add(l[i] - slideR);
					pqR.add(l[i] - slideR);
					pqL.add(R - slideL);
					L = pqL.peek() + slideL;
					R = pqR.peek() + slideR;
					ans += (l[i] - L);
				}
			}
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vector<ll> a(n); cin >> a;
    vector<bool> b(n+1, false);
    rep(i, n) {
        b[i] = a[i] == i+1;
    }
    ll ans = 0;
    rep(i, n) {
        if (b[i]) {
            b[i] = b[i+1] = false;
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
	int a, b;
	char op;
	do{
		scanf("%d %s %d", &a, &op, &b);
		if (op == '+')
		{
			printf("%d\n", a + b);
		}
		else if (op == '-')
		{
			printf("%d\n", a - b);
		}
		else if (op == '*')
		{
			printf("%d\n", a * b);
		}
		else if (op == '/')
		{
			printf("%d\n", a / b);
		}
	} while (op != '?');
	return 0;
}

Measured memory_bytes: 600
import numpy as np
fft = np.fft.rfft
ifft = np.fft.irfft

A = int(input())
B = int(input())
C = int(input())
X = int(input())

U = 20000
U = 1 << U.bit_length()


def conv(x, y):
    return (ifft(fft(x, U) * fft(y, U)) + 0.5).astype(np.int64)


fA = np.zeros(U, dtype=int)
fB = np.zeros(U, dtype=int)
fC = np.zeros(U, dtype=int)

fA[np.arange(A + 1) * 500] = 1
fB[np.arange(B + 1) * 100] = 1
fC[np.arange(C + 1) * 50] = 1

fABC = conv(conv(fA, fB), fC)
ans = fABC[X]
print(ans)

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = f(n);
  ans -= 1;
  ans -= choose(n,a);
  ans -= choose(n,b);
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long

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

	string s;
	cin >> s;
	bool flg = false;

	for (size_t i = 0; i < s.size()-1; i++)
	{
		if (s[i] == 'A'&&s[i + 1] == 'C')flg = true;
	}

	if (flg) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;i++)cin>>p.at(i);
  for(int i=0;i<n;i++)cin>>q.at(i);
  long long cnt=0;
  long long CNT=0;
  vector<int> v;
  for(int i=1;i<=n;i++)v.push_back(i);
  do{
    bool ok=true;
    cnt++;
    for(int i=0;i<n;i++){
      if(v.at(i)!=p.at(i)){
        ok=false;
      }
    }
    if(ok)break;
  }while(next_permutation(v.begin(),v.end()));
  sort(v.begin(),v.end());
  do{
    bool ok=true;
    CNT++;
    for(int i=0;i<n;i++){
      if(v.at(i)!=q.at(i)){
        ok=false;
      }
    }
    if(ok)break;
  }while(next_permutation(v.begin(),v.end()));
  cout<<abs(CNT-cnt)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if( a==b && a != c)
    cout << "Yes" ;
  else if(a == c && a != b)
    cout << "Yes";
  else if(b == c && a != b)
    cout << "Yes";
  else 
    cout << "No" ;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

import bisect
from itertools import accumulate

N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A.sort()

left = -1
right = 1 + 2 * 10 ** 5

def shake(x):
    cnt = 0
    for i in A:
        cnt += N - bisect.bisect_left(A, x - i)
    if cnt >= M:
        return 1
    else:
        return 0

while True:
    mid = (left + right) // 2
    if shake(mid):
        if not shake(mid + 1):
            X = mid
            break
        else:
            left = mid
    else:
        if shake(mid - 1):
            X = mid - 1
            break
        else:
            right = mid

happy = 0
cumsum_A = [0] + list(accumulate(A))

for j in A:
    idx = bisect.bisect_right(A, X - j)
    cnt = N - idx
    happy += cumsum_A[-1] - cumsum_A[idx] + cnt * j
    M -= cnt

happy += M * X

print(happy)


Measured memory_bytes: 60560
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(a == b && a == c && c ==a){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }        
    }
}

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

using namespace std;

int main(){
	string str;
	cin>>str;
	bool c=false,f=false;
	for (int i=0;i<str.length();i++){
		if(!c){
			if(str[i]=='C')c=true;
		}else if(!f){
			if(str[i]=='F')f=true;
		}
	}
	if(c&&f)printf("Yes\n");
	else printf("No\n");
}



Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

std::string s;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> s;

	int n = s.size();

	for (size_t i = 0; i < s.size()-1; i++)
	{
		if (s[i] != s[(s.size() - 2 - i)]) {
			out << -1 << endl;
			return 0;
		}
	}
	if (s.back() == '1') {
		out << -1 << endl;
		return 0;
	}
	if (s.front() != '1') {
		out << -1 << endl;
		return 0;
	}


	std::vector<std::pair<int, int>>res;
	res.emplace_back(1, 2);
	int32_t num = 2;
	int32_t node = 1;
	int32_t node_next = 2;
	for (size_t i = 0; i < n-2; i++)
	{
		if (s[i] == '1')
		{
			++num;
			res.emplace_back(node_next, num);
			node = node_next;
			node_next = num;
		}
		else
		{
			++num;
			res.emplace_back(node, num);
		}
	}
	for (auto& i : res) {
		out << i.first <<' '<< i.second << '\n';
	}


	return 0;
}
#endif



#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int32_t x[1000];
int32_t y[1000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		in >> x[i]>>y[i];
	}

	out << 30<<"\n1";
	for (uint32_t tmp = 2; tmp < (1<<30); tmp*=2)
	{
		out << ' ' << tmp;
	}
	out << '\n';



	return 0;
}
#endif


Measured memory_bytes: 2356
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int h, w;
    cin >> h >> w;
    char row[26];
    rep(i, 26) row[i] = (char)(i + 'A');
    vector<vector<string>> hw(h, vector<string>(w));
    rep(i, h) rep(j, w) cin >> hw[i][j];
    rep(i, h) rep(j, w) {
        if ( hw[i][j] == "snuke" ) {
            cout << row[j] << i + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
XL = list(map(int, input().split()))
YL = list(map(int, input().split()))

XL.append(X)
YL.append(Y)

Xa = max(XL)
Ya = min(YL)

if Xa < Ya:
  print("No War")
else:
  print("War")

Measured memory_bytes: 3060
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    println!("{}",(a+b)*c/2)
}

Measured memory_bytes: 4352
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    n, *P = map(int, read().split())

    ans = 0
    for i in range(1, n - 1):
        if P[i - 1] < P[i] < P[i + 1] or P[i + 1] < P[i] < P[i - 1]:
            ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9132
#include<map>
#include<queue>
#include<cstdio>
#include<string>

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

using namespace std;

const int INF=1<<29;

template<class T> struct Edge{
	int u,v;
	T w;
	Edge(int U,int V,T W):u(U),v(V),w(W){}
};

template<class T>
struct AdjList:public vector< vector< Edge<T> > >{
	AdjList(int n,const vector< Edge<T> > &v=vector< Edge<T> >()):vector< vector< Edge<T> > >(n,v){}
};

template<class T>
T Dijkstra(const AdjList<T> &adj,int s,int t){
	int n=adj.size();
	vector<T> d(n,INF); d[s]=0;

	priority_queue< pair<T,int> > pq; pq.push(make_pair(0,s));
	while(!pq.empty()){
		pair<T,int> a=pq.top(); pq.pop();
		int u=a.second;
		if(d[u]<-a.first) continue;
		if(u==t) break;

		rep(i,adj[u].size()){
			int v=adj[u][i].v;
			T w=adj[u][i].w;
			if(d[u]+w<d[v]){
				d[v]=d[u]+w;
				pq.push(make_pair(-d[v],v));
			}
		}
	}

	return d[t];
}

int main(){
	for(int n,m;scanf("%d%d",&n,&m),n;){
		int n2=0;
		map<string,int> f;

		int pos[3];
		rep(i,3){
			char s[1025]; scanf("%s",s);
			pos[i]=f[s]=n2++;
		}

		AdjList<int> adj(n);
		rep(_,m){
			char s1[1025],s2[1025];
			int u,v,d,t; scanf("%s%s%d%d",s1,s2,&d,&t);
			if(f.count(s1)==0) f[s1]=n2++;
			if(f.count(s2)==0) f[s2]=n2++;
			u=f[s1];
			v=f[s2];
			adj[u].push_back(Edge<int>(u,v,d/40+t));
			adj[v].push_back(Edge<int>(v,u,d/40+t));
		}

		printf("%d\n",Dijkstra(adj,pos[0],pos[1])+Dijkstra(adj,pos[1],pos[2]));
	}

	return 0;
}

Measured memory_bytes: 1088
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>

typedef long long LL;
using namespace std;

void read(int &v){int k=0,l=1;char ch;ch=getchar();while (ch>'9' || ch<'0'){if (ch=='-') l=-1;ch=getchar();}while (ch>='0' && ch<='9') k=k*10+ch-'0',ch=getchar();v=l*k;}
void print(int v){if (v<0) putchar('-'),v=-v;if (v>9) print(v/10);putchar(v%10+'0');}
int max(int a, int b) { return a>b ? a: b;}
int min(int a, int b) { return a<b ? a: b;}

static const int mod = 1e9 + 7;

static const int MAXN = 1e5 + 5;

static int Head[MAXN], Next[MAXN << 1], vet[MAXN << 1];
static int n, k, x, y, tot;

void add(int a, int b) {
        Next[++tot] = Head[a];
        vet[tot] = b;
        Head[a] = tot;
}

LL dfs(int x, LL colors, int pre) {
        LL val = 1;
        LL c = colors;
        for (int i = Head[x]; i; i = Next[i]) {
                int y = vet[i];
                if (y == pre) continue;
                val *= (c --) * dfs(y, max(colors - 1, k - 2), x) % mod;
                val %= mod;
        }
        return val;
}

int main() {
        read(n), read(k);
        for (int i = 1; i < n; ++i ) {
                read(x), read(y);
                add(x, y);
                add(y, x);
        }
        print(k * dfs(1, k - 1, 0) % mod);
        return 0;
}

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

int main(){
  
  int N;
  cin >> N;
  
  vector <int> A(N);
  
  cin >> A.at(0);
  int min = A.at(0);
  int max = A.at(0);
  
  for (int i=1; i<N; i++){
    cin >> A.at(i);
    if (A.at(i) < min ) min=A.at(i);
    else if (A.at(i) > max ) max = A.at(i);
    else continue;
  }
  
  cout << max - min <<endl;

}

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

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    while (n >= k) {
        n -= k * (n / k);
    }
    if (abs(n - k) < n) n = abs(n - k);
    cout << n;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ini(N);
  vi a(N); in(a);

  int ans = 0;
  rep(i,N) a[i]--;
  rep(i,N){
    ans += a[a[i]] == i;
  }
  out(ans / 2);
}

Measured memory_bytes: 640
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int K, rec[60], ans[60];
const int S = 50;

signed main() {
    cin >> K;
    int div = K / S, mo = K % S;
    rep(i,0,S) rec[i] = div + (i < mo);

    rep(i,0,S) {
        int sum = 0;
        rep(j,0,S) if(i != j) sum += rec[j];
        ans[i] = S * (rec[i] + 1) - sum - 1;
    }
    cout << S << endl;
    rep(i,0,S) cout << (i ? " " : "") << ans[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string S;
	cin >> S;
	int ans = 0;
	int tmp = 0;
	for (int i = 0; i<S.size(); i++) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
			tmp += 1;
		}
		else {
			tmp = 0;
		}
		if (ans < tmp) {
			ans = tmp;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n, m;
int k[11], p[11];
int s[11][11];

int main()
{
    int n, m, ans = 0;
    cin>>n>>m;
    REP(i,m) {
        cin>>k[i];
        REP(j,k[i]) {
            cin>>s[i][j];
        }
    }
    REP(i,m) {
        cin>>p[i];
    }
    REP(i,(1<<n)) {
        bool flag = true;
        REP(j,m) {
            int cnt = 0;
            REP(l,k[j]) {
                if (((1<<(s[j][l]-1)) & i) != 0) {
                    cnt++;
                }
            }
            if (cnt % 2 != p[j]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            ans ++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

const int Mod = 1e9 + 7, Nmax = 1e5 + 5;
void regl(int &x) { if(x>=Mod) x-=Mod; }

int n, i, j, ans, dp[Nmax], nxt[Nmax][3], s[Nmax];
char a[Nmax];

int main()
{
 ///   freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> (a+1);
    n = strlen(a+1);

    bool ok = 0;
    for(i=1; i<=n; ++i)
    {
        ok |= (i<n && a[i] == a[i+1]);
        a[i] -= 'a' - 1;
        s[i] = (s[i-1] + a[i]) % 3;
    }

    if(!ok)
    {
        cout << "1\n";
        return 0;
    }

    nxt[n+1][0] = nxt[n+1][1] = nxt[n+1][2] = n+1;
    for(i=n; i>=0; --i)
        memcpy(nxt[i], nxt[i+1], sizeof(nxt[i])), nxt[i][s[i]] = i;

    dp[0] = 1;
    for(i=0; i<=n; ++i)
    {
        dp[nxt[i][ (s[i]+1)%3 ]] += dp[i];
        regl(dp[nxt[i][ (s[i]+1)%3 ]]);

        dp[nxt[i][ (s[i]+2)%3 ]] += dp[i];
        regl(dp[nxt[i][ (s[i]+2)%3 ]]);

        if(s[i] == s[n] && i) ans += dp[i], regl(ans);
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


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

  ll N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;
  string t;
  cin >> t;

  ll ans = 0;
  REP(st, K){
    if (st+1>=N) break;
    ll nK = (N-st-1)/K+1;
    vector<vector<ll>> dp(nK, vector<ll>(3,0)); // max score end with {r, s, p}
    REP(i,nK){
      if (i==0){
        if(t[st+i*K]=='s') dp[i][0] = R;
        if(t[st+i*K]=='p') dp[i][1] = S;
        if(t[st+i*K]=='r') dp[i][2] = P;
      } else {
        ll pm = max(dp[i-1][0], max(dp[i-1][1], dp[i-1][2]));
        dp[i][0] = pm;
        dp[i][1] = pm;
        dp[i][2] = pm;
        if(t[st+i*K]=='s') dp[i][0] = max(pm, max(dp[i-1][1],dp[i-1][2]) + R);
        if(t[st+i*K]=='p') dp[i][1] = max(pm, max(dp[i-1][2],dp[i-1][0]) + S);
        if(t[st+i*K]=='r') dp[i][2] = max(pm, max(dp[i-1][0],dp[i-1][1]) + P);
      }
    }
    ans += max(max(dp[nK-1][0], dp[nK-1][1]), dp[nK-1][2]);
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 5840
//長方形の中に円が含まれるかを判定するプログラム
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void)
{
	int W,H,x,y,r;//整数


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

	if (x+r<=W&&x-r>=0&&y+r<=H&&y-r>=0) {
		printf("Yes\n");
	}
	
	else
	{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2132