akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HossamDoma
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {

            int n = in.nextInt();

            long[] a = new long[n];

            for (int i = 0; i < n; ++i)
                a[i] = in.nextLong();

            long ans = 1;

//        if(n == 1) {
//            out.println(0);
//            return;
//        }

            for (int i = 0; i < n; ++i) {
                ans = Functions.lcm(ans, a[i]);
            }

            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public Long nextLong() {
            return Long.parseLong(next());
        }

    }

    static class Functions {
        static long gcd(long a, long b) {

            while (b > 0) {
                long tmp = a % b;
                a = b;
                b = tmp;
            }

            return a;
        }

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

    }
}



Measured memory_bytes: 21460
// Ivan Zanov
// Template
#include <iostream>
#include <utility>
#include <bitset>
#include <vector>
#include <set>
#include <unordered_map>
#include <map>
#include <assert.h>
#include <cmath>
#include <algorithm>
#include <complex>
#include <deque>
#include <iomanip>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <memory>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <sstream>
#include <exception>
#include <functional>
#include <cstring>
#include <cstdlib>
using namespace std;
#define lowbit(x) ((x)&((x)^((x)-1)))
#define max(a,b) (a<b?b:a)
#define IOS ios_base::sync_with_stdio(0);
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define INF (int)1e9
#define EPS (int)1e-9
#define bit_count __builtin_popcount
#define gcd __gcd
#define size(r) r.size()
#define max3(a, b, c) max(a, max(b,c))
#define min3(a, b, c) min(a, min(b,c))
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
inline void set_bit(int & n, int b) { n |= (1 << (int) b); }
inline void unset_bit(int & n, int b) { n &= ~(1 << (int) b); }
inline bool check_bit(int n, int pos) { return ( n & (1 << (pos))); }
inline ll lcm(ll a, ll b){ return (a * b / gcd(a,b));}
int main() {
    long long a, b;
    cin>>a>>b;
    cout<<lcm(a,b)<<endl;
    return 0;
}


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

const ll MOD = 1e9 + 7;

ll modPow(ll a, ll x) {
  if (x == 0) return 1;
  if (x == 1) return a;
  ll temp = modPow(a, x / 2);
  ll ans = (temp * temp) % MOD;
  if (x % 2 == 1) ans = (ans * a) % MOD;
  return ans;
}

ll modInv(ll a) {
  return (modPow(a, MOD - 2) + MOD) % MOD;
}

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

  ll K; cin >> K;
  string S; cin >> S;
  ll N = S.size();
  ll ans = 0;

  ll C = 1;
  ll m25 = 1;
  ll m26 = 1;
  for (ll i = 0; i < K; i++) {
    m26 = (m26 * 26) % MOD;
  }
  ll inv26 = modInv(26);
  for (ll i = N - 1; i < N + K; i++) {
    if (i != N - 1) {
      C = (C * i) % MOD;
      ll temp = i - N + 1;
      C = (C * modInv(temp)) % MOD;

      m26 = (m26 * modInv(26)) % MOD;
      m25 = (m25 * 25) % MOD;
    }

    ll temp1 = (C * m25) % MOD;
    temp1 = (temp1 * m26) % MOD;

    // cout << C << '\n';
    // cout << m25 << '\n';
    // cout << m26 << '\n';
    // cout << temp1 << '\n';
    // cout << '\n';
    ans = (ans + temp1) % MOD;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4188
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College

'''
import sys
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]



def solve():
    
    
    
    # for _ in range(ii()):
    
    
    
    n = ii()
    a = li()
    suff = [0]*n
    for i in range(n-2,-1,-1):
        suff[i] = suff[i+1]
        suff[i] += a[i+1]
        suff[i] %= mod
    
    ans = 0
    for i in range(n):
        x = a[i]*suff[i]
        x %= mod
        ans += x
        ans %= mod
    print(ans)
    
        
    
    
if __name__ =="__main__":
    # read()
    solve()
    

Measured memory_bytes: 105236
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define EPS (1e-20)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 200

int N;
int h[MAX];

int solve(int r, int l){//cout<<r<<" "<<l<<endl;
	int mi = INF, ans = 0;
	if(l-r<1)return 0;
	for(int i = r; i < l; i++){
		mi = min(h[i],mi);
	}
	ans += mi;
	
	for(int i = r, t = r; i < l; i++){//cout<<r<<" cc"<<l<<i<<" "<<l-1<<endl;
		h[i] -= mi;
		
		if(h[i] == 0){
			ans += solve(t,i);
			t = i+1;
		}
		if(i == l-1)ans += solve(t,l);
	}
	//cout<<r<<" "<<l<<" ans = "<<ans<<endl;
	return ans;
}

signed main(){
	cout<<fixed<<setprecision(7);
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		cin>>h[i];
	}
	
	cout<<solve(0,N)<<endl;
	
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;
struct edge {ll to, cost;};

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, a, b, c, q, k, x, y;
vector<edge> e[100000];
ll d[100000];

void Dijkstra(ll s) {
	priority_queue<pll, vector<pll>, greater<pll>> que;
	fill(d, d+n, linf);
	d[s] = 0;
	que.push(pll(0,s));
	
	while(!que.empty()) {
		pll p = que.top(); que.pop();
		ll v = p.second;
		if (d[v]<p.first) continue;
		for (ll i = 0; i < e[v].size(); ++i) {
			edge en = e[v][i];
			if (d[en.to] > d[v] + en.cost) {
				d[en.to] = d[v] + en.cost;
				que.push(pll(d[en.to], en.to));
			}
		}
	}
}

int main() {
	cin >> n;
	rep(i,n-1) {
		cin >> a >> b >> c;
		a--, b--;
		e[a].pb(edge{b, c});
		e[b].pb(edge{a, c});
	}
	cin >> q >> k;
	// kと全ての頂点の距離
	Dijkstra(k-1);
	rep(i,q) {
		cin >> x >> y;
		x--, y--;
		cout << d[x] + d[y] << ln;
	}
}

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


void solve(long long N, std::vector<long long> W){
    long long sum = 0;
    long long sum_tmp = 0;
    long long diff = 1e9;
    for(int i = 0;i < N;i++) sum += W[i];

    for(int i = 0;i < N -1;i++){
        sum_tmp += W[i];
        sum -= W[i];
        if(abs(sum - sum_tmp) <= diff) diff = abs(sum - sum_tmp);
    }

    cout << diff << 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);
    std::vector<long long> W(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&W[i]);
    }
    solve(N, std::move(W));
    return 0;
}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

signed main() {
    ll N;
    cin>>N;
    vector<ll> A(N+2);
    A[0] = 0;
    rep(i,1,N+1)
        cin>>A[i];
    rep(i,1,N+2)
        A[i] += A[i-1];

    ll ans = 1LL << 62;
    rep(b,3,N){
        ll P,Q,R,S;
        {
            ll ng=0,ok=b;
            while(ng+1 < ok){
                ll m = (ng+ok)/2;
                if (A[m-1] >= A[b-1]-A[m-1]){
                    ok = m;
                } else {
                    ng = m;
                }
            }
            ll P1 = A[ok-1];
            ll Q1 = A[b-1] - P1;
            ll P2 = A[ok-2];
            ll Q2 = A[b-1] - P2;
            if (abs(P1-Q1)<abs(P2-Q2)){
                P=P1;Q=Q1;
            }else{
                P=P2;Q=Q2;
            }
        }
        {
            ll ng=b-1,ok=N+1;
            while(ng+1 < ok){
                ll m = (ng+ok)/2;
                if (A[m-1]-A[b-1] >= A[N]-A[m-1]){
                    ok = m;
                } else {
                    ng = m;
                }
            }
            ll R1 = A[ok-1]-A[b-1];
            ll S1 = A[N] -P -Q -R1;
            ll R2 = A[ok-2]-A[b-1];
            ll S2 = A[N] -P -Q -R2;
            if (abs(R1-S1)<abs(R2-S2)){
                R=R1;S=S1;
            }else{
                R=R2;S=S2;
            }
        }
        // printf("b=%d PQRS=%d %d %d %d\n",b,P,Q,R,S);
        ans = min(ans, max(P,max(Q,max(R, S))) - min(P,min(Q,min(R, S))));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
a,b,k = map(int,input().split())
lia = list(range(a,a+k))
lib = list(range(b-k+1,b+1))
if a+k > b:
  setans = set(lia + lib)&set(range(a,b+1))
else:
  setans = set(lia + lib)
for i in sorted(setans):
  print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
int main(){
	ll x;
	scanf("%lld",&x);
	ll g=x*360/gcd(360,x);
	printf("%lld\n",g/x);
	return 0;
}


Measured memory_bytes: 3776
#include<stdio.h>
#define rep(i,a,b) for(long long int i = a;i <= b;i++)
long long int choose2(long long int n){return n*(n-1)/2;}

int main(void){
  //acquisition of data
  long long int n; scanf("%lld",&n);
  long long int a[200010]; rep(i,1,n){scanf("%lld",&a[i]);}
  long long int cnt[200010]; rep(i,1,n){cnt[i] = 0;} 
                             rep(i,1,n){cnt[a[i]]++;}

  //answer when not be deleted
  long long int ans = 0;
  rep(i,1,n){ans += choose2(cnt[i]);}

  //answer
  rep(i,1,n){printf("%lld\n",ans - (choose2(cnt[a[i]]) - choose2(cnt[a[i]]-1)));}

  return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		int ans=0;
		for (int x=1;x*x<=i;x++)
		{
			for (int y=x;y*y<=i;y++)
			{
				for (int z=y;z*z<=i;z++)
				{
					if (x*x+y*y+z*z+x*y+y*z+z*x==i)
					{
						if (x!=y&&x!=z&&y!=z)ans+=6;
						else if (x!=y&&x!=z&&y==z||x!=y&&y!=z&&x==z||x!=z&&y!=z&&x==y)ans+=3;
						else ans++;
					}
				}
			}
		}
		cout<<ans<<"\n";
	}
}

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

bool ok1[200001], ok2[200001];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	f(i, 0, m){
		int a, b;
		scanf("%d%d", &a, &b);
		if (a > b)swap(a, b);
		if (a == 1)ok1[b] = true;
		else if (b == n)ok2[a] = true;
	}
	f(i, 2, n)if (ok1[i] && ok2[i]) { printf("POSSIBLE\n"); return 0; }
	printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 640
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));

  $n = strlen($s);
  $key = [];
  $alpha = 'abcdefghijklmnopqrstuvwxyz';
  for($i=0; $i<$n; $i++){
    $key[$s[$i]] = true;
  }
  for($i=0; $i<strlen($alpha); $i++){
    if(!isset($key[$alpha[$i]])){
      echo $alpha[$i];
      exit;
    }
  }
  echo "None";


Measured memory_bytes: 16456
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <map>

using namespace std;


int main()
{
    // 整数の入力
    long long N,Z,W,i,ai,pattern1,pattern2;
    vector<long long> As;
    cin >> N >> Z >> W;
    for (i= 0;i< N;i++){
        cin >>ai;
        As.push_back(ai);
    }

    if (N == 1){
        cout << abs(As[0] - W) <<endl;
    }else{
        pattern1 = abs(As[N-1] - W);
        pattern2 = abs(As[N-2] - As[N-1]);
        cout << max(pattern1,pattern2) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# C
import collections
N = int(input())
a = list(map(int, input().split()))
def color(rate):
    if 1 <= rate <= 400:
        return 'gray'
    elif 400 <= rate < 800:
        return 'brown'
    elif 800 <= rate < 1200:
        return 'green'
    elif 1200 <= rate < 1600:
        return 'mizu'
    elif 1600 <= rate < 2000:
        return 'blue'
    elif 2000 <= rate < 2400:
        return 'yellow'
    elif 2400 <= rate < 2800:
        return 'orange'
    elif 2800 <= rate < 3200:
        return 'red'
    else:
        return 'change'
color_lst = []
change_num = 0
for i in range(N):
    tmp = color(a[i])
    if tmp == 'change':
        change_num += 1
    else:
        color_lst.append(tmp)
color_counter = collections.Counter(color_lst)
num = color_counter.keys()
if len(num) != 0:
    print('{} {}'.format(len(num), len(num) + change_num))
else:
    print('{} {}'.format(1, change_num))

Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int main(){
  	int A1, A2, A3;
  	cin >> A1 >> A2 >> A3;
  	if(A1+A2+A3>=22){
    	cout << "bust" << endl;
    }else{
    	cout << "win" << endl;
    }
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    char moji = 0;
    for(char i='a';i<='z';++i) {
        bool match = false;
        for(int j=0;j<S.size();++j) {
            if(i==S[j]) match =true; 
        }
        if(match==false) {
            moji = i;
            break;
        }
    }
    if (moji==0) {
        cout << "None" << endl;
    } else {
        cout << moji << endl;
    }
}

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

using namespace std;

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

 	int h, w, mi; cin >> h >> w >> mi;
	vector<pair<int,int>> vh(h+1);
	vector<pair<int,int>> vw(w+1);
	
	for(int i = 0; i <= h; i++) vh[i].second = i;
	for(int i = 0; i <= w; i++) vw[i].second = i;

	map<pair<int, int>, int> m;
	
	for(int i=0; i < mi; i++){
		int h1, w1;	cin >> h1 >> w1;    
		vh[h1].first++; vw[w1].first++;
		m[make_pair(h1, w1)]++;
	}

	sort(vh.rbegin(), vh.rend());
	sort(vw.rbegin(), vw.rend());


	//for(int i = 0 ; i < (int)vh.size(); i++) cout << vh[i].second << " -- " << vh[i].first << "\n"; 
	//for(int i = 0 ; i < (int)vw.size(); i++) cout << vw[i].second << " -- " << vw[i].first << "\n"; 
	
	
	int max_ = vh[0].first + vw[0].first;
	int i = 0;
	bool isless = false;
	int sh = vh[0].first, sw = vw[0].first;
	while(vh[0].first == sh && vw[i].first == sw){
	//	cout << "counter: " << i << "\n"; 
		if(m.count(make_pair(vh[0].second, vw[i].second)) == 0 ) isless = true; 
		i++;
	}
	i = 0;
	while(vh[i].first == sh && vw[0].first == sw){
	//	cout << "counter: " << i << "\n"; 
		if(m.count(make_pair(vh[i].second, vw[0].second)) == 0 ) isless = true; 
		i++;
	}
	i = 0;	
	while(vh[i].first == sh && vw[i].first == sw){
//		cout << "counter: " << i << "\n"; 
		if(m.count(make_pair(vh[i].second, vw[i].second)) == 0 ) isless = true; 
		i++;
	}

	if(isless) cout << max_;
	else cout << max_ - 1;

  return 0;
}


Measured memory_bytes: 31432
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

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

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

int main()
{
  ll A,B; cin>>A>>B;
  cout<<lcm(A,B)<<endl;
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
using namespace std;
const long long INF = (1ull<<63) - 1;


int main() {
	int n;
	cin >> n;
	long long pmax = -INF, pmin = INF, mmax = -INF, mmin = INF;
	for (int i = 0; i < n; i++) {
		long long x, y;
		cin >> x >> y;
		pmax = max(pmax, x + y);
		pmin = min(pmin, x + y);
		mmax = max(mmax, x - y);
		mmin = min(mmin, x - y);
	}
	long long ans = max(pmax - pmin, mmax - mmin);
	cout << ans << endl;
	return 0;
}

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

int main()
{
	int X, sum = 0;
	cin >> X;
	for (int i = 1;; i++) {
		sum += i;
		if (sum >= X) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000001
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[200010];
    rep(i, N) cin >> A[i];
    int ok = -INF, ng = INF;
    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        int sum1 = 0, sum2 = 0;
        rep(i, N) sum1 += abs(A[i] - (mid + i));
        rep(i, N) sum2 += abs(A[i] - (mid + i + 1));
        if (sum1 - sum2 >= 0) ok = mid;
        else ng = mid;
        //cout << sum1 << " " << sum2 << " " << ok << " " << mid  << " " << ng << endl;
    }
    int ans = 0;
    rep(i, N) ans += abs(A[i] - (ok + i + 1));
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] stones = new int[n];
        for(int i=0; i<n; i++) stones[i] = scanner.nextInt();
        int[] dp = new int[n];
        if(n>1) dp[1] = Math.abs(stones[1] - stones[0]);
        for(int i=2; i<n; i++)
            dp[i] = Math.min(dp[i-1]+Math.abs(stones[i]-stones[i-1]),dp[i-2]+Math.abs(stones[i]-stones[i-2]));
        System.out.println(dp[n-1]);

    }

}


Measured memory_bytes: 50644
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if((c-a-b)>0&&(c-a-b)*(c-a-b)>4*a*b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
# 円状に席が並んでいるので、空席を作ると男女の並びが不自然になるのは確か
# 男 空席 男 とやると一見空席が見つけられないような気がするが、それは円のどこかで同性同士が隣り合ってしまうので無理
# 空席の隣は必ず男と女である

N = int(input())
# Vacantがあるとそこで並びがずれる

# 0を基準とする
print(0, flush=True)  # 0番目の座席に対してリクエストを送る
s0 = input()
if s0 == "Vacant":
    exit()

l = 0  # ずれていない(ずれているかも)
r = N-1  # ずれている
while r - l > 1:
    m = (l+r) // 2  # 中央値のリクエストを送る
    print(m, flush=False)
    s = input()
    if s == 'Vacant':
        exit()
    if m % 2 == 1:
        if s != s0:
            l = m
        else:
            r = m
    else:
        if s != s0:
            r = m
        else:
            l = m
print(r, flush=True)
sr = input()


Measured memory_bytes: 3660
N = int(input())
S = list(input())
#%%
ans= 0
for i in range(1,N):
    set1 = set()
    set2 = set()
    
    for s in S[:i]:
        set1.add(s)
    for s in S[i:]:
        set2.add(s)
    
    sets = set1 & set2
    ans = max(ans,len(list(sets)))

print(ans)
    
    
    
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define maxn 300005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
ll tw[maxn];
int p[maxn];
vi cu;
int vis[maxn];
int cnt[maxn];
ll jc[maxn];
ll bjc[maxn];
vi dv[maxn];
ll c(int a, int b) {
	if (a < b || b < 0) return 0;
	return jc[a] * bjc[a - b] % mod * bjc[b] % mod; 
}
int main() {
	jc[0] = bjc[0] = 1;
	for (int i = 1; i < maxn; i++)
		jc[i] = jc[i - 1] * i % mod, 
		bjc[i] = ksm(jc[i], mod - 2);
	for (int i = 1; i < maxn; i++)
		for (int j = 1; 1ll * j * i < maxn; j++)
			dv[j * i].pb(i);
	tw[1] = 1;
	for (int i = 2; i < maxn; i++)
		tw[i] = ksm(i, i - 2);
	int n;
	cin >> n;
	ll mt = 1;
	for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
	for (int i = 1; i <= n; i++) {
		if (vis[i]) continue;
		int j = i;
		int cnt = 0;
		while (1) {
			vis[j] = 1;
			cnt++;
			j = p[j];
			if (j == i) break; 
		}
		cu.pb(cnt);
	}
	sort(cu.begin(), cu.end());
	if (cu[0] >= 3) {
		cout << 0 << endl;
		return 0;
	}
	else {
		for (auto v : cu)
			cnt[v]++;
		ll ans = 1;
		int bg = cu[0];
	//	for (auto v : cu) cout << v << ' ';
	//	cout << endl;
		for (int i = 1; i < maxn; i++) {
			if (!cnt[i]) continue;
			else {
				if (i == bg) {
					if (i == 1) ans = ans * tw[cnt[1]] % mod;//, cout << ans << endl;
					else {
						ans = tw[cnt[2]] * cnt[2] % mod * ksm(2, cnt[2] - 1) % mod;
					}
				}
				else {
					ll tt = ksm(i, cnt[i]);
					ll mt = 0;
					for (auto q : dv[i]) {
						if (q == i) continue;
						mt = (mt + cnt[q] * ksm(i / q, mod - 2)) % mod;
					}
					int tid = cnt[i] + 1;
					ll na = 0;
					for (int s = 1; s <= cnt[i]; s++) {
						ll pw = c(tid - 2, s - 1) * ksm(mt, s) % mod * ksm(tid - 1, tid - 2 - (s - 1)) % mod;
					//	cout << s << ' ' << pw << endl;
						na = (na + pw) % mod;
					}
					na = na * tt % mod;
					ans = ans * na % mod;
			//		cout << i << ' ' << na << endl;
				} 
				
			}
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 46836
using System;

public class Program
{
    public static void Main(string[] args)
    {
        string s = Console.ReadLine();
        string t = Console.ReadLine();

        var sLength = s.Length;
        var tLength = t.Length;

        var ans = tLength;
        var pos = 0;
        while (pos + tLength <= sLength)
        {
            var current = s.Substring(pos, tLength);

            var match = 0;
            for (int i = 0; i < tLength; i++)
            {
                if (current[i].Equals(t[i]))
                    match++;
            }

            if (ans > tLength - match)
                ans = tLength - match;

            pos++;
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 26220
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)

const int inf = 3e18;

int d1[305][305];
int d2[305][305];
int N, M, L;

signed main()
{
	cin >> N >> M >> L;

	rep(i, N) rep(j, N) {
		d1[i][j] = inf;
		d2[i][j] = inf;
	}

	rep(i, N) d1[i][i] = d2[i][i] = 0;

	rep(_, M) {
		int a, b, c; cin >> a >> b >> c;
		--a, --b;
		d1[a][b] = d1[b][a] = c;
	}

	rep(k, N) rep(i, N) rep(j, N) {
		d1[i][j] = min(d1[i][j], d1[i][k] + d1[k][j]);
	}

	rep(i, N) rep(j, N) {
		if (i != j and d1[i][j] <= L) {
			d2[i][j] = 1;
		}
	}

	rep(k, N) rep(i, N) rep(j, N) {
		d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);
	}

	int q; cin >> q;

	rep(_, q) {
		int s, t; cin >> s >> t;
		--s, --t;
		cout << (d2[s][t] == inf ? -1 : d2[s][t] - 1) << endl;
	}
}


Measured memory_bytes: 1920
#include <iostream>
using namespace std;
int main (void) {
    int A, B, C;

    cin >> A >> B >> C;

    for (int i = 1; i <= B; i++) {
        if ((A * i) % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
 
using namespace std;

int main(){
	
	string hoge = "YAKI             ";
	
	string str;
	cin >> str;
	
	if(str.size() < 4){
		cout << "No" << endl;
		return 0;
	}
	
	for(int i = 0; i < str.size(); i++){
		if(hoge[i] != str[i] && i < 4){
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main () {

  char map[21][20];
  char com[101];

  char tank[4] = {'^','>','v','<'};
  int num;

  int dx[4] = { 0, 1, 0, -1};
  int dy[4] = { -1, 0, 1, 0};
   
  cin >> num;

  for ( int n=0; n<num; n++ )
	{
	  int h,w;
	  cin >> h >> w;
	  for ( int i=0; i<h; i++ )
		{
		  cin >> map[i];
		}

	  //for ( int i=0; i<h; i++ )
	  //cout << map[i] << endl;
	  
	  int comlen;
	  
	  cin >> comlen;
	  cin >> com;

	  int direct = -1;
	  int px, py;
	  int mx, my;
	  int bx, by;
	  bool move;
	  
	  //cout << com << endl;

	  for ( int i=0; i<h; i++ )
		{
		  for ( int j=0; j<w; j++ )
			{
			  switch ( map[i][j] )
				{
				case '^':
				  direct = 0;
				  px = j;
				  py = i;
				  break;
				case '>':
				  direct = 1;
				  px = j;
				  py = i;
				  break;
				case 'v':
				  direct = 2;
				  px = j;
				  py = i;
				  break;
				case '<':
				  direct = 3;
				  px = j;
				  py = i;
				  break;
				}
			}
		}

	  for ( int j=0; j<comlen; j++ )
		{
		  move = false;

		  
		  //cout << j << endl;
		  //cout << j << " " << com[j] << endl;
		  switch(com[j]) {
			
		  case 'U':
			direct = 0;
			move = true;
			break;
		  case 'R':
			direct = 1;
			move = true;
			break;
		  case 'D':
			direct = 2;
			move = true;
			break;
		  case 'L':
			direct = 3;
			move = true;
			break;
		  }
		  
		  bool pass = false;
		  if ( move ) {
			if ( py + dy[direct] >= h || py + dy[direct] < 0 || px + dx[direct] >= w || px + dx[direct] < 0 )
				map[py][px] = tank[direct];
			else if ( map[py+dy[direct]][px+dx[direct]] == '.')
			  {
				map[py+dy[direct]][px+dx[direct]] = tank[direct];
				map[py][px] = '.';
				px += dx[direct];
				py += dy[direct];
			  }
			else
			  {
				map[py][px] = tank[direct];
			  }
		  } else {
			if ( com[j] == 'S' )
			  {
				//cout << "in" << endl;
				//cout << tank[direct] << endl;
				mx = px + dx[direct];
				my = py + dy[direct];
				//cout << mx << " " << my << endl;//" " << map[my][mx] << endl;

				if ( my < h || my >= 0 || mx < w || mx >= 0 )
				  {				
					while ( map[my][mx] == '.' || map[my][mx] == '-' )
					  {
						my += dy[direct];
						mx += dx[direct];
						if ( my >= h || my < 0 || mx >= w || mx < 0 )
						  {
							pass = true;
							break;
						  }
					  }
				  }
				  if ( !pass ) {
					if ( map[my][mx] == '*')
					  {
						map[my][mx] = '.';
					  }
				  }
			  }

			//cout << mx << " " << my << endl;
		  }
		}
	    for ( int i=0; i<h; i++ )
		  cout << map[i] << endl;
		if ( !(n == num -1) )
		  cout << endl;
  

	}
  
}
		  

Measured memory_bytes: 0
n,q = input().split()
n = int(n)
q = int(q)

name = ['' for i in range(n)]
time = [0 for i in range(n)]
for i in range(n):
    x,y = input().split()
    name[i] = x
    time[i] = int(y)

ttl = 0
while 1:
    if len(name) == 0:
        break
    if time[0] - q <= 0:
        ttl += q - (q - time[0])
        ptime = ttl
        print(name[0],ptime)
        del name[0]
        del time[0]
    else:
        ttl += q
        time[0] -= q
        name.append(name[0])
        time.append(time[0])
        del name[0]
        del time[0]
        

    


Measured memory_bytes: 9456
import java.util.*;

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

    int[] cnt = new int[26];

    while(sc.hasNextLine()){
      String s = sc.nextLine();

      for(int i = 0; i < s.length(); i++){
        if('a' <= s.toLowerCase().charAt(i) && s.toLowerCase().charAt(i) <= 'z'){
          cnt[s.toLowerCase().charAt(i) - 'a'] += 1;
        }
      }
    }

    for(int i = 0; i < 26; i++){
        System.out.println((char)('a' + i) + " : " + cnt[i]);
    }
  }
}



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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("fibsubseq.in","r",stdin)
#define write()         freopen("fibsubseq.out","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long int
#define endll           pf("\n")
#define pf              printf
#define pi              acos(-1.0)
#define eps             1e-10
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())

bool Check(unsigned int  N,int pos){return (bool)(N & (1LL<<pos));}
ll  Set(unsigned int N,int pos){    return N=N | (1LL<<pos);}
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define mod  998244353
#define mod1 1000000009
#define var    int ii,i,j,n,k,m,z=0,c=0,t,x,y,l,r,mid
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

bitset<4000005> a;
int main()
{
    var;
    sf(n);
    a|=1;
    for(i=0;i<n;i++)
    {
        sf(x);
        z+=x;
        a|=(a<<x);
    }
    z+=1;
    z/=2;
    while(z)
    {
        if(a[z])
        {
            cout<<z<<endl;
            break;
        }
        z++;
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long long int combination_mod(long long int a,long long int b){
    long long int ans=1;
    b=min(b,a-b);
    for(int i=0;i<b;i++){
        ans*=a-b+i+1;
        ans%=MOD;
        ans*=modinv(i+1,MOD);
        ans%=MOD;
    }
    return ans;
}

int main(){
    LL(s);
    ll ans=0,ama;
    for(ll i=1;i*3<=s;i++){
        if(s>=3*i){
            ama=s-3*i;
            ans+=combination_mod(ama+i-1,i-1);
            ans%=MOD;
        }
    }
    ans%=MOD;
    out(ans);
}

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

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

    int a;
    vector<int> va;
    for(int i=0;i<n;i++){
        cin >> a;
        va.push_back(a);
    }

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


Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>

#define rep(i, a, b) for (ll i = a; i < b; i++)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

ll bfs(ll H, ll W, ll sx, ll sy, ll gx, ll gy, vector<vector<char>> &maze)
{
    const ll INF = 1e9;
    queue<pll> que;

    ll d[H][W];
    ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

    rep(i, 0, H)
    {
        rep(j, 0, W)
        {
            d[i][j] = INF;
        }
    }

    que.push(pll(sx, sy));
    d[sx][sy] = 0;

    while (que.size())
    {
        pll p = que.front();
        que.pop();

        if (p.first == gx && p.second == gy)
        {
            break;
        }

        rep(i, 0, 4)
        {
            ll nx = p.first + dx[i], ny = p.second + dy[i];

            if (0 <= nx && nx < H && 0 <= ny && ny < W && maze[nx][ny] != '#' && d[nx][ny] == INF)
            {
                que.push(pll(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    return d[gx][gy];
}

int main()
{
    ll H, W;
    input(H, W);

    vector<vector<char>> maze(H, vector<char>(W, ' '));
    rep(i, 0, H)
    {
        string s;
        input(s);
        rep(j, 0, W)
        {
            maze[i][j] = s[j];
        }
    }

    ll res = -1;
    rep(i, 0, H)
    {
        rep(j, 0, W)
        {
            rep(k, 0, H)
            {
                rep(h, 0, W)
                {
                    if ((i != k || j != h) && (maze[i][j] != '#' && maze[k][h] != '#'))
                    {
                        res = max(res, bfs(H, W, i, j, k, h, maze));
                    }
                }
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int b[100001]={0};
int main()
{
	int n;
	while(cin>>n)
	{
		int v;
		memset(b,0,sizeof(b));
		for(int i=1;i<=n;i++)
		{ int a;
			cin>>a;
			b[a+1]++;
			b[a-1]++;
			b[a]++;
		}
		sort(b,b+100001);
		cout<<b[100000]<<endl;
	}
	
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] nChar = sc.next().toCharArray();
    int[] n = new int[nChar.length];
    int sum = 0;
    String ans;

    for (int cnt = 0; cnt < n.length; cnt++) {
      n[cnt] = Character.getNumericValue(nChar[cnt]);
      sum += n[cnt];
    }
    if(sum % 9 == 0){
      ans = "Yes";
    }
    else{
      ans = "No";
    }

    System.out.println(ans);
    sc.close();
  }
}


Measured memory_bytes: 41240
import sys
from collections import Counter
input = sys.stdin.readline
N, M = map(int, input().split())
a = list(map(int, input().split()))
e = []
ee = [[] for _ in range(N + 1)]
for _ in range(M):
  u, v, c = map(int, input().split())
  e.append((c, u, v))
  ee[u].append((v, c))
  ee[v].append((u, c))
e.sort()

table = [0] + a[: ]

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1] * (n + 1)
    self.rnk = [0] * (n + 1)

  def Find_Root(self, x):
    if self.root[x] < 0:
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]

  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if x == y:
      return 
    elif self.rnk[x] > self.rnk[y]:
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if self.rnk[x] == self.rnk[y]:
        self.rnk[y] += 1

  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)

  def Count(self, x):
    return -self.root[self.Find_Root(x)]

uf = UnionFind(N)
edges = []
etable = [0] * (N + 1)
for i in range(M):
  c, u, v = e[i]
  if uf.isSameGroup(u, v):
    rt = uf.Find_Root(u)
    etable[rt] = max(etable[rt], c)
    if table[rt] >= etable[rt]: edges.append(i)

  else:
    ur = uf.Find_Root(u)
    vr = uf.Find_Root(v)
    uf.Unite(u, v)
    rt = uf.Find_Root(u)
    cmx = max(etable[ur], etable[vr], c)
    etable[rt] = cmx
    if table[ur] + table[vr] >= cmx: edges.append(i)

    table[rt] = table[ur] + table[vr]
edges.reverse()
vis = [0] * (N + 1)
evis = Counter()
res = M
#print(edges)
for i in edges:
  mx, s, _ = e[i]
  if vis[s]: continue
  sta = [s]
  vis[s] = 1
  while len(sta):
    x = sta.pop()
    for y, c in ee[x]:
      if c > mx: continue
      if evis[(min(x, y), max(x, y))]: continue
      evis[(min(x, y), max(x, y))] = 1
      res -= 1
      if vis[y]: continue
      sta.append(y)
      vis[y] = 1
  #print(vis, res, e[i])
print(res)

Measured memory_bytes: 141916
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,q;
ll x[100005],L;
int go[100005][20];
int main(){
	cin >> n;
	for(int i=1;i<=n;i++) scanf("%lld",&x[i]);
	cin >> L >> q;
	for(int i=1;i<=n;i++){
		go[i][0] = upper_bound(x+1,x+n+1,x[i]+L)-x;
		go[i][0]--; 
	}
	for(int j=1;j<20;j++){
		for(int i=1;i<=n;i++){
			go[i][j] = go[go[i][j-1]][j-1];
		}
	}
	for(int i=0;i<q;i++){
		int a,b; scanf("%d%d",&a,&b); if(a>b) swap(a,b);
		int lb = 0,ub = 200000;
		while(ub-lb>1){
			int mid = (lb+ub)/2;
			int cur = a;
			for(int j=0;j<20;j++){
				if(((mid>>j)&1)) cur = go[cur][j];
			}
			if(cur >= b) ub = mid;
			else lb = mid;
		}
		printf("%d\n",ub);
	}
}

Measured memory_bytes: 9472
#include<stdio.h>
int main()
{
	int n,a[11],i,j=0,k,f;
	scanf("%d",&n);
	while(n--)
	{	f=1;
		for(i=0;i<10;i++)
		scanf("%d",&a[i]);
		j=a[0];k=0;
		for(i=1;i<10;i++)
		{
			if(a[i]>j)
			j=a[i];
			else if(a[i]>k)
				k=a[i];
				else
				f=0;
		}
		if(f)
		printf("YES\n");
		else
		printf("NO\n");	
	}
	return 0;
}


Measured memory_bytes: 1972
N=int(input())
t,x,y=[None]*(N+1),[None]*(N+1),[None]*(N+1)
t[0],x[0],y[0]=0,0,0
for i in range(1,N+1):
    t[i],x[i],y[i] = map(int,input().split())
for i in range(N):
    l = t[i+1]-t[i]
    d = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if d <= l and (l-d) % 2 == 0:
        if i == N-1:
            print("Yes")
            break
    else:
        print("No")
        break

Measured memory_bytes: 11636
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		int ba = -1;
		for (int j = 0; j < w; j++) {
			if (s[j] == 'c') {
				cout << 0;
				ba = 0;
			}
			else if (ba >= 0) {
				ba++;
				cout << ba;
			}
			else {
				cout << -1;
			}
			if (j < w - 1) {
				cout << " ";
			}
		}
		cout << endl;
	}
}


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

int main(){
	string grades[] = {
		"light fly",
		"fly",
		"bantam",
		"feather",
		"light",
		"light welter",
		"welter",
		"light middle",
		"middle",
		"light heavy",
		"heavy"
	};
	double sep[] = { 48.00, 51.00, 54.00, 57.00, 60.00, 64.00,
					 69.00, 75.00, 81.00, 91.00 };
	string in;
	while( getline( cin, in ), in.length() ){
		double w;
		sscanf( in.c_str(), "%lf", &w );
		int i=0;
		for( ; i<10; i++ ){
			if( w <= sep[i] ){
				cout << grades[i] << endl;
				break;
			}
		}
		if( i == 10 )
			cout << grades[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
  public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   String  s = sc.next();
   char[] leader = s.toCharArray();
   int count1 = 0;
   int count2 = 0;
   for(int i = 0; i < 4; i++){
     if(leader[i] == '+'){
       count1++;
     }else{
       count2++;
     }
   }
   System.out.println(count1 - count2);
 }

}


Measured memory_bytes: 21716
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

bool is_prime(int64_t x) {
  for(int64_t i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}

int main() {
  ll x;
  cin >> x;
  ll i;
  for(i=x; i<=100003; i++){
    if(is_prime(i)) break;
  }
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
//おまじない
//#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include<iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;

int main(){
    
    int n,m;
    int sum = 0;
    int g[maxn+1]={0};
    string ans = "YES";
    
    cin >> n>>m;
    
    rep(i,m){
        int a,b;
        cin >> a>>b;
        if(a>b)swap(a,b);
        g[a]++;g[b]--;
    }
    
    rep(i,n){
        sum+=g[i+1];
        if(sum%2==1){
            ans="NO";
            break;
        }
    }
    
    cout << ans<<endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    string N; cin >> N;

    int ans1 = 0, ans2 = 0;
    REP(i, N.size()){
        ans1 += (int)(N[i] - '0');
    }
    ans2 = (int)(N[0] - '0') - 1;
    ans2 += 9 * (N.size() - 1);

    cout << max(ans1, ans2);
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256