akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdint-uintn.h>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <random>
#include <chrono>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

template<typename T> using maximum_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
template<typename T> using minimum_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
std::istream& operator>>(std::istream &is, std::vector<T> &v)
{
  for (typename std::vector<T>::size_type i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}

template<typename ID_TYPE = uint64_t>
class UnionFindTreeBase
{
private:
  std::vector<ID_TYPE> root, rank;

public:
  UnionFindTreeBase(ID_TYPE N)
  {
    root = std::vector<ID_TYPE>(N);
    for (ID_TYPE n = 0; n < N; ++n) { root[n] = n; }
    rank = std::vector<ID_TYPE>(N, 0);
  }

  ID_TYPE find(ID_TYPE x)
  {
    if (root[x] == x) { return x; }

    root[x] = find(root[x]);

    return root[x];
  }

  void unite(ID_TYPE x, ID_TYPE y)
  {
    ID_TYPE x_root = find(x), y_root = find(y);

    if (rank[x_root] > rank[y_root]) {
      root[y_root] = x_root;
    } else if (rank[x_root] < rank[y_root]) {
      root[x_root] = y_root;
    } else if (x_root != y_root) {
      root[y_root] = x_root;
      ++rank[x_root]; 
    }
  }

  bool is_same(ID_TYPE x, ID_TYPE y)
  {
    return find(x) == find(y);
  }

  ID_TYPE operator[](ID_TYPE x) {
    return find(x);
  }
};

typedef UnionFindTreeBase<uint64_t> UnionFindTree;

using namespace std;

int main()
{
  uint64_t N, M;
  cin >> N >> M;

  vector<uint64_t> p(N);
  cin >> p;
  N_TIMES(n, N) { --p[n]; }

	UnionFindTree uf_tree(N);
  N_TIMES(m, M) {
    uint64_t x, y;
    cin >> x >> y;
    --x; --y;

    uf_tree.unite(x, y);
  }

  uint64_t counter = 0;
  N_TIMES(n, N) { 
    if (uf_tree[n] == uf_tree[p[n]]) {
      ++counter;
    }
  }
  cout << counter << endl;

  return 0;
}

Measured memory_bytes: 5548
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
int vis[1010];
int a[1010];
int main()
{
    int n;scanf("%d",&n);
    int sum=0;int flag=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]>=1&&a[i]<=399)
            vis[1]=1;
        else if(a[i]>=400&&a[i]<=799)
            vis[2]=1;
        else if(a[i]>=800&&a[i]<=1199)
            vis[3]=1;
        else if(a[i]>=1200&&a[i]<=1599)
            vis[4]=1;
        else if(a[i]>=1600&&a[i]<=1999)
            vis[5]=1;
        else if(a[i]>=2000&&a[i]<=2399)
            vis[6]=1;
        else if(a[i]>=2400&&a[i]<=2799)
            vis[7]=1;
        else if(a[i]>=2800&&a[i]<=3199)
            vis[8]=1;
        else if(a[i]>=3200)
            flag++;
    }
    for(int i=1;i<=8;i++)
        if(vis[i])
            sum++;
    int bb=sum;
    if(sum==0)
        bb=1;
    int aaa=sum+flag;
    printf("%d %d\n",bb,aaa);
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::cmp::max;

fn main(){ 
    let (a,b) = (read::<i32>(),read::<i32>());
    println!("{}", max(max(a+b,a-b),a*b))
}
fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin.bytes().map(|c| c.expect("Error") as char) 
        .skip_while(|c| c.is_whitespace()).take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("Error")
}

Measured memory_bytes: 4352
def main():
  N,T=map(int,input().split())
  L=[[int(x) for x in input().split()] for _ in range(N)]
  L.sort(key=lambda x:x[0])
  dp=[0]+[-1]*(T+L[-1][0])

  for a,b in L:
    for j in range(T-1,-1,-1):
      if dp[j]>=0 and dp[j+a]<dp[j]+b:
        dp[j+a]=dp[j]+b

  print(max(dp))

if __name__ == '__main__':
  main()


Measured memory_bytes: 3800
import queue
import copy
import math


# そのまま入力文字列の入力
s = input()

alphas = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

found = False
for a in alphas:
    if s == a:
        found = True
        continue
    if found:
        print(a)
        exit(0)

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 111111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

vector <pair < int , int  > > g[MAXN] ;
ll dist[MAXN] ;
bool ok = true , visited[MAXN] ;

void dfs(int u) {
    visited[u] = 1 ;
    for(int  i = 0 ;i<g[u].size() ;i++) {
        int v =g[u][i].first ;
        int w = g[u][i].second ;

        if(!visited[v]) {
            dist[v] = dist[u] + (ll)w ;
            dfs(v) ;
        }
        else if(dist[v] - dist[u] !=(ll)w) {
            ok = false ;
            return ;
        }
    }
}

int main(){
    int n , m , x ,y ,w ;
    scanf("%d %d" , &n ,&m) ;

    for(int i =1 ;i<=m ;i++) {
        scanf("%d %d %d" ,&x ,&y ,&w) ;
        g[x].pb(mp(y, w)) ;
        g[y].pb(mp(x ,-w)) ;
    }
    
    for(int i = 1 ;i<=n && ok ;i++)if(!visited[i]) dfs(i) ;

    if(ok) printf("Yes\n") ;
    else printf("No\n") ;

    return 0 ;
}

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

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)

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

const ll INF = 1LL << 60;

int main(){
  int n,m,X,Y; cin >> n >> m >> X >> Y;
  vector<int> x(n),y(m);
  rep(i, n) cin >> x[i];
  rep(i, m) cin >> y[i];

  sort(x.begin(),x.end());
  sort(y.begin(),y.end());

  int max_x = max(X,x[n-1]);
  int min_y = min(Y,y[0]);
  if(max_x < min_y) std::cout << "No War" << '\n';
  else std::cout << "War" << '\n';
}


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

#define str(a) to_string(a)
#define int long long
#define pb push_back
#define mp make_pair
#define SORT(c) sort(c.begin(),c.end())
#define max_heap priority_queue<int>
#define min_heap priority_queue< int,vector<int>, greater<int> >
#define mod 1000000007
#define setbits(x) __builtin_popcount(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define start(t) int x;cin>>x;while(x--)
#define inf LLONG_MAX
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"






int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k; cin >> n >> k;
	vector<int> h(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> h[i];
	h[0] = 0;
	int dp[n + 1];
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	cerr << dp[1] << " " << dp[2] << endl;
	for (int i = 3; i <= n; i++) {
		int m = 1;
		int minn = INT_MAX;
		while (i - m >= 1 && m <= k) {
			if (dp[i - m] + abs(h[i] - h[i - m]) < minn)
				minn = dp[i - m] + abs(h[i] - h[i - m]);
			m++;
		}
		dp[i] = minn;
	}
	cout << dp[n] << endl;

}











Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, n, m) for(int i = n; i >= m; i--)
#define INF (1e12)
#define PI (acos(-1))
using namespace std;
typedef long long ll;

struct edge{ll to, cost;}; //edgeパラメータ
typedef pair<ll,ll> P;
struct graph{
  ll N; //ノードの個数
  ll M;
  vector<vector<edge> > G; //G[辺の元]((.to辺の先,.costコスト),...)
  vector<ll> d; // d[n] = ノードnまでのの重み

  graph(ll n){ //グラフ生成時
    N = n;
    G.resize(N); //Edge情報
    d.resize(N); //Node情報,ans
    rep(i,N){d[i] = -INF;}
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  ll bellman_ford(ll s){
    d[s] = 0;

    int ct=0;
    ll rec=0;

    while(true) {
        ct++;
        bool update = false;
        for(int i = 0; i < N; ++i) {
          for(int j = 0; j < (ll)G[i].size(); ++j) {
                edge e;
                e.to = G[i][j].to, e.cost = G[i][j].cost;
                if(d[i] != -INF && d[e.to] < d[i] + e.cost) {
                    d[e.to] = min((ll)INF , d[i] + e.cost);
                    if(ct>M){
                      d[e.to]=INF;
                    }
                    update = true;
                }
            }
        }

        if(ct==2*M){
          if(d[N-1]<INF){
            return max((ll)0,d[N-1]);
          }
          else{
            return -1;
          }
        }
    }
    return -2;
  }

};

int main(){
  ll NN,M,P;
  cin>>NN>>M>>P;
  graph g(NN+1);

  g.M=M;

  rep(i,M){
    ll A,B,C;
    cin>>A>>B>>C;
    g.add_edge(A,B,C-P);
  }

  std::cout << g.bellman_ford(1) << '\n';

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
 
int main()
{
	int a;
	int b;
	long long c;
	
	scanf("%d%d%", &a, &b);
	if (a == 1 && b == 1)
		printf("0");
	else 
    {
		if (a >= 2)
        {
          c = (a * (a - 1))/2;
        }
      if (b >= 2)
      {
        c += (b * (b - 1))/2;
      }
      printf("%d", c);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e4+6, M = 1e5+5, OO = 0x3f3f3f3f;

char s[3][3];
int t=0,p;
int main(){
    for(int i=0;i<3;i++)
            scanf("%s",s[i]);

    for(int i=0;i<3;i++)
        printf("%c",s[i][i]);



return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Triangular Relationship
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int INF = 1 << 30;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);

  int m = n / k;
  ll a = (ll)m * m * m;

  if (! (k & 1)) {
    int l = (n + k / 2) / k;
    a += (ll)l * l * l;
  }

  printf("%lld\n", a);
  return 0;
}


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

int main(){
  int r=0,n,buf=0,bf=0,h;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>h;
    //前より小さい
    if(bf>=h) buf++;
    else{
      if(r<buf) r=buf;
      buf=0;
    }

    bf=h;
  }
  if(r<buf) r=buf;
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 256
//written by libra9z
#define LOCAL_TIME
#include <bits/stdc++.h>
using namespace std;
#define Debug(x) cerr<<#x<<" = "<<x<<endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl
#define Debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")\n"
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n"
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl
#define SET(p,v) fill((__typeof(**p)*)p,(__typeof(**p)*)p+sizeof(p),v)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
#define all(s) s.begin(),s.end()
long long n;
long long a[3][100005],now[100005];
long long s[100005];
long long ans=0;
int main()
{
	cin>>n;
	for (int i=0;i<3;++i)
	{
		for (int j=0;j<n;++j)
		{
			cin>>a[i][j];
		}
		sort(a[i],a[i]+n);
	}
	for (int i=0;i<n;++i)
	{
		long long val=a[1][i];
		long long &x=now[i];
		long long l=0,r=n-1,p=n;
		while (l<=r)
		{
			long long mid=(l+r)/2;
			if (a[2][mid]>val)
			{
				p=mid;
				r=mid-1;
			}
			else
			{
				l=mid+1;
			}
		}
		x=n-p;
	}
	for (int i=n-1;i>=0;i--)
	{
		s[i]=s[i+1]+now[i];
	}
	long long j=0;
	for (int i=0;i<n;++i)
	{
		while (a[0][i]>=a[1][j] && j<n)
		{
			j++;
		}
		if (a[0][i]>=a[1][j])
		{
			break;
		}
		ans+=(long long)s[j];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
  int N, i;
  cin >> N >> i;
  cout << N-i+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s; cin >> s;
	int sz = 0;
	int so = 0;
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			if(s[i]=='0'){
				so++;		
			}else{
				sz++;
			}
		}else{
			if(s[i]=='0'){
				sz++;
			}else{
				so++;
			}
		}
	}
	cout << min(sz,so) << endl;
	return 0;
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var n int
	var a string
	var count int
	fmt.Scanf("%d", &n)
	m := make(map[string]int)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &a)
		s := sortString([]byte(a))
		if _, ok := m[s]; ok {
			count += m[s]
			m[s] += 1
		} else {
			m[s] += 1
		}
	}
	fmt.Println(count)
}

func sortString(str []byte) string {
	for i := 0; i < len(str)-1; i++ {
		for j := i + 1; j < len(str); j++ {
			if str[i] > str[j] {
				str[i], str[j] = str[j], str[i]
			}
		}
	}
	return string(str)
}

Measured memory_bytes: 11948
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s,t; cin>>s>>t;
	map<char,set<int>> idx;
	for (int i=0; i<s.size(); i++)
		idx[s[i]].insert(i);
	ll ret=0, iter=0;
	for (int i=0; i<t.size(); i++) {
		if(idx[t[i]].empty()) {
			cout<<-1<<"\n";
			return 0;
		}
		auto it=idx[t[i]].lower_bound(iter);
		if(it==idx[t[i]].end()) iter=0, ret+=s.size(), i--;
		else iter=*it+1;
	}
	cout<<ret+iter<<"\n";
	return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int W, a, b;
    cin >> W >> a >> b;
    
    int ans = abs(b - a) - W;
    
    if(ans > 0)
    {
        cout << ans << endl;
        return 0;
    }
    
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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 long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,a;
    cin >>n>>a;
    
    cout << (n%500 <= a? "Yes" : "No") << endl;
    
    return 0;
    
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

uint64_t gcd(uint64_t a, uint64_t b) {
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

uint64_t lcm(uint64_t a, uint64_t b)
{
	return (a * b / gcd(a, b));
}

uint64_t count(
	uint64_t n, uint64_t d1, uint64_t d2
)
{
	return n - ((n / d1) + (n / d2) - (n / lcm(d1, d2)));
}

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

	uint64_t a, b, c, d; cin >> a >> b >> c >> d;

	cout << (count(b, c, d) - count(a - 1, c, d)) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main ( )
{
	int a ;
	int b ;
	int t ;
	while ( scanf ( "%d" , &t ) == 1 ) {
		a = t ;
		b = 0 ;
		for ( int i = 0 ; i < 3 ; i++ ) {
			scanf ( "%d" , &t ) ;
			a += t ;
		}
		for ( int i = 0 ; i < 4 ; i++ ) {
			scanf ( "%d" , &t ) ;
			b += t ;
		}
		printf ( "%d\n" , ( a > b ) ? a : b ) ;
	}
	return 0 ;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

                    
using ll = long long;
using ull = unsigned long long;
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; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    int r;
    cin >> r;
    cout << r*r << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(ll i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(ll i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007



const int MAX_V = 1000;


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


int V;
vector<vector<edge> > G;
int d[MAX_V];


void dijkstra(int s){
	//greater<pii>????????????????????¨??§first????°???????????????????????????????????????????
	priority_queue<pii, vector<pii>, greater<pii> > que;
	fill(d, d + V, INF);
	d[s] = 0;
	que.push(pii(0, s));

	while(!que.empty()){
		pii p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(pii(d[e.to],e.to));
			}
		}
	}
}

int main(){
	int n, m, a, b, ans;
	while(cin>>n>>m){
		if(n == 0 && m == 0) break;
		G = vector<vector<edge> >(n);
		for(int i = 0; i < m; i++){
			cin>>a>>b;
			a--; b--;
			G[a].pb(edge(b, 1));
			G[b].pb(edge(a, 1));
		}
		V = n;
		dijkstra(0);
		ans = 0;
		for(int i = 1; i < n; i++){
			if(d[i] <= 2) ans++;
			//cout<< i <<" "<< d[i]<<endl;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	ll N,K;
	cin >> N >> K;
	YES((N-1)/2+1 >= K);
}

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

int main() {
    long long N, sum = 0; cin >> N;
    vector<long long> A(N), B(N);
    rep(i,N) {
        cin >> A[i];
        sum += A[i];
    }

    long long t = 1LL * N * (N + 1) / 2;
    if (sum % t) {
        puts("NO");
        return 0;
    }

    long long cnt = sum / t;
    rep(i,N) {
        B[i] = A[(i+1)%N] - A[i] - cnt;
    }
    bool ok = true;
    rep(i,N) {
        if (B[i] > 0 || (-B[i]) % N) ok = false;
    }

    cout << (ok ? "YES" : "NO") << endl;

    return 0;
}


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

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

	string sa;
	for (int i = 0; i < a; ++i) {
		sa += b + '0';
	}

	string sb;
	for (int i = 0; i < b; ++i) {
		sb += a + '0';
	}

	cout << min(sa, sb);
	
	return 0;
}
	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;


vector<long long> A;
int N,K;
int dp[5000] = {0};

bool solve( int a ) {
    
    fill( dp, dp+5000, 0 );
    
    dp[0] = 1;
    
    for ( int i = 0; i < N; i++ ) {
        if ( i == a ) { continue; }
        for ( int j = K-1; j >= 0; j-- ) {
            if ( dp[j] && j+A[i] < K ) {
                dp[ j+A[i] ] = 1;
            }
        }
    }
    
    bool ret = false;
    for ( int i = max( 0LL, K-A[a] ); i < K; i++ ) {
        if ( dp[i] ) { ret = true; break; }
    }
    
    return ret;
}

int main() {
    
    
    cin >> N >> K;
    A.resize(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    
    sort( A.begin(), A.end(), greater<long long>() );
    
    int l = -1;
    int r = N;
    
    while ( l != r ) {
        int mid = (l+r+1)/2;
        if ( solve(mid) ) {
            l = mid;
        }
        else {
            r = mid-1;
        }
    }
    
    cout << max( 0, N-( l+1 ) ) << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (#x) << " is " << (x) << endl;
#define SPD_emergency ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " "; cout << endl;}
void PA(int v[], int n) { for (int i = 0 ; i < n ; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n) {for (int i = 0; i < n; i++)cin >> a[i];}
//continue break deque stack queue sort reverse accumulate  count lower_bound upper_bound
// next_permutation copy_n __builtin_popcount

signed  main() {
  SPD_emergency

   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

  //int t; cin >> t; int tt = 1; while (t--)
  {
  
   int n;
   cin >> n;
   int ans = 0;
   map<string ,int> m;
   while(n--){
    string s;
    cin >> s;
    if(m[s]==0)
      ans++;
    m[s]++;
   }   
   cout<<ans<<endl;


  }
  return 0;
   
}

Measured memory_bytes: 19256
import java.util.Scanner;

class Main {
	static int mod = 1000000007;
	private static long[] fact;
	private static long[] inv_fact;

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

		int n = sc.nextInt();

		int[] a = new int[20];
		int[][] x = new int[20][20];
		int[][] y = new int[20][20];

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

			a[i] = sc.nextInt();

			for (int j = 0; j < a[i]; j++) {

				x[i][j] = sc.nextInt();
				y[i][j] = sc.nextInt();

				// System.out.println("j:" + j);
				// System.out.println("x:" + x + " y:" + y);
			}
		}

		int ans = 0;

		// n = 3 なら 1 << n は 8, n = 10 なら 1024
		for (int bit = 1; bit < (1 << n); bit++) {
			boolean flag = true;

			for (int i = 0; i < n; ++i) {
				if ((bit & (1 << i)) == 0) {
					continue;
				}
				for (int j = 0; j < a[i]; j++) {
					if ((((bit >> (x[i][j] - 1)) & 1) ^ y[i][j]) != 0) {
						flag = false;
					}
				}

			}
			if (flag)
				ans = Math.max(ans, counter(bit));

		}
		System.out.println(ans);

	}

	// 正直者の人数カウンタ
	static int counter(int x) {
		if (x == 0)
			return 0;
		return counter(x >> 1) + (x & 1);
	}

}

Measured memory_bytes: 23892
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int N = (int)(b-a);
        int h = wa(N-1);
        System.out.println(h-a);
    }
    
    public static int wa(int x) {
        if(x == 1) return 1;
        else return x + wa(x-1);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
signed main(){
  	bool isbroken=false;
	int n,a,ans=0,num=0;
  	cin>>n;
  	for(int i=0;i<n;i++){
      cin>>a;
      if(a == num+1){
        num++;
        isbroken = true;
      }
      else{
        ans++;
      }
    }
  if(isbroken)
    cout<<ans<<endl;	
  else
    cout<<"-1"<<endl;
  
	return(0);
}

Measured memory_bytes: 256
def keta(num):
    counter = 0
    while(1):
        num = num/10
        counter += 1
        if(num<1):
            break
    return counter
    
while(1):
    try:
        a,b = map(int, input().split())
        num=a+b
        print(keta(num))
    except:
        break


Measured memory_bytes: 5600
def main():
    n = int(input())
    s = str(input())
    cnt = 0
    r = s.count('R')
    g = s.count('G')
    b = s.count('B')

    for i in range(n):
        for j in range(i,n):
            if i == j:
                continue
            k = 2 * j - i
            if k > len(s) - 1:
                continue
            if s[i] == s[j] or s[j] == s[k] or s[k] == s[i]:
                continue

            cnt +=1

    all = r * g * b
    print(all - cnt) 
if __name__ == "__main__":
    main()



Measured memory_bytes: 9084
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int r, d, x;
  cin >> r >> d >> x;

  REP(i,10){
    x = r * x - d;
    cout << x << endl;
  }
  return 0;
}



Measured memory_bytes: 256
//It doesn't matter as long as you rise to the top - Katsuki Bakugo
#include<bits/stdc++.h>
using namespace std;
     
     
#define Fast_as_duck ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define rev(i,st,n) for(int i = st; i >= n ; i--)
#define ss second
#define ff first
#define ll long long 

typedef pair <int , int> pii;

const int N = 1e5 + 10 , mod =  1000000007;

void solve(){

    int n; cin >> n;
    std::vector<int> arr(n);
    forn(i,0,n){
        cin >> arr[i];
        
    }

    std::vector<ll> sum(n,0);

    sum[n-1] = arr[n-1];

    for(int i = n - 2; i >= 0; i--){
        sum[i] = (sum[i+1] + arr[i]) % mod;

        // cout << "dgs";
    }

    ll ans = 0;

    forn(i,0,n-1){
        ans = ( ans + (arr[i] * sum[i+1])%mod )%mod;

    }

    cout << ans;




    


    
    

    
    
        


}

int main(){
    Fast_as_duck;

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
*/
    int t = 1; 
    
    // cin >> t;
    

    while(t--){
        solve();
    }




    return 0;
}
      
       


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

typedef long long ll;
const int maxn = 100005, mod = 1e9 + 7;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

inline int add(int x, int y) {return x + y >= mod ? x + y - mod : x + y;}

int n, ans, a[maxn], cir[maxn], flen[maxn], sum[maxn], f[maxn], deg[maxn], vis[maxn];

void solvecir(int x)
{
	int len = 0, s = 0, lst = 0, slen = 0;
	while (cir[x]) {
		++len; cir[x] = 0;
		if (flen[x]) {
			if (!s) s = lst = len, slen = flen[x];
			else {
				ans = (ll)ans * ((flen[x] < len - lst) + (flen[x] <= len - lst)) % mod;
				lst = len;
			}
		}
		x = a[x];
	}
	if (!s) ++sum[len];
	else ans = (ll)ans * ((slen < len - lst + s) + (slen <= len - lst + s)) % mod;
}

void solve()
{
	for (int i = 1; i <= n; ++i) {
		if (deg[i]) continue;
		int x = i, len = 0;
		while (!cir[x]) x = a[x], ++len;
		flen[x] = len;
	}
	ans = 1;
	for (int i = 1; i <= n; ++i) if (cir[i]) solvecir(i);
	for (int i = 1; i <= n; ++i) {
		if (!sum[i]) continue;
		f[0] = 1;
		for (int j = 1; j <= sum[i]; ++j) {
			if (i > 1 && (i & 1)) f[j] = add(f[j - 1], f[j - 1]);
			else f[j] = f[j - 1];
			if (j > 1) f[j] = (f[j] + (ll)f[j - 2] * (j - 1) % mod * i) % mod;
		}
		ans = (ll)ans * f[sum[i]] % mod;
	}
}

int main()
{
	n = gi();
	for (int i = 1; i <= n; ++i) a[i] = gi(), ++deg[a[i]];
	for (int i = 1; i <= n; ++i) {
		if (vis[i]) continue;
		int x = i; while (!vis[x]) vis[x] = i, x = a[x];
		if (vis[x] != i) continue;
		while (!cir[x]) cir[x] = 1, x = a[x];
	}

	for (int i = 1; i <= n; ++i)
		if ((cir[i] && deg[i] > 2) || (!cir[i] && deg[i] > 1)) return puts("0"), 0;

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

	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int K;
queue<long long> que;
int c = 10;
 
int main(){
  long long answer;
  cin >> K;
  for ( int i = 0; i<9;i++){
    que.push(i+1);
  }
  
  if (K<=9){
    answer = K;
  }else{
    cout << "";
    while (que.size()){
      
    long long a;
    a = que.front();
    int k = a%10;
    if(k == 0){
        if (c == K){
          answer = a * 10;
          break;
        } else {
          que.push(a * 10);
        }
        c += 1;
        if (c == K){
          answer = a * 10 + 1;
          break;
        } else {
          que.push(a * 10 + 1);
        }
        c += 1;
    } else if (k < 9){
      if (c == K){
          answer = a * 10 + k -1;
          break;
        } else {
          que.push(a * 10 + k -1);
        }
        c += 1;
        if (c == K){
          answer = a * 10 +k;
          break;
        } else {
          que.push(a * 10+k);
        }
        c += 1;
        if (c == K){
          answer = a * 10+1+k;
          break;
        } else {
          que.push(a * 10+1+k);
        }
        c += 1;
    }else{
        if (c == K){
          answer = a * 10 +8;
          break;
        } else {
          que.push(a * 10+8);
        }
        c+= 1;
        if (c == K){
          answer = a * 10+9;
          break;
        } else {
          que.push(a * 10+9);
        }
        c+= 1;
      }
    que.pop();
    }
  }
cout << answer << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int a,b;
    cin >> a >> b;
    cout << (a<=b?a:a-1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define first fi
#define second se
const int MAX=100000;
const int inf=1e9;
vi G[MAX];
list<int> out;
bool V[MAX];
int indeg[MAX];
int v,e;

const int MAX_N=1e5+5;
class UnionFind
{
    int par[MAX_N];
    int rnk[MAX_N];
    int sizes[MAX_N];
    public:
    void init(int n)
    {
        for(int i=0;i<n;i++)
        {
            par[i]=i;
            rnk[i]=0;
            sizes[i]=1;
        }
    }
    int find(int x)
    {
        if(par[x]==x)
        {
            return x;
        }
        else
        {
            return par[x]=find(par[x]);
        }
    }
    void unite(int x,int y)
    {
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rnk[x]<rnk[y]) swap(x,y);
        par[y]=x;
        if(rnk[x]==rnk[y]) rnk[x]++;
        sizes[x]+=sizes[y];
    }
    bool same(int x,int y)
    {
        return find(x)==find(y);
    }
    int size(int x)
    {
        return sizes[find(x)];
    }
};

class Edge
{
  public:
  int source,target,cost;
  Edge(int source=0,int target=0,int cost=0):
  source(source),target(target),cost(cost){}
  bool operator < (const Edge &e ) const
  {
    return cost < e.cost;
  }
};

int kruskal(int N,vector<Edge> edges)
{
  int totalCost=0;
  sort(edges.begin(),edges.end());
  UnionFind uf;
  uf.init(N+1);
  for(int i=0;i<edges.size();i++)
  {
    Edge e=edges[i];
    if(!uf.same(e.source,e.target) )
    {
      totalCost+=e.cost;
      uf.unite(e.source,e.target);
    }
  }
  return totalCost;
}


int main(void)
{
  int N,M,cost;
  int source,target;
  cin >> N >> M;
  vector<Edge> edges;
  for(int i=0;i<M;i++)
  {
    cin >> source >> target >> cost;
    edges.push_back(Edge(source,target,cost));
  }
  cout << kruskal(N,edges) << endl;
  return 0;
}




Measured memory_bytes: 7784
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

def main():
  a, b, k = map(int, input().split())
  if a > b:
    tmp = a
    a = b
    b = tmp

  for i in range(1,a+1)[::-1]:
    if a%i == 0 and b%i==0:
      k -= 1
    if k == 0:
      print(i)
      break
  pass

if __name__=='__main__':
  main()


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine().ToInt();
            var A = Console.ReadLine().Split(' ');
            var aList = new List<decimal>();
            for (int i = 0; i < N; i++)
            {
                aList.Add(A[i].ToDecimal());
            }
            var dic = new Dictionary<decimal, decimal>();
            for (int i = 0; i < N; i++)
            {
                decimal j = 0;
                dic[aList[i]] = dic.TryGetValue(aList[i], out j) ? j + 1 : 1;
            }
            decimal ans = 0;
            foreach (var item in dic)
            {
                ans += (item.Value * (item.Value - 1)) / 2;
            }
            for (int i = 0; i < N; i++)
            {
                var a = aList[i];
                Console.WriteLine(ans - (dic[a] - 1));
            }
            Console.ReadLine();
        }
    }
}

public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 49732
#include <bits/stdc++.h>
using namespace std;
int main() {

 int a,b,c;
 cin >> a >> b >> c;
  
 int answer = 0;
 
 for (int i = a; i <= b; i++) {
     
     if (c % i == 0) {
         answer ++;
     }
 }
  cout << answer << endl;
}

  

    
    


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

int main(){

    long long x;
    cin >> x;

    long long cnt = x / (long long)(11) * (long long)(2);
    long long mod = x % (long long)(11);

    if(mod != 0){
        if(mod <= 6) cnt += 1;
        else if(mod <= 11) cnt += 2;
    }

    cout << cnt << endl;


}

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

int n;
int a[210];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];

    int res = 0;

    while (true){
        bool exist_odd = false;
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 != 0) exist_odd = true;
        }

        if (exist_odd) break;

        for (int i = 0; i < n; ++i) {
            a[i] /= 2;
        }
        ++res;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
def c_coloring_colorfully(S):
    s1 = '10' * (len(S) // 2) + ('1' if len(S) % 2 == 1 else '')
    s2 = '01' * (len(S) // 2) + ('0' if len(S) % 2 == 1 else '')
    ans1, ans2 = 0, 0
    for k, s in enumerate(S):
        if s != s1[k]:
            ans1 += 1
        if s != s2[k]:
            ans2 += 1
    return min(ans1, ans2)

S = input()
print(c_coloring_colorfully(S))

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

using namespace std;

typedef long long ll;
struct P{double x, y;};

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

	int r;
	cin >> r;
	cout << r * r << endl;
}


Measured memory_bytes: 256
#include         <bits/stdc++.h>
#include         <ext/pb_ds/assoc_container.hpp>
#define set(x)   tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo(x)   find_by_order(x)
#define ook(x)   order_of_key(x)
#define TC       int TC;  scanf("%d",&TC);  while(TC--)
using            namespace __gnu_pbds;
using            namespace std;
typedef          long long ll;
typedef          pair<ll,ll> pll;
typedef          pair<int,int> pii;


#define pi acos(-1)


int main(){



 
double a;
cin>>a;

double ans = 2*pi*a;
printf("%.6f",ans);

return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

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

bool valid(int l, int r, string &s) {
	for (int i = l; i <= r; ++i) {
		if (s.at(i) != 'A' && s.at(i) != 'C' && s.at(i) != 'G' && s.at(i) != 'T') {
			return false;
		}
	}
	return true;
}

int main() {
	int l = 0;
	int r = 0;
	string s;
	cin >> s;
	
	int res = 0;
	while (l < s.size() && r < s.size()) {
		if (valid(l, r, s)) {
			res = max(res, r-l+1);
			r++;
		} else {
			l=r;
			r++;
		}
	}
	
	cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <algorithm> 
using namespace std;

int main()
{   
    int h1,h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int res = (h2 - h1) * 60  + (m2 - m1) - k;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3620
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))

if n-m>=0: print(0)
else:
    l=[x[i+1]-x[i] for i in range(len(x)-1)] #階差
    ll=sorted(l, reverse=True)
    print(x[-1]-x[0]-sum(ll[0:n-1]))

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

int main() {
  ll n,d,ans=0;
  set<ll>sq;
  rep(i,130) sq.insert(i*i);
  cin >> n >> d;
  vector<vector<ll>>x(n,vector<ll>(d));
  rep(i,n) rep(j,d) cin >> x.at(i).at(j);
  rep(i,n){
  	for(ll j=i+1;j<n;j++){
  		ll tmp1=0,tmp2=0;
  		rep(k,d){
  			tmp1+=x.at(i).at(k)-x.at(j).at(k);
  			tmp1*=tmp1;
  			tmp2+=tmp1;
  			tmp1=0;
  		}
  		if(sq.count(tmp2)>0) ans++;
  	}
  }
  cout << ans << endl;
}


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


public class C
{
	public static void Main()
	{
		int N = Int32.Parse(Console.ReadLine());
		Dictionary<int,int> nums = new Dictionary<int,int>(N);
		for(int i = 0; i < N; i++)
		{
			int A = Int32.Parse(Console.ReadLine());
			int prevNum;
			if(!nums.TryGetValue(A, out prevNum))
				prevNum = 0;
			nums[A] = prevNum + 1;
		}

		int ans = 0;
		foreach(int key in nums.Keys)
		{
			if(nums[key] % 2 == 1)
				ans++;
		}
		Console.WriteLine(ans);
	}
}





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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

#define maxn 3005
ll dp[maxn][maxn];
string A, B;
string res;

ll solve(int i, int j) {
    if (i >= A.size() || j >= B.size())
        return 0;

    if (dp[i][j] != -1)
        return dp[i][j];

    dp[i][j] = 0;

    if (A[i] == B[j]) {
        dp[i][j] = solve(i + 1, j + 1) + 1;
    } else {
        dp[i][j] = solve(i + 1, j);
        dp[i][j] = max(dp[i][j], solve(i, j + 1));
    }

    return dp[i][j];
}

void getString(int i, int j) {
    if (i >= A.size() || j >= B.size())
        return;

    if (A[i] == B[j]) {
        res += A[i];
        getString(i + 1, j + 1);
    } else if (dp[i + 1][j] > dp[i][j + 1]) {
        getString(i + 1, j);
    } else {
        getString(i, j + 1);
    }
}

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

    cin >> A >> B;
    memset(dp, -1, sizeof(dp));

    solve(0, 0);
    getString(0, 0);

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 71040
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt();
        int k = in.nextInt();
        int x = in.nextInt();
        int y = in.nextInt();
        int total = 0;
        while (n != 0){
            if (k > 0){
                total += x;
                k--;
                n--;
            }
            else {
                total += y;
                n--;
            }
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 21716
n = int(input())
i = list(map(int, input().split()))

def cal(i):
    c = 1
    ans = 0
    for j in range(n):
        if i[j] == c:
            c += 1
        else:
            ans += 1

    if c == 1:
        return -1
    else:
        return ans

print(cal(i))

Measured memory_bytes: 24744
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
const int maxn = 100005;

int n,A,B,h[maxn];

int a[maxn];
bool check(int x){
  for(int i=0;i<n;i++)a[i]=max(0LL,h[i]-x*(ll)B);
  ll sum=0;
  for(int i=0;i<n;i++){
    if(a[i]==0)continue;
    sum+=(a[i]+A-B-1)/(A-B);
  }
  return sum<=x;
}

int main() {
#ifdef suiyuan2009
  freopen("in.cpp","r",stdin);
#endif
  cin>>n>>A>>B;
  for(int i=0;i<n;i++)cin>>h[i];
  int l=1,r=1000000000,ret=r;
  while(l<=r){
    int m=(l+r)>>1;
    if(check(m)){
      ret=m;
      r=m-1;
    } else l=m+1;
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 1024
function main(input) {
  const inputs =input.split('\n')
  const [N] = inputs[0].split(' ').map(Number)
  const A = inputs[1].split(' ').map(Number)

  console.log(
    A.reduce((h, e) => {
      return h && (e % 2 == 0 ? e % 3 === 0 || e % 5 === 0 : true)
    }, true) ? 'APPROVED' : 'DENIED'
  )
}

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


Measured memory_bytes: 29484
import sys
input = sys.stdin.readline
H,W = [int(i) for i in input().split()]
nes = ['0'] * H
indexa = []
for i in range(H) :
    li = list(input())
    nes[i] = li
for i in range(H) :
    del nes[i][-1]
a = 0
for i in range(H) :
    for j in range(W) :
        if nes[i][j] == "#" :
            a = 1
            break
    if a == 0 and nes[i][W-1] == "." :
        indexa.append(i)
    a = 0
count = 0
for i in indexa :
    del nes[i-count]
    count+=1
length = len(nes)
indexaa = []
b = 0
for j in range(W) :
    for i in range(length) :
        if nes[i][j] == "#" :
            b = 1
            break
    if nes[length-1][j] == "." and b == 0 :
        indexaa.append(j)
    b = 0
counta = 0
for i in indexaa :
    for j in range(length) :
        del nes[j][i-counta]
    counta+=1
for i in range(length) :
    t = ''.join(nes[i])
    print(t)

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

using namespace std;

int main() {

	int n;
	cin >> n ;
	vector<long long> a(n, 0);
	vector<long long> b(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i != 0) {
			b[i] = b[i-1]+a[i];
		}
		else { b[i] = a[i]; }
	}
	long long minn = INT64_MAX;
	for (int i = 0; i < n-1; i++) {
		minn = min(minn, abs(b[i] - (b[n - 1] - b[i])));
	}



	cout << minn<< endl;
}

Measured memory_bytes: 3328