akhauriyash/Code-Regression huggingface dataset:
<?php
/*プログラムのイメージ
--入力-----
5
3 8 7 5 5
-----------
2*3=a+b
2*8=b+c
2*7=c+d
2*5=d+e
2*5=e+a

2*3=a+(2*8-c)
2*3=a+(2*8-(2*7-d))
2*3=a+(2*8-(2*7-(2*5-e)))
2*3=a+(2*8-(2*7-(2*5-(2*5-a))))
a+a=(2*3)-(2*8-(2*7-(2*5-(2*5))))
2a=(2*3)-(2*8)+(2*7)-(2*5)+(2*5)
2a=6-16+14
a=2

e=(2*5)-a
e=8

d=(2*5)-e
d=2

c=(2*7)-d
c=12

b=(2*8)-c
b=4
*/
fscanf(STDIN,"%d",$N);
$lowA = fgets(STDIN);
$arrayA = explode(" ",$lowA);
$result = [];

//初期値設定
for($i=0;$i<$N;$i++){
  ${"mount".$i} = 0;
}

//ダム1に溜まった水計算
for($i=0;$i<$N;$i++){
  if($i%2===0){
    $mount0 += $arrayA[$i];
  }else{
    $mount0 -= $arrayA[$i];
  }
}

${"mount".($N-1)} = 2*$arrayA[$N-1]-$mount0;
for($i=$N-2;$i>0;$i--){
  ${"mount".($i)} = 2*$arrayA[$i]-${"mount".($i+1)};
}

for($i=0;$i<$N;$i++){
  $result[] = ${"mount".($i)};
}

echo implode(" ",$result);


Measured memory_bytes: 50420
#include<iostream>
using namespace std;
#include<map>
#define int long long int
int32_t main()
{
	int n,m;
	cin>>n>>m;
	int j,arr[n+1]={0};
	for(j=1;j<=n;j++)
	   cin>>arr[j];
	int prefix[n+1]={0};
	for(j=1;j<=n;j++)
	{
		prefix[j]=(arr[j]+prefix[j-1])%m;
	}
	int answer=0;
	map<int,int> mp;
	for(j=n;j>=1;j--)
	{
		mp[prefix[j]]++;
		answer+=mp[prefix[j-1]];
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,t=0,i,j,k,a,b;
    cin>>k;
    cin>>a>>b;
    for(i=a;i<=b;i++)
    {
       if(i%k==0)
            t=1;
    }
    if(t==1)
        cout<<"OK";
    else
        cout<<"NG";
}


Measured memory_bytes: 3652
N = gets.to_i
xs, ss = N.times.map{gets.split.map(&:to_i)}.transpose

sum = 0
ans = 0
mn = 0
N.times do |i|
    sum -= xs[i] - xs[i-1] if i > 0
    mn = [mn, sum].min
    sum += ss[i]
    ans = [ans, sum - mn].max
end
puts ans

Measured memory_bytes: 21372
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<deque>
#include<ctime>

using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int mod = 1000003;
/*
class UnionFind{//UnionFind木
 private:
    vector<int> Parent;
 public:
    UnionFind(int N){
        vector<int> Parent(N,-1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A]=root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]-=Parent[B];
        Parent[B]=A;
    }
};
*/
ll mpow(ll x, ll n){ //x^n(mod division) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

ll inv_mod(ll a){return mpow(a,mod-2);}

class Fuctorical{
private:
    vector<ll> fac;
public:
    
    Fuctorical(ll N){
        fac.push_back(1);
        for(int i=0;i<N;i++) fac.push_back(fac[i]*(i+1)%mod);
    }

    ll fact(ll a){return fac[a];}
    ll ifact(ll a){return inv_mod(fac[a]);}

    ll cmb(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0) return 0;
        ll tmp =ifact(a-b)*ifact(b)%mod;
        return tmp*fac[a]%mod;
    }
};

int gcd(int x,int y){return y ? gcd(y,x%y) : x;};//xとyの最大公約数

int main(){
    Fuctorical get(mod);
    int Q;
    cin>>Q;
    for(int i=0;i<Q;i++){
        ll x,d,n;
        cin>>x>>d>>n;
        if(d==0){
            cout<<mpow(x,n)<<endl;
            continue;
        }
        ll first =x*inv_mod(d)%mod;
        if(first<=mod&&mod<=first+n-1){
            cout<<0<<endl;
            continue;
        }
        ll a=get.fact(first+n-1)*get.ifact(first-1)%mod;
        cout<<a*mpow(d,n)%mod<<endl;
    }
}


Measured memory_bytes: 10348
#include<bits/stdc++.h>
typedef int ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define INF 10000
#define sc second
ll n,m;

char b[600][600];

//vector<vector<ll> > dp;
short dp[510][(1 << 20) + 10];

bool oe[600];

ll dfs(ll i) {
	if(i == n) {
		bool f = true;
		REP(j,m) {
			if(oe[j] == 1) {
				f = false;
			}
		}
		if(f) {
			return 0;
		}
		return -INF;
	}

	ll a = dfs(i + 1);

	char save[600];

	REP(j,m) {
		save[j] = oe[j];
	}

	REP(j,m) {
		oe[j] = (oe[j] xor b[i][j]);
	}

	ll b = dfs(i + 1) + 1;

	REP(j,m) {
		oe[j] = save[j];
	}

	return max(a,b);
}

ll dfs(ll i ,ll S) {
	if(i == n) {
		if(S == 0) {
			return 0;
		}
		return -INF;
	}
	if(dp[i][S] > -INF - 100)
		return dp[i][S];

	ll a = dfs(i + 1,S);

	ll S2 = 0;
	RREP(j,m) {
		S2 *= 2;
		S2 += (((S >> j) & 1) xor b[i][j]);
	}
	ll b = dfs(i + 1,S2) + 1;
	return dp[i][S] = max(a,b);
}

int main(){
	while(true) {
		cin >> n >> m;
		if(n == 0)
			break;
		REP(i,n) 
			cin >> b[i];

		REP(i,n) {
			REP(j,m) {
				b[i][j] -= '0';
			}
		}
		if(m > 20) {
			REP(i,m) {
				oe[i] = 0;
			}
			cout << dfs(0) << endl;
		}else {
			/*dp.clear();
			REP(i,n + 10) {
				vector<ll> v;
				dp.push_back(v);
				REP(j,(1 << m) + 10) 
					dp[i].pb(-INF - 100);
			}*/
			REP(i,n + 1) {
				REP(j,(1 << m) + 1) {
					dp[i][j] = -INF - 100;
				}
			}
			cout << dfs(0,0) << endl;
		}
	}
	return 0;
}



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

int main(){
  ll n,m;
  cin >> n >> m;
  ll ans=0;
  if(n==1 && m==1){
    ans=1;
  }else if(n==1 && m!=1){
    ans=m-2;
  }else if(n!=1 && m==1){
    ans=n-2;
  }else{
    ans=(n-2)*(m-2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))

const int MNUM=100000+5;
bool is_prime[MNUM];
int primeCumul[MNUM];

void eratosthenes(){
    fill(is_prime,is_prime+MNUM,true);
    is_prime[0]=false;
    is_prime[1]=false;
    for(int i=2;i*i<=MNUM;i++){
        if(is_prime[i]){
            for(int j=i*i;j<=MNUM;j+=i){
                is_prime[j]=false;
            }
        }
    }
}

int main(){
    ll q;
    cin >>q;
    eratosthenes();
    primeCumul[0]=0;
    for(int i=1;i<MNUM;i++){
        primeCumul[i]=primeCumul[i-1]+((is_prime[i]&&is_prime[(i+1)/2])?(1):(0));
    }
    for(int i=0;i<q;i++){
        ll ans=0,li,ri;
        cin >>li>>ri;
        ans=primeCumul[ri]-primeCumul[li-1];
        /*for(int x=li;x<=ri;x+=2){
            if(is_prime[x]&&is_prime[(x+1)/2])ans++;
        }*/
        cout <<ans<<endl;
    }


    return 0;

}

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

int main(){
  ll x;
  std::cin >> x;
  ll v =100;
  ll ans=0;
  while (v<x) {
    v+=v*0.01;
    ans++;
  }
  std::cout << ans << '\n';

}


Measured memory_bytes: 3636
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846;
typedef vector<ll> vll ;
typedef vector<int> vii ;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}
void solve()
{
    ll n;cin>>n;
    vector<ll>v(n+1,0);
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=n;j=j+i)
        {
            v[j]++;
        }
    }
   ll ans=0;
   for(ll i=1;i<=n;i++)
   {
      ans=ans+(i*(ll)v[i]);
   }
   cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
   // cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}

Measured memory_bytes: 81344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repin(a, n)  \
	vector<ll> a(n); \
	rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
	vector<string> a(n); \
	rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
	vector<double> a(n); \
	rep(i, n) { cin >> a[i]; }
#define in(a) \
	ll a;     \
	cin >> a;
#define ins(a) \
	string a;  \
	cin >> a;
#define ind(a) \
	double a;  \
	cin >> a;
template <class T>
inline void out(T a)
{
	cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x) (x).begin(), (x).end()
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
#define yes out("Yes")
#define no out("No")
#define degtorad(deg) (deg * M_PI / 180.0)
#define radtodeg(rad) (rad * 180.0 / PI)

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    in(n);
	if(n==1){
		out(0);
		return 0;		
	}
    const auto &res = prime_factorize(n);
	ll c = 0;
    for (auto p : res) {
		ll a = p.second;
        for(ll i = 1;i<numeric_limits<ll>::max();i++){
			a -= i;
			if(a < 0){
				break;
			}
			c += 1;
		}
    }
	out(c);
}

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

using namespace std;

const int N = 1e7 + 1000;
long long int a[N], b[N] , c[N] , ansa , ans;
pair <long long int , long long int> p[N];

int main () {
    long long int n;
    cin >> n;
    for(int i = 0 ; i < n ; i++ ) {
        cin >> a[i] >> b[i];
        ans -= b[i];
        c[i] = a[i] + b[i];
    }
    sort(c , c + n , greater<long long int>());
    for(int i = 0 ; i < n ; i+=2 ) {
        ans += c[i];
    }
    cout << ans;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef priority_queue<int> Pr; typedef vector<int> V; typedef vector<P> Vp; typedef map<int,int> MP;
const int mod = 1000000007; const Int INF = 1145141919810893931;
#define END {cout<<ans<<'\n'; return 0;}
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

  string s; cin>>s; int a[3]={};
  for (int i = 0; i < s.size(); i++)a[s[i]-'a']++;
  sort(a,a+3);
  cout<<(a[2]-a[1]<=1&&a[2]-a[0]<=1?"YES":"NO")<<'\n';
}

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

char c;

int main() {
    cin >> c;

    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }

    return 0;
}


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

using namespace std;
using ll = long long;

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  ll A[X], B[Y], C[Z];
  rep(i, X) in(A[i]);
  rep(i, Y) in(B[i]);
  rep(i, Z) in(C[i]);

  priority_queue<ll> q;
  rep(i, X) rep(j, Y) {
    q.push(A[i] + B[j]);
  }
  sort(C, C+Z);
  priority_queue<ll> ans;
  rep(i, K) {
    if (q.empty())
      break;
    ll p = q.top(); q.pop();
    rep(j, Z) {
      ans.push(p + C[j]);
    }
  }
  rep(i, K) {
    ll p = ans.top(); ans.pop();
    out(p);
  }

  return 0;
}


Measured memory_bytes: 43236
N, K = map(int, input().split())
S = input().split()
		
flag = False

for i in range(N, 10*N):
	for k in range(len(str(i))):
		if str(i)[k] in S:
			flag = False
			break
		else:
			flag = True
			continue
		
	if flag:
		print(i)
		break

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

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

        int sum=a;
        while(1){
                if(sum%b==c){
                        cout << "YES" << endl;
                        break;
                }
                sum+=a;
                if(sum%b==a%b){
                        cout << "NO" << endl;
                        break;
                }

        }
        return 0;
}


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

int n;
unsigned long long cnt;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		if (i % 3 != 0 && i % 5 != 0) cnt += i;
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3676
import scala.io.StdIn

object Main extends App {

  val Array(a, b, c, d) = StdIn.readLine().split(" ").map(_.toInt)
  val start = if(a <= c && c <= b) c else if(c <= a && a <= d) a else 101
  val end = if(a <= d && d <= b) d else if(c <= b && b <= d) b else -1

  println(if((end - start) <= 0) 0 else end - start)

}


Measured memory_bytes: 27316
#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 vector<int> vi;
typedef pair<int, int> pii;
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

const int MOD = 1000000007;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	string S; cin >> S;
	if ((S[0] == S[1] || S[2] == S[3]) && S[1] == S[2]) cout << "Yes";
	else cout << "No";
}

// read!
// ll vs. int!

Measured memory_bytes: 256
n,k=map(int,input().split())
A=list(map(int,input().split()))
s=0
for i in range(k):
  s=s+A[i]
ans=s
for i in range(n-k):
  s=s-A[i]+A[k+i]
  if s>ans:
    ans=s
print((ans+k)/2)

Measured memory_bytes: 25060
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int u, v;
    long long int x = 0, y = 0;
    for(int i = 1; i < n; i++){
        cin >> u >> v;
        x = x + (long long int)min(u,v) * (n - max(u, v) + 1);
        y = y + (long long int)(i) * (n - i + 1);
    }
    cout << y + n - x;
}


Measured memory_bytes: 3572
from collections import defaultdict
import math


def ggg(a, b):
    """規約分数を作る。n/0, 0/n は n=1,-1 にして返す。"""
    if a == b == 0:
        return 0, 0

    denominator = math.gcd(a, b)
    x, y = a // denominator, b // denominator
    return x, y


def main():
    n = int(input())
    mod = 1000000007
    zeroes = 0
    counter = defaultdict(lambda: defaultdict(int))
    for _ in range(n):
        a, b = [int(x) for x in input().split()]
        x, y = ggg(a, b)

        if x == y == 0:
            zeroes += 1
            continue
        if y < 0:
            # quadrant III, IV -> I, II
            x, y = -x, -y

        if x <= 0:
            # round 90° from quadrant II to I
            x, y = y, -x
            counter[(x, y)][1] += 1
        else:
            counter[(x, y)][0] += 1

    ans = 1
    for v in counter.values():
        now = 1
        now += pow(2, v[0], mod) - 1
        now += pow(2, v[1], mod) - 1
        ans = ans * now % mod
    ans += zeroes
    ans -= 1  # choose no fish
    return ans % mod


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 95584
N = str(input())
if int(N)%9 != 0: print("No")
else:
    if int(N) == 0 :print("Yes")
    else:
        sum = 0
        for i in range(0,len(N)):
           sum += int(N[i])
        if sum%9 == 0: print("Yes")
        else: print("No")

Measured memory_bytes: 71812
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>
 
// #include <unordered_set>
// #include <unordered_map>
 
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
 
#define pb push_back
#define mp make_pair
 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
 
typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;
 
const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
 
using namespace std;
 
#define N 1000000
int arr[N];
int a[N];
 
void eratosthenes(){
    REP(i,N){
        arr[i]=1;
    }
 
    for(int i=2;i<sqrt(N);i++){
        if(arr[i]){
            for(int j=0;i*(j+2)<N;j++){
                arr[i*(j+2)]=0;
            }
        }
    }
    arr[0]=0;
    arr[1]=0;
}
 
signed main(){

    eratosthenes();
    
    int n;
    int count=0;

    while(cin>>n){
        REP(i,n+1){
            if(arr[i]==1)count++;
        }

        cout<<count<<endl;
        count=0;
    }
 
}


Measured memory_bytes: 7004
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int INF = 1e8;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	int dist[n][n], used[n][n];
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			if (i == j) dist[i][j] = 0;
			else dist[i][j] = INF;
			used[i][j] = -1;
		}
	}
	int c[m];
	for (int i=0; i<m; i++) {
		int x, y;
		cin >> x >> y >> c[i];
		--x; --y;
		if (dist[x][y] >= c[i]) {
			dist[x][y] = dist[y][x] = c[i];
			used[x][y] = used[y][x] = i;
		}
	}
	
	for (int k=0; k<n; k++) {
		for (int i=0; i<n; i++) {
			if (i == k) continue;
			for (int j=0; j<n; j++) {
				if (i == j || j == k) continue;
				if (dist[i][j] > dist[i][k] + dist[k][j]) {
					dist[i][j] = dist[i][k] + dist[k][j];
					used[i][j] = used[i][k];
				}
			}
		}
	}
	
	bool vis[m];
	memset(vis, 0, sizeof(vis));
	int cnt = 0;
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			if (i == j) continue;
			if (!vis[used[i][j]]) cnt++;
			vis[used[i][j]] = true;
		}
	}
	cout << m - cnt;
}

Measured memory_bytes: 384
//  Created by conan1024hao on 2019/11/24.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------
int h,a[2000000];
void maxHeapify(int i){
    int l,r,maxx=i;
    l=2*i;
    r=2*i+1;
    if(l<=h&&a[l]>a[maxx])
        maxx=l;
    else maxx=i;
    if(r<=h&&a[r]>a[maxx])
        maxx=r;
    if(maxx!=i){
        swap(a[i],a[maxx]);
        maxHeapify(maxx);
    }
}
int extract(){
    int maxx;
    if(h<1)
        return -INF;
    maxx=a[1];
    a[1]=a[h--];
    maxHeapify(1);
    return maxx;
}
void increaseKey(int i, int key){
    if(key<a[i])
        return;
    a[i]=key;
    while(i>1&&a[i/2]<a[i]){
        swap(a[i],a[i/2]);
        i=i/2;
    }
}
void insert(int key){
    h++;
    a[h]=-INF;
    increaseKey(h, key);
}
//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //------------------------------
    int key;
    string s;
    while(1){
        cin>>s;
        if(s=="end")
            break;
        else if(s=="insert"){
            cin>>key;
            insert(key);
        }
        else if(s=="extract"){
            cout<<extract()<<endl;
        }
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



Measured memory_bytes: 6936
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=2e5+7,MOD=2019;
void solve(ll n,ll k){
    if(n==0){
        cout<<n<<endl;
        exit(0);
    }
    else{
            if( n < k){
                    if(n > k/2){cout<<k%n<<endl;exit(0);}
                    else{
                        cout<<n%k<<endl;
                        exit(0);
                    }
            }
            else{
                    solve(n%k,k);
            }
    }
}

int main (){
    ll n,k;cin>>n>>k;
    solve(n,k);
//    //main();
//    ll n,k;cin>>n>>k;
//    unordered_map<ll,int>cnt;
//    while(n){
//        cout<<n<<endl;
//        n = abs(n-k);
//        if(cnt[n])break;
//        cnt[n]=1;
//    }
//    cout<<n<<endl;
////    //cout<<max(n,k)%min(n,k)<<endl;
    //main();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class E implements Comparable<E>{
    int x,y;
    long c;
    E(int x,int y,long c){
        this.x=x;this.y=y;this.c=c;
    }
    @Override
    public int compareTo(E o){
        return Long.compare(c,o.c);
    }
}

class UnionFind {
    int[] parent;
    int[] rank;
    UnionFind(int n) {
	this.parent = new int[n];
	this.rank = new int[n];
	this.clear();
    }
    void clear() {
	int n = this.parent.length;
	for (int i = 0; i < n; ++i) {
	    this.parent[i] = i;
	    this.rank[i] = 0;
	}
    }
    void unify(int x, int y) {
	int rootX = this.root(x);
	int rootY = this.root(y);
	if (rootX == rootY) {
	    return;
	}
	if (this.rank[rootX] < this.rank[rootY]) {
	    this.parent[rootX] = rootY;
	} else {
	    this.parent[rootY] = rootX;
	    if (this.rank[rootX] == this.rank[rootY]) {
		this.rank[rootX]++;
	    }
	}
    }
    int root(int x) {
	if (this.parent[x] == x) {
	    return x;
	}
	return this.parent[x] = this.root(this.parent[x]);
    }
}


class Main {
    static final long I=(1L<<62)-1;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n=Integer.parseInt(scan.next());
        int q=Integer.parseInt(scan.next());
        List<E>e=new ArrayList<E>();
        long[]adj=new long[n];
        Arrays.fill(adj,I);
        for(int i=0;i<q;++i){
            int a=Integer.parseInt(scan.next());
            int b=Integer.parseInt(scan.next());
            long c=Integer.parseInt(scan.next());
            e.add(new E(a,b,c));
            adj[a]=Math.min(adj[a],c+1);
            adj[b]=Math.min(adj[b],c+2);
        }
        for(int i=0;i<2;++i)
            for(int j=0;j<n;++j)
                adj[j]=Math.min(adj[j],adj[(j+n-1)%n]+2);
        for(int i=0;i<n;++i)
            e.add(new E(i,(i+1)%n,adj[i]));
        Collections.sort(e);
        UnionFind u=new UnionFind(n);
        long t=0;
        for(E ee:e){
            int x=ee.x;
            int y=ee.y;
            long c=ee.c;
            if(u.root(x)!=u.root(y)){
                u.unify(x,y);
                t+=c;
            }
        }
        System.out.println(t);
    }
}


Measured memory_bytes: 102716
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define PI 3.14159265359

int main(){
    string s; cin >> s;
    int cnt = 0;
    int start;
    int end;
    rep(i, s.size()){
        if(s[i] == 'A'){
            start = i;
            break;
        }
    }
    for(int i=s.size(); i>0; i--){
        if(s[i] == 'Z'){
            end = i;
            break;
        }
    }
    cout << end - start + 1 << endl;

    return 0;
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n;
    cin >>n;

    int dp[101]={};

    for (int i = 0; i <= 100; i+=4){
        //dp[i]=1;
        for (int j = 0; i+j <= 100; j+=7){
            dp[i+j]=1;
        }
    }

    if(dp[n]!=0)flag = true;
    

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


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

int main()
{
	int a,i,b;
	cin>>a>>b;
	for(i=0;i<=20;i++)
		if(a*i-i+1>=b)
			{
				cout<<i<<endl;
				break;
			}
}

Measured memory_bytes: 3640
#include <stdio.h>
  
int main(){
        int n,a,b,x,y;
        scanf("%d",&n);
        scanf("%d",&a);
        scanf("%d",&b);

        if(a>b)x=b;
        else x=a;

        y=(a+b)-n;
        if(y < 0)y=0;

        printf("%d %d\n",x,y);

        return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;

	int n, query, cnt;
	int test;
	int[][] card;
	int[][] memo;

	void run() {
		for (;;) {
			n = sc.nextInt();
			if (n == 0) {
				return;
			}
			card = new int[n][2];
			for (int i = 0; i < n; i++) {
				card[i][0] = sc.nextInt();
				card[i][1] = sc.nextInt();
			}

			int g = sc.nextInt();
			memo = new int[1 << 10][1 << 13];
			for (int i = 0; i < g; i++) {
				cnt = 0;
				test = 0;
				query = sc.nextInt();
				dfs(0, 0);
				System.out.println(cnt);
			}
		}
	}

	void dfs(int k, int sum) {
		if (sum == query) {
			cnt++;
			return;
		}
		if (k == n) {
			return;
		}
		for (int i = 0; i <= card[k][1]; i++) {
			dfs(k + 1, sum + card[k][0] * i);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

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

int main()
{
  int X, A;
  cin >> X >> A;
  if (X<A) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
    
/*
    Author: Koushik Sahu
    Created: 19 Sep 2020 17:32:35
*/

int n, di, dj;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>n;
    int cnt = 0;
    bool ans = false;
    for(int i=0; i<n; i++){
        cin>>di>>dj;
        if(di==dj){
            cnt++;
        }else{
            cnt = 0;
        }
        if(cnt==3) ans = true;
    }
    if(ans) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

public class Main{ 
	
	static class FastReader{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

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

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

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	}
  
	public static void main(String[] args) 
	{ 
		FastReader sc = new FastReader(); 
		int n = sc.nextInt();
      	long[] arr = new long[n+1], brr = new long[n];
      	long res = 0;
      	for(int i=0;i<=n;i++){
           	arr[i] = sc.nextLong();
          	res+=arr[i];
        }
      	
      	for(int j=0;j<n;j++)
          	brr[j] = sc.nextLong();
		
      	for(int i=n-1;i>=0;i--){
          	long temp = Math.min(brr[i], arr[i+1]);
          	brr[i]-=temp;
          	arr[i+1]-=temp;
          	arr[i] -= Math.min(arr[i], brr[i]);
          	
          	res-=arr[i+1];
        }
      	res-=arr[0];
      	System.out.println(res); 
	}
}


Measured memory_bytes: 43992
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c, d = LI()
    print(max(a * b, c * d))
    return

#B
def B():
    _ = II()
    s = S()
    d = {}
    d["I"] = 1
    d["D"] = -1
    ans = 0
    now = 0
    for i in s:
        now += d[i]
        ans = max(ans, now)
    print(ans)
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()


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

void bubbleSort(string *A, int N){
  bool flag=true;
  while(flag){
    flag=false;
    for(int i=N-1;i>0;i--){
      if(A[i-1][1]>A[i][1]){
        swap(A[i-1], A[i]);
        flag=true;
      }
    }
  }
}

void selectionSort(string *A, int N){
  for(int i=0;i<N;i++){
    int minj=i;
    for(int j=i;j<N;j++){
      if(A[j][1]<A[minj][1]) minj=j;
    }
    if(i!=minj){
      swap(A[i], A[minj]);
    }
  }
}

int main(){

  int n;
  string c1[40], c2[40];

  cin>>n;
  for(int i=0;i<n;i++){
    string card;

    cin>>card;
    c1[i]=card;
    c2[i]=card;
  }

  bubbleSort(c1, n);
  selectionSort(c2, n);

  for(int i=0;i<n;i++){
    cout<<(i?" ":"");
    cout<<c1[i];
  }
  cout<<endl<<"Stable"<<endl;

  for(int i=0;i<n;i++){
    cout<<(i?" ":"");
    cout<<c2[i];
  }
  cout<<endl;

  bool flag=true;
  for(int i=0;i<n;i++){
    if(c1[i]!=c2[i]) flag=false;
  }
  if(flag) cout<<"Stable"<<endl;
  else cout<<"Not stable"<<endl;

  return 0;
}




Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=300009;
const int MOD=1e9+7;
ll a[N],n,ans;
int main() {
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<60;i++) {
        ll x=0;
        for(int j=0;j<n;j++) if((a[j]>>i)&1) x++;
        ll t=x*(n-x)%MOD;
        for(int j=0;j<i;j++) t=(t<<1)%MOD;
        ans=(ans+t)%MOD;
    }
    cout<<ans<<endl;
    return 0;
}

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

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

using namespace std;

const int inf = 1000000000 + 7;
const int N = 1e6 + 5;

typedef long long ll;

int a, b, n;
vector <int> v;
string ans;

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

    if(a <= b)
    {
        cout << "Impossible" << endl;
        fflush(stdout);
        exit(0);
    }

    v.pb(0);
    n = a + b;

    for(int i = 1; i < n; i ++)
    {
        if(v.empty())
        {
            v.pb(i);
            continue;
        }
        cout << "? " << v.back() << " " << i << endl;
        fflush(stdout);
        char c;
        cin >> c;
        if(c == 'N')
            v.pop_back();
        else
            v.pb(i);
    }

    ans = "!";

    for(int i = 0; i < n; i ++)
    {
        cout << "? " << v.back() << " " << i << endl;
        fflush(stdout);
        char c;
        cin >> c;
        if(c == 'N')
            ans += '0';
        else
            ans += '1';
    }
    cout << ans << endl;
    fflush(stdout);
}


Measured memory_bytes: 724
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let s: Vec<char> = sc.chars();
    if s[2] == s[3] && s[4] == s[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

const int MOD = 1e9 + 7;

ll pow_mod(ll n, ll k, ll m) {
  if (k == 0) {
    return 1;
  } else if (k % 2 == 1) {
    return pow_mod(n, k - 1, m) * n % m;
  } else {
    ll t = pow_mod(n, k / 2, m);
    return t * t % m;
  }
}

ll comb(ll n, ll r) {
  ll a = 1, b = 1;
  for (int i = 0; i < r; i++) {
    a = a * (n - i) % MOD;
    b *= i + 1;
    b %= MOD;
  }
  return a * pow_mod(b, MOD - 2, MOD) % MOD;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = pow_mod(2, n, MOD);
  ans -= 1;
  ans -= comb(n, a);
  if (ans < 0) ans += MOD;
  ans -= comb(n, b);
  if (ans < 0) ans += MOD;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int n;

typedef long long LL;

const LL mod = 1e9 + 7;
const int maxn = 1e6 + 5;
LL dp[maxn];
LL pre[maxn];
int main(){
    cin >> n;
    dp[1] = n;
    pre[1] = n;
    dp[2] = 1LL * n * n % mod;
    pre[2] = (dp[1] + dp[2]) % mod;
    dp[3] = dp[2] + 1LL * (n - 1) * (n - 1) + (n - 1);
    dp[3] %= mod;
    pre[3] = (pre[2] + dp[3]) % mod;
    for(int i = 4;i <= n;i++){
        dp[i] = dp[i - 1];
        dp[i] += 1LL * (n - 1) * (n - 1);
        dp[i] += pre[i - 3];
        dp[i] += (n + 2 - i);
        dp[i] %= mod;
        pre[i] = (pre[i - 1] + dp[i]) % mod;
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string A,B;
  cin >> A >> B;
  string C;
  C=A+B;
  int D=sqrt(stoi(C));
  if(D*D==stoi(C)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define db double
#define lowbit(p) (p&(-p))
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define A first
#define B second
using namespace std;
void read(int &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void read(ll &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void Min(int &x,int y){
	if (x>y)x=y;
}
void Max(int &x,int y){
	if (x<y)x=y;
}
void Min(ll &x,ll y){
	if (x>y)x=y;
}
void Max(ll &x,ll y){
	if (x<y)x=y;
}
/*
题意:
有一棵树,每个节点的权值v_x都要满足v_fa[x]<=v_x<=v_fa[x]+d

要求在v_x*p_x总和小于等于C
然后要所有节点的v_x的值最大
*/
#define M 55
struct ed{
	int x,nx;	
}e[M];
int nx[M],ecnt=1,fa[M];
void add(int x,int y){
	e[ecnt]=(ed){y,nx[x]};
	nx[x]=ecnt++;
}
struct node{
	ll cost,val,num;
}a[M];
ll v[M],V,d,dp[M*M*M];
int cnt[M],tot,n;
#define inf 1000000000
int m;
ll sz[M];
void dfs(int f,int x){
	cnt[x]=1;
	for (int i=nx[x];i;i=e[i].nx)if (e[i].x!=f){
		dfs(x,e[i].x);
		cnt[x]+=cnt[e[i].x];
		v[x]+=v[e[i].x];
	}
//	printf("%d %lld %d\n",x,v[x],cnt[x]);
	if (f)a[++tot]=(node){v[x],cnt[x],d};
				      //  cost  val  num
}
//多重背包
/*
容量范围在1e9
不过物品个数很少..?

那么问题就转化成
50种物品的多重背包
容量权值还有价值都是1e9的

看了题解
靠
好厉害


struct node{
	ll cost,val,num;
}a[M];
*/
bool cmp(node a,node b){
	//不会爆longlong
	return a.val*b.cost>b.val*a.cost;
}
ll chk(ll V){
	ll res=0;
	int i;
	ll tmp;
	for (i=1;i<=n;i++){
		tmp=min(sz[i],V/a[i].cost);
		res+=tmp*a[i].val;
		V-=a[i].cost*tmp;
	}
	return res;
}
void cal(){
	sort(a+1,a+tot+1,cmp);
	int i,j,k;
	m=0;
	for (i=1;i<=tot;i++){
//		printf("%lld ",a[i].num);
		sz[i]=max(0ll,a[i].num-50);
		Min(a[i].num,50);
		m+=a[i].num*a[i].val;
//		printf("   %lld %lld\n",a[i].num,sz[i]);
	}
//	printf("m=%d\n",m);
	for (i=1;i<=m;i++){
		dp[i]=V+1;
	}
	for (i=1;i<=tot;i++){
//		printf("i=%d num=%lld cost=%lld val=%lld\n",i,a[i].num,a[i].cost,a[i].val);
		for (k=m;k>=0;k--)if (dp[k]<=V){
			for (j=1;j<=a[i].num&&k+j*a[i].val<=m;j++){
//				nk=j*a[i].val+k;
				Min(dp[k+j*a[i].val],dp[k]+j*a[i].cost);
			}
		}
	}
	ll res=0;
//	printf("m=%d\n",m);
	for (i=0;i<=m;i++)if (dp[i]<=V){
//		printf("dp[%d]=%lld\n",i,dp[i]);
		Max(res,i+chk(V-dp[i]));
	}
	printf("%lld\n",res);
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
//	freopen("1.in","r",stdin);
	read(n); read(V); read(d);
	int i;
	read(v[1]);
	for (i=2;i<=n;i++){
		read(v[i]);
		read(fa[i]);
		add(fa[i],i);
	}
	dfs(0,1);
	a[++tot]=(node){v[1],cnt[1],V};
	cal();
	return 0;
}

Measured memory_bytes: 768
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        int N = r.i();
        long[] a = r.ll();
        long z = 0;
        for(long i : a)
            z += i;
        long min = Long.MAX_VALUE;
        for(int i = 0; i < N-1; i++){
            z -= 2*a[i];
            long zp = Math.abs(z);
            if(zp < min)
                min = zp;
        }
        println(min);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 51736
#include<stdio.h>
int main()
{
	
	int H,A,sum = 0,index, temp;
	scanf("%d%d",&H,&A);
	for(index =0; index<A; index++)
	{
		scanf("%d",&temp);
		sum = sum + temp;
	}
	if(sum >= H)
	{
		printf("Yes\n");
	}
	else
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define MOD 1000000007
#define MOD2 998244353

ll f(const vector<pll>& L, ll length, ll level){
   if(level == 0){
       //assert(1 <= length);
       return 1;
   } 
   ll res = 0;

   if(length == 1){
       return 0;
   }
   --length;

   if(length <= L[level-1].first){
       return f(L, length, level-1);
   }
   length -= L[level - 1].first;
   res += L[level - 1].second;

   if(length == 1){
       return res + 1;
   }
   --length;
   ++res;

   if(length <= L[level - 1].first){
       return res + f(L, length, level-1);
   }   
   length -= L[level - 1].first;
   res += L[level - 1].second;

   //assert(length <= 1);
   return res;
}

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

    ll N, X;
    cin >> N >> X;
    vector<pair<ll, ll>> L(N + 1);
    L[0] = {1, 1};
    for(ll i = 1; i<L.size();i++){
        L[i].first = L[i-1].first * 2 + 3;
        L[i].second = L[i-1].second * 2 + 1;
    }
    cout << f(L, X ,N) << endl;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstring>
#include<cstdio>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (1 ? 1e9 + 7 : 998244353);
const int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
ll a, b, c, d, e, f, n, T;




int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> a;
	if (a % 2 == 0 || a % 5 == 0)cout << -1 << endl;
	else
	{
		b = 7;
		c = 1;
		while (b % a != 0)
		{
			b %= a;
			b *= 10;
			b += 7;
			c++;
		}
		cout << c << endl;
	}
}



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

using namespace std;

int main()
{
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    int in = 1,res=0;
    while (in <b){

        in += a - 1;
        res += 1;


    }
    cout << res ;
    return 0;
}


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

void Main() {
  int n;
  cin >> n;
  set<int> s;
  rep(i,n) {
    int x;
    R x;
    if(s.count(x)) s.erase(x);
    else s.in(x);
  }
  pr(s.size());
}

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


Measured memory_bytes: 4992