akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.algorithm;
import std.conv;
import std.numeric;
import std.math;
import std.string;

void main()
{
	auto n = to!int(chomp(readln()));

	int result;
	while (true)
	{
		auto a1 = n / 100;
		auto a2 = (n / 10) % 10;
		auto a3 = n % 10;
	
		if (a1 == a2 && a1 == a3)
		{
			result = n;
			break;
		}
		++n;
	}

	writeln(result);
	stdout.flush();
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define v(T) vector<T>
#define imposs {cout<<"-1\n";return 0;}
#define LL_MAX LLONG_MAX
#define LL_MIN LLONG_MIN

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;
typedef multiset<int> msi;
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

//MOD//
const ll MOD = 1000000007;
struct big;
big ex(big a, ll tms);
typedef struct big{
  ll val;
  big():val(0){}
  big(ll val):val((val%MOD+MOD)%MOD){}
  big& operator += (const big& obj){ (val+=obj.val)%=MOD; return *this;}
  big& operator -= (const big& obj){ (val+=MOD-obj.val)%=MOD; return *this;}
  big& operator *= (const big& obj){ (val*=obj.val)%=MOD; return *this;}
  big& operator /= (const big& obj){ (val*=ex(obj,MOD-2).val)%=MOD; return *this;}
  big operator + (const big& obj)const{ return big(*this) += obj;}
  big operator - (const big& obj)const{ return big(*this) -= obj;}
  big operator * (const big& obj)const{ return big(*this) *= obj;}
  big operator / (const big& obj)const{ return big(*this) /= obj;}
  bool operator < (const big& obj)const{ return val < obj.val;}
  bool operator == (const big& obj)const{ return val == obj.val;}
} big;
istream& operator >> (istream& i, big& obj){ i>>obj.val; return i;}
ostream& operator << (ostream& o, const big& obj){ o<<obj.val; return o;}
big ex(big obj, ll tms){
  if(!tms) return 1;
  big ret = ex(obj, tms/2);
  ret *= ret;
  return (tms&1) ? ret*obj : ret;
}
//MOD//

big dp[1<<21];

int a[21][21];

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

  int N;
  cin >> N;
  rep(i,N)rep(j,N) cin >> a[i][j];

  dp[0] = 1;
  rep(i,1<<N) {
    int s = 0; // iのビット1の数
    rep(j,N) s += (i>>j) & 1;
    rep(j,N) {
      int x = 1 << j;
      if (i&x && a[s-1][j]) dp[i] += dp[i^x];
    }
  }
  big ans = dp[(1<<N)-1];
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 16640
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    
    let ans = n * (n - 1) / 2;
    
    println!("{}", ans);
}

Measured memory_bytes: 4352
N=int(input())
lst=[]
for i in range(N):
    lst.append(str(input()))

acn = 0
wan = 0
tlen = 0
ren = 0

for a in lst:
    if a == 'AC':
        acn += 1
    elif a == 'WA':
        wan += 1
    elif a == 'TLE':
        tlen += 1
    elif a == 'RE':
        ren += 1
    else:
        continue

print('AC x ' + str(acn))
print('WA x ' + str(wan))
print('TLE x ' + str(tlen))
print('RE x ' + str(ren))

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

long long MOD = 1000000007;

long long Calc(long long A, long long B) {
	if (B == 0) return 1;
	if (B % 2 == 0) {
		long long C = Calc(A, B / 2);
		return (C * C) % MOD;
	}
	return (A * Calc(A, B - 1)) % MOD;
}

int main() {
	int N;
	string S;
	static long long DP[5010][5010] = {};
	cin >> N >> S;
	DP[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		DP[i][0] = DP[i - 1][0] + DP[i - 1][1];
		DP[i][0] %= MOD;
		for (int j = 1; j <= N; j++) {
			DP[i][j] = DP[i - 1][j - 1] * 2 + DP[i - 1][j + 1];
			DP[i][j] %= MOD;
		}
	}
	cout << (DP[N][S.size()] * Calc(Calc(2, MOD - 2), S.size())) % MOD << endl;
}

Measured memory_bytes: 195968
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		float[][] xy = new float[N][2];
		double sum = 0;

		for (int i = 0; i < N; i++) {
			xy[i][0] = Float.parseFloat(sc.next());
			xy[i][1] = Float.parseFloat(sc.next());
		}
		for(int i = 0; i < N - 1; i++) {
			for(int j = i+1; j < N; j++) {
				double length = Math.sqrt((xy[i][0] - xy[j][0]) * (xy[i][0] - xy[j][0]) + (xy[i][1] - xy[j][1]) * (xy[i][1] - xy[j][1]));
				sum += length;
			}
		}
		System.out.println(sum/N*2);
	}
}

Measured memory_bytes: 24020
//Author - Sanket Mundra
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define IIITA ios::sync_with_stdio(0)
#define sanket cin.tie(0)
#define mundra cout.tie(0)
ll M = 1000000007;

int main()
{
	IIITA; sanket; mundra;
	ll t,i,j,n,m,l,k,r,sum,ans,mx,mn,x,y,z; cin>>t;
	ll a[t];
	for(i=0;i<t;i++) cin>>a[i];
	ans=0;
	for(j=1,i=0;i<t;i++)
	{
		if(a[i]!=j)
		{
			ans++;
		}
		else j++;
	}
	if(ans==t) cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

const MOD = 1e9 + 7

func main() {
	n, m := scanInt(), scanInt()
	b := make([]bool, n+1)
	for i := 0; i < m; i++ {
		a := scanInt()
		b[a] = true
	}

	dp := make([]int, n+1)
	dp[0] = 1
	if !b[1] {
		dp[1] = 1
	}

	for i := 2; i <= n; i++ {
		if b[i] {
			continue
		}
		dp[i] = (dp[i-2] + dp[i-1]) % MOD
	}
	fmt.Println(dp[n])

}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(){
    int n = 0;
    int x = 0;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.length(); ++i){
        if(s[i] == 'I'){
            ++x;
            ans = max(x, ans);
        }
        else{
            --x;
            ans = max(x,ans);
        }
    }
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")
#define  _CRT_SECURE_NO_WARNINGS

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}


#define int ll
void solve(){
	int n;
	cin >> n;
	map<string, int> cnt;
	REP(i, n) {
		string a;
		cin >> a;
		cnt[a]++;
	}
	vector<string> gogo;
	int now_itr = 0;
	for (auto x : cnt) {
		if (x.second > now_itr) {
			now_itr = x.second;
			gogo.clear();
		}
		if (x.second == now_itr) {
			gogo.push_back(x.first);
		}
	}
	REP(i, gogo.size()) {
		cout << gogo[i] << endl;
	}
}
#undef int
int main() {
	init();
	solve();
}

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

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  D(x)         cout << #x << " - " << x << endl;
  #define  D2(x)        cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
  #define  all(x)       (x).begin(), (x).end()
  #define  D2p(x)       cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;
  ll binpow(ll b,ll n){
  	 ll res = 1;
  	 while(n){
  	 	if(n%2){
  	 		res  = (res%MOD*b%MOD)%MOD;
  	 	}
  	 	b = (b%MOD*b%MOD)%MOD;
  	 	n/=2;
  	 }
  	 return res;
  }	
  ll cal(ll x,ll y){
  	 ll res = 1;
	 for(ll i =x;i>x-y;i--){
	 	res = (res%MOD*i%MOD)%MOD;
	 }  	
	 ll inv = 1;
	 for(ll i = 1;i <= y;i++){
	 	inv = (inv%MOD*i%MOD)%MOD;
	 }	
	 inv = binpow(inv,MOD-2);
	 return (res%MOD*inv%MOD)%MOD;
  }  	
  ll fact(ll x){
	ll res=1;
	for(int i=1;i<=x;i++){
		res = (res%MOD*i%MOD)%MOD;
	}
	return res;
  }
  void solve(){
	 int n,k;
	 cin >> n >> k;
	 ll ans=0;
	 for(ll i=1;i<=k;i++){
		ll sols = cal(k-1,i-1)%MOD;
		cout << ((sols%MOD*(cal(n-k+1,i))%MOD)%MOD) << '\n';
	 }   
	 
  }

  int main(){
    IOS
    solve();
    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,x=0,y=0,z=0;
    scanf("%d%d%d",&n,&a,&b);
    while(n--)
    {
        int t;
        scanf("%d",&t);
        if(t<=a) x++;
        else if(t<=b) y++;
        else z++;
    }
    printf("%d\n",min(min(x,y),z));
}


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

int main() {
    int n, k, d;
    cin >> n >> k;
    vector<int> check(n,0);
    vector<int> a;
    rep(i, k) {
        cin >> d;

        rep(j, d) {
            int tmp;
            cin >> tmp;
            a.push_back(tmp);
        }
    }
    rep(i, a.size()) { check[a[i] - 1] = 1; }
    cout << n - accumulate(check.begin(), check.end(), 0) << endl;
    return 0;
}

Measured memory_bytes: 3708
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	ll N; cin >> N;
	string ans;
	if (N == 0) {
		cout << 0 << endl;
		return 0;
	}
	while (N != 0) {
		if (N % 2 == 0) {
			ans.push_back('0');
		}
		else {
			ans.push_back('1');
		}
		if (N < 0) {
			N = (N - 1) / -2;
		}
		else {
			N /= -2;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int s,w;
	cin>>s>>w;
	if(w>=s) cout<<"unsafe\n";
	else cout<<"safe\n";
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

bool isPalindrome(int x){
  string s = to_string(x);
  int n=s.length();
  bool ret=true;
  repeat(i,(n+1)/2){
    ret &= s[i]==s[n-1-i];
  }
  return ret;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  int D,X;cin>>D>>X;
  vint A(N);
  repeat(i,N)cin>>A[i];
  ll ans = X;
  repeat(d,D){
    repeat(i,N){
      if(d%A[i]==0)ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(void) {
    string s;
    cin >> s;

    int cnt_g = 0;
    int cnt_p = 0;
    int point = 0;
    for(int i=0; i<s.size(); i++) {
        if(s[i] == 'p') {
            if(cnt_p == cnt_g) {
                cnt_g++;
                point--;
            } else {
                cnt_p++;
            }
        } else {
            if(cnt_p == cnt_g) {
                cnt_g++;
            } else {
                cnt_p++;
                point++;
            }
        }
    }

    cout << point << endl;
    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, d[55];
signed main() {
	cin >> n;
	rep(i, n)cin >> d[i];
	d[n] = 0;
	sort(d, d + n + 1);
	int a = 0, b = 0, ans = 24;
	REP(i, n) {
		if (i % 2) {
			ans = min(ans, d[i] - b);
			ans = min(ans, 24 - a - d[i]);
			b = d[i];
		}
		else {
			ans = min(ans, d[i] - a);
			ans = min(ans, 24 - b - d[i]);
			a = d[i];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int n , w , a[100][2] , dp[100][100001];
int f(int i , int v)
{
    int &d = dp[i][v];
    if( v == 0 ) return 0;
    if( i == n ) return 1e9+1;
    if( d != -1 ) return d;
    return d = min( f(i+1,v) , f(i+1,v-a[i][1]) + a[i][0] );
}
int main()
{
    memset(dp,-1,sizeof dp);
    cin >> n >> w;
    for(int i=0;i<n;++i)
        cin >> a[i][0] >> a[i][1];
    for(int i=1e5;i>=0;--i)
    {
        int wi = f(0,i);
        if( wi <= w )
        {
            cout << i; return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 39424
import java.util.Scanner;

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

		int A = sc.nextInt();
		int B = sc.nextInt();

		if (B % A == 0) {
			System.out.println(A + B);
		} else {
			System.out.println(B - A);
		}
	}
}

Measured memory_bytes: 23124
def main():
    _ = input()
    array = [int(x) for x in input().split()]
    print(" ".join(map(str, array)))

    for i in range(1, len(array)):
        moving = array[i]
        j = i - 1
        while j >= 0 and moving < array[j]:
            array[j+1] = array[j]
            j -= 1
        array[j+1] = moving
        print(" ".join(map(str, array)))
    return


main()


Measured memory_bytes: 5604
#include<map>
#include<queue>
#include<cmath>
#include<ctime>
#include<stack>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int P=1e9+7;
inline int read(){
	int ans=0,fh=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
		ans=ans*10+ch-'0',ch=getchar();
	return ans*fh;
}
const int maxn=1100;
int n,m,f[maxn][maxn];
char a[maxn][maxn];
int main(){
//	freopen(".in","r",stdin);
	n=read(),m=read();
	for(int i=1;i<=n;i++)
		scanf("%s",a[i]+1);
	f[1][1]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			if(a[i][j]=='#'||(i==1&&j==1)) continue;
			if(a[i][j-1]=='.') f[i][j]=f[i][j-1];
			if(a[i-1][j]=='.') (f[i][j]+=f[i-1][j])%=P;
		}
	printf("%d\n",f[n][m]);
	return 0;
}








Measured memory_bytes: 5504
#include <stdio.h>
#include <string.h>
#include <limits.h>


int HeapSize; 
void swap(int *a,int *b)
{
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}


void maxHeapify(int *A,int i)
{
  int l, r, largest;
  l= i*2;
  r = i*2+1;
  if(l <= HeapSize && A[l] > A[i])
    largest = l;
  else
    largest = i; 

  if(r <= HeapSize && A[r] > A[largest])
    largest = r;
  
  if(largest != i)
  {
    swap(&A[i],&A[largest]);
    maxHeapify(A,largest);
  }
}


int hExMax(int *A)
{
  int max;
  if(HeapSize < 1)
      return -1; 
  max = A[0];
  A[0] = A[HeapSize-1]; 
  HeapSize--;
  maxHeapify(A,0);
  return max;
}

void hIncKey(int *A,int i,int key)
{
  int j;
  if(key < A[i])
      return; 
    A[i] = key;
    if(i!=0 & 1)
        j = i/2; 
    else
        j = (i-1)/2;
  while(i > 0 && A[j] < A[i]){
    swap(&A[i],&A[j]);
    i = j;
    if(i!=0 & 1)
        j = i/2; 
    else
        j = (i-1)/2;
  }
}


void maxHInsert(int *A,int key)
{
  HeapSize++;
  A[HeapSize-1] =  INT_MIN;
  hIncKey(A,HeapSize-1,key);
}

int main(){
  int key;
  int A[2000000];
  char op[8];
  HeapSize = 0;
  int res=0;
  while(1)
  {
    scanf("%s", op);
    
    if(!strcmp(op,"insert"))
    {
      scanf("%d",&key);
      maxHInsert(A,key);
    }
    if(!strcmp(op,"extract"))
    {
        res = hExMax(A);
      printf("%d\n",res);
    }
    if(!strcmp(op,"end"))
    {
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 5688
#include <stdio.h>
#include<string.h>
 int main()
{
    int a,b,c,d,e,k;
    int s[10];
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
    s[0]=b-a;
    s[1]=c-a;
    s[2]=d-a;
    s[3]=e-a;
    s[4]=c-b;
    s[5]=d-b;
    s[6]=e-b;
    s[7]=d-c;
    s[8]=e-c;
    s[9]=e-d;
    int i;
    int flag=0;
    for(i=0;i<9;i++)
    {
        if(s[i]>k)
            flag=1;
    }
    if(flag==0)
        printf("Yay!");
    else
        printf(":(");
    return 0;
}


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

template <typename T> class SegmentTree{
	public :
		int n;
		SegmentTree(int size,T o): out_of_range(o){
			for(n=1;n<size;n<<=1);
			data=vector<T>(2*n,out_of_range);
			lazy=vector<bool>(2*n,false);
		}

		void update(int a,int b,T x,int k,int l,int r){
			if(r<=a || b<=l) return;
			if(a<=l&&r<=b){data[k]+=x,lazy[k]=true;return;}
			if(lazy[k]) lazy_evaluate(k);
			update(a,b,x,k*2+1,l,(l+r)/2);
			update(a,b,x,k*2+2,(l+r)/2,r);
			data[k]=data[k*2+1]+data[k*2+2];
		}

		T query(int a,int b,int k,int l,int r){
			if(r<=a||b<=l) return out_of_range;
			if(lazy[k]) return (r-l)*data[k];
			if(a<=l&&r<=b) return data[k];
			T vl = query(a,b,k*2+1,l,(l+r)/2);
			T vr = query(a,b,k*2+2,(l+r)/2,r);
			return vl+vr;
		}
	private:
		vector<T> data;
		vector<bool> lazy;
		const T out_of_range;

		inline void lazy_evaluate(int k){
			data[k*2+1]+=data[k];lazy[k*2+1]=true;
			data[k*2+2]+=data[k];lazy[k*2+2]=true;
			lazy[k]=false;
		}
};

int main(void){
	int N,Q;
	cin >>  N >> Q;
	SegmentTree<int> rsq(N,0);

	for(int i=0;i<Q;i++){
		int type;
		cin >> type;
		if(type){
			int s,t;
			cin >> s >> t;
			s--,t--;
			cout << rsq.query(s,t+1,0,0,rsq.n) << endl;
		}else{
			int a,x;
			cin >> a >> x;
			a--;
			rsq.update(a,a+1,x,0,0,rsq.n);
		}
	}
	return 0;
}

Measured memory_bytes: 2260
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const char wall = '#';
vector<vector<char>> fields;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

vector<vector<int>> friends;
vector<vector<int>> block;
vector<int> group;
vector<bool> used;
int groupCnt = 0;
map<int, int> mp;

void dfs(int s, int groupNum) {
  used[s] = true;
  group[s] = groupNum;
  mp[groupNum]++;
  for(int next: friends[s]) {
    if (!used[next])dfs(next, groupNum);
  }
}

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

  ll n, m, k;
  cin >> n >> m >> k;
  friends.resize(n);
  block.resize(n);
  used.resize(n, false);
  group.resize(n, -1);

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    friends[a].push_back(b);
    friends[b].push_back(a);
  }

  rep(i, k) {
    int c, d;
    cin >> c >> d;
    c--;
    d--;
    block[c].push_back(d);
    block[d].push_back(c);
  }

  rep(i, n) {
    if(!used[i]) {
      dfs(i, groupCnt++);
    }
  }
  
  vector<int> ans(n);
  rep(i, n) {
    ans[i] = mp[group[i]] - friends[i].size() - 1; //連結成分の個数 - すでに友達 - 自分
    for(int b: block[i]) {
      if (group[i] == group[b]) {
        ans[i]--;
      }
    }
  }
  rep(i,n) {
    printf("%d%c", ans[i], (i == n-1)?'\n':' ');
  }
  return 0;
}


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

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

    int A, B;
    cin >> A >> B;

    if(A == B) cout << "Draw" << endl;
    else if(A == 1) cout << "Alice" << endl;
    else if(B == 1) cout << "Bob" << endl;
    else cout << ((A > B) ? "Alice": "Bob") << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int N,W; cin>>N>>W;
  vector<ll> w0,w1,w2,w3;
  ll base;
  for(int i=0;i<N;i++){
    ll wei,val; cin>>wei>>val;
    if(i==0){
      base=wei;
      w0.push_back(val);
    }else{
      if(base==wei){
        w0.push_back(val);
      }else if(base+1==wei){
        w1.push_back(val);
      }else if(base+2==wei){
        w2.push_back(val);
      }else{
        w3.push_back(val);
      }
    }
  }
  sort(w0.rbegin(),w0.rend());
  sort(w1.rbegin(),w1.rend());
  sort(w2.rbegin(),w2.rend());
  sort(w3.rbegin(),w3.rend());
  vector<ll> sum0(w0.size()+1,0),sum1(w1.size()+1,0),sum2(w2.size()+1,0),sum3(w3.size()+1,0);
  for(int i=1;i<=w0.size();i++){
    sum0[i]=sum0[i-1]+w0[i-1];
  }
  for(int i=1;i<=w1.size();i++){
    sum1[i]=sum1[i-1]+w1[i-1];
  }
  for(int i=1;i<=w2.size();i++){
    sum2[i]=sum2[i-1]+w2[i-1];
  }
  for(int i=1;i<=w3.size();i++){
    sum3[i]=sum3[i-1]+w3[i-1];
  }
  ll sum,ans=0;
  for(int i=0;i<sum0.size();i++){
    if(W<i*base) break;
    for(int j=0;j<sum1.size();j++){
      if(W<i*base+(base+1)*j) break;
      for(int k=0;k<sum2.size();k++){
        if(W<i*base+(base+1)*j+(base+2)*k) break;
        for(int l=0;l<sum3.size();l++){
          if(W<i*base+(base+1)*j+(base+2)*k+(base+3)*l) break;
          sum=sum0[i]+sum1[j]+sum2[k]+sum3[l];
          if(sum>ans) ans=sum;
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

class UF():
    def __init__(self, num):
        self.par = [-1]*num
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            stack = []
            while self.par[x] >= 0:
                stack.append(x)
                x = self.par[x]
            for xi in stack:
                self.par[xi] = x
            return x
    
    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx != ry:
            if self.par[rx] > self.par[ry]:
                rx, ry = ry, rx
            self.par[rx] += self.par[ry]
            self.par[ry] = rx
        return rx

N, Q = map(int, readline().split())
 
T = UF(N)

Ans = []
for _ in range(Q):
    t, a, b = map(int, readline().split())
    if t == 0:
        T.union(a, b)
    else:
        Ans.append(int(T.find(a) == T.find(b)))
 
print('\n'.join(map(str, Ans)))

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

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

    int n;
    int a[100];

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

    for (int i = n - 1; i >= 0; i--) {
        cout << a[i];
        if (i == 0)
            cout << endl;
        else
            cout << " ";
    }
}


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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 2e16;
const int MB = 20;
const int MOD = 2019;

void solve() {
	int x;
	cin >> x;
	map<int, int> used = { {0, 0} };
	for (int i = 1;; i++) {
		int y = i * i * i * i * i;
		if (x - y <= y && used.count(abs(x - y))) {
			cout << i << " " << used[abs(x - y)] * (x - y < 0 ? 1 : -1);
			return;
		}
		used[y] = i;
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	//srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

Measured memory_bytes: 3612
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            if(s == "abc" || s == "acb" ||s == "bac" ||s == "bca" ||s == "cab" ||s == "cba" )
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder soto=new StringBuilder("");
		StringBuilder naka=new StringBuilder("");
		int H=sc.nextInt(),W=sc.nextInt();
	while(H!=0||W!=0){
			soto.append("##");
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");
			soto.append("#");}
		naka.append("#");
		System.out.println(soto);
		for(int n=1;n<=H-2;n++){
			System.out.println(naka);}
		System.out.println(soto);
		System.out.println();
		soto.delete(0,W);naka.delete(0,W);
		H=sc.nextInt();W=sc.nextInt();
			}
	}}

Measured memory_bytes: 20980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    ll res = 0;
    REPS(i,n) res += i * (n+1-i);
    REP(i,n-1){
        ll u, v; cin >> u >> v; u--; v--;
        if(u > v) swap(u, v);
        res -= (u + 1) * (n - v);
    }
    cout << res << endl;
}

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


def solve(N: int, K: int, x: "List[int]"):
    res = 0
    for x_ in x:
        res += 2*min(x_, abs(K-x_))
    print(res)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9024
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int M = sc.nextInt();
	int X = sc.nextInt();
	int Y = sc.nextInt();
	int[] x = new int[N+1];
	int[] y = new int[M+1];
	x[0] = X;
	y[0] = Y;
	for(int i = 1; i<N+1; i++) {
	    x[i] = sc.nextInt();
	}
	for(int i = 1; i<M+1; i++) {
	    y[i] = sc.nextInt();
	}
	Arrays.sort(x);
	Arrays.sort(y);
	if(x[N]<y[0]) {
	    System.out.println("No War");
	}else {
	    System.out.println("War");
	}
    }
}

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

int main(void)
{
	int i;
	int j;
	int n;
	char a[15];
	char b[15];
	scanf("%s",a);
	n=strlen(a)+1;
	for(j = 0, i = 0; i < n; i++){
		b[j] = a[i];
		if(a[i] == 'B'){
			if(j > 0){
				j--;
			}else{}
		}else{
			j++;
		}
	}
	printf("%s",b);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10, mod = 1e9 + 7;

int add (int a, int b) {
    return ((a += b) >= mod) ? a - mod : a;
}

int mul (int a, int b) {
    return 1LL * a * b % mod;
}

void minun (int &a, int b) {
    if ((a -= b) < 0) a += mod;
}

int power (int a,  long long b) {
    int res = 1;
    for (; b > 0 ; b >>= 1 , a = mul(a, a))
        if (b & 1) res = mul(res, a);
    return res;
}

int n, k ;

int f[nax];

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

    int ans = 0;

    for (int i = k ; i >= 1 ; -- i) {

        int can_div = k / i;
        f[i] = power(can_div, n);

        for (int j = i + i ; j <= k ; j += i) {
            minun(f[i], f[j]);
        }

        ans = add(ans, mul(f[i], i));
    }

    printf("%d\n", ans);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 4180
#include <bits/stdc++.h>
#include <stdio.h>
#include <execinfo.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>

using namespace std;

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

template<typename _T, typename _UPDATER=std::plus<_T>, _T _UNIT=0>
struct SegTree{
    SegTree(ll n) {
        _leafs = 1;
        while( _leafs < n ) _leafs *=2;
        _nodes.resize(2*_leafs-1, _UNIT);
    }

    SegTree(const vector<_T>& data) {
        _leafs = 1;
        while( _leafs < data.size()) _leafs*=2;
        _nodes.resize(2*_leafs-1);
        for(ll i = 0; i < data.size(); i++){
            _nodes[LeafIndex(i)] = data[i];
        }
        for(ll i = _leafs-2; i >= 0; i-- ){
            _nodes[i] = _updater( _nodes[Left(i)], _nodes[Right(i)]);
        }
    }

    void update(ll i, const _T& v){
        ll n = LeafIndex(i);
        _nodes[n] = v;
        while(true){
            n = Parent(n);
            _nodes[n] = _updater( _nodes[Left(n)], _nodes[Right(n)] );
            if( n == 0 ) break;
        }
    }

    // query [b,e) at node n. n's range is [l,r)
    _T query(ll b, ll e, ll i, ll l, ll r){
        if( r <= b || e <= l ){
            return _UNIT;
        }
        if( b <= l && r <= e ){
            return _nodes[i];
        }

        ll m = (l+r)/2;
        // left [l,m), right [m,r)
        return _updater(query(b, e, Left(i), l, m), query(b, e, Right(i), m, r) );
    }

    _T query(ll b, ll e){
        return query(b, e, 0, 0, _leafs);
    }

    _T operator[] (ll i){
        return _nodes[LeafIndex(i)];
    }

    ll LeafIndex(ll i){ return i+_leafs-1; }
    ll Parent(ll i){ return (i-1)/2; }
    ll Left(ll i){ return 2*i+1; }
    ll Right(ll i){ return 2*i+2; }

    vector<_T> _nodes;
    ll _leafs; // Always power of 2
    _UPDATER _updater;

    void dump(){
        for(int i = 0 ; i < _nodes.size(); i++ )
        {
            cout << _nodes[i] << ",";
        }
        cout << endl;
    }
};

int main(){
    std::cout<<std::fixed<<std::setprecision(10);
    ll N;
    string S;

    cin >> N >> S;

    vector<vector<ll>> counts(26, vector<ll>(N));
    REP(i, N){
        char c;
        counts[S[i]-'a'][i]++;
    }

    vector<SegTree<ll>> segs;
    REP(i, 26){
        segs.emplace_back(counts[i]);
        //cout << char('a'+i) << endl;
        //segs[i].dump();
    }

    ll Q;
    cin >> Q;

    REP(i, Q){
        ll q;
        cin >> q;
        if( q == 1 ){
            ll iq;
            char cq;
            cin >> iq >> cq;
            segs[S[iq-1]-'a'].update(iq-1, 0);
            segs[cq-'a'].update(iq-1, 1);
            S[iq-1] = cq;
        }else {
            ll lq, rq;
            cin >> lq >> rq;
            ll count = 0;
            REP(i, 26){
                // cout << char('a'+i) << endl;
                // segs[i].dump();
                if( segs[i].query(lq-1, rq) != 0) count++;
            }
            cout << count << endl;
        }
    }

}


Measured memory_bytes: 315584
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

using namespace std;
const int MX=100011;
int n;
struct Edge{int t,nxt;Edge(int _t=0,int _nxt=0):t(_t),nxt(_nxt){}}e[MX<<1];
int hed[MX],ec;
inline void ade(int f,int t){e[++ec]=Edge(t,hed[f]);hed[f]=ec;}
#define FE(k,i) for(int (i)=hed[k];(i);(i)=e[i].nxt)if(e[i].t!=f)
int SG(int k,int f){
	int sum=0;
	FE(k,i)sum^=SG(e[i].t,k)+1;
	return sum;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		static int a,b;scanf("%d%d",&a,&b);
		ade(a,b),ade(b,a);
	}
	puts(SG(1,0)?"Alice":"Bob");
	return 0;
}


Measured memory_bytes: 6784
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split()))
    C = Counter(A)
    S = sum(A)
    Q = int(input())
    for _ in range(Q):
        b, c = map(int, input().split())
        if C[b] > 0:
            cb = C[b]
            S -= b*cb
            S += c*cb
            C[b] = 0
            C[c] += cb
        print(S)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21396
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    string S;
    cin >> S;
    if (S[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    int c = 0;
    int N = S.size();
    for (int i = 2; i < N - 1; i++) {
        if (S[i] == 'C') {
            c++;
        }
    }
    if (c != 1) {
        cout << "WA" << endl;
        return 0;
    }
    for (int i = 2; i < N - 1; i++) {
        if (isupper(S[i]) && S[i] != 'C') {
            cout << "WA" << endl;
            return 0;
        }
    }
    if (isupper(S[1]) || isupper(S[N - 1])) {
        cout << "WA" << endl;
        return 0;
    }
    cout << "AC" << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    int q = sqrt(n);
    ll mini = n - 1;
    for (int i = 1; i <= q + 1; ++i)
        if (n % i == 0)
            mini = min(mini, i + n / i - 2);
    cout << mini << '\n';
    return 0;
}

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

int main(){
	int n,a[100000],ans = 0;
	map<int,int> mp;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		mp[a[i]] = i;
	}
	sort(a,a + n);
	for(int i = 0;i < n;i += 2){
		if(mp[a[i]] % 2) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    string s;
    cin >> s;
    s.replace(5, 1, " ");
    s.replace(13, 1, " ");
    cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int n, x, m[100];
    cin >> n >> x;
    for (int i = 0; i < n; i++) cin >> m[i];
    sort(m, m + n);
    int sum = 0;
    for (int i = 0; i < n; i++) sum += m[i];
    cout << n + (x - sum) / m[0] << endl;
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 100000 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

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

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

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> half(n);
    vector<ll> counts;
    rep(i, n) {
        half[i] = a[i] / 2;
        ll cnt_2 = 0;
        ll b = half[i];
        while (b % 2 == 0) {
            cnt_2++;
            b /= 2;
        }
        counts.push_back(cnt_2);
    }
    bool consistency = true;
    repeat(i, 1, n) {
        if (counts[i - 1] != counts[i]) consistency = false;
    }
    ll div = 1;
    rep(i, n) div = lcm(div, half[i]);
    if (div > m || !consistency) {
        out(0);
        return 0;
    }
    ll ans = m / (div * 2);
    if (ans != (m + div) / (div * 2)) ans++;
    out(ans);
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
typedef long double ld;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 3;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) exp(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
ll prime[100002];
ll exp(ll a,ll b);
void sieve(ll n);
ll gcd(ll a ,ll b);
ll countdigit(ll n);

ll mul(ll a,ll b)
{
    return ((a%mod)*(b%mod))%mod;
}
vector<ll>g[100005];
ll vis[100005]={0};
ll c=0;
void dfs(ll current) {
    vis[current]=1;
    ll z=g[current].size();
    for(ll i=0;i<z;i++) {
        ll child = g[current][i];
        if(vis[child]==0){
            dfs(child);
        }
    }
}

int main(){
    flash;
    ll t=1;
    //cin >> t;
    while(t--) {
        ll n,e;
        cin >> n >> e;
        rep(i,0,e) {
            ll a,b;
            cin >> a >> b;
            g[a].pb(b);
            g[b].pb(a);
        }
        for(ll i=1;i<=n;i++){
            if(vis[i]==0){
                c++;
                dfs(i);
            }
        }
        //cout<<c<<" ";
        c=c-1;
        cout<<c<<endl;
        
    }
}


//
//
//
//
//
// IMPORTANT FUNCTIONS
ll exp(ll a, ll b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
void sieve(ll n) {
    for(ll i=0;i<=n;i++) {
        prime[i]=1;
    }
    prime[0]=0;prime[1]=0;
    for(ll i=2;i<=n;i++) {
        if(prime[i]==1) {
            for(ll j=2;i*j<=n;j++) {
                prime[i*j]=0;
            }
        }
    }
}
ll countdigit(ll  n)
{
    return floor(log10(n) + 1);
}


Measured memory_bytes: 11460
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int count = 0;
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == 'x') {
				count++;
			}
		}
		System.out.println(count <= 7 ? "YES" : "NO");
	}
}


Measured memory_bytes: 22864
import numpy as np
n=int(input())
a=list(map(int,input().split()))
ans=1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans=ans*a[i]
    if ans>10**18 and not 0 in a:
      print(-1)
      exit()
if ans>10**18:
    anscheck=False
else:
    anscheck=True
print(ans if anscheck else -1)

Measured memory_bytes: 40052
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int mx = 0;
    int sum = 0;
    REP(i,n){
        int p;
        cin >> p;
        sum+=p;
        mx = max(mx,p);
    }
    cout << sum-mx+(mx/2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#include <functional>

using namespace std;
using lint = long long;

const int INF = 1 << 30;

struct SegmentTree {
    int N;
    vector<int> data;

    SegmentTree(int N) : N(N), data(N * 2, INF) {}

    int query(int l, int r) {
        l += N, r += N;
        int ret = INF;
        while (l < r) {
            if (l & 1) {
                ret = min(ret, data[l]);
                ++l;
            }
            if (r & 1) {
                ret = min(ret, data[r - 1]);
                --r;
            }
            l >>= 1;
            r >>= 1;
        }
        return ret;
    }

    void update(int i, int v) {
        i += N;
        data[i] = v;
        i >>= 1;
        while (i > 0) {
            data[i] = min(data[i * 2], data[i * 2 + 1]);
            i >>= 1;
        }
    }
};

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

    vector<vector<int>> ch(N);
    for (int v = 1; v < N; ++v) {
        int p;
        cin >> p;
        ch[--p].push_back(v);
    }

    vector<int> depth(N), tour;
    function<void(int, int)> dfs = [&](int v, int d) {
        depth[v] = d;
        tour.push_back(v);
        for (int sv : ch[v]) {
            dfs(sv, d + 1);
            tour.push_back(v);
        }
    };
    dfs(0, 0);

    int M = tour.size();

    vector<int> first(N, -1);
    for (int i = 0; i < tour.size(); ++i) {
        if (first[tour[i]] < 0) {
            first[tour[i]] = i;
        }
    }

    SegmentTree seg(M);
    for (int i = 0; i < tour.size(); ++i) {
        seg.update(i, depth[tour[i]]);
    }

    int prev = -1;
    queue<int> que;
    que.push(0);

    lint ans = 0;
    while (!que.empty()) {
        int v = que.front();
        que.pop();

        if (prev >= 0) {
            int l = min(first[prev], first[v]);
            int r = max(first[prev], first[v]);

            ans += depth[prev] + depth[v] -
                   seg.query(l, r + 1) * 2;
        }
        prev = v;
        for (auto sv : ch[v]) que.push(sv);
    }

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



Measured memory_bytes: 17500
class Main {
    public static void main(String args[]) {
        java.util.Scanner sc = new java.util.Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] A = new int[n + 1];
        for (int i = 1; i < n + 1; i++)
            A[i] = Integer.parseInt(sc.next());

        for (int i = A.length / 2; i > 0; i--) {
            maxHeapify(A, i);
        }

        for (int i = 1; i < A.length; i++) {
            System.out.print(" " + A[i]);
        }
        System.out.println();
        sc.close();
    }

    static private void maxHeapify(int[] A, int i) {
        int leftIndex = i * 2;
        int rightIndex = leftIndex + 1;

        // int largerIndex;
        // if(leftIndex >= A.length) largerIndex = ri
        // if(leftIndex >= A.length && rightIndex >= A.length){
        // return;
        // }

        int largerIndex = i;
        if (leftIndex < A.length && A[leftIndex] > A[i])
            largerIndex = leftIndex;
        if (rightIndex < A.length && A[rightIndex] > A[largerIndex])
            largerIndex = rightIndex;

        if (largerIndex != i) {
            swap(A, largerIndex, i);
            maxHeapify(A, largerIndex);
        }
    }

    static void swap(int[] A, int i, int j) {
        int tmp = A[i];
        A[i] = A[j];
        A[j] = tmp;
    }
}


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

#define ll long long int
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR1(i, m, n) for(int i=m; i<n; i++)
#define FOR2(i, n, m) for(int i=n-1; i>=m; i--)

using namespace std;

int main(int argc, char const *argv[])
{
	FASTIO;
	int t;
	cin >> t;
	int q = t / 2;
	int r = t % 2;
	cout << q+r << "\n";
	return 0;
}

Measured memory_bytes: 256