akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

ll int a;
cin >> a;

cout << a + a*a + a*a*a;











	return 0;

}



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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<int>v(a,a+n);
    sort(v.begin(),v.end());
    int ai = v[n-1];
    int aj;
    std::vector<int>::iterator low,up;
    low = lower_bound(v.begin(),v.end(),ai/2.0);
//    up = upper_bound(v.begin(),v.end(),ai/2.0);
    if(v[low-v.begin()]-ai/2.0 < ai/2.0-v[low-v.begin()-1]&&low-v.begin()!=n-1){
        aj= v[low-v.begin()];
    }else{
        aj= v[low-v.begin()-1];
    }
    cout << ai << " " << aj << endl;
}

Measured memory_bytes: 1024
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

// fn minus(a: Vec<isize>, b:Vec<isize>) -> Vec<isize> {
//     let mut z = vec![0,0,0];
//     for (i, (aval, bval)) in a.iter().zip(&b).enumerate() {
//         z[i] = aval - bval;
//     }
//     z
// }

fn main() {
    input! {
        s: char
    //   n: isize,
    //   m: isize
    }
    if s.is_uppercase() {
        println!("A")
    } else {
        println!("a")
    }
}

Measured memory_bytes: 2144
#include <stdio.h>
#include <string.h>

class Dice{
	int mn[6];	
	
	public:
		void set(int num, int val){
			mn[num] = val;
		}
	
		void rot(char dir){
			int buf, old[6];
			memcpy(old, mn, sizeof(mn));
			switch(dir){
				case 'E':
				mn[0] = old[3];
				mn[2] = old[0];
				mn[5] = old[2];
				mn[3] = old[5];
				break;
				case 'W':
				mn[3] = old[0];
				mn[0] = old[2];
				mn[2] = old[5];
				mn[5] = old[3];
				break;
				case 'S':
				mn[0] = old[4];
				mn[1] = old[0];
				mn[5] = old[1];
				mn[4] = old[5];
				break;
				case 'N':
				mn[4] = old[0];
				mn[0] = old[1];
				mn[1] = old[5];
				mn[5] = old[4];
				break;
			}
		}
		
		int get(int num){
			return mn[num];
		}
};


int main() {
	int b, i;
	char c;
	Dice dice;
	
	for(i = 0; 6 > i; i++){~
		scanf("%d", &b);
		dice.set(i,b);
	}
	
	while(scanf("%c", &c) != EOF){
		dice.rot(c);
	}
	printf("%d\n", dice.get(0));
	return 0;
}

Measured memory_bytes: 1028
/*
    NO 
        TIME 
            TO 
                DIE
                    --007
                            */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <complex>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
// define x, y as real(), imag()


template<class T>
istream& operator>> (istream& is, complex<T>& p) {
  T value;
  is >> value;
  p.real(value);
  is >> value;
  p.imag(value);
  return is;
}
#define M_PI 3.14159265358979323846
typedef long long int lli;
lli mod=1e9+9ll;
#define OS //single input use oeis
lli INF=9223372036854775807;
lli eps=1e-8;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y-x)>>(31))&(x^y))^y; }
int fmi(int x, int y) { return (((y-x)>>(31))&(x^y))^x; }
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,z,k,x,m,d,y,q,b,c,s,t;
const double pi=3.14159265358979323846;
lli me(lli a,lli b)
{
    // cout<<mod<<"\n";
    lli res=1;
    while(b)
    {
        if(b&1)
        res=(res%mod*a%mod)%mod;
        a=a*a;
        a%=mod;
        b=b>>1;
    }
    return res;
}
lli mI(lli a)
{
    return (me(a,mod-2)%mod+mod)%mod;
}
vector<lli> v[1005];
lli mk[1005][1005];
lli vis[1005];
lli val=-1;
void bfs()
{
    queue<ll> q;
    q.push({s,0});
    while(!q.empty())
    {
        ll no=q.front();
        q.pop();
        if(vis[no.first])
        continue;
        vis[no.first]=1;
        if(no.first==t)
        {
            val=no.second;
            break;
        }
        for(auto &j: v[no.first])
        {
            q.push({j,no.second+1});
        }
    }
}
int main()
{
lli a,b,c,k;
  cin>>a>>b>>c>>k;
  lli ans=min(a,k);
  k-=ans;
  if(k)
  {
  	lli oo=min(k,b);
  	k-=oo;
  	if(k)
  	{
  		oo=min(k,c);
  		k-=oo;
  		ans-=oo;
  	}
  }
  cout<<ans;
}

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

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  const int MAX = 55555;
  int N,sum;
  cin>>N;
  int a[N],b[MAX]={},ans[5]={};
  int cnt=0;
  int flag=0;
  for (int i=2;i<MAX;i++){
    if(isPrime(i) && i%5==1){
      b[flag]=i;
      flag++;
    }
  }
  for(int i=0;i<N;i++){
    a[i]=b[i];
  }

  for (int i=0;i<N-1;i++){
    cout<<a[i]<<" ";
  }
  cout<<a[N-1];
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point
{
public:
  double x, y;
  Point(double x = 0, double y = 0) : x(x), y(y) {}

  Point operator+(Point p)
  {
    return Point(x + p.x, y + p.y);
  }
  Point operator-(Point p)
  {
    return Point(x - p.x, y - p.y);
  }
  Point operator*(double a)
  {
    return Point(a * x, a * y);
  }
  Point operator/(double a)
  {
    return Point(x / a, y / a);
  }

  double abs()
  {
    return sqrt(norm());
  }
  double norm()
  {
    return x * x + y * y;
  }

  bool operator<(const Point &p) const
  {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator==(const Point &p) const
  {
    return equals(x, p.x) && equals(y, p.y);
  }

  void print()
  {
    printf("%.10f %.10f\n", x, y);
  }
};

typedef Point Vector;

double dot(Vector a, Vector b)
{
  return a.x * b.x + a.y * b.y;
}
double cross(Vector a, Vector b)
{
  return a.x * b.y - a.y * b.x;
}

struct Segment
{
  Point p1, p2;
};

typedef Segment Line;

class Circle
{
public:
  Point c;
  double r;
  Circle(Point c = Point(), double r = 0) : c(c), r(r) {}
};

typedef vector<Point> Polygon;

Point projection(Line l, Point p)
{
  return l.p1 + (l.p2 - l.p1) * (dot(p - l.p1, l.p2 - l.p1) / (l.p2 - l.p1).norm());
}

Point reflection(Line l, Point p)
{
  Point x = projection(l, p);
  return p + (x - p) * 2;
}

int main()
{
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  Line l = {Point{x1, y1}, Point{x2, y2}};
  int q;
  cin >> q;
  rep(i, q)
  {
    double x, y;
    cin >> x >> y;
    Point p = {x, y};
    Point a = reflection(l, p);
    a.print();
  }
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    string S; cin>>S;
    S.replace(S.size()-1,1,"");

    string ans;
    while(!S.empty()){
        if(S.size()%2==0){
            string _S=S.substr(S.size()/2);
            if(_S==S.substr(0,_S.size())){ans=S; break;}
        }
        S.replace(S.size()-1,1,"");
    }

    cout<<ans.size()<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        if (str.equals("AAA") || str.equals("BBB")) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 23764
from collections import deque
n, Q = map(int, input().split())
edges = [[] for _ in range(n+1)]
count = [0]*(n+1)
q = deque()
q.append((1, 0))

for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)
for _ in range(Q):
    p, x = map(int, input().split())
    count[p] += x

while(q):
    k = q.popleft()
    count[k[0]] += count[k[1]]
    for i in edges[k[0]]:
        if not i == k[1]:
            q.append((i, k[0]))

print(*count[1:])


Measured memory_bytes: 57724
def merge(x, y, z, w):
    P = [x, y, z, w]
    P.sort()
    return P[-1], P[-2]


def main():
    N = int(input())
    a = list(map(int, input().split()))
    dp = [0]*(2*(N+1)*((1 << N)))

    def calc(i, j, k):
        return (2*N + 2) * i + (N+1)*k + j
    for i in range(1 << N):
        dp[calc(i, 0, 0)] = a[i]
    for j in range(1, N+1):
        for i in range(1 << N):
            x = calc(i, j, 0)
            y = calc(i & ~(1 << (j-1)), j - 1, 0)          
            if (i & (1 << (j-1))):
                dp[x], dp[x+N+1] = merge(dp[y], dp[y+N+1], dp[x-1], dp[x+N])
            else:
                dp[x], dp[x+N+1] = dp[x-1], dp[x+N]
    result = [0]*(1 << N)
    for k in range(1, 1 << N):
        result[k] = max(result[k-1], dp[calc(k, N, 0)]+dp[calc(k, N, 1)])
        print(result[k])
    return


if __name__ == "__main__":
    main()



Measured memory_bytes: 170536
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define mp make_pair
#define ff first
#define ss second
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll o=ceil((ld)n/2);
	ld res=((ld)o/(ld)n);
	cout<<fixed<<setprecision(10)<<res<<"\n";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
 class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder stringBuilder = new StringBuilder();
		int size = Integer.parseInt(bufferedReader.readLine());
//		List<String> strings = new ArrayList<>();
		HashSet<String> strings = new HashSet<>();
		for (int i = 0; i < size; i++) {
			String order = bufferedReader.readLine();
			if (order.charAt(0) == 'i') {
				strings.add(order.substring(7));
			} else {
				if (strings.contains(order.substring(5))) {
					stringBuilder.append("yes\n");
				} else {
					stringBuilder.append("no\n");
				}
			}
		}
		System.out.print(stringBuilder.toString());
	}

}

Measured memory_bytes: 129160
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>   
using namespace std;
 
int main(){
int a,ii = 0;
cin >> a;
int b[a],c[a],ans[a];
while(a > ii){
    cin >> b[ii] >> c[ii];
    ans[ii] =  b[ii] % c[ii];
    if(ans[ii] == 0) ans[ii] = c[ii];
    ii++;
}
ii = 0;
while(a > ii){
cout << ans[ii] << endl;
ii++;
}
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

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

  /*問題は，ケーキをx個，ドーナツをy個買うとしたときに
    4x+7y=N
    を満たす自然数(x,y)が存在するかという条件と同値である．
    x=(N-7y)/4 (この商は数学の商)
    を考えるが， N-7yが4で割り切れるような自然数yがあればよい．
  */

  //自然数(x,y)の組が存在するかどうかの変数．初期値は0．
  int flag = 0;
  for(int y=0; N>=7*y; y++){
    if((N-7*y)%4 == 0){
      flag = 1;
      break;
    } 
  }

  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

    
  return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define pb emplace_back
#define mp make_pair

#define DEBUG

using namespace std;

const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

typedef pair<ll, ll> P;

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;
}

ll R, C, N, K;

bool v[15][10005];

ll a[20];

signed main() {
    cin >> N;

    vector<int> a(N), b(N), c(N);
    rep(i, N) { cin >> a[i]; }
    rep(i, N) { cin >> b[i]; }
    rep(i, N) { cin >> c[i]; }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll count = 0;

    rep(i, N) {
        auto itrA = upper_bound(a.begin(), a.end(), b[i]-1);
        auto itrB = lower_bound(c.begin(), c.end(), b[i]+1);
        if(itrA == a.begin() || itrB == c.end()){continue;}
        count += (itrA - a.begin()) * (c.end() - itrB);
    }

    cout << count << endl;
}


Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int K, X;

    cin >> K >> X;

    if(500*K>=X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
    
}

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

using namespace std;

#define MAX_SIZE 100010

struct Vect2D {
  int x, y;
};

ostream& operator<<(ostream& s, const Vect2D& v) {
  s << v.x << ' ' << v.y;
}

bool comp(const Vect2D& v1, const Vect2D& v2) {
  if (v1.x == v2.x) return v1.y < v2.y;
  else return v1.x < v2.x;
}

int main() {
  Vect2D P[MAX_SIZE];
  int n;

  cin >> n;

  for (int i = 0; i < n; ++i) {
    cin >> P[i].x >> P[i].y;
  }

  sort(P, P + n, comp);

  for (int i = 0; i < n; ++i) {
    cout << P[i] << endl;
  }

  return 0;
}



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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    string s;
    cin >> s;
    ll Q;
    cin >> Q;
    
    bool isReversed = false;
    int reverseCnt = 0;
    rep(i,Q)
    {
        int tmp;
        cin >> tmp;
        if( tmp == 1 )
        {
            isReversed = !isReversed;
            reverseCnt++;
        }
        else
        {
            int tmp2;
            char key;
            cin >> tmp2 >> key;
            if( (isReversed && tmp2 == 2) || (!isReversed && tmp2==1) ) s.insert(s.begin(),key);
            else s.push_back(key);
        }
    }
    if( (reverseCnt+2)%2 == 0 ) cout << s << endl;
    else
    {
        rep(i,s.size()) cout << s[s.size()-1-i];
        cout << endl;
    }
}


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

using namespace std;

typedef long long LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = N; i >= 0; i--)

template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}

template<class T>
vector<T> unique_vec(const vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}

int main() {
  LL a,b,c,d;
  cin >> a >> b >> c >> d;
  vector<LL> res(4);
  res[0] = a*c;
  res[1] = a*d;
  res[2] = b*c;
  res[3] = b*d;
  sort(res.begin(), res.end());
  cout << res[3] << endl;

  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int N=20;
int n,a[N],b[N];
int f[1<<18][N],cnt[1<<18];
int main(){
	scanf("%d",&n);
	For(i,0,n-1) scanf("%d",&a[i]);
	For(i,0,n-1) scanf("%d",&b[i]);
 	memset(f,60,sizeof(f));
	For(i,0,n-1) f[1<<i][i]=0;
	For(i,0,(1<<n)-1) cnt[i]=cnt[i/2]+(i&1);
	For(i,1,(1<<n)-1) For(j,0,n-1){
		if (!(i&(1<<j))) continue;
		int v=(abs(j-cnt[i]-1)&1?b[j]:a[j]),dif=0;
		//cout<<i<<' '<<j<<' '<<v<<endl;
		Rep(k,n-1,0) if (!(i&(1<<k))){
			int vv=(abs(k-cnt[i])&1?b[k]:a[k]);
			if (vv<v) continue;
			//cout<<j<<' '<<k<<' '<<dif<<endl;
			f[i|(1<<k)][k]=min(f[i|(1<<k)][k],f[i][j]+dif);
		}
		else ++dif;
	}
	int ans=1<<30;
	For(i,0,n-1) ans=min(ans,f[(1<<n)-1][i]);
	printf("%d\n",ans>10000?-1:ans);
}

Measured memory_bytes: 21760
#include <cstdio>
#include <algorithm>
using namespace std;
int n,m,f[100005],g[100005];

void zzk(int L,int R){
	for (int k=1,kk,kkk,a,Max,Min; k<=m && k<=R;){
		// k<=kk<=(l-1)/a
		a=(L-1)/k;
		if (a==0) Max=99999999; else Max=(L-1)/a; Min=k-1;
		kk=R/(a+1);
		kk=min(kk,Max); kk=max(kk,Min);
		f[k]++; f[kk+1]--;
		k=Max+1;
	}
}

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1,l,r; i<=n; i++){
		scanf("%d%d",&l,&r);
		zzk(l,r);
	}
	for (int i=1; i<=m; i++) g[i]=g[i-1]+f[i],printf("%d\n",g[i]);
}

/*
3 3
1 2
2 3
3 3

*/

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

using namespace std;

typedef long long ll;

int main(){
  ll N;
  bool x = false;
  cin >> N;
  while(N>0){
    if(N%10==7) x = true;
    N /= 10;
  }

  if(x) cout << "Yes";
  else cout << "No";
}

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

int main()
{
    int N;
    cin >> N;
    char S[N];
    cin >> S;
    if (N % 2 != 0)
    {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < N / 2; i++)
    {
        if (S[i] != S[i + N / 2])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

int main(){
  int n, num, ans = 0;
  int x[100], y[100];
  string s;
  cin >> n >> s;
  
  for ( int i = 1; i < n; i++ ){	//切断位置決定
    //初期化
    num = 0;
    for ( int j = 0; j < n; j++ ){
      x[j] = 0;
      y[j] = 0;
    }
    
    //切断後文字列のアルファベットの有無を判定
    for ( int j = 0; j < i; j++ ){
      x[s[j] - 'a'] = 1;
    }
    for ( int j = i; j < n; j++ ){
      y[s[j] - 'a'] = 1;
    }
    
    //アルファベットの被り判定
    for ( int j = 0; j < n; j++ ){
      if ( x[j] != 0 && x[j] == y[j] ){
        num++;
      }
    }
    
    ans = max(ans, num);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        
        long num = long.Parse(Reader.ReadLine());
        if(num == 0) {
            Console.WriteLine(0);
            return;
        }
        this.numList[0] = 1;
        for (int i = 1; i < numList.Length; i++) {
            numList[i] = numList[i - 1] * -2;
        }
        numList = numList.Reverse().ToArray();

        List<char> ans = GetAns(1, numList.Length - 1, num);
        while(ans.First() == '0') {
            ans.RemoveAt(0);
        }
        Console.WriteLine(string.Join("", ans));
    }
    long[] numList = new long[63];

    private List<char> GetAns(int idx, int remainIdx, long remain) {
        if(remainIdx == 1) {
                        
            if(remain == 0) {
                return new List<char>(new char[] { '0' });
            } else if(remain == 1) {
                return new List<char>(new char[] { '1' });
            } else {
                return null;
            }
        }
        long tmp = Math.Abs(numList[idx - 1]);
        if(remain > tmp) {
            return null;
        }
        if (remain < tmp * -1)  {
            return null;
        }

        List<char> tmp1 = GetAns(idx + 1, remainIdx - 1, remain - numList[idx]);
        List<char> ans = new List<char>();
        if(tmp1 != null) {
            ans.Add('1');
            ans.AddRange(tmp1);
            return ans;
        }

        tmp1 = GetAns(idx + 1, remainIdx - 1, remain);
        if (tmp1 != null)
        {
            ans.Add('0');
            ans.AddRange(tmp1);
            return ans;
        }
        return null;

    }

    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


2


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


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

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


Measured memory_bytes: 3912
#include <bits/stdc++.h>
using  namespace std ;
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define ALL(x) (x).begin(),(x).end() 
#define UNQ(x) (x).erase( unique(ALL(x)) , (x).end() ) 
#define lwb( x , y ) lower_bound(ALL(x) , (y) ) - (x).begin() 
#define upb( x , y ) upper_bound(ALL(x) , (y) ) - (x).begin() 
#define sz(x) (int)(x).size() 
#define pb push_back
typedef long long ll ;

int n , m , arr[100010] , div4 = 0 , div2 = 0 , div1 = 0; 

int main(){
	// freopen("in.txt" , "r" , stdin);
	// freopen("out.txt" , "w" , stdout) ;
	scanf("%d",&n) ;
	for(int i=0;i<n;i++){
		scanf("%d" , arr +i ) ;
		if(arr[i]%4 == 0) div4 ++ ;
		else if(arr[i]%2 == 0) div2 ++ ;
		else div1++ ;
	}
	if(div1 <= div4) printf("Yes") ;
	else if(div1 + div4 == n && (div1-div4) <= 1) printf("Yes") ;
	else printf("No") ;
	return  0 ;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<long long,long long> P;



int main(){
	int N;
	long long C;
	long long x[100000],v[100000];

	scanf("%d %lld", &N, &C);
	for(int i=0;i<N;i++){
		scanf("%lld %lld", &x[i],&v[i]);
	}

	long long f0[100000],f1[100000],g0[100000],g1[100000];

	f0[0] = v[0];
	for(int i=1;i<N;i++) f0[i] = f0[i-1]+v[i];
	for(int i=0;i<N;i++) f0[i] -= x[i];
	g0[0] = f0[0];
	for(int i=1;i<N;i++) g0[i] = max(g0[i-1],f0[i]);
	for(int i=0;i<N;i++){
		//printf("%lld\n", g0[i]);
	}

	f1[0] = v[N-1];
	for(int i=1;i<N;i++) f1[i] = f1[i-1]+v[N-1-i];
	for(int i=0;i<N;i++) f1[i] -= C-x[N-1-i];
	g1[0] = f1[0];
	for(int i=1;i<N;i++) g1[i] = max(g1[i-1],f1[i]);


	long long ans0 = max(0ll,g0[N-1]);
	for(int b=0;b<N;b++){
		long long tmp = f1[b] - (C-x[N-1-b]);
		if(b<N-1) tmp += g0[N-2-b];
		//if(ans0<tmp) printf("b:%d\n", b);
		ans0 = max(ans0,tmp);
	}

	long long ans1 = max(0ll,g1[N-1]);
	for(int b=0;b<N;b++){
		long long tmp = f0[b] - x[b];
		if(b<N-1) tmp += g1[N-2-b];
		//if(ans1<tmp) printf("b:%d\n", b);
		ans1 = max(ans1,tmp);
	}

	long long ans = max(ans0,ans1);
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 4992
function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const w = lines.slice(1, n + 1);

  let memory: { [s: string]: boolean } = {};
  let isShiritori = true;
  for (let i = 0; i < n; i++) {
    if ((memory[w[i]] !== undefined) ||
      (i !== 0 && w[i - 1][w[i - 1].length - 1] !== w[i][0])
    ) {
      isShiritori = false;
      break;
    }
    memory[w[i]] = true;
  }

  const msg = isShiritori ? 'Yes' : 'No';

  console.log(msg);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(){
	int N,M;
	int k,s;
	vector<vector<int>> swi;
	cin>>N>>M;
	rep(i,M){
		cin>>k;
		swi.push_back(vector<int>());
		rep(j,k){
			cin>>s;
			swi[i].push_back(s-1);
		}
	}

	int inp;
	vector<int> p;
	rep(i,M){
		cin>>inp;
		p.push_back(inp);
	}
	ll ans = 0;
	rep(x,1<<N){
		bool flag = true;
		rep(i,M){
			int count = 0;
			rep(j,swi[i].size()){
				if((x>>swi[i][j])&1){
					count++;
				}
			}
			if(count%2 != p[i]){
				flag = false;

				break;
			}
		}
		if(flag) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline


N = int(input().strip())


all_list = list(map(int, input().strip().split()))


li = []

for i, item in enumerate(all_list):
    li.append(i + all_list[i])

#print(li)

ri = []

for j, item in enumerate(all_list):
    ri.append(j - all_list[j])

#print(ri)

# li to hash
li_hash = {}
for i, item in enumerate(li):
    if item not in li_hash:
        li_hash[item] = 1
        continue
    elif item in li_hash:
        li_hash[item] += 1

#print(li_hash)

res = 0
for item in ri:
    if item in li_hash:
        res += li_hash[item]

print(res)

Measured memory_bytes: 50644
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [[] for i in range(M)]
for i in range(M):
    AB[i] = list(map(int, input().split()))

cnt = 0
memo_loser = []
for bridge in AB:
    

    value = min(H[bridge[0]-1], H[bridge[1]-1])
    if value == H[bridge[0]-1] and not bridge[0] in memo_loser:
        memo_loser.append(bridge[0])
    if value == H[bridge[1] - 1] and not bridge[1] in memo_loser:
        memo_loser.append(bridge[1])
print(N - len(memo_loser))


Measured memory_bytes: 95172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c&&a==c)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
x, y = c - a, d - b

ans = "U" * y
ans += "R" * x
ans += "D" * y
ans += "L" * (x + 1)
ans += "U" * (y + 1)
ans += "R" * (x + 1)
ans += "DR"
ans += "D" * (y + 1)
ans += "L" * (x + 1)
ans += "U"
print(ans)


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

int main(){
  string st;
  cin >> st;
  vector<int> S;
  int N = st.size();
  rep(i, N){
    S.push_back(st.at(i)-'0');
  } 
  
  int64_t ans = 0;
  
  for (int tmp = 0; tmp < (1 << N-1); tmp++) {
    bitset<10> s(tmp);
    int64_t sum = S.at(0);
    for (int i = 0; i < N-1; i++){
      if(s.test(i)){
        ans += sum;
        sum = S.at(i+1);
      } else {
        sum = 10 * sum + S.at(i+1);
      }
    }
    ans += sum;
  }
  cout << ans << endl;
}


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

#define ll long long int
using namespace std;

int main()
{
    string s;
    cin>>s;
    int Q;
    cin>>Q;
    vector<pair<int, char>>post_process;
    // (prev=0/post=1, char) pair 
    int rev=0;
    for(int i=0; i<Q; i++){
        int T;
        cin>>T;
        if(T == 1){
            rev = rev ^ 1;
        }
        else{
            int F;
            char C;
            cin>>F>>C;
            int location = -1;
            if(rev == 0){
                if(F == 1){
                    location = 0;
                }
                else{
                    location = 1;
                }
            }
            else{
                if(F==1){
                    location = 1;
                }
                else{
                    location = 0;
                }
            }
            post_process.push_back(make_pair(location, C));
        }
    }
    string pref="", post="";
    for(int j=0; j<post_process.size(); j++){
        pair<int, char> x = post_process[j];
        if(x.first == 0){
            pref += x.second;
        }
        else{
            post += x.second;
        }
    }
    reverse(pref.begin(), pref.end());
    string ans=pref + s + post;
    // cout<<pref<<"   "<<s <<"  "<<post<<"\n";
    if(rev == 1){
        reverse(ans.begin(), ans.end());
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 2928
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	let N = parseInt(input[0][0], 10);
	let v_A = input[1].map(e => parseInt(e, 10));

	let v_checkPlus = [];
	let v_checkMinus = [];

	for (let i = 1; i < N; i++){
		if (i - v_A[0] - v_A[i] < 0) {
			if (v_checkMinus[v_A[0] - i + v_A[i]] == undefined) v_checkMinus[v_A[0] - i + v_A[i]] = 1;
			else v_checkMinus[v_A[0] - i + v_A[i]] ++;
		} else {
			if (v_checkPlus[i - v_A[0] - v_A[i]] == undefined) v_checkPlus[i - v_A[0] - v_A[i]] = 1;
			else v_checkPlus[i - v_A[0] - v_A[i]] ++;
		}
	}

	let tmp = 0;
	let ans = 0;
	for (let i = 1; i < N; i ++){
		// console.log(tmp);
		// console.log(v_checkMinus, v_checkPlus);

		if (tmp <= 0){
			ans += (v_checkPlus[tmp * -1] | 0);
		} else {
			ans += (v_checkMinus[tmp] | 0);
		}

		// console.log("ans", ans);

		if (i - v_A[0] - v_A[i] < 0) {
			v_checkMinus[v_A[0] - i + v_A[i]] --;
		} else {
			v_checkPlus[i - v_A[0] - v_A[i]] --;
		}

		tmp += (v_A[i - 1] - v_A[i] - 1);

		
	}
	
	console.log(ans);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 73400
import scala.math.abs

object Main extends App {

  val sc = new java.util.Scanner(System.in)
  val A = sc.nextInt()
  val B = sc.nextInt()
  var socket = 1
  var tap =  0
  while(socket < B) {
    socket = socket + A - 1
    tap += 1
  }
  println(tap)
}

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

int n;
priority_queue<long long,vector<long long>,greater<long long> > p1;
priority_queue<long long> p2;
long long num=0;
long long r[400005];
long long l[400005];
long long a[400005];

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=3*n;i++)
        scanf("%lld",&a[i]);
    for(int i=1;i<=3*n;i++)
    {
        if(p1.size()==n)
        {
            if(p1.top()<a[i])
            {
                num-=p1.top();
                p1.pop();
                p1.push(a[i]);
                num+=a[i];
            }
        }
        else
        {
            num+=a[i];
            p1.push(a[i]);
        }
        if(p1.size()==n)l[i]=num;
        if(p1.size()!=n)l[i]=-1e17;
    }
    num=0;
    for(int i=3*n;i>=1;i--)
    {
        if(p2.size()==n)
        {
            if(p2.top()>a[i])
            {
                num-=p2.top();
                p2.pop();
                p2.push(a[i]);
                num+=a[i];
            }
        }
        else
        {
            num+=a[i];
            p2.push(a[i]);
        }
        if(p2.size()==n)r[i]=num;
        if(p2.size()!=n)r[i]=1e17;
    }
    long long ans=-1e17;
    for(int i=1;i<3*n;i++)
        ans=max(ans,l[i]-r[i+1]);
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 11124
#include<iostream>
#include<string>

using namespace std;

int main()
{
	int a[4],b[4];
	int ina,inb,i,j;
	while(cin>>ina){
		a[0]=ina;
		int h=0,blow=0;
		for(i=1;i<4;i++)
			cin>>a[i];
		for(j=0;j<4;j++)
			cin>>b[j];
		for(i=0;i<4;i++)
			for(j=0;j<4;j++)
				if(a[i]==b[j]){
					if(i==j){
						h++;
						break;
					}
					blow++;
				}
		cout<<h<<" "<< blow<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("O3", "unroll-loops")

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <sstream>
#include <deque>
#include <queue>
#include <random>
#include <complex>

using namespace std;

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FIXED cout << fixed << setprecision(12);
#define RANDOM srand(94385)
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define graph vector<vector<int>>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define f first
#define s second
#define hashmap unordered_map
#define hashset unordered_set
#define eps 1e-9
#define mod 1000000007
#define inf 3000000000000000007ll
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define shuffle(a) \
    for (int i = 0; i < sz(a); ++i) \
        swap(a[i], a[rand() % sz(a)])

template<class T, class U> inline void checkmin(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void checkmax(T &x, U y) { if (y > x) x = y; }
template<class T, class U> inline bool ifmax(T &x, U y) { if (y > x) return x = y, true; return false; }
template<class T, class U> inline bool ifmin(T &x, U y) { if (y < x) return x = y, true; return false; }
template<class T> inline void sort(T &a) { sort(all(a)); }
template<class T> inline void rsort(T &a) { sort(rall(a)); }
template<class T> inline void reverse(T &a) { reverse(all(a)); }
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.f >> p.s; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

bool cmp(const pair<pair<string, int>, int> &a, const pair<pair<string, int>, int> &b) {
    if (a.f.f != b.f.f) return a.f.f < b.f.f;
    return a.f.s > b.f.s;
}

signed main() {
    FAST; FIXED; RANDOM;
    int n;
    cin >> n;
    vector<pair<pair<string, int>, int>> a(n);
    for (int i = 0; i < n; ++i) {
        a[i].s = i;
        cin >> a[i].f;
    }
    sort(all(a), cmp);
    for (auto i : a) cout << i.s + 1 << '\n';
    return 0;
}   

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int MAXN = 1e6 + 5;
int n;
int mat[2][105];
int dp[2][105];
int rec(int i, int j){
    if(i == 1 && j == n - 1)return mat[i][j];
    if(dp[i][j] != -1)return dp[i][j];
    int ret = 0;
    if(i + 1 < 2){
        ret = max(ret, rec(i + 1, j) + mat[i][j]);
    }
    if(j + 1 < n){
        ret = max(ret, rec(i, j + 1) + mat[i][j]);
    }
    return dp[i][j] = ret;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < 2; i ++){
        for(int j = 0; j < n; j ++){
            cin >> mat[i][j];
            dp[i][j] = -1;
        }
    }
    cout << rec(0, 0) << endl;
    return 0;
}




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

using namespace std;

const int MAXN=2e5+5;
int n;
int a[MAXN];
long long sum[MAXN];

map<long long,int> mp;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	++mp[0];
	for(int i=1;i<=n;++i){
		sum[i]=sum[i-1]+a[i];
		++mp[sum[i]];
	}
	long long ans=0;
	for(map<long long,int>::iterator i=mp.begin();i!=mp.end();++i)
		ans+=(long long)i->second*(i->second-1)>>1;
	printf("%lld",ans);
	return 0;
}

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

#define            ll              long long
#define            pb              push_back
#define            mp              make_pair
#define            loop(i,a,n)     for(int i=a;i<n;++i)
#define            clr(x)          memset(x,0,sizeof x)
#define            min3(a,b,c)     min(a,min(b,c))
#define            max3(a,b,c)     max(a,max(b,c))
#define            min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define            max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define            fast            ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define            pii             pair<int,int>
#define            pll             pair<ll,ll>
#define            pli             pair<ll,int>
#define            pil             pair<int,ll>
#define            FF              first
#define            SS              second
#define            PI              acos(-1.0)
#define            bug             cout<<"ok"<<endl;

using namespace std;
using namespace __gnu_pbds;

typedef tree<int , null_type,less<int>,
       rb_tree_tag, tree_order_statistics_node_update> anik;

const int MOD = 1e9 + 7;
const ll MX= 1e9;
const ll INF = 1e9;


ll dp[1009][1009];


main()
{
   int h,w;
   cin>>h>>w;
   dp[0][0]=1;
   string s[h];
   loop(i,0,h)cin>>s[i];
   for(int i=0;i<h;++i)
   {
       for(int j=0;j<w;++j)
       {
           if(s[i][j]=='#')dp[i][j]=0;
           else
           {
               if(i-1>=0 )dp[i][j]+=(dp[i-1][j]%MOD);
               if(j-1>=0)dp[i][j]+=(dp[i][j-1]%MOD);
               //cout<<i<<"->"<<j<<"->"<<dp[i][j]<<endl;
           }
       }
   }
   cout<<(dp[h-1][w-1])%MOD<<endl;

}


Measured memory_bytes: 9216
A, B = [int(y) for y in input().split(' ')]
if int((A/8) * 100) == (A/8) * 100:
  priceA_min = int((A/8) * 100)
else:
  priceA_min = int((A/8) * 100) + 1
if int(((A+1)/8) * 100) == ((A+1)/8) * 100:
  priceA_max = int(((A+1)/8) * 100) - 1
else:
  priceA_max = int(((A+1)/8) * 100)
found = False
for x in range(priceA_min,priceA_max+1,1):
  if int(x*0.1) == B:
    print(x)
    found = True
    break
if not found:
  print(-1)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),OUT(YES),OUT(NO))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 998244353;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL NONE=-2;
#define endl "\n"
ut N, M,K,  Q, D, H, W;
Vpr edges[SIZE];
LL vals[SIZE], answer = zero;
LL A[SIZE],B[SIZE],C[SIZE];
int color[SIZE];
void dfs(int now,int from,int fc){
	int nc=1;
	for(auto next:edges[now]){
		if(next.first==from) continue;
		if(nc==fc) nc++;
		color[next.second]=nc;
		dfs(next.first,now,nc);
		nc++;
	}

}
LL solve(){
	int N;
	cin >> N;
	LL mx=0;
	REP(i,N-1){
		LL a,b;
		cin >> a >> b;
		edges[a].pb(b,i);
		edges[b].pb(a,i);
		MX(mx,(LL)edges[a].size());
		MX(mx,(LL)edges[b].size());
	}
	dfs(1,-1,-1);
	cout << mx << endl;
	REP(i,N-1){
		cout << color[i] << endl;
	}
	return NONE;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	string s;
	LL T;
	DEFAULT;
	
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}

Measured memory_bytes: 21376
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
   string s;
   cin >> s;

   int N = s.size();
   string t;
   REP(i, N){
     if(i != N-1) if(s[i] == 'B' && s[i+1] == 'C'){
       t += 'D';
       i++;
     }
     else t += s[i];
   }

   N = t.size();

   int ans = 0;
   int A = 0;
   REP(i, N){
     if(t[i] == 'A') A++;
     if(t[i] == 'B' || t[i] == 'C') A = 0;
     if(t[i] == 'D'){
       ans += A;
     }
   }

   cout << ans << "\n";

  return 0;
}

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

int main() {
    int k;
    cin >> k;
    string s;
    cin >> s;
    int d = s.size()-k;    
    if(d>0) s = s.substr(0, k) + "...";
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3628
#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() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<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 = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int X, Y;

void solve() {
	cin >> X >> Y;
	if(4 * X - Y < 0 || Y - 2 * X < 0) {
		cout << "No\n";
	}
	else if((4 * X - Y) % 2 || (Y - 2 * X) % 2) {
		cout << "No\n";
	}
	else cout << "Yes\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

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




Measured memory_bytes: 3792
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define pu(n) cout << n; 
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
int i,j,k,l;
int main(void){
	int w,h,x,y;
		cin >> w >> h >> x >> y;
	printf("%f ",(double)w*h/2);
	if(x*2==w && y*2==h){
		puts(1);
	}else{
		puts(0);}
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+2);
    for(int i = 1; i <= n; i++){
        cin >> a.at(i);
    }
    int now = 0;
    long sum = 0;
    for(int i = 1; i <= n+1; i++){
        sum = sum + abs(now - a[i]);
        now = a[i];
    }
    int diff = 0;
    for(int i = 1; i <= n; i++){
        diff = abs(a[i-1]-a[i]) + abs(a[i]-a[i+1]) - abs(a[i-1]-a[i+1]);
        cout << sum - diff << endl;
    }
}

Measured memory_bytes: 1664