akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

int di[] = {1, 0, -1, 0}, dj[] = {0, 1, 0, -1};

void solve() {
  int h, w;
  while (cin >> h >> w, h) {
    vs s(h);
    rep(i, h) cin >> s[i];
    int x = 0;
    rep(i, h) rep(j, w) {
      char done = '7';
      function<void(int, int, char)> dfs = [&](int i, int j, char c) {
        if (c == done || i < 0 || j < 0 || i >= h || j >= w || s[i][j] != c) return;
        s[i][j] = done;
        rep(k, 4) dfs(i + di[k], j + dj[k], c);
      };
      x += s[i][j] != done;
      dfs(i, j, s[i][j]);
    }
    cout << x << endl;
  }
}

Measured memory_bytes: 4084
use itertools::Itertools;

fn main() {
    proconio::input! {
    a:String,
    }
    let a=a.chars().collect_vec();
    let mut b =Vec::new();
    for i in 0..a.len() {
        if i%2==0 {
            b.push(a[i])
        }
    }
    let b:String=b.into_iter().collect();
    println!("{}",b)
}

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

int main(){
  constexpr int64_t Pmax= 1e18;
  int N;
  cin >> N;

  vector<int64_t> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());

  int64_t ans= 1;
  for(int i=0; i<N; i++){
    ans= (data.at(0)==0 || Pmax/ans >= data.at(i)) ? ans* data.at(i)
                                                  : -1;
    if(ans==-1 || ans==0){ break; }
  }

  cout << ans << endl;
}

Measured memory_bytes: 4052
#include <stdio.h>
int main()
{
	int S, h, m, s;
	scanf("%d",&S);
	h = S /60 /60;
	m = (S - h*60*60) /60;
	s = S - h*60*60 - m*60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define int long long
using namespace std;
typedef pair<int, int> P;

int fsum(int n, int x, int d) {
	return n * x + d * (n * (n - 1) / 2);
}

int n, x, d;
map<int, vector<P>> segDict;

signed main() {
	cin >> n >> x >> d;
	if (d < 0) {
		d = -d;
		x = -x;
	}
	if (d == 0) {
		//xがN個. 0, x, …, Nxを作れる. x = 0なら0の1個, x ≠ 0ならこれらは相異なりN + 1個.
		if (x == 0) { cout << 1 << endl; }
		else { cout << n + 1 << endl; }
	 	return 0;
	}
	
	for (int i = 0; i <= n; i++) {
		int smin = fsum(i, x, d);
		int smax = fsum(i, x + (n - i) * d, d);
		int mods = (smin % d + d) % d;
		int u = (smin - mods) / d;
		int v = (smax - mods) / d;
		//mods : u, u + 1, …, v
		segDict[mods].push_back(P(u, v));
	}
	
	int ans = 0;
	for (map<int, vector<P>>::iterator it = segDict.begin(); it != segDict.end(); it++) {
		vector<P> segs = it->second;
		sort(segs.begin(), segs.end());
		
		int r = segs[0].first - 1;
		int cnt = 0;
		for (int i = 0; i < segs.size(); i++) {
			if (r < segs[i].first) {
				cnt += segs[i].second - segs[i].first + 1;
				r = segs[i].second;
			}
			else if (r < segs[i].second) {
				cnt += segs[i].second - r;
				r = segs[i].second;
			}
		}
		ans += cnt;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 22144
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll N; cin >> N;
    vector<P> lis(0);
    rep(i, 0, N-1){
        ll a, b; cin >> a >> b;
        lis.emplace_back(mp(a,b));
    }
    ll ans = 0;
    ans += (N+2)*N*(N+1)/6;
    for(auto x: lis){
        ll a = max(x.first, x.second), b = min(x.first, x.second);
        ans -= b*(N-a+1);
    }
    prtl(ans);
}



Measured memory_bytes: 7376
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  char s[n];
  scanf("%s",s);
  int i=0,count=0;
  if(n%2==1){
    printf("No\n");
    return 0;}
  else{
    for(i=0;i<n/2;i++){
      if(s[i]==s[i+(n/2)])
	count++;
    }
  }
  if(count==n/2)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int mn =1001;
    int mx =-1;
    int a;
    for(int i=1; i<=n; i++){
        cin >> a;
        if(mn>a) mn = a;
        if(mx<a) mx = a;
    }
    cout << mx-mn << endl;
    return 0;
}




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

using namespace std;

void LoopUntilZeroInpput() {
	int N = 0;
	while (cin >> N && N != 0) {
	}
}

int main() {
	string S;
	cin >> S;
	int strSize = S.size();

	char lastChar;
	lastChar = S[0];
	int count = 0;
	for (int i = 1; i < strSize; i++) {
		if (S[i] != lastChar) {
			count++;
		}
		lastChar = S[i];
	}

	cout << count << endl;
}

Measured memory_bytes: 512
import itertools

N, A, B = list(map(int,input().split()))

if N==1:
    if A==B:
        print(1)
        exit()
    else:
        print(0)
        exit()

if A > B:
    print(0)
    exit()

min = A*(N-1)+B
max = A+B*(N-1)

print(max-min+1)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

#define For(i,n) for(int i;i<n;i++)

int main(){
    int n;
    cin>>n;
    vector<int>vec(n);
    For(i,n)
        cin>>vec.at(i);
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    int count=1;
    for(int i=1;i<n;i++){
       if(vec.at(i)==vec.at(i-1)){
           continue;
       }
       count++; 
    }
    printf("%d\n",count);        
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long int llint;
string k;
llint d;
llint dp[10005][105][2];
llint sum2(llint a,llint b) {
	return ((a%1000000007)+(b%1000000007))%1000000007;
}
llint rek(llint ind,llint sum,llint tight) {
	if(ind>=k.size()) return llint(sum==0);
	if(dp[ind][sum][tight]!=-1) return dp[ind][sum][tight];
	llint ret=0;
	llint x=9;
	if(tight==1) x=int(k[ind])-48;
	for(llint i=0;i<=x;i++) {
		if(i<x) ret=sum2(ret,rek(ind+1,(sum+i)%d,0));
		else ret=sum2(ret,rek(ind+1,(sum+i)%d,tight));
	}
	if(tight==0) dp[ind][sum][tight]=ret;
	//cout <<ind<<" "<<sum<<" "<<tight<<" "<<ret<<endl;
	return ret;
}
int main()
{
	cin >> k >> d;
	memset(dp,-1,sizeof(dp));
	cout <<(rek(0,0,1)-1+1000000007)%1000000007;
	/*for(int i=0;i<k.size();i++) {
		for(int j=0;j<20;j++) {
			cout <<dp[i][j][1]<<" ";
		}
		cout <<endl;
	}*/
	return 0;
}


Measured memory_bytes: 17664
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int e = scan.nextInt();

		String answer;
		if(c - e < 0 || c + e > a){
			answer = "No";
		}else if(d - e < 0 || d + e >b){
			answer = "No";
		}else{
			answer = "Yes";
		}

		System.out.println(answer);
		scan.close();
	}
}

Measured memory_bytes: 26380
import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
L = [int(v) * -1 for v in input().split()]

heapify(L)

for i in range(M):
    a = heappop(L) * -1

    heappush(L, a // 2 * -1)

print(sum(L) * -1)

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

int main() {
	std::ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	ll n, m, x;
	ll L = 1;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> x;
		x /= 2;
		L = L * x / __gcd(L, x);
		if (L > 1e18) {
			cout << 0 << endl;
			return 0;
		}
	}
	L /= x;
	m /= x;
	if (L % 2 == 0 || L > m) {
		cout << 0 << endl;
	} else {
		cout << (m / L + 1) / 2 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pb push_back
#define f first
#define s second
#define MOD 998244353
 
using namespace std;


int main(){
 
	ios_base::sync_with_stdio(false);
	//cin.tie(0);
	cout<<fixed<<setprecision(12);
	//memset(dp,-1,sizeof(dp));
	int a,b; cin>>a>>b;
	for(int i=0; i <=100000; i++){
		if((i*2)/25 == a && i/10 == b){
			cout<<i;
			return 0;
		}
	}
	cout<<-1;

	return 0;
}
 

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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return

#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define repd(i,a,b) for (ll i = (a); i >= b; i--)
#define repdz(i,a) for (ll i = a; i >=0; i--)
#define trav(a, x) for (auto& a : x)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

void solve()
{
    int x,y;
    cin >> x >> y;

    if (y%2!=0)
    {
        cout << "No" << endl;
        re;
    }

    int a = 2*x - y/2;
    int b = y/2 - x;

    if (a < 0 || b < 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //llin(t);
    //while (t--)
    //{
        solve();
    //}
}


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

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	cin >> n;
	a[0] = -1;
	ll ans = -1;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		if (a[i] > a[i-1] + 1) {
			cout << "-1\n";
			exit(0);
		}

		if (a[i] == a[i-1] + 1) ans ++;
		else ans += a[i];
	}
    
	cout << ans << '\n';

   	return Accepted;
}

// B...a


Measured memory_bytes: 18816
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std; 
int dp[100003];
int main(){
	fastIO;         
	string s;
	cin>>s;
	dp[0]=1;
	for(int i=0;i<(int)s.size();i++){
		if(dp[i]==0)continue;
		if(i+5 <= (int)s.size() && s.substr(i,5) == "dream")dp[i+5]=1;			
		if(i+7 <= (int)s.size() && s.substr(i,7) == "dreamer")dp[i+7]=1;
		if(i+5 <= (int)s.size() && s.substr(i,5) == "erase")dp[i+5]=1;
		if(i+6 <= (int)s.size() && s.substr(i,6) == "eraser")dp[i+6]=1;
	} 
	if(dp[(int)s.size()] ==1)cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 848
import java.util.*;

public class Main {

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

		long ans = 0;
		for (int i = 1; i <= N; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				ans += i;
			}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 35796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector <pair <string, ll>> v(n, pair <string, ll> ());
  map <string, ll> score;
  map <pair <string, ll>, ll> tmp;
  rep(i, n) {
    string s;
    ll p;
    cin >> s >> p;
    v.at(i) = make_pair(s, p);
    tmp[v.at(i)] = i+1;
    if (score.count(s)) {
      score.at(s)++;
    } else {
      score[s] = 1;
    }
  }
  sort(v.begin(), v.end());
  rep(i, n) {
    string str = v.at(i).first;
    ll num = score.at(str);
    i += num-1;
    for (ll j = 0; j < num; j++) {
      pair <string, ll> p = v.at(i-j);
      cout << tmp.at(p) << endl;
    }
  }
}

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

using namespace std;
typedef long long ll;
const int N = 1010;

void solve(ll n)
{
	if(n == 0)	return;						// 除至末尾，结束递归
	if(n % 26 == 0)
	{
		solve((n - 1) / 26);				// 被26整除不需要进位，因此用(n-1)递归
		printf("z");						// 被26整除单独处理
	}
	else
	{
		solve(n / 26);						// 进制转换的正常处理算法
		printf("%c", n % 26 + 'a' - 1);		// 余数即当前位数值
	}
}

int main()
{
	ll n;
	scanf("%lld", &n);
	solve(n);
	return 0;
}



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

int main(){
    int n;
    cin >> n;

  	int m_cnt = 0;
  	int id;
    rep(i,n){
        int idx = i;
        int cnt = 0;
        while(idx > 0){
            if(idx % 2 == 0)
                cnt++;
            idx /= 2;
        }
        if(m_cnt <= cnt){
        	m_cnt = cnt;
			id = i;
        }
    }

    cout << id << endl;

    return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>
#include <stdlib.h>

struct node{
  int key;
  struct node *pa;
  struct node *le;
  struct node *ri;
};
typedef struct node* TREE;
TREE root;

void insert(int);
int find(int);
void print();
void inorder(TREE);
void preorder(TREE);

int main(){
  int i,m,num;
  char com[7];

  scanf("%d",&m);
  if(m>500000) exit(2);
  root = NULL;
  for(i=0;i<m;i++){
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d",&num);
      insert(num);
    }
    else if(com[0] == 'p')print();
    else if(com[0] == 'f'){
      scanf("%d",&num);
      if(find(num) == 1) printf("yes\n");
      else printf("no\n");
    }
  }
  
  return 0;
}

void insert(int key){
  TREE node_root=root,newnode,p,oya=NULL;

  newnode = (TREE)malloc(sizeof(struct node));
  newnode->le = newnode->ri = NULL;
  newnode->key = key;
  p=node_root;
  while(p!=NULL){
    oya=p;
    if(p->key > key) p=p->le;
    else p=p->ri;
  }
  newnode->pa = oya;
  if(oya == NULL){
    root = newnode;
  }else{
    if(oya->key > newnode->key) oya->le = newnode;
    else oya->ri = newnode;
  }
}

void print(){
  inorder(root);
  printf("\n");
  preorder(root);
  printf("\n");
}

void inorder(TREE out){
  if(out == NULL) return;
  inorder(out->le);
  printf(" %d",out->key);
  inorder(out->ri);
}

void preorder(TREE out){
  if(out == NULL) return;
  printf(" %d",out->key);
  preorder(out->le);
  preorder(out->ri);
}

int find(int key){
  TREE node_root=root,p;

  p=root;
  while(p!=NULL){
    if(p->key == key) return 1;
    if(p->key > key) p=p->le;
    else p=p->ri;
  }
  return 0;
}



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

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

  if(n%2==0) {
    long x=0;
    for(long i=0;i<n;i+=2) {
      x+=a[i];
    }
    ans=x;
    for(long i=n-1;i>0;i-=2) {
      x+=a[i]-a[i-1];
      ans=max(ans,x);
    }
  } else {
    vector<vector<long>> aa(n/2,vector<long>(3));
    aa[n/2-1][2]=a[n-1];
    aa[n/2-1][1]=max(aa[n/2-1][2],a[n-2]);
    aa[n/2-1][0]=max(aa[n/2-1][1],a[n-3]);
    for(long i=n/2-2;i>=0;i--) {
      aa[i][2]=aa[i+1][2]+a[i*2+2];
      aa[i][1]=max(aa[i][2],aa[i+1][1]+a[i*2+1]);
      aa[i][0]=max(aa[i][1],aa[i+1][0]+a[i*2]);
    }
    ans=max(aa[0][0],max(aa[0][1],aa[0][2]));
  }
  cout << ans << endl;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

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

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint operator()(int n) { return fact[n]; }
};
int main() {
    lint N, K;
    cin >> N >> K;
    mint total = 0;
    vector<lint> A(2 * 1000000, 0);
    rep(i, 1000000) { A[i + 1] = A[i] + i; }

    for (int i = K; i <= N + 1; i++) {
        mint mi = A[i];
        mint ma = A[N + 1] - A[N + 1 - i];
        total += (ma - mi) + 1;
    }
    cout << total.x << endl;
    return 0;
}

Measured memory_bytes: 18832
import java.io.*;
import java.util.*;

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

        int n = cin.nextInt(), k = cin.nextInt(), cnt = 0;;
        for(int i=0;i<n;i++) if(cin.nextInt() >= k) cnt++;
    
        cout.println(cnt);
        cout.close();
    }
}

Measured memory_bytes: 46708
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_E
// Wikipedia(ja) solution
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(int argc, char **argv)
{
        string s1, s2;
        cin >> s1 >> s2;
        int n1 = s1.size(), n2 = s2.size();
        vector<vector<int>> dp(n1+1, vector<int>(n2+1));
        for (int i = 0; i <= n1; i++)
                dp[i][0] = i;
        for (int i = 0; i <= n2; i++)
                dp[0][i] = i;
        for (int i = 1; i <= n1; i++) {
                for (int j = 1; j <= n2; j++) {
                        int c = dp[i-1][j-1];
                        c += s1[i-1] == s2[j-1] ? 0 : 1;
                        c = min(c, dp[i-1][j] + 1);
                        c = min(c, dp[i][j-1] + 1);
                        dp[i][j] = c;
                }
        }
        cout << dp[n1][n2] << endl;
        return 0;
}

Measured memory_bytes: 6704
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
ll MOD = 998244353;

int main(){
    int N;
    cin >> N;
    int div4=0,div2=0,etc=0;
    for(int i=0;i<N;i++){
        ll x;
        cin >> x;
        if(x%4 == 0) div4++;
        else if(x%2 == 0) div2++;
        else etc++;
    }
    string ans = "No";
    if(div2 == 0){
        if(div4+1 >= etc) ans = "Yes";
    }
    else if(div4 >= etc) ans = "Yes";
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える定数
#define N_MAX 200


//問題文のとおりの変数
int N;
vector<vector<int>> F;
vector<vector<int>> P;

LL ans = -INF;

//オリジナル変数



//サブ関数
void calc(vector<bool> set) {
	for (auto flag : set) {
		if (flag) {
			goto a;
		}
	}
	return;
a:
	LL money = 0;
	REP(i, N) {
		int num = 0;
		REP(j, 10) {
			if (set[j]==true && F[i][j]==1) {
				num++;
			}
		}
		money += P[i][num];
		//cout << i << "  "<<num <<" "<< P[i][num] << endl;
	}
	//cout << money << endl;
	//for (auto flag : set) {
	//	cout << flag << " ";
	//}
	//cout << endl;
	ans = max(ans, money);
}


void roop(vector<bool> set) {
	if (set.size() == 10) {
		//安全性の確認
		calc(set);
		return;
	}
	set.push_back(true);
	roop(set);
	set.pop_back();

	set.push_back(false);
	roop(set);
	set.pop_back();
}



//メイン関数
int main() {
	cin >> N;
	REP(i, N) {
		vector<int> tmp;
		REP(j, 10) {
			int c;
			cin >> c;
			tmp.push_back(c);
		}
		F.push_back(tmp);
	}
	REP(i, N) {
		vector<int> tmp;
		REP(j, 11) {
			int c;
			cin >> c;
			tmp.push_back(c);
		}
		P.push_back(tmp);
	}


	vector<bool> aaa;
	roop(aaa);


	cout << ans<< endl;
	
	cin >> ans;
	cin >> N;
	REP(i, 100000) {
		cin >> N;
	}
	return 0;
}




Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

struct RH {
  vector<unsigned long long> p,hash;
  void init(const string s) {
    unsigned long long m=1000000007,q=1,n=s.size();
    p.resize(n+1);hash.resize(n+1);p[0]=q;hash[0]=0;
    rep(i,n){p[i+1]=p[i]*m;hash[i+1]=s[i]+hash[i]*m;}
  }
  unsigned long long h(int i)const{return hash[i];}
  unsigned long long h(int i,int j)const{return h(j)-h(i)*p[j-i];}
};

RH t;

void Main() {
  ll n;
  string s;
  cin >> n >> s;
  t.init(s);
  ll l=0,r=n/2+1;
  while(l+1<r) {
    ll m=(l+r)/2,f=0;
    rep(i,n) {
      REP(j,i+m,n) {
        if(j+m>n) break;
        if(t.h(i,i+m)==t.h(j,j+m)) {
          f=1;
          i=n;
          break;
        }
      }
    }
    if(f) l=m;
    else r=m;
  }
  pr(l);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    string s;
    cin >> s;

    int MIN = 0;
    int MAX = 0;

    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'A')
        {
            MIN = i;
            break;
        }
    }
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'Z')
        {
            MAX = i;
        }
    }

    cout << MAX - MIN + 1 << endl;

    return 0;
}

Measured memory_bytes: 640
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int w, a, b;
  readf("%s %s %s\n", &w, &a, &b);
  
  if (a < b) {
    if (b > a + w) {
      writeln(b - (a + w));
    } else {
      writeln(0);
    }
  } else {
    if (a > b + w) {
      writeln(a - (b + w));
    } else {
      writeln(0);
    }
  }
  
}


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

using ll = long long;

const int N = 1005;

int n;
ll a[N], d[N], p[N];
vector<int> r;

void f(int x){
    if(!p[x]){
        for(int i = 1; i < x; i++) r.push_back(1);
        return;
    }
    for(int j = (x + p[x]) / 2; j > p[x]; j--) r.push_back(j);
    f(p[x]);
}

int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%lld", a + i);
        for(int j = i - 2; j >= 1; j -= 2){
            if(d[i] < d[j]){
                d[i] = d[j];
                p[i] = j;
            }
        }
        d[i] += a[i];
    }
    int t = int(max_element(d + 1, d + n + 1) - d);
    printf("%lld\n", d[t]);
    for(int i = n; i > t; i--) r.push_back(i);
    f(t);
    printf("%d\n", r.size());
    for(int i : r) printf("%d\n", i);
}

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

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define st first
#define nd second

#define DMAX 
#define NMAX 
#define MMAX 

using namespace std;

int n, k, a[200100];
long long s[200100];

template<class T>
ostream& operator<<(ostream& out, vector<T> v) {
	out << v.size() << '\n';
	for(auto e : v) out << e << ' ';
	return out;
}

map<long long, int> f;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i]; s[i] = s[i - 1] + a[i];
	}

	f[0] = 1;
	long long ans = 0;
	for(int i = 1; i <= n; i++) {
		ans += f[s[i]];
		f[s[i]]++;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 15104
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<limits>
#include<iomanip>
#include<set>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1000000000 //long long int専用
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
	int n;
	double t, a;
	cin >> n;
	cin >> t >> a;
	vector<double> h(n);
	rep(i, n)cin >> h[i];
	
	int ans = 0;
	double minv = INF,memo;
	rep(i, n) {
		memo = t - h[i] * 0.006;
		memo = abs(a - memo);
		//cout << memo << endl;
		if (min(memo, minv) == memo) {
			minv = memo;
			ans = (i+1);
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	char c;
	cin >> c;
	char a = c + 1;
	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, X;
  cin>>N>>X;
  ll ans = 0;
  ll A[N];
  for(int i=0;i<N;++i) {
    cin>>A[i];
    if(A[i]>X) {
      ans += A[i]-X;
      A[i] = X;
    }
  }
  for(int i=1;i<N;++i) {
    if(A[i-1]+A[i]>X) {
      ans += A[i-1]+A[i]-X;
      A[i] -= A[i-1]+A[i]-X;
    }
  }
  cout<<ans<<endl;
}



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

int main() {
  string s;
  cin >> s;
  if (s == "a" || s == "i" || s == "u" || s == "e" || s == "o")
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int n, m, l; cin >> n >> m >> l;
	vvi a(n, vi(m));
	vvi b(m, vi(l));
	REP(i, n) REP(j, m) cin >> a[i][j];
	REP(i, m) REP(j, l) cin >> b[i][j];
	vvl res(n, vl(l));
	REP(i, n) {
		REP(j, l) {
			ll sum = 0;
			REP(k, m) {
				sum += a[i][k] * b[k][j];
			}
			res[i][j] = sum;
		}
	}
	REP(i, n) {
		REP(j, l) {
			cout << res[i][j];
			if (j == l - 1) cout << endl;
			else cout << " ";
		}
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 3272
import bisect
iipt=lambda:int(input())
miipt=lambda:list(map(int,input().split(" ")))
n, m=miipt()
a=[]
done=[0]*m
for i in range(m):
    a.append(miipt())
b=sorted(a, key=lambda x:x[1])
c=0
d=-1
for p, q in b:
    if not p<=d<q:
        c+=1
        d=q-1
print(c)

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

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;
//#define int ll

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; cout << '\n'; return O;}


void _main() {
        int k, n; cin >> k >> n;
        vector<int> a(n); cin >> a;
        sort(all(a));
        a.insert(a.end(), all(a));
        for (int i = n; i < a.size(); i++) {
                a[i] += k;
        }

        int ans = 1e9;
        for (int i = 0; i + n - 1 < a.size(); i++) {
                ans = min(ans, a[i + n - 1] - a[i]);
        }

        cout << ans;
}

#undef int
int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define X first
#define Y second

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

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

    while(n --){
        vector<pair<double, double> > in(4);
        vector<double> m(2);

        rep(i, 4) cin >> in[i].X >> in[i].Y;
        rep(i, 2) m[i] = (in[2 * i].Y - in[2 * i + 1].Y) / (in[2 * i].X - in[2 * i + 1].X);
        if(m[0] == m[1]) cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 1224
#include <stdio.h>
#define N 100000
int A[N], n;
int partition(int, int );
int main(){
    int i, q;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &A[i]);
    }
    q = partition(0, n-1);
    for(i=0; i<n; i++){
        if(i!=0){
            printf(" ");
        }
        if(i==q){
            printf("[");
        }
        printf("%d",A[i]);
        if(i==q){
            printf("]");
        }
    }
    printf("\n");
    return 0;
}

int partition(int p, int r){
    int x;
    int i, j;
    int a;
    
    x = A[r];
    i = p-1;
    for(j=p; j<r; j++){
        if(A[j]<=x){
            i++;
            a = A[i];
            A[i] = A[j];
            A[j] = a;
        }
    }
    a=A[i+1];
    A[i+1]=A[r];
    A[r]=a;
    return i+1;
}


Measured memory_bytes: 2096
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String str=sc.next();
        BigInteger a=new BigInteger(str);
        str=sc.next();
        BigInteger b=new BigInteger(str);
        System.out.println(a.subtract(b));
    }
}



Measured memory_bytes: 75064
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    cin >> N;
    ll curr;
    cin >> curr;
    ll sum = 0;
    rep(i, N-1){
        cin >> A;
        sum += max(0ll, (curr - A));
        curr = A;
    }
    sum += curr;
    cout << sum;
}


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

typedef long long ll;

const ll mod=1e9+7;
const int maxn=2e5+5;

int top=0;
int head[maxn];

void init(){
	top=0;
	memset(head,-1,sizeof(head));
}

struct Edge{
	int to,next;
}edge[maxn];

void addedge(int x,int y){
	edge[top].to=y;
	edge[top].next=head[x];
	head[x]=top++;
	edge[top].to=x;
	edge[top].next=head[y];
	head[y]=top++;
}

int vis[maxn];

int mx=0;

void dfs(int u,int fa,int col){
	int num=1;
	for(int i=head[u];i!=-1;i=edge[i].next){
		int to=edge[i].to;
		if(to==fa) continue;
		if(num==col) num++;
		vis[i]=num;vis[i|1]=num;
		dfs(to,u,num);
		num++;
	}
}

int du[maxn];

int main(){
	init();
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		addedge(x,y);
		du[x]++;du[y]++;
	}
	for(int i=1;i<=n;i++){
		mx=max(mx,du[i]);
	}
	dfs(1,0,0);
	printf("%d\n",mx);
	for(int i=0;i<2*(n-1);i+=2){
		printf("%d\n",vis[i]);
	}
	return 0;
}

Measured memory_bytes: 6400
S = input()
K = int(input())
oans = 0
head = 0
tail = 0
N = len(S)
count = 1

if S.count(S[0]) == N:
  print(N*K//2)
  exit()
for i in range(N-1):
  if S[i+1] == S[i]:
    count += 1
  else:
    oans += count // 2
    if head == 0:
      head = count
    count = 1
  if i == N-2:
    oans += count // 2
    tail = count
    if head == 0:
      print(N*K//2)
      exit()
plus = 0

if S[0] != S[-1]:
  print(oans * K)
  exit()

d = head//2 + tail //2 -(head + tail)//2

print(oans*K -(K-1)*d)

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

long rec(vector<int> adj[], int n, int id, bool vis[], long mem[])
{
  if(id==n+1)
    return 0;
  if(vis[id])
    return mem[id];
  if(mem[id]!=-1)
    return mem[id];
  vis[id]=true;
  long ans=-1;
  for(int i=0;i<adj[id].size();i++)
  {
    long a=rec(adj,n,adj[id][i],vis,mem);
    ans=max(ans,a);
  }
  mem[id]=ans+1;
  return mem[id];
}

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> adj[n+1];
  for(int i=0;i<m;i++)
  {
    int x,y;
    cin>>x>>y;
    adj[x].push_back(y);
  }
  bool vis[n+1];
  for(int i=0;i<=n;i++)
	vis[i]=false;
  long mem[n+1];
  for(int i=0;i<=n;i++)
    mem[i]=-1;
  for(int i=1;i<=n;i++)
  {
  	if(!vis[i])
  	  rec(adj,n,i,vis,mem);
  }
  long mx=0;
  for(int i=1;i<=n;i++)
  {
    if(mx<mem[i])
      mx=mem[i];
  }
  cout<<mx;
	
  
}

Measured memory_bytes: 9984
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!.toCharArray()

    var result = ""
    for (i in 0 until s.size) {
        var a = (((s[i].toInt() - 65 + n) % 26) + 65).toChar()
        result += a.toString()
    }
    println(result)
}

Measured memory_bytes: 114132
#include "bits/stdc++.h"
using namespace std;

int main() {
	int H, W;
	for (int a = 0; ; a++) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if ((i + j) % 2 == 0) cout << '#';
				else cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3104
# ABC134D - Preparing Boxes
def main():
    n = int(input())
    A = [0] + list(map(int, input().rstrip().split()))
    B = [0] * (n + 1)
    for i in range(n, 0, -1):
        cnt, p = 0, 2
        while i * p <= n:
            cnt += B[i * p]
            p += 1
        if cnt % 2 != A[i]:
            B[i] += 1
    total = sum(B)
    if total == 0:
        print(0)
    else:
        print(total)
        print(*(i for i, j in enumerate(B[1:], start=1) if j == 1))


if __name__ == "__main__":
    main()

Measured memory_bytes: 13356
<?php
// H W
while(true){
    //STDIN
    fscanf(STDIN, "%d %d", $h, $w);

    //break
    if($h == 0 && $w == 0){
        return;
    }
    
    for($i = 1; $i <= $h; $i++){
        if($i == 1 || $i == $h){
            //top & bottom
            echo str_repeat("#", $w).PHP_EOL;
        }else{
            //middle
            echo "#". str_repeat(".", $w-2). "#".PHP_EOL;
        }
    }
    echo PHP_EOL;
}
?>

Measured memory_bytes: 14916
// Aizu Vol-1 0159: The Best Body
// 2017.8.2

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#define GOAL 22.0
#define EPS 0.00001

char *gets(char *);
char buf[100], *p;

int getInt(void)
{
	int n = 0;
	while (isspace(*p)) p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

int main()
{
	int i, n, a, id;
	double bmi, h, t, min;

	while (1) {
		gets(p = buf);
		if (!(n = getInt())) break;
		min = 1000000000.0;
		for (i = 0; i < n; i++) {
			gets(p = buf);
			a = getInt(), h = getInt() / 100.0, bmi = getInt();
			bmi = bmi / (h*h);
			if (bmi >= GOAL) t = bmi - GOAL;
			else             t = GOAL - bmi;
			if (t <= min) {
				if (-EPS <= t - min && t - min <= EPS);
				else id = a, min = t;
			}
		}
		printf("%d\n", id);
	}
	return 0;
}

Measured memory_bytes: 524
N = int(input())
p_list = list(map(int, input().split()))

count = 0 # p_j > p_i である回数
p_length = len(p_list)
p_min = p_list[0] # 現時点での最小値

for i in range(p_length):
    if p_list[i]<=p_min:
        p_min = p_list[i]
        count = count + 1 # カウントを１つ増やす
    else:
        continue

print(count)


Measured memory_bytes: 24744
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b;
  cin >> a >> b;
  cout << a * b - (a + b - 1) << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=302;
const ll mod=1e9+7;
ll dp[M][M],tp[M][M];
std::vector<pair<int,int> > v[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int l,r,x;
		cin>>l>>r>>x;
		v[r].pb({l,x});
	}
	if(n==1)
	{
		ll ans=3;
		for(auto u:v[1])
			if(u.ss!=1)
				ans=0;
		cout<<ans<<"\n";
		return 0;
	}
	dp[0][0]=3;
	for(int i=2;i<=n;i++)
	{
		memset(tp,0,sizeof(tp));
		for(int j=0;j<i-1;j++)
		{
			for(int k=0;k<i-1;k++)
			{
				tp[j][k]=(tp[j][k]+dp[j][k])%mod;	
				tp[i-1][k]=(tp[i-1][k]+dp[j][k])%mod;	
				tp[j][i-1]=(tp[j][i-1]+dp[j][k])%mod;
			}
		}
		for(int j=0;j<i;j++)
		{
			for(int k=0;k<i;k++)
			{
				dp[j][k]=tp[j][k];
				for(auto u:v[i])
				{
					int ct = 1;
					if(u.ff<=j)
						ct++;
					if(u.ff<=k)
						ct++;
					if(ct!=u.ss)
						dp[j][k]=0;
				}
			}
		}
	}
	ll ans=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			ans=(ans+dp[i][j])%mod;
	// ans=(ans*6)%mod;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int in;
  cin >> in;
  int g = gcd(in, 360);
  cout << 360/g << endl;
  return 0;
}

Measured memory_bytes: 3572
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N;

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

  double ans = 0;

  ans = ceil((double)N / 2) / N;

  printf("%.9f\n", ans);

  return 0;
}


Measured memory_bytes: 888