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

public class Main {


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int l = sc.nextInt();

        Integer taste[] = new Integer[n];
        for (int i=0; i<n; i++){
            taste[i] = l+i;
        }

        int origin=0;
        for (int i=0; i<n; i++){
            origin += taste[i];
        }

        if (Arrays.asList(taste).contains(0)){
            System.out.println(origin);
        }else if (0<taste[0]){
            System.out.println(origin-taste[0]);
        }else{
            System.out.println(origin-taste[n-1]);
        }

    }
}



Measured memory_bytes: 21076
# https://atcoder.jp/contests/abc133/tasks/abc133_b

n, d = map(int, input().split())

matrix = []
for _ in range(n):
    row = [int(i) for i in input().split()]
    matrix.append(row)

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        s = matrix[i]
        t = matrix[j]
        dist = 0
        for k in range(d):
            dist += (s[k] - t[k]) ** 2
        
        temp = 1
        while temp ** 2 <= dist:
            if temp ** 2 == dist:
                ans += 1
                break
            else:
                temp += 1
print(ans)

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

int main()
{
    long int a,b;
    cin>>a>>b;
    if(a+b==15)
    {
        cout<<"+"<<endl;
    }
    else if(a*b==15)
    {
        cout<<"*"<<endl;
    }
    else
    {
        cout<<"x"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};

int main(void){
	int l,r,d,tot=0;
	scanf("%d%d%d",&l,&r,&d);
	for(int e=l;e<=r;e++) if(e%d==0) tot++;
	printf("%d",tot);
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> dp(n + 1);
	dp[0] = dp[1] = 1;
	for (int i = 1; i < n; i++) {
		dp[i + 1] = dp[i] + dp[i - 1];
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3100
n=int(input())
cnt=[0]*(n+1)
s=set([2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,91,97])
for k in range(1,n+1):
  for i in range(2,k+1):
    if k%i==0 and i in s:
      m=k
      while m%i==0:
        cnt[i]+=1
        m//=i
cnt2,cnt4,cnt14,cnt24,cnt74=0,0,0,0,0
for i in range(2,n+1):
  if cnt[i]>=2:
    cnt2+=1
  if cnt[i]>=4:
    cnt4+=1
  if cnt[i]>=14:
    cnt14+=1
  if cnt[i]>=24:
    cnt24+=1
  if cnt[i]>=74:
    cnt74+=1
ans=cnt74+cnt14*(cnt4-1)+cnt24*(cnt2-1)+(cnt2-2)*cnt4*(cnt4-1)//2
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = ll(1e18)+5;

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

    return 0;
}

Measured memory_bytes: 3960
let () =
    let main () =
        let n = int_of_string (read_line ()) in
        let xl = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun x l -> x + l, x - l)) in
        Array.sort compare xl;
        let _, m = Array.fold_left (fun (left, m) (r, l) ->
            if l >= left then (r, m + 1) else (left, m)) (-1_000_000_001, 0) xl
        in
        Printf.printf "%d\n" m
    in
    main ()

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=k;i<(ll)(n);i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
const ll inf=1001001001001001;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
vi node,lazy;
ll N=1;
void init(vi v){
    while(N<v.size())N*=2;
    node=vi(N*2-1,inf);
    lazy=vi(N*2-1,-inf);
    rep(i,v.size())node[i+N-1]=v[i];
    for(ll i=N-2;i>=0;i--)node[i]=min(node[i*2+2],node[i*2+2]);
}
void eval(ll i,ll l,ll r){
    if(lazy[i]==-inf)return;
    node[i]=lazy[i];
    if(r-l>1){
        lazy[i*2+1]=lazy[i];
        lazy[i*2+2]=lazy[i];
    }
    lazy[i]=-inf;
}
void update(ll a,ll b,ll k,ll l,ll r,ll x){
    eval(k,l,r);
    if(b<=l||r<=a)return;
    if(a<=l&&r<=b){
        lazy[k]=x;
        eval(k,l,r);
    }
    else{
        update(a,b,k*2+1,l,(l+r)/2,x);
        update(a,b,k*2+2,(l+r)/2,r,x);
        node[k]=min(node[k*2+1],node[k*2+2]);
        eval(k,l,r);
    }
}
ll getmi(ll a,ll b,ll k,ll l,ll r){
    eval(k,l,r);
    if(b<=l||r<=a)return inf;
    if(a<=l&&r<=b)return node[k];
    ll c1=getmi(a,b,2*k+1,l,(l+r)/2);
    ll c2=getmi(a,b,2*k+2,(l+r)/2,r);
    return min(c1,c2);
}
int main(){
    ll n,q;cin>>n>>q;
    vi v(n,(1ll<<31)-1);
    init(v);
    rep(i,q){
        ll c;cin>>c;
        if(c){
            ll a,b;cin>>a>>b;
            cout<<getmi(a,b+1,0,0,N)<<endl;
        }
        else{
            ll a,b,d;cin>>a>>b>>d;
            update(a,b+1,0,0,N,d);
            //rep(i,n)cout<<node[i+N-1]<<' ';
            //cout<<endl;
        }
    }
}


Measured memory_bytes: 8416
use std::io;
use std::cmp;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}


fn main() {
    let n = read_line();
    let bs = n.as_bytes();
    for mask in 0..(1 << 4) {
        let mut s = (bs[0] - ('0' as u8)) as i32;
        for i in 1..4 {
            if ((mask >> i) & 1) == 1 {
                s += (bs[i] - ('0' as u8)) as i32;
            }
            else{
                s -= (bs[i] - ('0' as u8)) as i32;
            }
        }
        if s == 7 {
            print!("{}", (bs[0] - ('0' as u8)) as i32);
            for i in 1..4 {
                if ((mask >> i) & 1) == 1 {
                    print!("+");
                }
                else{
                    print!("-");
                }
                print!("{}", (bs[i] - ('0' as u8)) as i32);
            }
            println!("=7");
            return;
        }
    }

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define AC ios::sync_with_stdio(0),cin.tie(0);
#define ll long long int
int main(){
	AC
	string a,b;
	cin>>a>>b;
	int ans=100000;
	for(int i=b.size()-1;i<a.size();i++){
		int j=i;
		int k=b.size()-1;
		int countt=0;
		if(a[j]!=b[k])countt++;
		while(k-- && j--){
			if(a[j]!=b[k])countt++;
		}
		ans=min(countt,ans);
	} 
	cout<<ans<<endl;
} 


Measured memory_bytes: 3636
#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 INF 999999999
typedef long long ll;
using namespace std;
int main() {
    char X, Y;
    cin >> X >> Y;
    if(X<Y) {
        puts("<");
    }else if(X == Y) {
        puts("=");
    }else {
        puts(">");
    }
}

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

void solve(long long N, long long M) {
  cout << ((N * (N - 1)) / 2) + ((M * (M - 1)) / 2) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  solve(N, M);
  return 0;
}


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

typedef long long ll;
#define PI 2 * acos (0.0)

ll MOD = 1e9 + 7 ;

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

  if(a + b + c >= 22) cout << "bust" << endl ;
  else  cout << "win" << endl ;
}


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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N,C,K;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> C >> K;
    vi v;
    F0R(i,N) {
        int t; cin >> t;
        v.pb(t);
    }
    sort(all(v));
    int ans = 0, cnum = 0, cti;
    F0R(i,sz(v)) {
        if (cnum == 0) {
            cti = v[i];
            cnum = 1;
        } else if (cnum < C && cti+K >= v[i]) {
            cnum ++;
        } else {
            ans ++;
            cti = v[i];
            cnum = 1;
        }
    }
    if (cnum) ans ++;
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 892
import sys

x = int(input())
b_p = 0
b_m = 0

def div(n):
    divs = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divs.append(i)
            if i != n // i:
                divs.append(n//i)
    divs
    divs += list(map(lambda x: x*(-1), divs))
    return divs

divs = div(x)
while True:  
    for i in divs:
        a_p = i + b_p
        a_m = i + b_m
        if a_p ** 5 == x + b_p ** 5:
            print(a_p, b_p)
            sys.exit()
        if a_m ** 5 == x + b_m ** 5:
            print(a_m, b_m)
            sys.exit()
    b_p += 1
    b_m -= 1

Measured memory_bytes: 9488
#include <stdio.h>

int main(void)
{

	int i,k,flag,data,num[4000]={0};
	long long int tanka[4000],uriage[4000],total[4000];
	
	while(scanf("%d",&data),data){
		
		for(i=0;i<data;i++){
			scanf("%d %lld %lld",&num[i],&tanka[i],&uriage[i]);
			total[i]=tanka[i]*uriage[i];
			for(k=0;k<i;k++){
				if(num[i]==num[k]){
					total[k]=total[i]+total[k];
					total[i]=0;
				}
			}
		}
			
		flag=0;
		
		for(i=0;i<data;i++){
			if(total[i]>=1000000){
				printf("%d\n",num[i]);
				flag=1;
			}
		}
		if(flag==0){
			printf("NA\n");
		}
		
	}

	return 0;

}

Measured memory_bytes: 668
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;

string S;

int main() {
	cin >> S;

	const string goal = "keyence";
	int i_stop;
	for (int i = 0; i < goal.size(); i++)
	{
		if (S[i] != goal[i]) {
			i_stop = i;
			break;
		}
		else if (i == goal.size() - 1) {
			i_stop = goal.size();
		}
	}
	bool is_okay = true;
	for (int i = 0; i < goal.size() - i_stop; i++)
	{
		if (S[S.size() - 1 - i] != goal[goal.size() - 1 - i]) {
			is_okay = false;
			break;
		}
	}

	string ans;
	if (is_okay) {
		ans = "YES";
	}
	else {
		ans = "NO";
	}
	cout << ans << endl;
}


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

int N;
int L[105];
int ans;

signed main(){
    cin>>N;
    for(int i=0;i<N;++i)cin>>L[i];
    sort(L,L+N);
    for(int i=0;i<N-2;++i){
        for(int j=i+1;j<N-1;++j){
            for(int k=j+1;k<N;++k){
                if(L[i]+L[j]>L[k]&&L[i]!=L[j]&&L[j]!=L[k]&&L[k]!=L[i]){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
int main(){
	long N,X,Z[51],i;cin>>N>>X;Z[0]=1;
	for(i=1;i<=N;i++)Z[i]=Z[i-1]*2+3;
	long ans=0,l=1,h=Z[N],m=(h+l)/2;
	while(1){
		if(m<=X){l=m,ans+=(h-l)/2+1;}
		else h=m;
		l++,h--;
		if(l>h) break;
		m=(h+l)/2;
    }
	cout<<ans;
}

Measured memory_bytes: 256
N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
  sum = 0
  P, X = map(int, input().split())
  for j in range(N):
    if j == P-1:
      sum += X
    else:
      sum += T[j]
      
  print(sum)

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

int main() {
  int N;
  cin >> N;
  
  bool flag = false;
  
  int maxC = N / 4 + 1;
  int maxD = N / 7 + 1;
  
  for (int c = 0; c < maxC; c++) {
    for (int d = 0; d < maxD; d++) {
      if ((4 * c + 7 * d) == N) {
        flag = true;
      }
    }
  }
  
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i != j) sum += vec[i] * vec[j];
    }
  }
  sum /= 2;
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,i;
	ll m,a,t,ans=0ll;
	vector<ll> v;
	cin >> n >> m;
	v.push_back(0ll);
	for(i=0; i<n; ++i){
		cin >> a;
		v.push_back(a+v[i]);
	}
	for(i=n; i>0; --i){
		v[i] %= m;
	}
	sort(v.begin(),v.end());
	v.push_back(m);
	for(i=0; i<=n; ++i){
		t = (ll)(upper_bound(v.begin(),v.end(),v[i])-lower_bound(v.begin(),v.end(),v[i]));
		ans += (t-1);
	}
	cout << ans/2 << endl;
	return 0;
}


Measured memory_bytes: 1400
function main(arg) {
	arg = arg.split("\n")[0].split(" ").map(Number)
	if (arg[0] == arg[1] && arg[0] == arg[2]) {
		console.log("Yes")
	} else {
		console.log("No")
	}
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22076
x = list(map(int, input().split()))
ans = 0
if x[0] == 0:
  ans = 1
elif x[1] == 0:
  ans = 2
elif x[2] == 0:
  ans = 3
elif x[3] == 0:
  ans = 4
elif x[4] == 0:
  ans = 5
print(ans)

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
const int mxN=2e5;
int n, a[mxN];
ll c[mxN], ans;
 
int main() {
//	ios::sync_with_stdio(0);
//	cin.tie(0);
 
	cin >> n;
	for(int i=0; i<n; ++i) {
		cin >> a[i], --a[i];
		++c[a[i]];
	}
	for(int i=0; i<n; ++i)
		ans+=c[i]*(c[i]-1)/2;
	for(int i=0; i<n; ++i) {
		ans-=c[a[i]]*(c[a[i]]-1)/2;
		--c[a[i]]*(c[a[i]]-1)/2;
		ans+=c[a[i]]*(c[a[i]]-1)/2;
		cout << ans << "\n";
		ans-=c[a[i]]*(c[a[i]]-1)/2;
		++c[a[i]]*(c[a[i]]-1)/2;
		ans+=c[a[i]]*(c[a[i]]-1)/2;
	}
}

Measured memory_bytes: 3968
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	for (int b = k+1; b <= n; b++){
		int num = n / b;
		if (k == 0) ans += (b - k)*num - 1;
		else ans += (b - k)*num;
		ans += max(0, n - (b*num+k)+1);
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
  int n; cin >> n;
  int d[n];
  int D[n];
  for(int i = 0; i < n; i++){
    cin >> d[i];
    D[i] = d[i];
  }
  int sum = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i!=j){
        sum += d[i]*D[j];
      }
    }
  }
  if(sum%2==0) cout << sum/2 << endl;
  else cout << sum/2+1 << endl;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define pi pair<int,int>
#define PQ priority_queue<double, vector<double>, greater<double> >q
#define _sort(v) sort(v.begin(),v.end())
#define MP map<ll int,ll int>mp
#define MEM(x) memset(x,0,sizeof(x))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vec() vector<ll int>v1,v2
#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
//Upper_bound   auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; if(x==v[a].end())break;
//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//ll mod_inverse(ll a, ll mod){return bigmod(a,mod-2,mod);}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{
    ll int n,m,res=0,cnt=0,x,y;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>x>>y;
        if(x==y)
            cnt++;
        else
            cnt=0;
        if(cnt>2)
            res=1;
    }
    if(res)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,dep[maxn],rt;
vector<int > e[maxn];

void dfs(int x,int fa) {
    dep[x]=dep[fa]+1;
    if(dep[x]>dep[rt]) rt=x;
    for(auto v:e[x]) if(v!=fa) dfs(v,x);
}

int main() {
    read(n);
    for(int i=1,x,y;i<n;i++) read(x),read(y),e[x].pb(y),e[y].pb(x);
    dep[0]=-1,dfs(1,0),dfs(rt,0);
    puts(dep[rt]%3==1?"Second":"First");
    return 0;
}


Measured memory_bytes: 40448
#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;
    cin >> n;
    int a[n+1];
    rep(i,n) cin >> a[i+1];
    int box[n+1] = {};
    vector<int> ans;
    for (int i = n; i > 0; i--) {
        int su = 0;
        for (int j = i; j <= n; j+=i) su += box[j];
        if (su % 2 != a[i]) {
            box[i] = 1;
            ans.push_back(i);
        }
    }
    cout << ans.size() << endl;
    if (ans.size() > 0) {
        rep(i,ans.size()) {
            cout << ans[i];
            if (i < ans.size()-1) cout << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 3064
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll s[100001],n,m,a,t[100001],mod;
ll f(ll x){
    if(x==0)return 1;
    else if(t[x-1]!=-1){
        if(x>1&&t[x-2]!=-1){
            return (f(x-1)+f(x-2)+2)%mod;
        }
        else {
            return (f(x-1)+1)%mod;
        }
    }
    else if(x>1) return (f(x-2)+1)%mod;
    else return 1;
}
int main(void){
    mod=1e9+7;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>s[i];
        t[s[i]]=-1;
        if(i>0){
            if(s[i]-s[i-1]<=1){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    t[0]=1;
    //cout<<t[3]<<endl;
    for(int i=1;i<=n;i++){
        if(t[i]==-1)continue;
        else{
            if(i==1)t[1]=t[0];
            else{
                t[i]+=max(0LL,t[i-1])+max(0LL,t[i-2]);
                t[i]%=mod;            }
        }
        
    }
    cout<<t[n]<<endl;
}


Measured memory_bytes: 1408
import sys
input=sys.stdin.readline

D=int(input().rstrip('\n'))
cs=[int(x) for x in input().rstrip('\n').split()]
S={}
for i in range(D):
  S[i] = [int(x)-y for x,y in zip(input().rstrip('\n').split(),cs)]
for i in range(D):
  s1 = S[i]
  s1_s=sorted(s1,reverse=True)
  if i!=D-1:
    s2=S[i+1]
    if s2.index(max(s2))==s1.index(max(s1)):
      print(s1.index(s1_s[1])+1)
    else:
      print(s1.index(s1_s[0])+1)
print(S[D-1].index(max(S[D-1]))+1)

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

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<int, P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};

void chmax(int &a, int b){
    a = max(a,b);
}

bool solve(){
    int n, c;
    cin >> n >> c;
    if(n==0) return true;
    vector<int> a(n), b(c);
    for(int i=0;i<n;i++){
        for(int j=0;j<16;j++){
            int x;
            cin >> x;
            a[i] |= x<<j;
        }
    }
    for(int i=0;i<c;i++){
        for(int j=0;j<16;j++){
            int x;
            cin >> x;
            b[i] |= x<<j;
        }
    }
    vector<vector<int> > dp(n+1, vector<int>(1<<16,-1));
    dp[0][0] = 0;
    for(int i=0;i<n;i++){
        for(int S=0;S<1<<16;S++){
            if(dp[i][S] < 0) continue;
            int T = S|a[i];
            chmax(dp[i+1][T], dp[i][S]);
            for(int j=0;j<c;j++){
                int X = T&b[j], cnt = 0;
                for(int k=0;k<16;k++){
                    if((X>>k)&1) cnt++;
                }
                chmax(dp[i+1][T^X], dp[i][S]+cnt);
            }
        }
    }
    int ans = 0;
    for(int S=0;S<1<<16;S++){
        chmax(ans, dp[n][S]);
    }
    cout << ans << endl;
    return false;
}

int main() {
    while(!solve());
    return 0;
}



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

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

    string a= s.substr(0, 2);;
    string b= s.substr(2);;
    int before=stoi(a);
    int after=stoi(b);

    if(0<before && before<13)
    {
        if(0<after && after<13)
        {
            cout<<"AMBIGUOUS"<<endl;
            return 0;
        }
        else
        {
            cout<<"MMYY"<<endl;
            return 0;
        }
    }
    else if(0<after && after<13)
    {
        cout<<"YYMM"<<endl;
        return 0;
    }
    else
    {
        cout<<"NA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
// created_by  Rishi_Mohan

#include<bits/stdc++.h>

#define    ll           long long
#define    db1(x)       cout<<#x<<"="<<x<<'\n'
#define    db2(x,y)     cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define    db3(x,y,z)   cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

using namespace std;

void solve()
{
   int n , k;
   cin >> n >> k;
   vector<int> v(n);
   for(int i=0;i<n;i++) cin >> v[i];
    sort(v.begin() , v.end());
   int ans = 0;
    for(int i=0;i<k;i++) ans+=v[i];
        cout << ans ;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();

}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

const int MAXN = 3005;
const int mod = 1e9 + 7;

inline void inc(int &x, int y) { x += y; if( x >= mod ) x -= mod; }

int n, m, dp[MAXN][MAXN][2], ans;

int main()
{
	//freopen ("data.in","r",stdin);
	//freopen ("data.out","w",stdout);
	scanf( "%d%d", &n, &m );
	for( int i = 1 ; i <= n ; i++ ) dp[ 0 ][ i ][ 0 ] = 1;
	dp[ 0 ][ 0 ][ 1 ] = 1;
	for( int i = 0 ; i < m ; i++ )
		for( int j = 0 ; j <= n ; j++ )
			for( int k = 0 ; k < 2 ; k++ ) if( int cur = dp[ i ][ j ][ k ] )
			{
				if( !j )
				{
					inc( dp[ i + 1 ][ j ][ 1 ], cur );
					inc( dp[ i + 1 ][ j + 1 ][ 1 ], cur );	
				}
				else if( j == n )
				{
					inc( dp[ i + 1 ][ j ][ k | ( j == 1 ) ], cur );
					inc( dp[ i + 1 ][ j - 1 ][ k | ( j == 1 ) ], cur );
				}
				else
				{
					inc( dp[ i + 1 ][ j ][ k ], cur );
					inc( dp[ i + 1 ][ j + 1 ][ k ], cur );
					inc( dp[ i + 1 ][ j ][ k | ( j == 1 ) ], cur );
					inc( dp[ i + 1 ][ j - 1 ][ k | ( j == 1 ) ], cur );
				}
			}
	/*for (int i=0;i<=m;i++)
	{
		for (int j=0;j<=n;j++)
			cout<<dp[i][j][1]<<' ';
		cout<<endl;
	}
	cout<<endl;
	for (int i=0;i<=m;i++)
	{
		for (int j=0;j<=n;j++)
			cout<<dp[i][j][0] <<' ';
		cout<<endl;
	}*/
	for( int i = 0 ; i <= n ; i++ ) inc( ans, dp[ m ][ i ][ 1 ] );
	return printf( "%d\n", ans ), 0;
}



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

const int N = 110;

int dp[N][N];
bool mat[N][N];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++) {
            dp[i][j] = 1e9;
            mat[i][j] = (s[j] == '#');
        }
    }
    dp[0][0] = mat[0][0];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            if (i)
                dp[i][j] = dp[i - 1][j] + (mat[i][j] && !mat[i - 1][j]);
            if (j)
                dp[i][j] = min(dp[i][j], dp[i][j - 1] + (mat[i][j] && !mat[i][j - 1]));
        }
    cout << dp[n - 1][m - 1] << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long a = scan.nextLong();
        long b = scan.nextLong();

        if((a+b)%2 == 0){
            System.out.println((a+b)/2);
        }else{
            System.out.println("IMPOSSIBLE");
        }
    }
}


Measured memory_bytes: 21716
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    s = list(input())

    open_cnt = 0
    close_cnt = 0
    for si in s:
        if si == "(":
            open_cnt += 1
        else:
            if open_cnt == 0:
                close_cnt += 1
            else:
                open_cnt -= 1


    for i in range(close_cnt):
        s.insert(0, "(")

    for i in range(open_cnt):
        s.append(")")

    print(*s, sep="")


if __name__ == '__main__':
    main()


Measured memory_bytes: 5588
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
#define N 100010
int d[N],in[N],ans[N];
vector<int> mp[N];
int main(){
    int m,n,a,b;
    while (scanf("%d %d",&n,&m)!=EOF) {
        for (int i=1;i<=n;i++)
            mp[i].clear();
        for (int i=0;i<m;i++) {
            scanf("%d %d",&a,&b);
            mp[a].push_back(b);
            mp[b].push_back(a);
        }
        for (int i=1;i<=n;i++)
        {
            d[i] = n;
            in[i] = 0;
        }
        d[1] = 0;
        in[1] = 1;
        queue<int> q;
        q.push(1);
        while (!q.empty()) {
            int f = q.front();
            q.pop();
            for (int i=0;i<mp[f].size();i++) {
                int next = mp[f][i];
                if (d[next]>d[f]+1) {
                    ans[next] = f;
                    d[next] = d[f] + 1;
                    if (!in[next]) {
                        in[next] = 1;
                        q.push(next);
                    }
                }
            }
        }

        bool flag = true;
        for (int i=2;i<=n;i++) {
            if (d[i] == n) {
                printf("No\n");
                flag = false;
                break;
            }
            //printf("d[%d]=%d\n",i,d[i]);
        }
        if (flag) {
            printf("Yes\n");
            for (int i=2;i<=n;i++)
                printf("%d\n",ans[i]);
        }

    }
    return 0;
}




Measured memory_bytes: 10796
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b , c , d;
    cin >> a >> b >> c >> d;
    if( a + b > c + d ) cout << "Left";
    else if( a + b == c + d ) cout << "Balanced";
    else cout << "Right";
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, m;
    string s;

    cin >> n >> m >> s;

    V res;

    int i = n;

    while (i > 0)
    {
        for (int j = max(0, i - m); j <= i; j++)
        {
            if (s[j] == '0')
            {
                if (j == i)
                {
                    cout << -1 << endl;
                    return 0;
                }

                res.push_back(i - j);

                i = j;
                break;
            }
        }
    }

    for (int i = res.size() - 1; i >= 0; i--)
        cout << res[i] << (i == 0 ? "\n" : " ");

    return 0;
}

Measured memory_bytes: 1096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_153
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] hn = ReadInts();
            int h = hn[0];
            int n = hn[1];
            int[] array = ReadInts();
            int sum = 0;
            for (int i = 0; i < n; i++) sum += array[i];
            WriteLine(sum < h ? "No" : "Yes");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

#define int long long int
#define mp make_pair
using namespace std;

int32_t main() {
    int n,h,w;
    scanf("%lld", &n);
    scanf("%lld", &h);
    scanf("%lld", &w);
    int ans = (n - h + 1)*(n - w + 1);
    printf("%lld",ans);
    return 0;
}

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

int main()
{
	int s[33] = {1, 1, 2};
	int n;
	
	for (int i = 3; i <= 33; i++){
		s[i] = s[i - 3] + s[i - 2] + s[i - 1];
	}
	
	while (cin >> n, n){
		if (s[n] % 3650 == 0){
			cout << s[n] / 3650 << endl;
		}
		else {
			cout << s[n] / 3650 + 1 << endl;
		}
	}
	
	return (0);
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, D = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    d2=D**2
    cnt=0
    for x,y in S:
        if x**2+y**2<=d2:
            cnt+=1
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 107596
import java.util.*;

public class Main {

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

        int n = sc.nextInt();

        long[] array = new long[n];
        Arrays.fill(array, 1);

        for (int i = 2; i <= n; i++) {
            int count = 0;
            int index;
            while ((index = ++count * i) <= n) {
                array[index - 1]++;
            }
        }

        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += array[i] * (i + 1);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 116092
#include <string>
#include <vector>
#include<iostream>
#include <cstdlib>
#include<stdlib.h>
using namespace std;
    

int main(){
    int n;
    cin >> n;
    
    int heights[n];
    
    for (int i = 0; i < n; i++) {
        cin >> heights[i];
    }
    
    int current_max = -99;
    for (int i = 0; i < n; i++) {
        int counter = 0;
        while (i < n - 1 && heights[i] >= heights[i+1]) {
            counter++;
            i++;
        }
        if (counter > current_max)
            current_max = counter;
    }
    
    cout << current_max << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define EQ(a,b) (abs((a)-(b))<EPS)
int d[10];
int main()
{
	while(1)
	{
		for(int i=0;i<10;i++)
		{
			d[i]=0;
		}
		int n;
		cin >> n;
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			int x;
			cin >> x;
			d[x]++;
		}
		for(int i=0;i<10;i++)
		{
			if(d[i]==0)
			{
				cout << '-' << endl;
			}
			else
			{
				for(int j=0;j<d[i];j++)
				{
					cout << '*';
				}
				cout << endl;
			}
		}
	}
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  int sum=0;
  vector<int> W(N);
  for(int i=0;i<N;++i){
    cin>>W.at(i);
    sum=sum+W.at(i);
  }


  int min=10001;
  int sub_sum=0;
  for(int T=0;T<N-1;++T){
    sub_sum=sub_sum+W.at(T);
    if(min>abs(sum-2*sub_sum)){
      min=abs(sum-2*sub_sum);
    }
  }

  cout<<min<<endl;
}

Measured memory_bytes: 256
/*
  Warn - Don't change next line else you will get WA verdict. Online Judge is configured to give WA if next line is not present.
  Author - Aryan Choudhary (@aryanc403)
 
  const short DEBUG { 0 };
  #define debug(x) if (DEBUG) cout << #x << " = " << x << '\n'
*/

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"
#define PI 3.1415926535897932384626433832795
typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

//const lli [3] ={ 999119999L,1000000007L,1000992299L};
//const lli [3] ={ 97L,101L,103L};
//const lli  = chrono::high_resolution_clock::now().time_since_epoch().count();
clock_t time_p=clock();
void aryanc403()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

class CMP
{
public:
    bool operator()(lli a , lli b) //For min priority_queue .
    {
        return ! ( a <= b );
    }
};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt==m.end())         m.insert(mp(x,cnt));
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}
const lli INF = 0xFFFFFFFFFFFFFFFL;
const lli mod = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r;
    lli m,a,b;
    string s;
    vi :: iterator it;
    //priority_queue < lli , vector < lli > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>a>>b;
    if(b%a==0)
        cout<<a+b<<endl;
    else
        cout<<b-a<<endl;
}   aryanc403();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int k,n;
    cin >> k >> n;
    
    vector<int> a(n);
    
    for (int i=0;i<n;i++){
        cin >>a.at(i);
    }
    
    int ans=k-a.at(n-1)+a.at(0);
    
    for(int i=0;i<n-1;i++){
        ans=max(ans,a.at((i+1))-a.at(i));
    }
    
    cout <<k-ans;
}


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

int main() {
  int data[3];
  for(int i=0; i<3; i++) {
    int h, m, s;
    cin >> h >> m >> s;
    data[i] = h*3600 + m*60 + s;
    cin >> h >> m >> s;
    data[i] = h*3600 + m*60 + s - data[i];
  }

  for(int i=0; i<3; i++) {
    cout << data[i]/3600 << " ";
    data[i] %= 3600;
    cout << data[i]/60 << " ";
    data[i] %= 60;
    cout << data[i] << endl;
  }
}

Measured memory_bytes: 1160
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
static string[] input = Console.ReadLine().Split(' ');
static long r = long.Parse(input[0]);//行数
static long c = long.Parse(input[1]);//列数
static int nn = 0;
static long[,] startPosition = new long[9999999,2];//スタート地点の個数と、xy座標
static long[,] distances = new long[r,c];//最短距離
static Queue<long[]> que = new Queue<long[]>();//幅優先探索用のキュー
static long[,] wallPositions = new long[r+2,c+2];//壁は1
static long[] VectorArrow = new long[8]{0,1,0,-1,1,0,-1,0};//上下左右に進む為のベクトル

	static void Main()
	{  
		for(long i = 0; i < r; i++)
    {
      string inputc = Console.ReadLine();
      for(long j = 0; j < c; j++)
      {
        if(inputc[(int)j] == '#')//スタート地点の取得
        {
          startPosition[nn,0] = i;
          startPosition[nn,1] = j;
          nn++;
        }
      }
    }

    for(long i = 0; i < r+2; i++)//周囲を壁で埋める
    {
      wallPositions[i,0] = 1;
      wallPositions[i,c+1] = 1;
    }
    for(long j = 0; j < c+2; j++)
    {
      wallPositions[0,j] = 1;
      wallPositions[r+1,j] = 1;
    }
    
		BFS(startPosition);//幅優先探索
	}

  static void BFS(long[,] startPositions)//幅優先探索。引数はスタートの座標。
  {
    int n = nn;//スタート地点の個数
    long[][] startPosition = new long[n][];
    for(int i = 0; i < n; i++)
    {
      startPosition[i] = new long[2];
      startPosition[i][0] = startPositions[i,0];
      startPosition[i][1] = startPositions[i,1];
      que.Enqueue(startPosition[i]);
    }
    
    for(long i = 0; i < r; i++)
    {
      for(long j = 0; j < c; j++)
      {
        distances[i,j] = long.MaxValue;//距離を無限と仮定
      }
    }

    for(int i = 0; i < n; i++)
    {
      distances[startPosition[i][0], startPosition[i][1]] = 0;//スタート地点までの距離は0
    }
    long poppedMemoX = 0;
    long poppedMemoY = 0;
    while(que.Count > 0)
    {
      poppedMemoX = que.Peek()[0];
      poppedMemoY = que.Peek()[1];
      que.Dequeue();
    
      for(long partnerNum = 0; partnerNum < 4; partnerNum++)//上下左右に進みたい
      {
        long aimX = poppedMemoX+VectorArrow[2*partnerNum];
        long aimY = poppedMemoY+VectorArrow[2*partnerNum+1];
        if(wallPositions[aimX+1, aimY+1] == 1) continue;//壁なら無視
        if(distances[aimX, aimY] != long.MaxValue) continue;//距離が確定済みなら無視
        distances[aimX, aimY] = distances[poppedMemoX, poppedMemoY] + 1;//距離の加算
        que.Enqueue(new long[2]{aimX, aimY});
      }
    }

      long answer = 0;
      for(long i = 0; i < r; i++)//各点までの距離の表示
      {
        for(long j = 0; j < c; j++)
        {
          answer = Math.Max(answer, distances[i,j]);
        }
      }
      Console.WriteLine(answer);
      
      
  }
}

Measured memory_bytes: 118008
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5;
int a[maxn];
int main()
{
    int n,k;
    cin>>n>>k;
    int t=1<<30;
    for(int i=1;i<n;i++){
        cin>>a[i];
        if(a[i]==1)t=i;
    }
    int ans=ceil(1.0*(n-1)/(k-1));
    cout<<ans;
}


Measured memory_bytes: 640
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int K;
  ci(K);
  if(K % 2 == 0){
    co(pow(K / 2, 2));
  }
  else{
    co((K / 2) * (K / 2 + 1));
  }
}

Measured memory_bytes: 256