akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repr(i, a, b) for (int i = (int)a; i > (int)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 4e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
bool used[1000005];
int num = 0;
int dist[1000005];
vii edges[1000005];
bool dfs(int now,int bef){
    used[now] = true;
    //各頂点からの最大深さを記録。dfsで子を全部試した後最大の深さ+1を距離とする。
    if (edges[now].empty()){
        dist[now] = 1;
        return true;
    }
    for (auto nex:edges[now]){
        if (used[nex] && dist[nex]==0){
            return false;
        }
        if (!(used[nex])){
            if (!(dfs(nex, now)))
            {
                return false;
            }
        }
        dist[now] = max(dist[now], dist[nex] + 1);
    }
    return true;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    map<pii, int> idx;
    rep(i,n-1){
        repf(j, i+1, n)
        {
            idx[mp(i, j)] = num;
            dist[num] = 0;
            num++;
        }
    }
    rep(i,n){
        int bef;
        cin >> bef;
        bef--;
        rep(j,n-2){
            int now;
            cin >> now;
            now--;
            //cout << i << " " << bef << " " << i << " " << now << ENDL;
            //cout << idx[mp(min(i, bef), max(i, bef))] << " " << idx[mp(min(i, now), max(i, now))] << ENDL;
            edges[idx[mp(min(i, bef), max(i, bef))]].eb(idx[mp(min(i, now), max(i, now))]);
            bef = now;
        }
    }
    rep(i,num){
        if (used[i])
            continue;
        if (!(dfs(i, -1))){
            cout << -1 << ENDL;
            return 0;
        }
    }
    int ans = 0;
    rep(i, num){
        ans = max(ans, dist[i]);
    }
    cout << ans << ENDL;
}

Measured memory_bytes: 74240
def B():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        return
    ret = 1
    for d in a:
        ret *= d
        if ret > pow(10, 18) :
            print(-1)
            return
    print(ret)
B()

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

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

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

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

int main(){
	LL n,a,b,h[101001]={};
	cin>>n>>a>>b;
	FOR(i,0,n)cin>>h[i];
	sort(h,h+n);
	LL l=0,r=1e9,m=(l+r+1)/2,c=a-b;
	while(m!=r){
		LL cnt=0;
		FOR(i,0,n){
			if(h[i]>b*m)cnt+=(h[i]-b*m+c-1)/c;
		}
		if(cnt<=m){
			r=m;
		}else{
			l=m;
		}
		m=(l+r+1)/2;
	}
	cout<<m<<endl;



    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

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

            for (int A = 1; A <= 9; A++) {
                for (int B = 1; B <= 9; B++) {
                    if (A * B == N) {
                        System.out.println("Yes");
                        return;
                    }
                }
            }

            System.out.println("No");
        }
    }
}


Measured memory_bytes: 27092
N = int(input())
words = {}
ans = []
for i in range(N):
  w = input()
  words.setdefault(w, 0)
  words[w] += 1
m = max(list(words.values()))
for k, v in words.items():
  if v == m:
    ans.append(k)
ans.sort()
for w in ans:
  print(w)

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

int x_1, x_2, y_1, y_2, absx, absy;

int main(){
    scanf("%d%d%d%d", &x_1, &y_1, &x_2, &y_2);
    absx = y_1-y_2;
    absy = x_2-x_1;
    printf("%d %d %d %d\n", x_2+absx, y_2+absy, x_1+absx, y_1+absy);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        char a[] = s1.toCharArray();
        char b[] = s2.toCharArray();
        int count =0 ;
        for(int i = 0; i<a.length ; i++){
               if(a[i] ==b[i]){
                   count++;
               }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;

void b_0or1_swap(void) {
	int n;
	int* p;
	int* p_copy;
	int d;
	cin >> n;
	p = (int*)calloc(n, sizeof(int));
	p_copy = (int*)calloc(n, sizeof(int));

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

	sort(p_copy, p_copy + n);

	int det = 0;
	for (int i = 0; i < n; i++) {
		int diff = p[i] - p_copy[i];
		if (diff != 0) det++;
	}

	if (det > 2)cout << "NO" << endl;
	else        cout << "YES" << endl;
}

int main()
{
    b_0or1_swap();

    return 0;
}

Measured memory_bytes: 3528
/*
AizuOnline A0555
Ring
*/
#include <stdio.h>
#include <string.h>

char ring[21];
char search[11];


main()
{
  int i,j;
  int cnt;
  int len;
  int N;

  scanf("%s",search);
  len = strlen(search);

  scanf("%d",&N);
  cnt = 0;

  /* printf("s=%s N=%d\n",search,N);*/


  for(i=0;i<N;i++)
    {
      scanf(" %s",ring);
      strncpy(&(ring[10]),ring,10);
      ring[20]='\0';
      /* printf("%s",ring); */
      for(j=0;j<10;j++)
	if(0==strncmp(&(ring[j]),search,len))
	  {
	    cnt++;
	    break;
	  }
    }

  printf("%d\n",cnt);

return(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc167/abc167_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, M, X;
  cin >> N >> M >> X;

  vector<int> c(N);
  vector<vector<int>> a(N, vector<int>(M, 0));
  rep(i, N) {
    cin >> c[i];
    rep(j, M) { cin >> a[i][j]; }
  }

  ll ans = LINF;
  rep(i, pow(2, N)) {
    ll tmpans = 0;
    vector<ll> buf(M, 0);
    rep(j, N) {
      if (i & (1 << j)) {
        tmpans += c[j];
        rep(l, M) { buf[l] += a[j][l]; }
      }
    }
    bool ok = true;
    rep(k, M) { ok &= X <= buf[k]; }
    if (ok) ans = min(tmpans, ans);
  }

  cout << (ans != LINF ? ans : -1) << endl;
}

Measured memory_bytes: 4072
#include<bits/stdc++.h>
#define  f first 
#define  s second 
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int w,h,c=1,sx,sy,gx,gy;
char mp[101][101];
int bt[101][101];
int cs[101][101];
int nn[5][5]=
  {{2,2,2,2,2},
   {2,3,3,3,2},
   {2,3,1e8,3,2},
   {2,3,3,3,2},
   {2,2,2,2,2}
  };
int used[100][101][101];
 
void nu(int x,int y){
  for(int i=0;i<5;i++)
    for(int j=0;j<5;j++){
      int nx=x+j-2,ny=y+i-2;
      if(nx<0||w<=nx||ny<0||h<=ny)continue;
      cs[ny][nx]=max(nn[i][j],cs[ny][nx]);
    }
}
 
int cal(){
  priority_queue<PP,vector<PP>,greater<PP> > Q;
  Q.push(PP(P(0,0),P(sx,sy)));
  int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
  while(!Q.empty()){
    PP p=Q.top();
    Q.pop();
    if(p.s.f==gx&&p.s.s==gy&&p.f.s==c-1)return p.f.f;
    if(used[p.f.s][p.s.s][p.s.f]==1)continue;
    used[p.f.s][p.s.s][p.s.f]=1;
    for(int i=0;i<4;i++){
      int nx=p.s.f+dx[i],ny=p.s.s+dy[i];
      int ncs=p.f.f+cs[p.s.s][p.s.f],nbt=p.f.s|bt[p.s.s][p.s.f];
      if(nx<0||w<=nx||ny<0||h<=ny)continue;
      Q.push(PP(P(ncs,nbt),P(nx,ny)));
    }
  }
}
 
 
int main(){
  cin>>w>>h;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      cin>>mp[i][j];
      cs[i][j]=max(1,cs[i][j]);
      if(mp[i][j]=='M')bt[i][j]=c,c*=2;
      if(mp[i][j]=='#')nu(j,i);
      if(mp[i][j]=='S')sx=j,sy=i;
      if(mp[i][j]=='G')gx=j,gy=i;
    }
  cout<<cal()<<endl; 
  return 0;
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int parent[100009];
int sizee[100009];

void make_set(int v) {
    parent[v] = v;
    sizee[v] = 1;
}

int find_set(int v) {
    if (v == parent[v])
        return v;
    return find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (sizee[a] < sizee[b])
            swap(a, b);
        parent[b] = a;
        sizee[a] += sizee[b];
    }
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N, M;
    cin >> N >> M;
    VI A(N+2);
    FOR(i, 1, N) {
        make_set(i);
        cin >> A[i];
    }
    REP(i, M) {
        int x, y;
        cin >> x >> y;
        union_sets(x, y);
    }
    int ans = 0;
    FOR(i, 1, N) {
        if (find_set(A[i]) == find_set(i)) {
            ans++;
        }
    }
    cout << ans << endl;

}

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

int main() {
  string X; cin >> X;
  int stack = 0, puyo = 0;
  for (int i = 0; i < (int)X.size(); ++i) {
	if (X[i] == 'S') ++stack;
	else if (stack > 0) --stack, ++puyo;
  }
  cout << (int)X.size() - puyo*2 << endl;
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] data = new int[M][2];
        for (int i = 0; i < M; i++) {
            data[i][0] = sc.nextInt();
            data[i][1] = sc.nextInt();
        }

        sortByColumn(data, 1);
        int result = 0;
        int nowclear = 0;

        int nowfrom = 0;
        int nowto = 0;
        for (int i = 0; i < M; i++) {
            nowfrom = data[i][0];
            nowto = data[i][1];

            if (nowclear < nowfrom) {
                nowclear = nowto - 1;
                result++;
            }
        }
        System.out.println(result);

    }

    //多维数组对某一列进行排序，参考https://www.cnblogs.com/whaozl/p/4061993.html
    private static void sortByColumn(int[][] ob, int column) {
        Arrays.sort(ob, new Comparator<int[]>() {
            public int compare(int[] one, int[] two) {
                return one[column] - two[column];
            }
        });
    }
}


Measured memory_bytes: 92016
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m) for (int i = 0; i < (int)(m); i++)
 
int main() {
 string s;
 cin>>s;
 
 string k = s;
 
 reverse(k.begin(),k.end());
 if (k[0]=='s')
 {
   cout<<s<<"es";
 }
 else{cout<<s<<"s";}
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef  long long 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;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    string s,t;
    cin>>s>>t;
    vector<int> si(s.size()),ti(t.size());
    rep(i,s.size())si[i]=s.at(i)-'a';
    rep(i,t.size())ti[i]=t.at(i)-'a';
    sort(si.begin(),si.end());
    sort(ti.begin(),ti.end(),greater<int>());
    rep(i,min(s.size(),t.size())){
        if(si.at(i)==ti.at(i))continue;
        else if(si.at(i)>ti.at(i)){
            cout<<"No"<<endl;
            return 0;
        }
        else {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    if(s.size()>=t.size())cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int flg = 0;
    while(true) {
        C -= B;
        if (C <= 0) {
            flg =1;
            break;
        }
        A -= D;
        if (A <= 0) {
            flg = 0;
            break;
        }
    }
            if (flg == 0) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
}

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

using namespace std;

int main(){
    long long n,a,b;
    long long ans;
    scanf("%lld %lld %lld",&n,&a,&b);
    if(n==0 || b<a){
        ans=0;
    }else if(n==1 && a!=b){
        ans=0;
    }else if(n==1 && a==b){
        ans=1;
    }else{
        long long minn=b+(n-1)*a;
        long long maxx=a+(n-1)*b;
        ans=maxx-minn+1;
    }
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, x: "List[int]", y: "List[int]"):
    diffs = []
    for i in range(N):
        for j in range(i + 1, N):
            diffs.append([x[j] - x[i], y[j] - y[i]])
            diffs.append([x[i] - x[j], y[i] - y[j]])
    diffs.sort()
    cnt = 0
    tmp = 1
    for i in range(1, len(diffs)):
        if diffs[i] == diffs[i - 1]:
            tmp += 1
        else:
            cnt = max(tmp, cnt)
            tmp = 1
    ret = N - cnt
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}
int dp[200][200];
struct z{
	int a,b,c;
};
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	int n,t;cin>>n>>t;
	double ans = 0;
	for(int i = 0; n > i; i++){
		int a,b;cin>>a>>b;
		ans = max(ans,(double)b/a*t);
	}
	cout << fixed << setprecision(10) << ans << endl;
	
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
vector<int>v;
int main() {
	int n;
	cin >> n;
	rep(i, n) {
		int a;
		cin >> a;
		v.push_back(a);
	}
	v.erase(unique(v.begin(), v.end()), v.end());
	rep(i, v.size())cout << v[i] << (i == v.size() - 1 ? "\n" : " ");
	return 0;
}


Measured memory_bytes: 3432
#include <stdio.h>





typedef struct {
  int p,l,r; 
} Node;



Node Tree[100000];
int dep(int);
int PrintChild(int);
void Print(int);


int main()
{
  int n;
  int i=0,j;
  int c,id,k;
    int pre;
  scanf("%d",&n);
  while(i<n){
      Tree[i].p = -1; 
      Tree[i].l = -1;
      Tree[i].r = -1;
      i++;
    }
  i=0;
  while(i<n){
      scanf("%d %d",&id,&k);
      for(j=0;j<k;j++)
    {
      scanf("%d",&c);
      Tree[c].p=id;
      if(j==0) Tree[id].l = c;
      else Tree[pre].r = c;
      pre = c;
    }
      i++;
    }
  i=0;
  while(i<n){
      Print(i);
      i++;
    }
  return 0;
}
void Print(int id)
{
  int i;
  printf("node %d: parent = %d, depth = %d, ",id,Tree[id].p,dep(id));
  if(Tree[id].p == -1){

 printf("root, [");

  }
  else if(Tree[id].l == -1){
 printf("leaf, ");
    
    printf("[");
  } 
  
 else printf("internal node, [");
  PrintChild(Tree[id].l);
  printf("]\n");
}

int dep(int id)
{
  if(Tree[id].p == -1) return 0;
  return 1+dep(Tree[id].p);
}

int PrintChild(int id)
{
  if(id == -1) return 0;
  if(Tree[id].r == -1)printf("%d",id);
  else
    {
      printf("%d, ",id);
      PrintChild(Tree[id].r);
    }
  return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#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 pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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

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

	string s; cin>>s;
	REP(i,s.size()) if(!(i&1)) cout<<s[i];
	cout<<endl;

	return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using  ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

//string ans = "Yes";


int SetAns() {
	int N, M, K;
	cin >> N >> M >> K;

	vector<int> A(N);
	vector<int> B(M);
	rep(i, N) cin >> A[i];
	rep(i, M) cin >> B[i];

	//本体
	int ans = 0;
	ll sumA = 0;
	rep(j, N) sumA += A[j]; //against TLE

	ll nowSumA = sumA;
	ll nowSumB = 0;
	int bChecker = 0;

	rep(i, N + 1) {
		int nowAns = N - i + bChecker;
		ll time = nowSumA + nowSumB;
		if (i != N) nowSumA -= A[N - 1 - i];
		if (time > K) continue;
		
		for(;bChecker< M;bChecker++){
			if (time + B[bChecker] > K) break;
			nowAns++;
			nowSumB += B[bChecker];
			time += B[bChecker];
		}

		ans = max(ans, nowAns);
	}

	return ans;
}

int main() {
	
	cout << SetAns() << endl;
	return 0;
}


Measured memory_bytes: 4464
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef gp_hash_table<int, null_type,hash<int>, equal_to<int>, direct_mask_range_hashing<int>, linear_probe_fn<>,
    hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>,true>> hash_set;
typedef gp_hash_table<int,null_type> hash_map;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 100005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

const ld PI = (ld)4*atanl(1);

mt19937 g1(chrono::steady_clock::now().time_since_epoch().count());

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int len,num_q,cnt[MAXN],good,pen;
bool done[MAXN];

int main(){
    fastio; cin >> len >> num_q;
    for(int i=1; i<=num_q; i++){
        int op; string s; cin >> op >> s;
        if(s == "WA") cnt[op]++;
        else{
            if(done[op]) continue;
            good++, pen+=cnt[op];
            done[op] = true;
        }
    }
    cout << good << " " << pen << endl;
}

Measured memory_bytes: 768
H,W=gets.split.map(&:to_i)
ss=$<.read.split

H.times do |y|
    s = ''
    W.times do |x|
        if ss[y][x] == '#'
            s << '#'
        else
            c = 0
            (-1..1).each do |dy|
                (-1..1).each do |dx|
                    next if x+dx < 0 || W <= x+dx
                    next if y+dy < 0 || H <= y+dy
                    c += 1 if ss[y+dy][x+dx] == '#'
                end
            end
            s << c.to_s
        end
    end
    puts s
end


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <map>
using namespace std;
 
#define rep(i,a,b) for(int i=(a);i<(b);i++)
 
class Dice {
private:
    map<char, string> mp;
public:
    string d = "RENSWL";
    vector<int> v; //UFRLBD:123456
    Dice() {
        init();
        v.resize(6);
    };
    Dice(vector<int> v) :v(v) {
        init();
    };
    void init(){
        mp[d[0]] = "2354";
        mp[d[1]] = "1463";
        mp[d[2]] = "1265";
        mp[d[3]] = "1562";
        mp[d[4]] = "1364";
        mp[d[5]] = "2453";
    }
    void input() { rep(i, 0, 6) { cin >> v[i]; } }
    void roll(char c) { roll(mp[c]); }
    void roll(string s) {
        int tmp = v[s[0] - '1'];
        rep(i, 1, s.size())v[s[i - 1] - '1'] = v[s[i] - '1'];
        v[s[s.size() - 1] - '1'] = tmp;
    }
    bool operator==(const Dice &D)const { return v == D.v; }
};
 
signed main() {
    int n; cin >> n;
    vector<Dice> D(n); rep(i, 0, n) { D[i].input(); }
    rep(i, 0, n) {
        rep(j, i + 1, n) {
            rep(k, 0, 30) {
                if (D[i] == D[j]) {
                    cout << "No" << endl;
                    return 0;
                }
                D[j].roll( D[j].d[rand() % 6] );
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long c = Long.parseLong(sc.next());
        sc.close();

        // 主処理
        long result = 0;
        if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1) {
            long ab = a * b;
            long bc = b * c;
            long ac = a * c;
            result = Math.min(Math.min(ab, bc), ac);
        }

        // 出力
        System.out.println(result);
    }
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	ll x;
	cin >> x;
	int ans = 0;
	ll cur = 0;
	for(int i = 1 ; cur < x ; ++i , ++ans)cur += i;
	die(ans);


	return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict


def input():
    return sys.stdin.readline().strip()


MOD = 10 ** 9 + 7
sys.setrecursionlimit(20000000)
INF = float("inf")


def main():
    N, M = map(int, input().split())
    key = []
    for _ in range(M):
        a, b = map(int, input().split())
        C = list(map(lambda x: int(x) - 1, input().split()))
        state = 0
        for c in C:
            state += 2 ** c
        key.append((a, state))
    dp = [INF for _ in range(2 ** N)]
    dp[0] = 0
    for i in range(2 ** N - 1):
        for k in range(M):
            state = key[k][1]
            tmp = dp[i] + key[k][0]
            if dp[i | state] > tmp:
                dp[i | state] = tmp
    if dp[-1] == INF:
        print(-1)
    else:
        print(dp[-1])


if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    int a;
    cin >> a;
    a--;
    G[a].emplace_back(i + 1);
  }
  function<int(int)> rec = [&](int u) {
    if (G[u].empty()) return 0;
    vector<int> res;
    for (int v : G[u]) {
      res.emplace_back(rec(v));
    }
    sort(res.begin(), res.end(), greater<int>());
    for (int i = 0; i < (int)res.size(); i++) {
      res[i] += i + 1;
    }
    return *max_element(res.begin(), res.end());
  };
  cout << rec(0) << '\n';
  return 0;
}


Measured memory_bytes: 17920
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
const int mod=1e9+7,maxn=1e6+10;
const int dx[10]={0,0,-1,1,-1,-1,1,1},dy[10]={-1,1,0,0,-1,1,-1,1};
ll tong[10],h,w,n,sum,tot;
pair<int,int> node[maxn];
map<pair<int,int>,int>mp;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int main()
{
	scanf("%lld%lld%lld",&h,&w,&n);
	for(int i=1;i<=n;i++)
	{
		int x,y;
		node[i].first=read(),node[i].second=read();
		mp[node[i]]=1;
	}
	for(int i=1;i<=n;i++)
		for(int j=0;j<8;j++)
		{
			int nx=node[i].first+dx[j];
            int ny=node[i].second+dy[j];
            if(nx>=1&&nx<=h&&ny>=1&ny<=w)
            {
            	pair<int,int>temp(nx,ny);
            	mp[temp]++;
			}
   		}
	tot=(h-2)*(w-2);
	map<pair<int,int>,int>::iterator it,ed=mp.end();
	for(it=mp.begin();it!=ed;it++)
	{
		int x=it->first.first;
		int y=it->first.second;
		int val=it->second;
		if(x>1&&x<h&&y>1&&y<w)
		{
			tong[val]++;
			sum++;
		}
	}
	tong[0]=tot-sum;
	for(int i=0;i<=9;i++)
		printf("%lld\n",tong[i]);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }
};


int main()
{
  string s; cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll d = abs(A - B);
  ll r;
  
  if (d%2==0) r = d / 2;
  else {
    if (A+B-2 > 2*N-A-B) r = min(N-A-(d-1)/2,N-B+1+(d-1)/2);
    else if (A+B-2 < 2*N-A-B) r = min(A+(d-1)/2,B+(d-1)/2);
    else r = N/2;
  }
  
  cout << r << endl;
}

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

int main() {
    priority_queue <long> pq;
    int n, m, i;
    cin >> n >> m;
    long a, s = 0;
    for(i = 0; i < n; i ++)
    {
        cin >> a;
        pq.push(a);
    }
    while(m --) {
        a = pq.top();
        pq.pop();
        pq.push(a/2);
    }
    
    while(!pq.empty()) {
        s += pq.top();
        pq.pop();
    }
    
    cout << s;
    return 0;
}

Measured memory_bytes: 1400
from collections import Counter
n = int(input())

# 全てをソートして、一致するものを探すのが早い？
s = [0] * n
for i in range(n):
    IN = input()
    inSort = sorted(IN)
    # リストの要素を結合
    s[i] = ''.join(inSort)

count = Counter(s)
most = count.most_common()
# print(count)
inSet = set(s)
loop = list(inSet)


ans = 0
for i in most:
    # for i in count:
    # print(i)
    aa = i[1]
    if (aa == 1):
        pass
    else:
        ans += aa * (aa - 1) / 2


print(int(ans))


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

typedef long long ll;

int main()
{
  ll n,ans=0;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    ll a;
    cin>>a;
    while(a%2==0)
    {
      ans++;
      a/=2;
    }
  }
  cout<<ans;
  return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	rep(i,N) cin >> a[i];
	rep(i,N) a[i]--;
	int ans=0;
	rep(i,N) if(a[a[i]]==i) ans++;
	cout << ans/2 << endl;

	return 0;
}

Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <string>
static const std::vector<double> half{ 0, 35.50, 37.50, 40, 43, 50,55, 70 };
static const std::vector<double> kilo{ 0, 71, 77, 83, 89, 105, 116, 148 };
static const std::vector<std::string> grade{ "AAA", "AA", "A", "B", "C", "D", "E", "NA" };

int bin_half(const double &time, const int &left = 0, const int &right = 7) {
	if (left == right) {
		return left;
	}
	else {
		auto mid = ((left + right + 1) >> 1);
		if (half.at(mid) > time) {
			return bin_half(time, left, mid - 1);
		}
		else {
			return bin_half(time, mid, right);
		}
	}
}
int bin_kilo(const double &time, const int &left = 0, const int &right = 7) {
	if (left == right) {
		return left;
	}
	else {
		auto mid = ((left + right + 1) >> 1);
		if (kilo.at(mid) > time) {
			return bin_kilo(time, left, mid - 1);
		}
		else {
			return bin_kilo(time, mid, right);
		}
	}
}
std::string cul_grade(const double &half_t, const double &kilo_t) {
	auto h{ bin_half(half_t) }, k{ bin_kilo(kilo_t) };
	if (h < k) {
		return grade.at(k);
	}
	else {
		return grade.at(h);
	}
}
int main() {
	double h, k;
	while (std::cin >> h >> k) {
		std::cout << cul_grade(h, k) << '\n';
	}
	return 0;
}

Measured memory_bytes: 3092
main(V,d,a,b,c){for(;~scanf("%d%d",&V,&d);printf("%d\n",b+(c<d))){int f[1001]={0};for(a=b=1;V--;a=b,b=c)c=a+b,f[c%=1001]=1;for(c=-1e4,b=a=0;a<1001;c*=!f[a++])b+=++c==d;}}

Measured memory_bytes: 0
import java.util.Scanner;

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

		if (s.equals("ABC")) {
			System.out.println("ARC");
		} else {
			System.out.println("ABC");
		}
	}
}


Measured memory_bytes: 35608
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scnr = new Scanner(System.in);
      	int a = scnr.nextInt();
      	int b = scnr.nextInt();
      	if (b % a == 0) {
        	System.out.println(a + b);
        } else {
        	System.out.println(b - a);
        }
    }
}

Measured memory_bytes: 25300
#include <cstdio>

int main() {
    int N, K;
    scanf(" %d", &N);
    scanf(" %d", &K);

    int ans = 1;
    for (int i = 0; i < N; i++) {
        // printf("bool: %d\n", int(ans*2 < ans+K));
        // printf("ans*2: %d, ans+K:%d\n", ans*2, ans+K);
        ans = (ans*2 < ans+K) ? ans*2 : ans+K;
        // printf("ans: %d\n", ans);
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
struct str{
	int x0;
	int y0;
	int index;
	int ans;
}y[500010];
bool cmp(str a, str b)
{
	if(a.x0/700==b.x0/700) return a.y0<b.y0;
	return (a.x0/700)<(b.x0/700);
}
bool cmp2(str a, str b)
{
	return a.index<b.index;
}

int C = 0;
int count[500010];
void func(int k)
{
	if(count[k]==0) C++;
	count[k]++;
}
void func2(int k)
{
	if(count[k]==1) C--;
	count[k]--;
}

int x[500010];
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	for(int i=1;i<=b;i++)
	{
		int c,d;
		scanf("%d%d",&c,&d);
		y[i]={c,d,i,0};
	}
	std::sort(y+1,y+b+1,cmp);
	
	for(int i=y[1].x0;i<=y[1].y0;i++) func(x[i]);
	y[1].ans = C;
	
	int L = y[1].x0, R = y[1].y0;
	for(int i=2;i<=b;i++)
	{
		if(y[i].y0>=R) while(R<y[i].y0) func(x[++R]);
		else while(R>y[i].y0) func2(x[R--]);
		
		if(y[i].x0<=L) while(L>y[i].x0) func(x[--L]);
		else while(L<y[i].x0) func2(x[L++]);
		
		y[i].ans = C;
	}
	std::sort(y+1,y+b+1,cmp2);
	for(int i=1;i<=b;i++) printf("%d\n",y[i].ans);
}

Measured memory_bytes: 15352
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int inf = 10000000;
int main(){
    int n,m,l,K,a,h;
    while(cin >> n >> m >> l >> K >> a >> h&&n!=0){
        int dp[101][101]={};
        rep(i,101){
            rep(j,101){
                if(i!=j)dp[i][j]=inf;
            }
        }
        set<int>st;
        rep(i,l){
            int x;
            cin >> x;
            st.insert(x);
        }
        st.insert(a);
        st.insert(h);
        rep(i,K){
            int x,y,t;
            cin >> x >> y >> t;
            dp[x][y] = t;
            dp[y][x] = t;
        }
        rep(k,n){
            rep(i,n){
                rep(j,n){
                    dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j]);
                }
            }
        }
        rep(i,n){
            rep(j,n){
                if(st.count(i)&&st.count(j)){
                    if(dp[i][j]>m){
                        dp[i][j] = inf;
                    }
                }else{
                    dp[i][j] = inf;
                }
            }
        }
        rep(k,n){
            rep(i,n){
                rep(j,n){
                    dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j]);
                }
            }
        }
        if(dp[a][h]>=inf){
            cout << "Help!" << endl;
        }else{
            if(dp[a][h]>m){
                cout << dp[a][h] + (dp[a][h]-m) << endl;
            }else{
                cout << dp[a][h] << endl;
            }
        }
    }

    return 0;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    vector<int> cnt(4);
    for (int i = 0; i < 3; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        cnt[a]++;
        cnt[b]++;
    }
    vector<int> ans = {1, 2, 2, 1};
    sort(all(ans));
    sort(all(cnt));
    if (cnt == ans) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	//A
	/*
	int n;
	int a, b, c, d;
	cin >> n;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	string s;
	cin >> s;
	int i;
	for (i = a - 1; i <= c - 1; i++) {
		if ((s[i] == '#') && (s[i + 1] == '#')) {
			cout << "No";
			return 0;
		}
	}
	for (i = b - 1; i <= d - 1; i++) {
		if ((s[i] == '#') && (s[i + 1] == '#')) {
			cout << "No";
			return 0;
		}
	}
	if (c < d) {
		cout << "Yes";
		return 0;
	}
	else {
		for (i = b - 1; i <= d - 1; i++) {
			if ((s[i - 1] == '.') && (s[i + 1] == '.') && (s[i] == '.')) {
				cout << "Yes";
				return 0;
			}
		}
		cout << "No";
		return 0;
	}
	return 0;*/
	//B

	string s;
	long long int counter = 0;
	long long int counterA = 0;
	int bflag = 0;
	int i;
	cin >> s;
	for (i = 0; i < s.length(); i++) {
		if (s[i] == 'A') {
			if (bflag == 1) {
				bflag = 0;
				counterA = 0;
			}
			counterA++;
			//cout << counter;
		}
		else if (s[i] == 'B') {
			if (bflag == 1) {
				counterA = 0;
			}
			bflag = 1;
			//cout << counter;
		}
		else if (s[i] == 'C') {
			if (bflag == 1) {
				counter = counter + counterA;
				bflag = 0;
			}
			else {
				counterA = 0;
			}
			//cout << counter;
		}
	}
	cout << counter;
	return 0;
}

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

int main()
{
	int n;
  cin >> n;
  if( n <= 1000){
		cout << 1000 - n << endl;
	}
  else if( 2000 >= n && n > 1000 ){
		cout << 2000 - n << endl;
	}
  else if( 3000 >= n && n > 2000 ){
		cout << 3000 - n << endl;
	}
  else if( 4000 >= n && n > 3000 ){
		cout << 4000 - n << endl;
	}
  else if( 5000 >= n && n > 4000 ){
		cout << 5000 - n << endl;
	}
  else if( 6000 >= n && n > 5000 ){
		cout << 6000 - n << endl;
	}
  else if( 7000 >= n && n > 6000 ){
		cout << 7000 - n << endl;
	}
  else if( 8000 >= n && n > 7000 ){
		cout << 8000 - n << endl;
	}
  else if( 9000 >= n && n > 8000 ){
		cout << 9000 - n << endl;
	}
  else if( 10000 >= n && n > 9000 ){
		cout << 10000 - n << endl;
	}
    
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

#define inf 999999

int G[100][100];

void SSSPI(int);

void SSSPI(int n)
{
  int u,min,i,j;
  int judge[100],d[100];

  for(i=0;i<n;i++) {
    d[i] = inf;
    judge[i] = 0;
  }

  d[0] = 0;
  judge[0] = 1;

  while(1) {
    min = inf;
    u = -1;
    for(i=0;i<n;i++) {
      if(min > d[i] && judge[i] != 2) {
	u = i;
	min = d[i];
      }
    }
    if(u == -1)
      break;
    judge[u] = 2;
    for(j=0;j<n;j++) {
      if(judge[j] != 2 && G[u][j] != inf) {
	if(d[j] > d[u]+G[u][j]) {
	  d[j] = d[u] + G[u][j];
	  judge[j] = 1;
	}
      }
    }
  }

  for(i=0;i<n;i++) {
    printf("%d ",i);
    if(d[i] == inf) {
      printf("-1\n"); /* 距離が出なかった場合-1を出力 */
    }else{
      printf("%d\n",d[i]);
    }
  }
}
  

int main()
{
  int n,i,j;
  int a,b,c,d;

  scanf("%d",&n);

  for(i=0;i<n;i++) {
    for(j=0;j<n;j++) {
      G[i][j] = inf;
    }
  }

  for(i=0;i<n;i++) {
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++) {
      scanf("%d%d",&c,&d);
      G[a][c] = d;
    }
  }

  SSSPI(n);

  return 0;
}



Measured memory_bytes: 2048
#include <stdio.h>
int m, d, ans;
int main() {
	scanf("%d%d", &m, &d);
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= d; j++) {
			if ((j % 10) > 1 && (j / 10) > 1 && i == (j / 10) * (j % 10)) {
				ans++;
			}
		}
	}
	printf("%d\n", ans);
}

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

int square(int x)
{
	return (x * x);
}

int main()
{
	int n, tmp;
	int answer = 0;
	int answer2 = 0;
	int ave = 0;
	int ave2 = 0;
	vector<int> v;

	cin >> n;

	rep(i, n)
	{
		cin >> tmp;
		v.emplace_back(tmp);
		ave += tmp;
	}

	if (ave % n != 0) {
		ave2 = ave / n + 1;
	}
	ave /= n;



	while (!v.empty()) {
		answer += square(v.back() - ave);
		answer2 += square(v.back() - ave2);
		v.pop_back();
	}

	printf("%d", (answer < answer2 ? answer : answer2));
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = str(readline().rstrip().decode('utf-8'))
    d = {"2": "hon", "4": "hon", "5": "hon", "7": "hon", "9": "hon", "0": "pon", "1": "pon", "6": "pon", "8": "pon", "3": "bon"}
    print(d[n[-1]])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 61948
#include <stdio.h>

int main(void){
    int n,i,v,ans1,ans2=-1,a;
    scanf("%d",&n);
    scanf("%d %d",&ans1,&ans2);
    for(i=0;i<n-1;i++){
        scanf("%d %d",&a,&v);
        if(ans2 < v){
            ans1=a;
            ans2=v;
        }
        else if(ans2 == v){
            if(ans1 > a){
                ans1=a;
                ans2=v;
            }
        }
    }
    printf("%d %d\n",ans1,ans2);
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
    int w,a,b;
    cin>>w>>a>>b;
    if(a>b)swap(a,b);
    if(a<=b&&b<=a+w){
        cout<<0<<endl;
    }else{
        cout<<b-(a+w)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            String s = in.next();
            int n = s.length() / 2;
            for (int i = 0; ; i++) {
                s = s.substring(0, s.length() - 1);
                if (s.length() % 2 == 0 && isEven(s)) {
                    out.println(s.length());
                    return;
                }
            }
        }

        private boolean isEven(String s) {
            return s.substring(0, s.length() / 2).equals(s.substring(s.length() / 2, s.length()));
        }

    }

    static class FastReader {
        BufferedReader reader;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return null;
                    }
                    st = new StringTokenizer(line);
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 21716
from collections import defaultdict,deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

n, m = inpl()
ans = n * (n - 1)//2 + m * (m - 1)//2
print(ans)

Measured memory_bytes: 39020