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

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

        if (N.indexOf('7') >= 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26976
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;
const long long P = 1000000007;

int main() {
  int n,d;
  cin >> n >> d;
  int x[n][d];
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }
  int count = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i+1; j < n; j++) {
      int len = 0;
      for(int k = 0; k < d ; k++) {
        int dif = abs(x[i][k] - x[j][k]);
        len += dif*dif;
      }
      bool flag = false;
      for(int k = 0; k <= len; k++) {
        if(k*k == len) {
          flag = true;
        }
      }
      if(flag) count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

int main(){
    double x1, x2, y1, y2, lengs;
    scanf("%lf %lf %lf %lf", &x1, &x2, &y1, &y2);
    
    lengs = sqrt(pow((y1 - x1),2) + pow((y2 - x2),2));
    printf("%lf", lengs);
    return 0;
}



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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n+x-1)/x*t) << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>

long long n, m;
long long root[100010], a[100010], b[100010], size[100010], ans[100010];

int getRoot(int x)
{
	return x == root[x] ? x : root[x] = getRoot(root[x]);
}

int main()
{
	std::ios::sync_with_stdio(0);
	std::cin.tie(0), std::cout.tie(0);
	std::cin >> n >> m;
	for (int i = 1; i <= m; ++i)
		std::cin >> a[i] >> b[i];
	for (int i = 1; i <= n; ++i)
		root[i] = i, size[i] = 1;
	ans[m + 1] = n * (n - 1) / 2;
	for (int i = m; i > 1; --i)
	{
		int x = getRoot(a[i]), y = getRoot(b[i]);
		if (x == y)
			ans[i] = ans[i + 1];
		else
		{
			ans[i] = ans[i + 1] - size[x] * size[y];
			size[x] += size[y];
			size[y] = 0;
			root[y] = x;
		}
	}
	for (int i = 2; i <= m + 1; ++i)
		std::cout << ans[i] << "\n";
	return 0;
}


Measured memory_bytes: 5248
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//236
	string s;
	cin>>s;
	vector<int> arr(3,0);
	for(char c:s)arr[c-'a']++;
	int mi = min(arr[0],min(arr[1],arr[2]));
	arr[0]-=mi;arr[1]-=mi;arr[2]-=mi;
	if((((arr[0]+arr[1]+arr[2]>2)||arr[0]>1||arr[1]>1||arr[2]>1)))cout<<"NO";
	else cout<<"YES";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3728
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]
p_lst = list(map(int, (input().split())))

res = 0
for i in range(2**n):
    format_string = '0' + str(n) + 'b'
    i_str = format(i, format_string)
    for k, lamp in enumerate(lst):
        count = 0
        r = p_lst[k]
        for switch in lamp[1:]:
            count += int(i_str[switch-1])
        if r != count % 2:
            #print('NG: ', i)
            break
    else:
        #print('OK: ', i)
        res += 1
print(res)            

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 2e3 + 5;
const int MAXPOS = MAXN*2;

inline void chk_min(int &a,int b){ if(a>b) a=b;}
inline int min(int a,int b,int c){ return min(min(a,b),c);}
inline int max(int a,int b,int c){ return max(max(a,b),c);}

inline bool eq(char a,char b){ return a==b || a=='?' || b=='?';}

template<typename T,int SIZE>
struct Array
{
	T a_[SIZE<<1];
	T *a;
	Array(void): a(a_+SIZE) {}
	inline T& operator [] (const int x){ return a[x];}
	
	inline void set(int val){ memset(a_, val, sizeof(a_));}
};

char a[MAXN],b[MAXN],c[MAXN];

Array<bool,MAXPOS> ab,bc,ac;

void calcPos(const char a[],const int la, const char b[],const int lb, Array<bool,MAXPOS> &ab)
{
	ab.set(1);
	
	for(int i=-lb; i<la; ++i)
	{
		for(int j=max(-i,0); j<lb && i+j<la; ++j)
			if(!eq(a[i+j], b[j]))
			{
				ab[i]=0;
				break;
			}
	}
}

int main(void)
{
	scanf("%s%s%s",a,b,c);
	int la = strlen(a);
	int lb = strlen(b);
	int lc = strlen(c);
	
	calcPos(a,la, b,lb, ab);
	calcPos(a,la, c,lc, ac);
	calcPos(b,lb, c,lc, bc);
	
	int ans = la+lb+lc;
	int maxp = max(la+lb, la+lc, lb+lc);
	
	for(int i=-maxp; i<=maxp; ++i)
	{
		if(!ab[i]) continue;
		for(int j=-maxp; j<=maxp; ++j)
		{
			if(!ac[j]) continue;
			
			int k = j-i;
			if(k>=-MAXPOS && k<MAXPOS && !bc[k]) continue;
			
			chk_min(ans, max(la,i+lb,j+lc) - min(0,i,j));
		}
	}
	
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int N;
  cin >> N;
  vector<queue<int>> v(N);
  rep(i,N){
    rep(j,N-1){
      int a;
      cin >> a;
      a--;
      v[i].push(a);
    }
  }

  set<pair<int,int>> s;
  set<int> t;
  rep(i,N) t.insert(i);

  int ret = 0;
  while(true){
    set<int> tmp;
    FOR(it,t){
      int a = *it;
      if(v[a].empty()) continue;
      int b = v[a].front(); v[a].pop();
      if(a>b) swap(a,b);

      auto f = s.find(make_pair(a,b));
      if(f != s.end()){
        s.erase(f);
        tmp.insert(a);
        tmp.insert(b);
      }else{
        s.insert(make_pair(a,b));
      }
    }

    //cerr << ret << "\t";
    //FOR(x,s) cerr << x->first << "," << x->second << " "; cerr << endl;
    
    if(tmp.empty() && !s.empty()){
      cout << -1 << endl;
      return 0;
    }
    if(tmp.empty() && s.empty()){
      cout << ret << endl;
      return 0;
    }

    ret++;
    swap(t, tmp);
  }
  
  return 0;
}


Measured memory_bytes: 4736
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a*b, c*d) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
#define LL long long
#define MP make_pair
#define PB push_back
#define SZ(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000 + 47;
using namespace std;
const int mod = 998244353;
int cnt[4];
int mask[4];
int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	LL ans = 1;
	cnt[0] = n;
	for(auto &x : s)
	{
		if(x == 'R')
			x = 0;
		else if(x == 'G')
			x = 1;
		else
			x = 2;
	}
	mask[1] = mask[2] = 7;
	for(auto x : s)
	{
		
		for(int i = 2; i >= 0; i--)
		{
			if((mask[i] & (1 << x)) == 0 && cnt[i])
			{
				ans *= cnt[i];
				ans %= mod;
				mask[i + 1] = mask[i] | (1 << x);
				cnt[i]--;
				cnt[i + 1]++;
				break;
			}
		}
	}
	
	cout << ans;
}


Measured memory_bytes: 900
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int main(){
  int N,time=0;
  int x,y;
  bool flag=true;
  cin>>N;
  vector<pair<int,int> > v;
  for(int i=0;i<N;i++){
    cin>>x>>y;
    v.push_back(make_pair(y,x));
  }
  sort(v.begin(),v.end());
  for(int i=0;i<N;i++){
    time+=v[i].second;
    if(time>v[i].first){cout<<"No"<<endl; flag=false; break;}
  }
  if(flag)cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 2420
s = input()
start_i, end_i = 0, 0
a_flag = True

for i, c in enumerate(s):
  if c == 'A' and a_flag:
    start_i = i
    a_flag = False
  if c == 'Z':
    end_i = i
    
print(end_i - start_i + 1)


Measured memory_bytes: 9304
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		double[] X = new double[N];
		double[] Y = new double[N];
		int s = 0;
		double a = 0;
		for(int i=0; i<N; i++) {
			X[i] = sc.nextInt();
			Y[i] = sc.nextInt();
		}
		for(int i=0; i<N; i++) {
			a = Math.sqrt(Math.pow(X[i],2)+Math.pow(Y[i],2));
			if(a<=D) {
				s++;
			}
		}
		sc.close();
		System.out.println(s);
	}

}

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

using namespace std;

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

  string N; cin >> N;
  const int kNum = N.size();
  long long dp[2];
  dp[1] = 1;
  for (int i = 0; i < kNum; i++) {
    auto n = N[i]-'0';
    auto a = dp[0] + n;
    auto b = dp[1] + 10 - n;
    auto c = dp[0] + n + 1;
    auto d = dp[1] + 10 - (n + 1);
    dp[0] = min(a, b);
    dp[1] = min(c, d);
  }
  auto ans = dp[0];
  cout << ans << endl;

  return 0;
}


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

using namespace std;

map<pair<string, string>, long long> cnt1, cnt2;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, i;
	string s;
	string a, b, c, d;
	long long sol = 0;
	
	cin>>n>>s;
	
	for (int bit = 0; bit < (1<<n); ++bit)
	{
		a = b = c = d = "";
		
		for (i = 0; i < n; ++i)
		{
			(bit & 1<<i ? a : b) += s[i];
			(bit & 1<<i ? d : c) += s[2 * n - i - 1];
		}
		
		++cnt1[{a, b}];
		++cnt2[{c, d}];
	}
	
	for (const auto& x: cnt1)
	{
//		cout<<x.first.first<<' '<<x.first.second<<' '<<x.second<<' '<<cnt2[x.first]<<endl;
		sol += x.second * cnt2[x.first];
	}
	
	cout<<sol<<'\n';
}


Measured memory_bytes: 109824
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
// package codeforces;

import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class Main {
    public static void main(String[] args) {
        int n, k;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k = sc.nextInt();
        long ans = 0;
        for (int i = k+1; i <= n; ++i) {
            ans += n/i*(i-k) + (n%i-k+1 >= 0 ? n%i-k+1 : 0);
        }
        if (k == 0) {
            ans = (long) n*n;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 2e5 + 5 ; 
const int M = 15 + 5 ; 
int n, m, w[M], cnt, a[N], st[N], top, Go[M][N], dp[1 << M][M], W[N] ; 
signed main()
{
	n = gi(), m = gi() ;
	rep( i, 1, n ) a[i] = gi() ; 
	while( m ) w[++ cnt] = m, m = m / 2 ; 
	w[++ cnt] = 0 ; 
	int r = 1 ; 
	for( re int k = 1; k <= cnt; ++ k ) {
		r = 1 ; int befr = 0 ; 
		for( re int i = 1; i <= n; ++ i ) {
			r = max( r, i ) ; 
			while( r < n && a[r + 1] - a[max( i, r )] <= w[k] ) ++ r ;  
			Go[k][i] = r ;
			if( ( k == 1 ) && ( r != befr ) ) st[++ top] = r, W[r] = top, befr = r ;
		}
	}
	if( top > cnt ) {
		rep( i, 1, n ) puts("Impossible") ;
		exit(0) ;
	}
	int maxn = ( 1 << cnt ) - 1 ; dp[0][0] = 0 ;
	rep( i, 1, cnt ) Go[i][n + 1] = n ;
	for( re int i = 0; i < maxn; ++ i ) {
		rep( t, 0, top ) {
			for( re int j = 1; j <= cnt; ++ j ) {
				int k = ( 1 << ( j - 1 ) ) ;
				if( ( i & k ) ) continue ;  
				if( j == 1 && t == 0 ) {
					dp[i ^ k][W[Go[j][dp[i][t] + 1]]] = max( dp[i ^ k][W[Go[j][dp[i][t] + 1]]], Go[j][dp[i][t] + 1] ) ;
				}
				else if( j != 1 ) dp[i ^ k][t] = max( dp[i ^ k][t], Go[j][dp[i][t] + 1] ) ;
			}
		}
	}
	rep( i, 1, n ) {
		if( dp[maxn][W[Go[1][i]]] >= n ) puts("Possible") ;
		else puts("Impossible") ;
	}
	return 0 ;
}


Measured memory_bytes: 61824
#include <stdio.h>
#define MAX 251

int main(){
  int n,i;
  int A[MAX];
  
  scanf("%d",&n);
  for(i = 1; i <= n; i++){
    scanf("%d",&A[i]);
  }

  for(i = 1; i <= n; i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i != 1) printf("parent key = %d, ",A[i/2]);
    if(2*i <= n) printf("left key = %d, ",A[2*i]);
    if(((2*i)+1) <= n) printf("right key = %d, ",A[(2*i)+1]);
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2052
s=input()
t=input()

n=len(s)+1
m=len(t)+1

dp=[[0 for i in range(m)] for i in range(n)]

for i in range(n-1):
 for j in range(m-1):

  if s[i]==t[j]:
   dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1)

  dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j])
  dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1])

#print(dp[-1][-1])

n-=1
m-=1

ans=''
while n>0 and m>0:
 if dp[n][m]==dp[n-1][m]:
  n-=1
 elif dp[n][m]==dp[n][m-1]:
  m-=1
 else:
  m-=1
  n-=1
  ans=s[n]+ans

print(ans)

Measured memory_bytes: 121308
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int L[210000];
int R[210000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int p,q;scanf("%d%d",&p,&q);
		p--;q--;
		if(p>q)swap(p,q);
		if(p==0)L[q]=1;
		if(q==a-1)R[p]=1;
	}
	for(int i=0;i<a;i++){
		if(L[i]&&R[i]){printf("POSSIBLE\n");return 0;}
	}
	printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
  string w;
  cin >> w;
  
  vector<int>counter(w.size());
  
  for(int i = 0; i < w.size(); i ++){
    for(int j = 0; j <= i; j ++){
      if(w.at(i) == w.at(j)){
        counter.at(j) ++;
        break;
      }
    }
  }
  
  bool hantei = false;
  
  for(int i = 0; i < w.size(); i ++){
    if(counter.at(i) % 2 == 1){
      hantei = true;
      break;
    }
  }
  
  if(hantei){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
package main

import (
    "fmt"
)

func main() {
    var N int
    fmt.Scan(&N)
    ans := "No"
    for i := 1; i < 10; i++ {
        d := N / i
        m := N % i
        if m == 0 && d <= 9 {
            ans = "Yes"
        }
    }
    fmt.Println(ans)
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;
int K;

void init()
{
	cin >> N;
}

bool ch()
{
	K = 1;
	while (K * (K + 1) / 2 < N) K++;
	return K * (K + 1) / 2 == N;
}


void solve()
{
	if (!ch()) {
		cout << "No" << endl;
		return;
	}
	cout << "Yes" << endl;
	cout << K + 1 << endl;
	vector<vector<int> > v(K+1, vector<int>(K+1, 0));
	int x = 1;
	rep(i, K) {
		reps(j, i+1, K+1) {
			v[i][j] = v[j][i] = x++;
		}
	}
	rep(i, K+1) {
		cout << K;
		rep(j, K+1) {
			if (v[i][j]) {
				cout << " " << v[i][j];
			}
		}
		cout << endl;
	}
}





Measured memory_bytes: 2176
n = int(input())
a = list(map(int,input().split()))
c = [i for i in range(1,n+1)]
for i in range(n):
    c[i] += a[i]
ans = 0
count = {c[0]:1}
for i in range(1,n):
    if i + 1 - a[i] in count:
        ans += count[i + 1 - a[i]]
    if c[i] in count:count[c[i]] += 1
    else:count[c[i]] = 1

print(ans)

Measured memory_bytes: 124972
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int main(){
 

  int N;
    cin>>N;
  VI a(N);
  REP(i,N){
      cin>>a[i];
  }
    sort(ALL(a));
     int old=0;

     int ans=0;
     REP(i,N){
         if(old<a[i]){
             old=a[i];
             ans++;
         }
     }

    cout<<ans<<endl;




}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.inter", "r", stdin);
	string str = "";
	while (getline (cin, str ) ){
		if (str.empty() ){
			break;
		} // end if
		double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
		stringstream ss(str);
		ss >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2;
		bool inter = true; 

		if ( max (xa1, xa2 ) < min (xb1, xb2 ) 
 		  || min (xa1, xa2 ) > max (xb1, xb2 ) ){
			inter = false;
		}else{
			if ( min (ya1, ya2 ) > max (yb1, yb2 ) 
			  || max (ya1, ya2 ) < min (yb1, yb2 ) ){
				inter = false;
			} // end if
		} // end if
		if (inter){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		} // end if
	} //  end while
		
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int ar[n][3];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
    }
    for(int i=1;i<n;i++)
    {
        ar[i][0]+=max(ar[i-1][1],ar[i-1][2]);
        ar[i][1]+=max(ar[i-1][0],ar[i-1][2]);
        ar[i][2]+=max(ar[i-1][1],ar[i-1][0]);
        
        //cout<<min(v[i-1]+abs(ar[i]-ar[i-1]),v[i-2]+abs(ar[i]-ar[i-2]))<<" ";
    }
    //cout<<endl;
    cout<<max(ar[n-1][0],max(ar[n-1][1],ar[n-1][2]));
}


Measured memory_bytes: 1408
N = int(input())
s = [input() for _ in range(N)]

ans = 0
k = [0] * 3
for i in range(N):
    ans += s[i].count("AB")
    if s[i][0] == "B" and s[i][-1] == "A":
        k[0] += 1
    elif s[i][0] == "B":
        k[1] += 1
    elif s[i][-1] == "A":
        k[2] += 1

if k[0] >= 1:
    k[0] -= 1
    if k[1] >= 1:
        k[1] -= 1
        k[0] += 1
    if k[2] >= 1:
        k[2] -= 1
        k[0] += 1

print(ans + k[0] + min(k[1], k[2]))

Measured memory_bytes: 3700
import java.util.*;

public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
        long target = Long.valueOf(sc.next());
        long yen = 100;
        int count = 0;

        for(;;) {
            yen *= 1.01;
            count++;
            if(yen >= target) break;
        }
        System.out.println(count);
	}
}

Measured memory_bytes: 35480
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));

int main() {
	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];

	auto ans = mat(int, h, w, 0);
	int ai = 0;
	rep(i, h) {
		rep(j, w) {
			ans[i][j] = ai + 1;
			a[ai]--;
			if (a[ai] <= 0)ai++;
		}
		i++;
		if (i < h) {
			for (int j = w - 1; j >= 0; j--) {
				ans[i][j] = ai + 1;
				a[ai]--;
				if (a[ai] <= 0)ai++;
			}
		}

	}
	rep(i, h) {
		rep(j, w)cout << ans[i][j] << " ";
		cout << endl;
	}
	return 0;
}





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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin>>n&&n){
    vary(int,v,n+1,0);
    rep(i,n){
      cin >> v[i];
    }
    v[n]=inf;
    int ans = 0;
    int len = n;
    while(len != 1){
      int i = 0;
      while(i < len){
        if(v[i] > v[i+1]){
          swap(v[i],v[i+1]);
          ++ans;
        }
        ++i;
      }
      --len;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vvchar vector<vector<char>>
#define vchar vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n);
    rep(i,n)cin>>a[i];
    cout<<MAX(a)-MIN(a);
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
using namespace std;

ll N,M,ans;
vector<ll> X,Y;

int main(){
     cin >> N >> M;
     X.resize(M); 
     Y.resize(M-1);

     FOR(i,0,M){
             cin >> X[i];
     }
     sort(X.begin(),X.end());
     FOR(i,0,M-1){
             Y[i] = X[i+1] - X[i];
     }
     sort(Y.begin(),Y.end());
     FOR(i,0,M-N){
             ans += Y[i];
     }
     cout << ans << endl;

     return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
    q[i]=p[i];
  }
  sort(q.begin(),q.end());
  int cnt=0;
  for(int i=0;i<n;i++){
    if(p[i]!=q[i]){
      cnt++;
    }
  }
  if(cnt<=2){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
# coding: utf-8


def solve(*args: str) -> str:
    h, w, k = map(int, args[0].split())
    black = [[c == '#' for c in C] for C in args[1:]]

    ret = 0
    for x in range(2**w):
        for y in range(2**h):
            cnt = 0
            for i in range(w):
                for j in range(h):
                    if (x >> i) & 1 and (y >> j) & 1 and black[j][i]:
                        cnt += 1
            if cnt == k:
                ret += 1
    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 9204
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N, K;
    cin >> N >> K;

    map<int,int> cnts;
    for (int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        ++cnts[x];
    }

    vector<int> A;
    for (auto& p : cnts) {
        A.push_back(p.second);
    }
    sort(A.begin(), A.end());
    int res = 0;
    for (int i = 0; i + K + 1 <= A.size(); ++i) {
        res += A[i];
    }
    
    cout << res << '\n';

    return 0;
}

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

#define ll long long
#define ld long double
#define pi 3.14159265359

int main() {
    int X, Y, Z; cin >> X >> Y >> Z;
    swap(X, Y);
    swap(X, Z);
    cout << X << ' ' << Y << ' ' << Z << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main() {
	int n = 0;
	string s;
	cin >> n >> s;

	int cnt = 0;
	rep(i,n-2) {
		if (s[i] == 'A') {
			if (s[i + 1] == 'B') {
				if (s[i + 2] == 'C') {
					cnt++;
				}
			}
		}
	}

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

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

using namespace std;
int main()
{
  int N,A,B;
  int result;
  scanf("%d %d %d",&N,&A,&B);
  if(N*A<B)
    result = N*A;
  else
    result = B;
  printf("%d\n",result);
  return 0;
}

Measured memory_bytes: 256
import sys
import os
import math
import string
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    H, N = il()
    A = il()
    print('Yes' if H <= sum(A) else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 13004
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }

int main() {
	int t;
	//cin >> t;
	t = 1;
	while(t--) {
		int n, x;
        cin >> n;
        
        vector<int> arr(100005, 0);
        ll sm = 0;
        for(int i=0; i<n; i++) {
            cin >> x;
            ++arr[x];
            sm += x;
        }
        
        int q, b, c;
        cin >> q;
        
        for(int i=0; i<q; i++) {
            cin >> b >> c;
            sm += (arr[b] * (c-b));
            arr[c] += arr[b];
            arr[b] = 0;
            
            cout << sm << endl;
        }
	}

	return 0;
}

Measured memory_bytes: 3784
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  newl           cout<<"\n";
#define  f              first
#define  s              second
#define  pb             push_back
#define  mp             make_pair
#define  sym(s)         s="#"+s+"#";   
#define  all(x)         (x).begin(),(x).end()
#define  alll(x, n)     x+1, x+n+1
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  mset1d(a,n,v)  foo(i,0,n+5)a[i]=v;
#define  mset2d(a,n,m,v)foo(i,0,n+5)foo(j,0,m+5)a[i][j]=v;
#define  INP(a,n)       foo(i,1,n) cin>>a[i];
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  debm(a)        for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  debp(a,n)      foo(i,1,n)cout<<"{"<<a[i].f<<","<<a[i].s<<"}, ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ld   PI    =  3.14159265358979323846; 
const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/



/***************************************** FUNCTION IMPLEMENTATIONS **************************************/



/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];newl;
}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
    MAIN(i);
    }
}

Measured memory_bytes: 8308
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<stdlib.h>
#include<time.h>
using namespace std;
int dp[100001],rd[100001];
vector<int>b[100001];
int n,m,a1,a2;
priority_queue<pair<int,int> >q;
int Rand(int a,int b)
{
	return (rand()%(b-a+1))+a;
} 
void DFS()
{
	while(!q.empty()) 
	{
		int x=q.top().second;
		q.pop();
		for(int i=0;i<b[x].size();i++)
		{
			int to=b[x][i];
			rd[to]--;
			if(rd[to]==0)
			{
				q.push(make_pair(Rand(1,1000),to));
			}
			if(dp[to]<dp[x]+1)
				dp[to]=dp[x]+1;
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&a1,&a2);
		rd[a2]++;
		b[a1].push_back(a2);
	}
	for(int i=1;i<=n;i++)
	{
		if(rd[i]==0)
		{
			q.push(make_pair(Rand(1,1000),i));
		}	
	}
	DFS();
	int mx=0;
	for(int i=1;i<=n;i++)
	{
		mx=max(mx,dp[i]);
	}
	cout<<mx<<endl;
	return 0;
}


Measured memory_bytes: 6528
n, m = map(int, input().split())
a = list()
for i in range(n) :   #1行ずつn行まで読み込みlistに格納
  a.append(list(map(int, input().split())))
b = list()
for j in range(m) :
  b.append(int(input()))
  
for i in range(n) :
  s = 0
  for j in range(m) :
    s += a[i][j] * b[j]
  print(s)



Measured memory_bytes: 6004
#include <stdio.h>

int main(){

    int n = 0;
    int m = 0;
    int x = 0;
    int y = 0;
    int buf;
    int bufxn = -101;
    int bufym = 101;

    int ans = 0;

    scanf("%d%d%d%d",&n,&m,&x,&y);


    for (int i = 0; i < n; i++) {
        scanf("%d", &buf);
        if (buf > bufxn) {
            bufxn = buf;
        }
    }

    for (int i = 0; i < m; i++) {
        scanf("%d", &buf);
        if (buf < bufym) {
            bufym = buf;
        }
    }

    if (x < y) {
        if (bufxn < y) {
            if (x < bufym) {
                if (bufxn < bufym) {
                    ans = 1;
                }
            }
        }
    }


    if (ans == 1) {
        printf("No War");
    } else {
        printf("War");
    }
    
    return 0; 
    
	
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)

ll N, K;
ll A[101010];
ll Fa[101010];

ll i, j, k, ans;

ll moddiv(ll a,ll b){
    a %= MOD;
    b %= MOD;
    for(ll m=MOD-2;m>0;m/=2){
        if(m&1){
            a=a*b%MOD;
        }
        b=b*b%MOD;
    }
    return a;
}


int main(){
    scanf("%lld%lld", &N, &K);
    
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }

    Fa[0] = 1;
    fornum(i,0,N){
        Fa[i + 1] = Fa[i] * (i + 1) % MOD;
    }

    sort(A, A + N);
    fornum(i,0,N){
        A[i] = (MOD + A[i]) % MOD;
    }
    fornum(i,0,N-K+1){
        ans += (MOD - A[i]) * moddiv(Fa[N - i - 1], Fa[K - 1]* Fa[N - i - K]);
        ans %= MOD;
    }
    for (i = N - 1; K - 1 <= i;--i){
        ans += A[i] * moddiv(Fa[i], Fa[K - 1]* Fa[i - K + 1]);
        ans %= MOD;
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 1792
n=gets.to_i
d=gets.split.map(&:to_i)
l=[1]+[0]*12
d.each do |e|
  l[e]+=1
end
if l[0]>1||l[12]>1||l.max>2
  puts 0
  exit
end
m=0
s=[0,24]
t=[]
u=[]
13.times do |i|
  next if i==0
  if l[i]==1
    if i==12
      s << 12
    else
      t << i
      u << 24-i
    end
  elsif l[i]==2
    s << i
    s << 24-i
  end
end
tz=t.size
[0,1].repeated_permutation(tz) do |b|
  r=[]
  tz.times do |i|
    if b[i]==0
      r << t[i]
    else
      r << u[i]
    end
  end
  r=(s+r).sort
  mm=24
  (r.size-1).times do |i|
    mm=r[i+1]-r[i] if mm>r[i+1]-r[i]
  end
  m=mm if mm>m
end
puts m


Measured memory_bytes: 14320
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
#define int ll
using pii = pair <int, int>;
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = 0;
const int mod = 998244353;

int n, x, y;
vector <int> G[2020];
int dpd[2020];
int dt[2020];
int32_t main()
{
    usecppio
    cin >> n >> x >> y;
    for (int i = 1; i<n; i++)
    {
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[x].push_back(y);
    G[y].push_back(x);
    for (int i = 1; i<=n; i++)
    {
        memset(dt, 0x7f, sizeof(dt));
        queue <int> q;
        q.push(i);
        dt[i] = 0;
        while(!q.empty())
        {
            int p = q.front();
            q.pop();
            for (auto it:G[p])
            {
                if (dt[it]==INF)
                {
                    dt[it] = dt[p]+1;
                    q.push(it);
                }
            }
        }
        for (int j = 1; j<=n; j++)
        {
            dpd[dt[j]]++;
        }
    }
    for (int i = 1; i<n; i++)
    {
        cout << dpd[i]/2 << '\n';
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        int vis[n + 1];
        memset(vis, 0, sizeof(vis));
        map<int, int> mp;
        while (m--)
        {
            int x;
            string s;
            cin >> x >> s;
            if (s == "WA")
            {
                if (!vis[x])
                    mp[x]++;
            }
            else
            {
                vis[x] = 1;
            }
        }
        int tota = 0, totp = 0;
        for (int i = 1; i <= n; ++i)
        {
            if (vis[i])
            {
                tota++;
                totp += mp[i];
            }
        }
        cout << tota << " " << totp << "\n";
    }
}

Measured memory_bytes: 10648
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 2e9;

ll dist[205][205];

void warchall_floyd(int N){
    rep(k,N)rep(i,N){
        if(dist[i][k] == INF) continue;
        rep(j,N){
            if(dist[k][j] == INF) continue;
	        chmin(dist[i][j], dist[i][k]+dist[k][j]);
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    rep(i,10)rep(j,10) cin >> dist[i][j];
    warchall_floyd(10);
    ll ans = 0;
    rep(i,h)rep(j,w){
        int a;
        cin >> a;
        if(a == -1) continue;
        if(a == 1) continue;
        ans += dist[a][1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [int(_a) for _a in input().split()]

b = [0] * int(1e5)
c = [0] * int(1e5)
for _a in a:
    b[_a] += 1

for i in range(int(1e5)):
    if i != 0:
        c[i] += b[i-1]
    if i != int(1e5-1):
        c[i] += b[i+1]
    c[i] += b[i]

print(max(c))

Measured memory_bytes: 13964
#include<bits/stdc++.h>
// Begin Header {{{
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
using namespace std;
using Graph = vector<vector<lli>>;
using P = pair<int, int>;
// }}} End Header

int main(){
	long double a, b;
	cin >> a >> b;
	lli ans = (lli)(a*b);
	cout << ans << endl;
	return 0;
}

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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int N, Q; cin >> N >> Q;
    string s; cin >> s;
    
    vector<int> sum( N );
    REP( i, N ){
        if( i == 0 ) continue;
        sum[i] = sum[i - 1];
        if( s[i - 1] == 'A' && s[i] == 'C' ){
            sum[i]++;
        }
    }

    REP( i, Q ){
        int l, r; cin >> l >> r;
        l--, r--;
        cout << sum[r] - sum[l] << endl;
    }

}

/*

*/

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N;
ll C, x[100002], v[100002], MAX;
lP r[100002], l[100002], r2[100002], l2[100002];

int main(){
	cin >> N >> C;
	for (int i = 1; i != N + 1; ++i) {
		cin >> x[i] >> v[i];
	}
	x[N + 1] = C;
	for (int i = 1; i != N + 2; ++i) {
		r[i].first = r[i - 1].first + v[i] - x[i] + x[i - 1];
		r2[i].first = r2[i - 1].first + v[i] + (x[i - 1] - x[i]) * 2;
		r[i].second = max(r[i].first, r[i - 1].second);
		r2[i].second = max(r2[i].first, r2[i - 1].second);
	}
	for (int i = N; i != -1; --i) {
		l[i].first = l[i + 1].first + v[i] - x[i + 1] + x[i];
		l2[i].first = l2[i + 1].first + v[i] + (x[i] - x[i + 1]) * 2;
		l[i].second = max(l[i].first, l[i + 1].second);
		l2[i].second = max(l2[i].first, l2[i + 1].second);
	}
	for (int i = 0; i != N + 1; ++i) {
		MAX = max({ MAX,r[i].second + l2[i + 1].second,r2[i].second + l[i + 1].second });
	}
	cout << MAX << endl;
	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 k, x;
int main() {
  cin >> k >> x;
  for (i64 i = x - k + 1; i <= x + k - 1; ++i) cout << i << ' ';
  cout << endl;
  return 0;
}


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

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

  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  if (a > b) {
    ll c = a - v * t;
    ll d = b - w * t;

    if (c <= d) cout << "YES\n";
    else cout << "NO\n";
  } else {
    ll c = a + v * t;
    ll d = b + w * t;

    if (c >= d) cout << "YES\n";
    else cout << "NO\n";
  }

  return (0);
}


Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                int[] nums = new int[10];

                for (int i = 0; i < 10; i++)
                {
                    nums[i] = input[i] - '0';
                }

                for (int i = 9; i > 0; i--)
                {
                    for (int j = 0; j < i; j++)
                    {
                        nums[j] = (nums[j] + nums[j + 1]) % 10;
                    }
                }
                sb.AppendLine(nums[0].ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9012
#include<stdio.h>

int main(){
    int a,b,n,m,sum=0,i,count=0;
    scanf("%d %d %d",&n,&a,&b);
    for(i=1;i<n+1;i++){
        sum=0;
        m=i;
    while(m!=0){
        sum=sum+m%10;
        m=m/10;
    }
    if(a<=sum&&sum<=b){
        count=count+i;
    }
    }
    printf("%d",count);
}



Measured memory_bytes: 128
A=[]
X=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
  A.append(list(map(int,input().split())))

def bingo_index(a,b):
  for i in range(3):
    if b in a[i]:
      return [i,a[i].index(b)]
  return 0
  
N=int(input())
for i in range(N):
  B=int(input())
  temp=bingo_index(A,B)
  if temp!=0:
    X[temp[0]][temp[1]]=1

ans='No'
for i in range(3):
  if X[i]==[1,1,1]:
    ans='Yes'
  if X[0][i]==1 and X[1][i]==1 and X[2][i]==1:
    ans='Yes'

if X[0][0]==1 and X[1][1]==1 and X[2][2]==1:
  ans='Yes'
if X[2][0]==1 and X[1][1]==1 and X[0][2]==1:
  ans='Yes'

print(ans)

Measured memory_bytes: 3316