akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 2e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

int k, n, ans;
int a[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> k >> n;
    ForE(i, 1, n){
        cin >> a[i];
        ans += a[i];
    }
    int mx = a[1] + k - a[n];
    ForE(i, 2, n){
        mx = max(mx, a[i] - a[i - 1]);
    }
    cout << k - mx;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

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

int main(){
  int a,b;
  cin >> a >> b;
  
  int x = b - a;
  
  int y = 0;
  
  for(int i=1; i<x+1; i++){
    y = y + i;
  }
  
  cout << y - b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  
  int j, n, m;
  scanf("%d", &n);
  
  int a[n];
  for(int i = 0;i < n;i++){
  	scanf("%d", &a[i]);
  }
  
  j = 0;
  m = 1;
  while(1){
    for(int i = j;i < n;i++){
      if(a[i] == m){
        m++;
        j = i;
        continue;
      }
  	}
    break;
  }
  
  if(m != 1){
  	printf("%d\n", n - m + 1);
  }
  else{
    printf("-1\n");
  }

  return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
using namespace std;
int mx,a[200010];
int main()
{
    int k,n,i;
    cin>>k>>n;
    for(i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    mx=a[1]+k-a[n];
    for(i=2;i<=n;i++)
     if(a[i]-a[i-1]>mx) 
      mx=a[i]-a[i-1];
    cout<<k-mx;
}


Measured memory_bytes: 1024
import math

N = int(input())
list_N = [list(map(int, input().split())) for _ in range(N)]

frac = math.factorial(N)
route_count = math.factorial(N-1)
sum = 0

for i in range(N):
  for j in range(N):
    if i != j:
      sum += math.sqrt((list_N[i][0]-list_N[j][0])**2+(list_N[i][1]-list_N[j][1])**2)
      #print(sum)

print(sum/N)

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

const long long int MOD = 1000000007;
const long long int pow2_20 = 1 << 20;
const int MAX_K = 202020;
//#define MOD 1000000007
//#define MAX_K 202020


int a, b;
long long int n;
long long int inv[MAX_K], com[MAX_K];

void COMinit(long long int n){
  com[0] = 1LL;
  inv[1] = 1LL;
  for(int i = 2; i < MAX_K; i++){
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
  }
  for(int i = 1; i < MAX_K; i++){
    com[i] = com[i - 1] * (n - i + 1) % MOD * inv[i] % MOD;
  }
}

long long int COM(int k){
  return com[k];
}


int main(){
  cin >> n >> a >> b;
  long long int res = 1;
  if(n >= pow2_20){
    rep(i, n / 20){
      res *= pow2_20;
      res %= MOD;
    }
    rep(i, n % 20){
      res *= 2;
      res %= MOD;
    }
  }else{
    rep(i, n){
      res *= 2;
      res %= MOD;
    }
  }
  
  COMinit(n);
  res += MOD - COM(a);
  res %= MOD;
  res += MOD - COM(b);
  res %= MOD;
  res--;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3456
# ABC068C - Cat Snuke and a Voyage (ARC079C)
import sys
input = sys.stdin.readline

def main():
    N, M = input().split()
    A = tuple(input().split() for _ in range(int(M)))
    S, D = set(), set()  # start, destination
    for a, b in A:
        if a == "1":
            S |= {b}
        if b == N:
            D |= {a}
    flg = S & D  # if the same X in both S & D -> possible
    print("POSSIBLE" if flg else "IMPOSSIBLE")


if __name__ == "__main__":
    main()

Measured memory_bytes: 66180
#include <stdio.h>

int main(void);

int main()
{
  unsigned int a,b,tmp;
  a = b = tmp = 0;
  
  scanf("%d %d", &a, &b);
  tmp = (a*b) % 2;
  if(tmp == 0){
    printf("Even\n");
  }else{
    printf("Odd\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {
    
    
    int a,b,x;
    cin>>a>>b>>x;

    if(a>x)fin("NO");
    else if(b>= x-a){
        fin("YES");
    } else fin("NO");
    
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()

    ans = 0
    for A in range(1,N+1):
        for B in range(1,N+1):
            if A*B > N:
                break

            C = N - A*B
            if C > 0:
                ans += 1
    
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 67812
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int x;
  cin >> x;
  int a;
  cin >> a;
  if (x < a) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
  return 0;

  return 0;
}


Measured memory_bytes: 888
# AOJ 0137 Middle-Square Method
# Python3 2018.6.17 bal4u

for i in range(int(input())):
	print('Case ', i+1, ':', sep='')
	s = int(input())
	for j in range(10):
		s = (s * s // 100) % 10000
		print(s)


Measured memory_bytes: 5584
//#define _USE_MATH_DEFINES
//#include <cmath>

#include <iostream>


using namespace std;


int A1, A2, A3;


int main()
{

	cin >> A1;
	cin >> A2;
	cin >> A3;

	int sum = A1 + A2 + A3;

	cout << (sum > 21? "bust":"win") << endl;

	return 0;
}


Measured memory_bytes: 256
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    A, B, C, K = map(int, input().split())

    if A >= K:
        print(K)
        return
    ans = A
    K -= (A + B)
    if K > 0:
        ans -= K
    print(ans)


main()


Measured memory_bytes: 9180
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main() {
	int n, m, i;
	fscanf(stdin, "%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		if (i) fprintf(stdout, " ");
		if (i <= n / 2) fprintf(stdout, "%d", 0);
		else fprintf(stdout, "%d", m);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mp make_pair
const int maxn = 4e5+5;
const int MOD = 1e9+7;
#define mod(x) x % MOD
#define INF 0x3f3f3f3f

int dp[maxn];
int a[maxn];
int main(){
    int n = 0;
    while(~scanf("%d", &n)){
        for(int i = 1;i <= n;i++){
            a[i] = MOD;
        }
        for(int i = 1;i <= n;i++){
            scanf("%d",a + i);
        }
        dp[0] = 0;
        dp[1] = 0;
        dp[2] = abs(a[2] - a[1]);
        for(int i = 3;i <= n;i++){
            dp[i] = min( dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]) );
        }
        /*for(int i = 1;i <= n;i++){
            dp[i+1] = min(dp[i+1], dp[i] + abs(a[i] - a[i+1]));
            dp[i+2] = min(dp[i+2], dp[i] + abs(a[i] - a[i+2]));
        }*/
        printf("%d\n",dp[n]);
    }
    return 0;
}

Measured memory_bytes: 1024
import sys
from fractions import gcd
from functools import reduce

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def lcm(x, y):
    return x * y // gcd(x, y)


def main():
    N, M, *A = map(int, read().split())
    A = [a // 2 for a in A]

    semi_lcm = reduce(lcm, A)
    for a in A[1:]:
        semi_lcm = lcm(semi_lcm, a)
        if semi_lcm > M or semi_lcm // a % 2 == 0:
            print(0)
            return

    print((M // semi_lcm + 1) // 2)
    return


if __name__ == '__main__':
    main()


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


void main()
{
  'x'.repeat(readln.chomp.length).writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N - 1);
    for(int i = 0; i < N - 1; i++){
        cin >> B[i];
    }
    if(N == 2){
        cout << 2 * B[0] << endl;
    }
    else{
        for(int i = 0; i < N - 2; i++){
            if(B[i] >= B[i + 1]){
                if(i == 0){
                    A[i] = B[i];
                }
                if(i == N - 3){
                    A[i + 2] = B[i + 1];
                }
                A[i + 1] = B[i + 1];
            }
            else{
                if(i == 0){
                    A[i] = B[i];
                }
                if(i == N - 3){
                    A[i + 2] = B[i + 1];
                }
                A[i + 1] = B[i];
            }
        }
        int ans = 0;
        for(int i = 0; i < N; i++){
            ans += A[i]; 
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#N = 要素数　p = 配列
N = int(input())
p = list(map(int, input().split()))
#count= 番地と入力番号が一致しない数字の数
count = 0 

for i in range (N):
    if i +1 !=p[i]:
        count +=1
if(count ==0 or count == 2):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 2940
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

N,*W = map(int,read().split())

Wcum = itertools.accumulate(W)

S = sum(W)
answer = min(abs(S-x-x) for x in Wcum)
print(answer)



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

struct UnionFind {
    vector<int> data;
    int sz;
    UnionFind(int sz) : data(sz, -1), sz(sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x; sz--;
        return true;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return sz; }
};

int main() {
    int n, m; cin >> n >> m;
    vector<pair<int, int>> es(m);
    for (auto &p: es) cin >> p.first >> p.second, p.first--, p.second--;
    int cnt = 0;
    for (int i = 0; i < m; i++) {
        UnionFind uf(n);
        for (int j = 0; j < m; j++) if (i != j) {
            uf.unionSet(es[j].first, es[j].second);
        }
        if (uf.size() > 1) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
void debug(){cerr << "]" << endl;}
template<class H, class... T> void debug(H h, T... t) {
	cerr << to_string(h);
	if(sizeof...(t))
	cerr << ", ";
	debug(t...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", debug(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  double d,t,s;
  cin>>d>>t>>s;
  double m = d/s;
  if(m<=t)cout<<"Yes\n";
  else cout<<"No\n";
}



Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
pair<int,int> pii;
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fastio() ios::sync_with_stdio(0);cin.tie(0);
#define nl "\n"
#define wi(x) cerr << #x << " is " << x << nl

void solve(){
	int ans;
	rep(i,1,5){
		int a; cin>>a; if(a == 0) ans = i;
	}
	cout << ans;
}

int main(){
	fastio()
	
	int T = 1; //cin>>T;
	while(T--)solve();

	return 0;
}


Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(NULL); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif


int A, B;
int main() {
	cin >> A >> B;
	REP(i, 0, A) {
		REP(j, 0, B) {
			string a;
			cin >> a;
			if (a == "snuke") {
				cout << (char)('A' + j) << i + 1 << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    ll t; double a; cin>>t>>a;
    vector<double> h(n);
    rep(i,n) cin>>h[i];
    double nin=1e10;
    ll res=-1;
    rep(i,n){
        double tmp=t-h[i]*0.006;
        if(abs(tmp-a)<nin){
            nin=abs(tmp-a);
            res=i+1;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	double t;
	int total = 0;
	int next;

	cin >> a;
	cin >> b;
	cin >> t;

	next = a;
	t += 0.5;

	while (t > next) {
		total += b;
		next += a;
	}

    cout << total; 
}


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

int main() {
  int N,M;
  cin >> N;
  vector<string>s(N);
  vector<string>t(M);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
  }
  
  vector<int>count(N,0);
  for (int i = 0; i < N; i++) {
    for (int j = i; j < N; j++) {
      if (s.at(i) == s.at(j)){
        count.at(i)++;
      }
      if (j == N-1){
        for (int k = 0; k < M; k++) {
          if (s.at(i) == t.at(k)){
            count.at(i)--;
          }
        }
      }
    }
  }
  sort(count.begin(), count.end());
  
  if (count.at(N-1) < 0){
    cout << 0 << endl;
  }
  else {
     cout << count.at(N-1) << endl;
  }
}
  

Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}
ll n,m;
ll c;

vector<ll> v[200001];
ll vis[200001];
void dfs(ll node){
	vis[node]=1;
	c++;

	
	for(auto i:v[node]){
		if(vis[i]==0){
			

			dfs(i);

		}
	}
}

void solve(){
	
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		ll a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);

	}
	ll cc=INT_MIN;
	for(ll i=1;i<=n;i++){
		if(vis[i]==0){
			c=0;

			dfs(i);
			cc=max(cc,c);


		}

	}
	cout<<cc<<endl;












return;
}




int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    ll t;
    t=1;
   //cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 22384
#include<iostream>
using namespace std;
 
int main(){
  int x,y;
  
  cin >> x >> y;
  while (x > 0 or y > 0){
      if (x > y){
          int z;
          z = y;
          y = x;
          x = z;
      }
      cout << x << " " << y << endl;
      cin >> x >> y;
  }
  
      

  return 0;		 
}
		   


Measured memory_bytes: 2984
#include<stdio.h>
int main()
{
    int i,p=0,f=0;
    char ch[7]={1,3,5,7,8,10,12},ch1[4]={4,6,9,11},ch2[1]={2};
    int a,b;
    scanf("%d%d",&a,&b);
    for(i=0;i<7;i++)
    {
        if(ch[i]==a){
            p=1;
            break;
        }
    }
    for(i=0;i<4;i++)
    {
        if(ch1[i]==a)
        {
            p=2;
            break;
        }
    }
    for(i=0;i<1;i++)
    {
        if(ch2[i]==a)
        {
            p=3;
            break;
        }
    }
    if(p==1){
    for(i=0;i<7;i++)
    {
        if(ch[i]==b)
        {
            f=1;
            break;
        }
    }}
    else if(p==2)
    {
        for(i=0;i<4;i++)
        {
            if(ch1[i]==b)
            {
                f=1;
                break;
            }
        }
    }
    else if(p==3)
    {
        for(i=0;i<1;i++)
        {
            if(ch2[i]==b)
            {
                f=1;
                break;
            }
        }
    }
    if(f==1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    vector<string> s(n); cin >> s;

    function<bool(int, int)> solve = [&](int dy, int dx) {
        FOR(i, 0, n)FOR(j, 0, n) {
            if (s[(i - dy + n) % n][(j - dx + n) % n]
                != s[(j - dy + n) % n][(i - dx + n) % n])
                return false;
        }
        return true;
    };

    int ans = 0;
    FOR(i, 0, n) {
        if (solve(0, i))ans += n;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[][] a = getIntArr(in, n, 3);
		long r = solve(n, a);
		System.out.println(r);
		in.close();
	}

	private static long solve(int n, int[][] a) {
		Arrays.sort(a, new Comparator<int[]>() {
			@Override
			public int compare(int[] o1, int[] o2) {
				return Integer.compare(o1[0] + o1[1], o2[0] + o2[1]);
			}
		});

		long[][] dp = new long[n + 1][20101];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 20101; j++) {
				dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j]);
				if (j <= a[i][1]) {
					dp[i + 1][j + a[i][0]] = Math.max(dp[i + 1][j + a[i][0]], dp[i][j] + a[i][2]);
				}
			}
		}
		long max = 0;
		for (int i = 0; i < 20101; i++) {
			max = Math.max(max, dp[n][i]);
		}
		return max;
	}

	static String str(int[] a) {
		String[] str = new String[a.length];
		for (int i = 0; i < a.length; i++) {
			str[i] = a[i] + "";
		}
		return String.join(" ", str);
	}

	static int[] getIntArr(Scanner in, int size) {
		int[] arr = new int[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.nextInt();
		}
		return arr;
	}

	static int[][] getIntArr(Scanner in, int row, int col) {
		int[][] arr = new int[row][];
		for (int i = 0; i < row; i++) {
			arr[i] = getIntArr(in, col);
		}
		return arr;
	}

	static char[] getCharArr(Scanner in, int size) {
		char[] arr = in.next().toCharArray();
		return arr;
	}

	static String[] getStringArr(Scanner in, int size) {
		String[] arr = new String[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.next();
		}
		return arr;
	}

	static Map<Integer, List<Integer>> getEdges(Scanner in, int size, boolean directed) {
		Map<Integer, List<Integer>> edges = new HashMap<>();
		for (int i = 0; i < size; i++) {
			int from = in.nextInt();
			int to = in.nextInt();
			if (!edges.containsKey(from)) {
				edges.put(from, new ArrayList<Integer>());
			}
			edges.get(from).add(to);
			if (!directed) {
				if (!edges.containsKey(to)) {
					edges.put(to, new ArrayList<Integer>());
				}
				edges.get(to).add(from);
			}

		}
		return edges;
	}
}


Measured memory_bytes: 245540
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static int t;
        static int pos;

        static void Main(string[] args)
        {
            //[summary]C - Traveling
            int n = int.Parse(Console.ReadLine());
            t = 0;
            pos = 0;

            if (IsGoaled(n))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static bool IsGoaled(int n)
        {
            for (int i = 0; i < n; i++)
            {
                if (!CanReach())
                {
                    return false;
                }
            }

            return true;
        }

        static bool CanReach()
        {
            var line = ReadLine();
            int nextT = line[0];
            int nextPos = line[1] + line[2];

            int distance = nextPos - pos;
            int time = nextT - t;

            if (time >= distance && (time - distance) % 2 == 0)
            {
                t = nextT;
                pos = nextPos;
                return true;
            }
            else
            {
                return false;
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13392
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void) {

	int a, b, c;

	cin >> a >> b >> c;

	if (a + b >= c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
l = input().split()
a = int(l[0])
b = int(l[1])
c = int(l[2])

if a < b and b < c:
    print(a,b,c)
elif a < c and c < b:
    print(a,c,b)
elif b < a and a < c:
    print(b,a,c)
elif b < c and c < a:
    print(b,c,a)
elif c < a and a < b:
    print(c,a,b)
elif c < b and b < a:
    print(c,b,a)
elif a == b and b < c:
    print(a,b,c)
elif a == c and c < b:
    print(a,c,b)
elif b == c and c < a:
    print(b,c,a)



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

using namespace std;

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < v.size();++i)

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

int main(){
    string s;
    cin>>s;
    REP(i,s.size()-8){
        cout<<s[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long long x, long long y) {
   if (x % y == 0) {
       return(y);
   } else {
       return(gcd(y, x%y));
   }
}
 
long long lcm(long long x, long long y) {
   return x * y / gcd(x, y);
}
 
int main() {
    long long a, b, c, d, cd;
    long long ans, e, f, g;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    e = (b / c) - ((a - 1) / c);
    f = (b / d) - ((a - 1) / d);
    cd = lcm(c, d);
    g = (b / cd) - ((a - 1) / cd);
    ans = b - a + 1 - (e + f - g);
    printf("%lld\n", ans);
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define wi(t) int t;cin>>t;while(t--)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve()
    {
     ll int d,l,r,ans=0;
     cin>>l>>r>>d;
     for(int i=l;i<=r;i++)
     {
         if(i%d==0)
         ans++;
     }
     cout<<ans;
  
  
  
  
    }

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

   // wi(t)
    {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}






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

#define MOD 1000000007
#define ll long long int 
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    off;

    int n;cin>>n;

    ll arr[n];
    for (int i = 0; i < n; ++i) cin>>arr[i];

    for (int i = 1; i < n; ++i) arr[i] += arr[i-1];

    ll dp[n][n];

    for (int i = 0; i < n; ++i) dp[i][i] = 0;

    for (int j = 2; j <= n; ++j){
        for (int i = 0; i < n; ++i){
            ll l = i, r= i+j-1;
            if(r<n){
                dp[i][r] = 9223372036854775807;
                for (int k = l; k < r; ++k)
                {
                    ll cost = arr[r]+dp[l][k]+dp[k+1][r];
                    if(l>0)
                        cost -= arr[l-1];
                    dp[i][r] = min(dp[i][r], cost);
                }
            }
        }
    }

    cout<<dp[0][n-1];
    return 0;
} 



Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<ll> a(N), b(N);
  ll A = 0, B = 0;
  REP(i, N){
    cin >> a[i];
    A += a[i];
  }
  REP(i, N){
    cin >> b[i];
    B += b[i];
  }
  ll res = B - A;
  ll cntA = 0, cntB = 0;
  REP(i, N){
    if(a[i] > b[i]){
      cntB += a[i] - b[i];
    }else{
      cntA += (b[i]-a[i]+1)/2;
    }
  }
  if(res >= max(cntA, cntB)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3760
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define slow ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define set_bits(x) __builtin_popcount(x)
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846
#define mod 1000000007

#include"bits/stdc++.h"
using namespace std;

#define int long long

int32_t main(){
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> r(n+1, 0); 
    vector<int> c(m+1, 0);
    int x[t], y[t];
    map<pair<int,int>, int> have;
    for( int i = 0; i < t; i++ ){
        int u, v;
        cin >> u >> v;
        r[u]++;
        c[v]++;
        x[i] = u;
        y[i] = v;
        have[make_pair(u, v)] = 1;
    }
    int MaxC = 0, MaxR = 0;
    int C = -1, R = -1;
    int ans = 0;
    for( int i = 1; i <= n; i++ ){
        if( r[i] > MaxR ){
            MaxR = r[i];
            R = i;
        }
    }
    for( int i = 1; i <= m; i++ ){
        if( c[i] > MaxC ){
            MaxC = c[i];
            C = i;
        }
    }
    //watch4(R, C, MaxR, MaxC);
    if( C != -1 && R != -1 ){
        ans = r[R] + c[C];
        if( have.count(make_pair(R, C)) == 1 ){
            for( int i = 1; i <= m; i++ ){
                if( i != C && MaxC == c[i] && have.count(make_pair(R, i)) == 0 ){
                    cout << ans;
                    return 0;
                }
            }
            for( int i = 1; i <= n; i++ ){
                if( i != R && MaxR == r[i] && have.count(make_pair(i, C)) == 0 ){
                    cout << ans;
                    return 0;
                }
            }
            ans--;
        }
    }
    else if( C == -1 && R != -1 ){
        ans = r[R];
    }
    else if( R == -1 && C != -1 ){
        ans = c[C];
    }
    cout << ans;
}

Measured memory_bytes: 31484
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

int main() {
  int w, h;
  while (cin >> w >> h, w) {
    vector<vector<int>> W(2 * h - 1);
    vector<vector<int>> ret(w, vector<int>(h, 0));
    for (int i = 0; i < 2 * h - 1; ++i) {
      int j_range = i % 2 == 0 ? w - 1 : w;
      for (int j = 0; j < j_range; ++j) {
        int tmp;
        cin >> tmp;
        W[i].push_back(tmp);
      }
    }

    queue<PII> que;
    ret[0][0] = 1;
    que.push(make_pair(0, 0));
    while (!que.empty()) {
      PII p = que.front(); que.pop();
      int wy[4] = {p.second * 2 + 1, p.second * 2, p.second * 2 - 1,
                   p.second * 2},
          wx[4] = {p.first, p.first, p.first, p.first - 1};
      for (int i = 0; i < 4; ++i) {
        int nx = p.first + dx[i], ny = p.second + dy[i];
        if (0 <= nx && nx < w && 0 <= ny && ny < h && ret[nx][ny] == 0) {
          if (W[wy[i]][wx[i]] != 1) {
            que.push(make_pair(nx, ny));
            ret[nx][ny] = ret[p.first][p.second] + 1;
          }
        }
      }
    }
    cout << ret[w - 1][h - 1] << endl;
  }
}

Measured memory_bytes: 3020
n, m = map(int, input().split())

ans = [-1] * n
flag = True

for i in range(m):
    s, c = map(int, input().split())
    if ans[s - 1] == -1:
        ans[s - 1] = c
    elif ans[s - 1] != c:
        flag = False
        break

if n > 1 and ans[0] == 0:
    flag = False

if not flag:
    print(-1)
    exit()

ans = [0 if i == -1 else i for i in ans]
if n > 1 and ans[0] == 0:
    ans[0] = 1
ans = ''.join(map(str, ans))
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main() {
	int N, four=0, two=0, others=0, i, a;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &a);
		if (a % 4 == 0)four++;
		else if(a%2==0)two++;
		else others++;
	}
	if((four-others)>=0)printf("Yes");
	else if(((four-others)>=-1)&&two==0)printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n, x, max int
	var s string
	fmt.Scan(&n, &s)
	for _, v := range s {
		if string(v) == "I" {
			x++
		} else {
			x--
		}
		if max < x {
			max = x
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

void mainp()
{
	int r;
	double g;
	cin>>r>>g;
	cout<<(g*2-r)<<endl;
}

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

	mainp();
	return 0;
}


Measured memory_bytes: 256
// AOJ 0164
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int main(void)
{
	int n;
	while (cin >> n, n){
		vector <int> kotori(n);
		int kotori_cnt = 0, honoka = 32;
		for (int i = 0; i < n; i++){
			cin >> kotori[i];
		}
		while (honoka > 0){
			honoka -= ((honoka - 1) % 5);
			cout << honoka << endl;
				// kotori
			honoka -= (kotori[kotori_cnt % n]);
			// cout << "*** DEBUG " << kotori_cnt << endl;
			kotori_cnt++;
			if (honoka <= 0) break;
			cout << honoka << endl;
		}
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void)
{
    int n;
    scanf("%d", &n);
    if (n >= 30)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1664
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI = 3.141592653589793;

void solve()
{
	string s;
	cin >> s;
	int a=s.size(),b=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='A') a = min(a,i);
		if(s[i]=='Z') b = max(b,i);
	}
	cout << max(b-a+1,0LL);
}

int32_t main()
{
	FastIO;
	Fast_D;
	solve();
	return 0;
}


Measured memory_bytes: 3780
#include<stdio.h>
#include<algorithm>
using std::sort;
#define rpt(n) for(register int ttxyc=0;ttxyc<(n);++ttxyc)//宏定义
inline int read()//快读
{
	register int x=0,t=0;register char c=getchar();for(;c<'0'||c>'9';t|=c=='-',c=getchar());
	for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+(c^48),c=getchar());return t?-x:x;
}
int n,m,x[100000],a[100000],ans;
main()
{
	n=read();m=read();rpt(m)x[ttxyc]=read();
	sort(x,x+m);
	rpt(m-1)a[ttxyc]=x[ttxyc+1]-x[ttxyc];
	sort(a,a+m-1);
	rpt(m-n)ans+=a[ttxyc];
	printf("%d",ans);
}/**/

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

using namespace std;
#define rep(i, N) for(int i=0;i<int(N);++i)
#define rep1(i, N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll X;
    cin >> X;
    ll cnt = 0;
    ll tmp = 100;
    while(tmp < X){
        tmp = tmp + tmp / 100;
        cnt++;
    }
    cout << cnt << endl;
}

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

int main(int argc, char const *argv[])
{
    int x, y;
    while(1) {
        cin >> x >> y;
        
        if(x == 0 && y == 0)
            break;

        if(x <= y) {
            cout << x << ' ' << y << endl;
        } else {
            cout << y << ' ' << x << endl;
        } 
    }
    
    return 0;
}




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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int k;
        cin>>k;
        queue<long long>q;
        vector<long long>ans;
        for(int i=1;i<=9;i++){
            q.push(i);
            ans.push_back(i);
        }
        if(k<=ans.size()){
            cout<<ans[k-1];
            return 0;
        }
        while(1){
            if(k<=ans.size()){
                cout<<ans[k-1];
                break;
            }
            long long x=q.front();
            q.pop();
            for(int i=-1;i<=1;i++){
                int y=x%10;
                if(y+i<0 || y+i>9)
                    continue;
                long long nx=(x*10)+(y+i);
                ans.push_back(nx);
                q.push(nx);
            }
        }
//        cout<<"\n";
//        for(int i=0;i<20;i++)
//            cout<<ans[i]<<" ";
        return 0;
    }


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  LL sum = 0;
  FOR (i, k + 1, n + 1) {
    sum += (n / i) * (i - k);
    if (k == 0) sum += n % i;
    else if (0 < k && k <= n % i) sum +=  (n % i) - k + 1;
  }

  printf("%lld\n", sum);
}


Measured memory_bytes: 256