akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


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

  REP(i, max(a, b)){
    cout << min(a, b);
  }
  cout << endl;

  return 0;
}

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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

  bool same(int x , int y){
    x = root(x) , y = root(y);
    return x == y;
  }

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm


int main(){
  faster();
  string s;
  cin >> s;
  if(s == "AAA" || s == "BBB"){
    cout << "No";
    return 0;
  }
  cout << "Yes";
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}



Measured memory_bytes: 256
a = list(map(int,input().split()))

#K枚の優先順位を選ぶ
#＋１の枚数分だけ選択、KからAを引く、総和のリストにA枚分の+1を追加
# K<Aのとき、K枚分だけリストにAを追加、KからKを引く
#0の枚数分だけ選択、KからBを引く、総和のリストにB枚分の0を追加

#・・・総和のリストないの総和を計算する
sum_num = []
card_num = [1,0,-1]
for i,card in enumerate(a[0:3]):
  if card > a[3]:
    sum_num.append(a[3] * card_num[i])
    a[3] -= a[3]
  else:
    sum_num.append(card * card_num[i])
    a[3] -= card
print(sum(sum_num))


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

using namespace std;

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

    if(s=="Sunny"){
        cout<<"Cloudy";
    }
    else if(s=="Cloudy"){
        cout<<"Rainy";
    }
    else{
        cout<<"Sunny";
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>

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

using namespace std;

int main(){
	int A, B, C;
	int count = 0;
	scanf("%d %d %d", &A, &B, &C);
	int max = A;
	if (B > max)max = B;
	if (C > max)max = C;
	count = max * 3 - A - B - C;
	if (count % 2 == 0)printf("%d", count / 2);
	else printf("%d", (count + 3) / 2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int inf=1e9;

signed main(){
	int n;cin>>n;
	vector<int> p(n);
	for(auto&& w:p){cin>>w;w--;}
	vector<int> v(n);
	for(int i=0;i<n;i++){v.at(p.at(i))=i;}
	int cnt=1,mx=0;
	for(int i=1;i<n;i++){
		if(v.at(i)>v.at(i-1))cnt++;
		else{ mx=max(mx,cnt);cnt=1;}
	}
	mx=max(mx,cnt);
	cout<<n-mx<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
using namespace std;


ll gcd(ll a, ll b)   //Function to find gcd of two numbers
{
    if (a == 0)
    return b;
    return gcd(b % a, a);
}

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

    int s,d,t;
    cin>>d>>t>>s;

   double x = (double)d / s;

   if(x<=t)
   cout<<"Yes"<<endl;
   else
   {
       cout<<"No"<<endl;
   }
   
    return 0;
}

Measured memory_bytes: 3496
#include<stdio.h>
#include<stdlib.h>

struct node{
	struct node *right;
	struct node *left;
	struct node *parent;
	int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum (Node x ){

}

Node treeSearch (Node u, int k ){
	if (u == NIL || u->key == k ) return u;
	else
	if (u->key < k ){
		return treeSearch (u->right, k );
	}else{
		return treeSearch (u->left, k );
	} // end if 
}

Node treeSuccessor (Node x ){

}

void treeDelete (Node z ){
	Node y;	// node to be deleted
	Node x;	// child of y
}

void insert (int k ){
	Node y = NIL;
	Node x = root;
	Node z;

	z = malloc (sizeof (struct node ) );
	z->key = k;
	z->left = NIL;
	z->right = NIL;

	if (x == NIL ){
		root = z;
	}else{
		do{
			if (x->key < k ){
				y = x->right;
			}else{
				y = x->left;
			} // end if

			if (y != NIL ){
				y->parent = x;
			}else{
				if (x->key < k )
					x->right = z;
				else
					x->left = z;
			} // end if
			x = y;
		}while (x != NIL ); // end while
	} // end if
}

void inorder (Node u ){
	if (u == NIL ) return;
	inorder (u->left );
	printf (" %d", u->key );
	inorder (u->right );
}

void preorder (Node u ){
	if (u == NIL ) return;
	printf (" %d", u->key );
	preorder (u->left );
	preorder (u->right );
}

int main()
{
	int n, i, x;
	char com[20];

	root = NIL;
	scanf ("%d", &n );
	for (i = 0; i < n; i++ ){
		scanf ("%s", com );
		if (com[0] == 'i' ){	// case insert 
			scanf ("%d", &x );
			insert (x );
		}else
		if (com[0] == 'p' ){ // case print
			inorder (root );
			printf ("\n" );
			preorder (root );
			printf ("\n" );
		}else
		if (com[0] == 'f' ){	// case find
			scanf ("%d", &x );
			Node t = treeSearch (root, x );
			if ( t != NIL ) printf ("yes\n" );
			else printf ("no\n" );
		} // end if
	} // end for

	return 0;
}



Measured memory_bytes: 20456
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(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);
  //  ABC110B - 1 Dimensional World's Tale
  int N, M, X, Y; cin >> N >> M >> X >> Y;
  int maxX = -100, minY = 100;
  REP(i, N){
    int tmp; cin >> tmp;
    maxX = max(maxX, tmp);
  }
  maxX = max(maxX, X);
  REP(i, M){
    int tmp; cin >> tmp;
    minY = min(minY, tmp);
  }
  minY = min(minY, Y);
  if(maxX < minY){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }
}

Measured memory_bytes: 256
n = gets.chomp.to_i

n.times do
  l = gets.chomp.split
  3.times do |i|
    l[i] = l[i].to_i
  end
  l.sort!
  if l[0]**2 + l[1]**2 == l[2]**2
    puts "YES"
  else
    puts "NO"
  end
end



Measured memory_bytes: 6848
#pragma GCC optimize("unroll-loops,Ofast")
#pragma GCC target("avx,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1<<18, mod = 1e9 + 7;
bool can(string s, int k) {
	if(k == 1) return true;
	for(char c = '0'; c < '2'; c++)
	for(int l = 0, p = -1, i = 0; i < s.size(); i++) {
		if(i < s.size()-k || i >= k) s[i] = c;
		if(p == s[i]) l++;
		else p = s[i], l = 1;
		if(l >= k) return true;
	}
	return false;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 1<<20; i>>=1;)
		if(ans+i <= s.size() && can(s, ans+i)) ans += i;
	cout << ans;
	return 0;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n;
int a[100001];
int b[100000];

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

	cin >> n;
	rep(i, n + 1)cin >> a[i];
	rep(i, n)cin >> b[i];

	long long ans = 0;
	rep(i,n) {
		int x = b[i];
		int y = min(x, a[i]);
		a[i] -= y;
		x -= y;

		int z = min(x, a[i + 1]);
		a[i + 1] -= z;
		x -= z;

		ans += y + z;
	}


	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <stack>

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, x, n) for (int i = x; i < n; ++i)

typedef std::vector<int> v;
typedef std::vector<std::vector<int>> vv;
typedef unsigned long long ull;

int main(void)
{
    ull a, b, n;
    scanf("%lld %lld %lld", &a, &b, &n);
    printf("%lld", a * std::min(n, b - 1) / b);
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;

const ll N = 200001;
const ll MOD = 1000000007;
const ll INF = LLONG_MAX;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl
#define space ' '
#define nl '\n'

void COUT(vector<ll>v){for(auto it:v)cout<<it<<space;cout<<nl;}
void CIN(vector<ll>&v){for(auto &it:v)cin>>it;}

bool ok(string s)
{
    string t=s;
    reverse(all(t));
    return (s==t);
}
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        string s,a,b;
        cin>>s;
        ll n=s.size();
        a=s.substr(0,n/2);
        b=s.substr((n+2)/2,n/2);
        if(ok(a)&&ok(b)&&ok(s))
            cout<<"Yes"<<nl;
        else
            cout<<"No"<<nl;
    }
}


Measured memory_bytes: 256
import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for i in b:
  ai = bisect.bisect_left(a, i)
  ci = n - bisect.bisect_right(c, i)
  ans += ai*ci
print(ans)

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

static const int MOD = 1000000007;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main(){
  long long N,A,B;
  cin>> N>>A>>B;
  long long total=0;
  total=modpow(2,N,MOD);
  total--;
  
  long long temp=1;
  for(int i=N;i>=N-A+1;i--){
    temp=temp*i%MOD;
  }
  long long temp2=1;
  for(int i=1;i<=A;i++){
    temp2=temp2*i%MOD;
  }
  temp2=modpow(temp2,MOD-2,MOD);
  temp=temp*temp2%MOD;
  
  long long temp3=1;
  for(int i=N;i>=N-B+1;i--){
    temp3=temp3*i%MOD;
  }
  long long temp4=1;
  for(int i=1;i<=B;i++){
    temp4=temp4*i%MOD;
  }
  temp4=modpow(temp4,MOD-2,MOD);
  temp3=temp3*temp4%MOD;
  
  if(total-temp-temp3<0){
    total=total+MOD;
  }
  if(total-temp-temp3<0){
    total=total+MOD;
  } 
  
  //cout<<total<<" "<<temp<<" "<<temp3<<endl;
  cout<<total-temp-temp3<<endl;

  return 0;
}




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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
  os << "[";
  REP(i, SZ(v)) {
    if (i) os << ", ";
    os << v[i];
  }
  return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
  return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

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

  ll n; cin >> n;
  ll cnt = 0;
  for(ll a=1;a<n;++a) {
    cnt += n / a - (n % a == 0);
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3644
import sys, math
from functools import lru_cache
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    s, t = [list(i) for i in zip(*[input().split() for i in range(N)])]
    t = list(map(int, t))
    k = s.index(input())
    print(sum(int(t[i]) for i in range(k+1, N)))



if __name__ == '__main__':
    main()

Measured memory_bytes: 9544
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    while (scanner.hasNext()) {
      int n = scanner.nextInt();
      if (n == 0) {
        break;
      }
      int[] za = new int[n];
      for (int ii = 0; ii < n; ii++) {
        za[ii] = scanner.nextInt();
      }
      int oo = 32;
      for (int t = 0, zac = 0; oo > 0; t++) {
        if (t % 2 == 0) {
          oo -= (oo - 1) % 5;
        } else {
          oo -= za[zac];
          zac++;
          if (zac >= za.length) {
            zac = 0;
          }
        }
        if (oo < 0) {
          oo = 0;
        }
        System.out.println(oo);
      }
    }
  }
}

Measured memory_bytes: 20840
from sys import stdin
readline = stdin.readline


def main():
    q = int(readline())
    for i in range(q):
        print(parallel_orthogonal())


def parallel_orthogonal():
    xy = map(int, readline().split())
    p0, p1, p2, p3 = [x + y * 1j for x, y in zip(*[xy] * 2)]
    if 0 == dot(p1 - p0, p3 - p2):
        return 1
    if 0 == cross(p1 - p0, p3 - p2):
        return 2
    return 0


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def cross(a, b):
    return a.real * b.imag - a.imag * b.real
main()

Measured memory_bytes: 6752
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl            '\n'
#define mem(a, n)       memset(a, n, sizeof(a))
#define repeat(n)       for(int i=0; i<n; i++)
#define Unique(n)       (n).erase(unique(all(n)), (n).end())
#define isPowerOfTwo(n) (n && !(n & (n - 1)))
#define NumofDigits(n)  ((int)log10(n)+1)
#define all(a)          a.begin(), a.end()

unsigned long long pow(long long base, long long power);

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

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

/*
    Special functions:
        find_by_order(k) --> returns iterator to the kth largest element counting from 0
        order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

int main(){
    quicken();

    long long n, m, a, r, c, h, ans;
    string str; cin >> n;
    m = a = r = c = h = ans = 0;
    while(n--){
        cin >> str;
        if(str[0]=='M') m++;
        else if(str[0]=='A') a++;
        else if(str[0]=='R') r++;
        else if(str[0]=='C') c++;
        else if(str[0]=='H') h++;
    }

    ans += m*a*r;
    ans += m*a*c;
    ans += m*a*h;
    ans += m*r*c;
    ans += m*r*h;
    ans += m*c*h;
    ans += a*r*c;
    ans += a*r*h;
    ans += a*c*h;
    ans += r*c*h;

    cout << ans;
    return 0;
}

unsigned long long pow(long long base, long long power){
    if(power==0) return 1;
    if(power==1) return base;

    unsigned long long ans = pow(base, power/2);
    ans *= ans; /// ans = (ans%mod)*(ans%mod);

    if(power&1) return ans*base; /// (ans%mod)*(base%mod);
    return ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, s1,s2,s3;
  cin >> N;
  s1 = N/100;
  s2 = (N- s1*100)/10;
  s3 = N - s1*100 - s2*10;

  cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define INF 1000000
#define WHITE 0
#define BLACK 1
#define N 100
 
int n;
int w[N][N];

void dijkstra(void);

int main(){
 
    int i,j;
    int u,v;
    int k;
    int c;
 
    scanf("%d",&n);
 
    for( i = 0 ; i < n ; i++ ){
        for( j = 0 ; j < n ; j++ ){
            w[i][j] = INF;
        }
    }
     
    for( i = 0 ; i < n ; i++ ){
        scanf("%d %d",&u,&k);
        for( j = 0 ; j < k ; j++ ){
            scanf("%d %d",&v,&c);
            w[u][v] = c;
        }
    }
     
    dijkstra();
 
    return 0;
}

void dijkstra(){
 
    int i,u,v;
    int mincost;
    int d[N],color[N],pi[N];
 
    for( i = 0 ; i < n ; i++ ){
        d[i] = INF;
        color[i] = WHITE;
    }
 
    d[0] = 0;
 
    while( 1 ){
 
        mincost = INF;
 
        for( i = 0 ; i < n ; i++ ){
            if( color[i] != BLACK && d[i] < mincost ){
                mincost = d[i];
                u = i;
            }
        }
 
        if( mincost == INF ){
            break;
        }
 
        color[u] = BLACK;
 
        for( v = 0 ; v < n ; v++ ){
 
            if(  color[v] != BLACK && w[u][v] + d[u] < d[v] ){
	      pi[v]=u;
                d[v] = w[u][v] + d[u];
            }
        }
 
    }
 
 
    for( i = 0 ; i < n ; i++ ){
        if( d[i] != INF ){
            printf("%d %d\n",i,d[i]);
        }
    }
 
}
 

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

vector<int> ab[101010];
int psd[101010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin>>n>>m;
    rep(i,m){
        int a,b;cin>>a>>b;
        ab[a].push_back(b);
        ab[b].push_back(a);
    }
    rep(i, 101010) psd[i] = -1;
    psd[1] = 0;
    queue<int> q;
    q.push(1);
    while(!q.empty()){
        int nw = q.front(); q.pop();
        for(auto a : ab[nw]){
            if(psd[a] != -1) continue;
            psd[a] = nw;
            q.push(a);
        }
    }
    int rcnt = 0;
    rep(i, 101010){
        if(psd[i] != -1) rcnt++;
    }
    if(rcnt != n) {
        cout<<"No"<<endl;
        return 0;
    }else{
        cout<<"Yes"<<endl;
        for(int i=2; i<=n; i++){
            cout<<psd[i]<<endl;
        }
        return 0;
    }

}

Measured memory_bytes: 10588
def proc(begin_val, end_val, **keyargs):
  if begin_val * end_val > 0:
    return sum(list(range(begin_val, end_val + 1))) - min(abs(begin_val), abs(end_val)) * end_val // abs(end_val)
  
  if begin_val * end_val <= 0:
    return sum(list(range(begin_val, end_val + 1)))


N, L = map(int, input().split())

begin_val = L
end_val = L + N - 1

print(proc(**locals()))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
  int x,y,r,z;
  scanf("%d %d",&x,&y);

  if(x<y){
    z=x;
    x=y;
    y=z;
    }
  r =x%y;
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
    }

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

  return 0;
}

Measured memory_bytes: 1856
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define ov(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
	fastio();
	ll N;
	cin>>N;
	ll ar[3][N];
	for(ll i=0;i<N;i++)
	{
		cin>>ar[0][i]>>ar[1][i]>>ar[2][i];
	}
	for(ll i=1;i<N;i++)
	{
		for(ll j=0;j<3;j++)
		{
			ar[j][i]+=max(ar[(j+1)%3][i-1],ar[(j+2)%3][i-1]);
		}
	}
	ll ans=max(ar[0][N-1],ar[1][N-1]);
	ans=max(ans,ar[2][N-1]);
	cout<<ans<<endl;
}	


Measured memory_bytes: 2560
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define for(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) for(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/

void solve()
{
    ll n;
    cin>>n;

    ll a[n],b[n];
    f(i,n) cin>>a[i];
    f(i,n) cin>>b[i];

    ll neg=0,c=0;
    vector<ll> diff;

    f(i,n)
    {
        if(a[i]>b[i]) diff.pb(a[i]-b[i]);
        else if(a[i]<b[i]) neg+=b[i]-a[i],c++;
    }
    sort(diff.begin(), diff.end(),greater<ll> ());

    ll sum=0;

    ll i=0;
    while(i<sz(diff) && sum<neg)
    {
        sum+=diff[i];
        c++;
        i++;
    }

    if(sum>=neg)
    {
        cout<<c<<"\n";
    }
    else cout<<"-1\n";

    return;
}

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

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


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

int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  int l[8];
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }

  int ans = 1000000000;
  for (int bit = 0; bit < (1 << 2 * N); bit++) {
    int lengthA = 0;
    int cntA = 0;
    int lengthB = 0;
    int cntB = 0;
    int lengthC = 0;
    int cntC = 0;
    for (int i = 0; i < N; i++) {
      int flag = 2 * ((bit >> (2 * i + 1)) & 1) + ((bit >> 2 * i) & 1);
      if (flag == 1) {
        lengthA += l[i];
        cntA += 1;
      }
      if (flag == 2) {
        lengthB += l[i];
        cntB += 1;
      }
      if (flag == 3) {
        lengthC += l[i];
        cntC += 1;
      }
    }

    if (lengthA != 0 && lengthB != 0 && lengthC != 0) {
      int mps = abs(A - lengthA) + (cntA - 1) * 10 +  abs(B - lengthB) + (cntB - 1) * 10 +  abs(C - lengthC) + (cntC - 1) * 10;
      ans = min(mps, ans);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;



int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    set<int> s;
    for(int i=0; i<n; i++){
        int x;
        cin>>x;
        auto it=s.find(x);
        if(it!=s.end()) s.erase(it);
        else s.insert(x);
    }
    cout<<s.size();
    
    
   
   
    
    return 0;
    
}

Measured memory_bytes: 4992
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()



inl = [LI() for i in range(N)]
inl.sort(key=lambda x: x[2], reverse=True)

st=set()
prevset=set()
for x,y,h in inl:
    st = set()
    for i in range(101):
        for j in range(101):
            abso = abs(x-i)+abs(y-j)
            if not h == 0:
                st.add((i,j, h+abso))
            else:
                for k in range(1, abso+1):
                    st.add((i,j, k))

    prevset = st if not prevset else st.intersection(prevset)
    if len(prevset) == 1:
        break

print(*prevset.pop())


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

int main(){
  int n;
  const int coins[] = {500,100,50,10,5,1};
  while(cin >> n, n){
    n = 1000-n;
    int ans = 0;
    for(int i=0;i<6;i++){
      while(coins[i] <= n){
	n -= coins[i];
	ans++;
      }
    }
    cout << ans << endl;
  }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> r(N);
  for(int i = 0; i < N; i++) r.at(i) = -1;
  
  for(int i = 0; i < M; i++){
    int s,c;
    cin >> s >> c;
    s = s - 1;
    if(r.at(s) == -1 || r.at(s) == c){
      r.at(s) = c;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  
  if(N != 1){
    if(r.at(0) == 0){
        cout << -1 << endl;
        return 0;
    }
  }  
  for(int i = 0; i < N; i++){
    if(i == 0){
      if(r.at(i) == -1){
        if(N == 1){
          r.at(i) = 0;
        } else {
           r.at(i) = 1;
        }
      }
    } else {
      if(r.at(i) == -1) r.at(i) = 0;
    }
    cout << r.at(i);
  }
  cout << endl;  
}


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

using ll = long long;
// Loop
#define REP(i, a, b) for(ll(i) = (a); (i) < (b); (i)++)
#define RREP(i, a, b) for(ll(i) = (a); (i) >= (b); (i)--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)

int main(void) {
	int a[5];
	rep(i, 5) { cin >> a[i]; }
	rep(i, 5) {
		if(a[i] == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
# define REP(i,n,N) for(int i=n;i<N;i++)
# define p(S) cout<<S<<endl;
using namespace std;
int ans;
vector<pair<int, int>> vt;
vector<int> vt2;
int m;

int product(pair<int, int> p1, pair<int, int> p2, pair<int, int> p3, pair<int, int> p4){
    int x2 = p2.first - p1.first;
    int y2 = p2.second - p1.second;
    int x4 = p4.first - p3.first;
    int y4 = p4.second - p3.second;
    return x2 * y4 - x4 * y2;
}
bool used[20];
void dfs(vector<pair<pair<int,int>, pair<int,int>>> &po){
    if(po.size()==m/2){
        int cnt=0;
        for(int i=0;i<m/2-1;i++){
            for(int j=i+1;j<m/2;j++){
                if(product(po[i].first, po[i].second, po[j].first, po[j].second) == 0) cnt++;
            }
        }
        ans = max(ans,cnt);
        return;
    }
    int left;
    for(int i=0;i<m; i++){
        if(!used[i]){
            used[i]=true;
            left=i;
            break;
        }
    }
    for(int i=0;i<m;i++){
        if(used[i]) continue;
        used[i] = true;
        po.emplace_back(vt[left], vt[i]);
        dfs(po);
        po.pop_back();
        used[i]=false;
    }
    used[left]=false;
}
int main() {
    cin>>m;
    REP(i,0,m){
        int x,y;
        cin >> x >> y;
        vt.emplace_back(x, y);
    }
    vector<pair<pair<int,int>, pair<int,int>>> tmp;
    dfs(tmp);
    p(ans);

    return 0;
}


Measured memory_bytes: 3120
package main

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

func main(){
	var sc = bufio.NewScanner(os.Stdin)
  	sc.Scan()
  	a := sc.Text()
  	b := strings.Split(a, " ")
  	c,_ := strconv.Atoi(b[0])
  	d,_ := strconv.Atoi(b[1])
      A := (c + d) /2

      B := c - A
      C := d - A
    if B < 0 {
      B = -(B)
    }
    if C < 0{
      C = -(C) 
    }
    if B == C{
      fmt.Println(A)
    }else{
    fmt.Printf("IMPOSSIBLE")
    }
 
}

Measured memory_bytes: 640
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*/
//vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s;
  cin >> s;
  int mojicount=0;
  int Aflag=0,Bflag=0,Cflag=0,count=0;
  
  if(s.at(0)=='A')Aflag=1;

  for(int i=2;i<s.size()-1;i++){
    if(s.at(i)=='C')count++;
  }
  if(count ==1)Bflag=1;
  rep(i,s.size()) if(17<= (s.at(i)-'0') && (s.at(i)-'0')<=42) mojicount++;
  if(mojicount == 2)Cflag=1;
//  cout << s.at(0)-'0'<< endl;  
//  cout << s.at(1)-'0'<< endl;  
//  cout << s.at(2)-'0'<< endl;  
//  cout << Cflag << endl;
  if(Aflag==1 && Bflag==1 && Cflag==1) cout<<"AC"<<endl;
  else cout<<"WA"<<endl;
} 


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

int64_t gcd(int64_t a, int64_t b){
	while(b){
		int64_t tmp = b;
		b = a % b;
		a = tmp;
	}
	return a;
}

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

int main(){
	int n;
	cin >> n;
	int64_t t[n];
	for(int64_t &i:t) cin >> i;
	int64_t ans = 1;
	for(int64_t &i:t) ans = lcm(ans, i);
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, ans string
	fmt.Scan(&n)
	str := strings.Split(n, "")
	for _, num := range str {
		if num == "1" {
			num = "9"
		} else if num == "9" {
			num = "1"
		}
		ans += num
	}
	fmt.Println(ans)
}

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

using namespace std;
const double EPS = 1e-8;

inline bool equals(double x, double y) {
    return fabs(x - y) <= EPS;
}

class Point {//Point类，点
public:
    double x, y;

    Point(double x = 0, double y = 0) : x(x), y(y) {}

    Point operator+(Point p) { return Point(x + p.x, y + p.y); }

    Point operator-(Point p) { return Point(x - p.x, y - p.y); }

    Point operator*(double a) { return Point(a * x, a * y); }

    Point operator/(double a) { return Point(x / a, y / a); }

    double abs() { return sqrt(norm()); }

    double norm() { return x * x + y * y; }

    bool operator<(const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator==(const Point &p) const {
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }
};

typedef Point Vector;//Vector类，向量

struct Segment {//Segment 线段
    Point p1, p2;
};

double dot(Vector a, Vector b) {//内积
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {//外积
    return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Vector a, Vector b) {//判断正交
    return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {//判断正交
    return isOrthogonal(a1 - a2, b1 - b2);
}

bool isOrthogonal(Segment s1, Segment s2) {//判断正交
    return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

bool isParallel(Vector a, Vector b) {//判断平行
    return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2) {//判断平行
    return isParallel(a1 - a2, b1 - b2);
}

bool isParallel(Segment s1, Segment s2) {//判断平行
    return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

Point project(Segment s, Point p) {//投影 对于给定的三个点p1、p2、p，从点p向通过
//p1、p2的直线引一条垂线，求垂足x的坐标。（点p在直线p1p2上的投影）
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / base.norm();
    return s.p1 + base * r;
}

int main() {
    Point p1, p2, p, pt;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;

    Segment s;
    s.p1 = p1;
    s.p2 = p2;

    int q;
    cin >> q;

    while (q--) {
        cin >> p.x >> p.y;
        pt = project(s, p);
        printf("%.10f %.10f\n", 2 * pt.x - p.x, 2 * pt.y - p.y);
    }
}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define rep(i,x,y) for(register int i = x;i <= y; ++ i)
#define repd(i,x,y) for(register int i = x;i >= y; -- i)
typedef long long ll;
using namespace std;
template<typename T>inline void read(T&x)
{
	char c;int sign = 1;x = 0;
	do { c = getchar(); if(c == '-') sign = - 1; }while(!isdigit(c));
	do { x = x * 10 + c - '0'; c = getchar(); }while(isdigit(c));
	x *= sign;
}

const int N = 403,M = 1e5 + 50;
int n,m,a[M],b[M];
bool k[N];
bitset<N> z[N];

int main()
{
	read(n); read(m);
	rep(i,1,m) read(a[i]),read(b[i]);
	rep(i,1,n)
	{
		z[i][i] = 1;
		repd(j,m,1)
		{
			int x = z[i][a[j]],y = z[i][b[j]];
			if(x & y)
			{
				k[i] = 1;
				break;
			}
			if(x) {z[i][b[j]] = 1; continue;} 
			if(y) {z[i][a[j]] = 1; continue;}

		}
	}

	int ans = 0;

	rep(i,1,n)
	{
		if(k[i]) continue;
		rep(j,i + 1,n)
		{
			if(k[j]) continue;
			if(!((z[i] & z[j]).any())) ++ ans;
		}
	}

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

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    int h, w, i, j;

    scanf("%d %d", &h, &w);

    while ((h!=0) || (w!=0)) {
        // ceiling
        for (j=0; j<w; j++) {
            printf("#");
        }
        printf("\n");

        for (i=0; i<h-2; i++) {
            printf("#");
            for (j=0; j<w-2; j++) {
                printf(".");
            }
            printf("#\n");
        }
        
        // bottom
        for (j=0; j<w; j++) {
            printf("#");
        }
        printf("\n\n");
        
        scanf("%d %d", &h, &w);
    }

    return 0;
}


Measured memory_bytes: 2104
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math
import bisect

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

x,k,d = readInts()

if abs(x)>=k*d:
	print(abs(x)-(k*d))
elif x>=0:
	t = x//d+1
	r = k-t
	now = x-t*d+r%2*d
	print(abs(now))
else:
	t = x//d+1
	r = k-t
	now = x-t*d+r%2*d
	print(abs(now))

Measured memory_bytes: 9464
L = int(input())

num = L // 3
rem = L % 3

if rem == 1:
    res = (num+1)*(num**2)

elif rem == 2:
    res = ((num + 1) ** 2) * num

else:
    res = num ** 3

res2 = (L/3)**3
if res > res2:
    print(res)
else:
    print(res2)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	long long ans=1;
	long long a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==0){
			cout<<0;
			return 0;
		}
	}
	for(i=0;i<n;i++){
		if(1000000000000000000/ans<a[i]){
			cout<<-1;
			return 0;
		}
		ans*=a[i];
	}
	cout<<ans;
}

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

class Dice{

public:
    void SetDice(int s1,int s2,int s3,int s4,int s5,int s6)
    {
        side.at(0)=s1; //top
        side.at(1)=s2; //front
        side.at(2)=s3; //right
        side.at(3)=s4; //left
        side.at(4)=s5; //back
        side.at(5)=s6; //bottoms
    }

    int GetTop(void){
        return(side.at(0));
    }

    int GetRight(void){
        return(side.at(2));
    }

    int SetPos(int top, int front){
        //search top  and rotation
        vector<int> rot1={0,4,5,1};
        int top_rot1=0;
        for(int i=0;i<rot1.size();i++){
          if(side.at(rot1.at(i))==top)
            top_rot1=i;
        }

        for(int i=0;i<top_rot1;i++){
          Rotate('S');
        }

        vector<int> rot2={0,2,5,3};
        int top_rot2=0;
        for(int i=0;i<rot2.size();i++){
          if(side.at(rot2.at(i))==top)
            top_rot2=i;
        }

        for(int i=0;i<top_rot2;i++){
          Rotate('W');
        }

        vector<int> rot_f = {1,3,4,2};
        int front_rot=0;
        for(int i=0;i<rot_f.size();i++){
          if(side.at(rot_f.at(i))==front)
            front_rot=i;
        }

        for(int i=0;i<front_rot;i++){
          Rotate('H');
        }

        return 0;
        
    }

    void Rotate(char direction){
        if(direction=='N'){
            int wk=side.at(0);
            side.at(0)=side.at(1);
            side.at(1)=side.at(5);
            side.at(5)=side.at(4);
            side.at(4)=wk;
        }
        else if(direction=='S'){
            int wk=side.at(0);
            side.at(0)=side.at(4);
            side.at(4)=side.at(5);
            side.at(5)=side.at(1);
            side.at(1)=wk;
        }
        else if(direction=='W'){
            int wk=side.at(0);
            side.at(0)=side.at(2);
            side.at(2)=side.at(5);
            side.at(5)=side.at(3);
            side.at(3)=wk;
        }
        else if(direction=='E'){
            int wk=side.at(0);
            side.at(0)=side.at(3);
            side.at(3)=side.at(5);
            side.at(5)=side.at(2);
            side.at(2)=wk;
        }
        else if(direction=='H'){
            int wk=side.at(2);
            side.at(2)=side.at(1);
            side.at(1)=side.at(3);
            side.at(3)=side.at(4);
            side.at(4)=wk;
        }
    }

    private:
          vector<int> side = vector<int> (8); //この定義にしないと「型指定子が必要です」エラーが出る。
};

int main() {
    int s1,s2,s3,s4,s5,s6;
    cin>>s1>>s2>>s3>>s4>>s5>>s6;

    Dice dice;
    dice.SetDice(s1,s2,s3,s4,s5,s6);

    int n;
    cin>>n;

    for(int i=0;i<n;i++){
      int top_wk,front_wk;
      cin>>top_wk>>front_wk;
      dice.SetPos(top_wk,front_wk);
      cout<<dice.GetRight()<<endl;
    }

    return 0;
}


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

//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define foe(i,x) for(auto& i: x)
#define ar array
#define pb push_back
#define vt vector
#define F first
#define S second

template<class T> bool umin(T& a,const T& b){return b<a?a=b,1:0;}
template<class T> bool umax(T& a,const T& b){return b>a?a=b,1:0;}

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {cin>>x;}
void read(double& d) {string t;read(t);	d=stod(t);}
void read(long double& d) {	string t;read(t);d=stold(t);}
template<class H, class... T> void read(H& h, T&... t) {read(h);read(t...);}
template<class A> void read(vt<A>& x) {	foe(a, x)read(a);}
int nxt(){int a;read(a);return a;}   // iota(all(v),0); genrate(all(v),nxt);

// no change 
const ll MOD = 1e9+7;  
int mx = 1e6+1;
void Titan(){
	int n;
	read(n);
	string s;
	read(s);
	int x= 0;
	int ans = 0;
	for(char c: s){
		if(c== 'I')x++;
		else if(c=='D')x--;
		umax(ans,x);
	}
	cout << ans;
}

	

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T = 1;
	//cin >> T;		//cmt if one test case
    fo(T){
		//cout << "Case #" << i+1 << ": " ;
		Titan();
	}
}
/*///////////////////////////////////////////////////////////
Important Notes : 
* check long long 
* check base cases
* do not loose Hope
* if case fails on 2nd test case maybe some cases are missing check them
* do not sit idle
* try to do it using pen/paper.
*/


Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	double PI = acos(-1.0);
	double X = 0, Y = 0;
	int angle = 90;
	while (true) {
		int x, y;char c;cin >> x >> c >> y;
		if (x == 0 && y == 0) break;
		X += x*cos(angle / 180.0 *PI);
		Y += x*sin(angle / 180.0*PI);
		angle += y;
	}
	cout << -(int)X << endl << (int)Y << endl;
}

Measured memory_bytes: 3344
N = gets.chomp.to_i
T, A = gets.chomp.split(" ").map(&:to_i)
h = gets.chomp.split(" ").map(&:to_i)
h2 = []
h.each do |i| 
    h2 << (A - (T - (i*0.006))).abs
end
puts h2.index(h2.min)+1

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string A; 
    cin >>A;
    sort(A.begin(),A.end());
    vector<int>vec(26,0);
    for(int i=0;i<A.size();i++){
        if('a'==A.at(i)){
            vec.at(0)++;
        }

                else if('b'==A.at(i)){
            vec.at(1)++;
        }
                else if('c'==A.at(i)){
            vec.at(2)++;
        }
                else if('d'==A.at(i)){
            vec.at(3)++;
        }
                else if('e'==A.at(i)){
            vec.at(4)++;
        }
                else if('f'==A.at(i)){
            vec.at(5)++;
        }
                else if('g'==A.at(i)){
            vec.at(6)++;
        }
                else if('h'==A.at(i)){
            vec.at(7)++;
        }
                else if('i'==A.at(i)){
            vec.at(8)++;
        }
                else if('j'==A.at(i)){
            vec.at(9)++;
        }
                else if('k'==A.at(i)){
            vec.at(10)++;
        }
                else if('l'==A.at(i)){
            vec.at(11)++;
        }
                else if('m'==A.at(i)){
            vec.at(12)++;
        }        else if('n'==A.at(i)){
            vec.at(13)++;
        }        else if('o'==A.at(i)){
            vec.at(14)++;
        }        else if('p'==A.at(i)){
            vec.at(15)++;
        }        else if('q'==A.at(i)){
            vec.at(16)++;
        }        else if('r'==A.at(i)){
            vec.at(17)++;
        }        else if('s'==A.at(i)){
            vec.at(18)++;
        }        else if('t'==A.at(i)){
            vec.at(19)++;
        }        else if('u'==A.at(i)){
            vec.at(20)++;
        }        else if('v'==A.at(i)){
            vec.at(21)++;
        }        else if('w'==A.at(i)){
            vec.at(22)++;
        }        else if('x'==A.at(i)){
            vec.at(23)++;
        }        else if('y'==A.at(i)){
            vec.at(24)++;
        }        else if('z'==A.at(i)){
            vec.at(25)++;
        }
    }
    for(int i=0;i<26;i++){
        if(vec.at(i)%2==1){
            cout << "No"<<endl;
            return 0;
        }
    }
    cout <<"Yes"<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

/*
    基数として乱数をとりたい場合 :
    ll B_1, B_2, MOD_1 = 1000000007, MOD_2 = 1000000009;
    random_device rnd;
    mt19937 mt(rnd());
    B_1 = mt() % (MOD_1 - 2) + 2;
    B_2 = mt() % (MOD_2 - 2) + 2;
    RollingHash<char> rh(s, B_1, B_2, MOD_1, MOD_2);
*/
template <typename T>
struct RollingHash {
    using ll = long long;
    ll B_1, B_2, MOD_1, MOD_2;
    vector<ll> hash_1, hash_2, pow_1, pow_2;

    RollingHash(vector<T> v, ll B_1 = 1007, ll B_2 = 1009,
                ll MOD_1 = 1000000007, ll MOD_2 = 1000000009)
        : B_1(B_1), B_2(B_2), MOD_1(MOD_1), MOD_2(MOD_2) {
        init(v);
    }

    RollingHash(string& s, ll B_1 = 1007, ll B_2 = 1009, ll MOD_1 = 1000000007,
                ll MOD_2 = 1000000009)
        : B_1(B_1), B_2(B_2), MOD_1(MOD_1), MOD_2(MOD_2) {
        vector<T> v;
        for (char c : s) v.emplace_back(c);
        init(v);
    }

    void init(vector<T> v) {
        int n = v.size();
        hash_1.assign(n + 1, 0);
        hash_2.assign(n + 1, 0);
        pow_1.assign(n + 1, 1);
        pow_2.assign(n + 1, 1);
        for (int i = 0; i < n; i++) {
            hash_1[i + 1] = (hash_1[i] * B_1 + v[i]) % MOD_1;
            hash_2[i + 1] = (hash_2[i] * B_2 + v[i]) % MOD_2;
            pow_1[i + 1] = pow_1[i] * B_1 % MOD_1;
            pow_2[i + 1] = pow_2[i] * B_2 % MOD_2;
        }
    }

    pair<ll, ll> get(int l, int r) {
        ll res_1 =
            ((hash_1[r] - hash_1[l] * pow_1[r - l]) % MOD_1 + MOD_1) % MOD_1;
        ll res_2 =
            ((hash_2[r] - hash_2[l] * pow_2[r - l]) % MOD_2 + MOD_2) % MOD_2;
        return pair<ll, ll>(res_1, res_2);
    }
};

signed main() {
    int n;
    cin >> n;
    int a[n], b[n];
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        cin >> b[i];
    }
    vector<int> xa(n), xb(n);
    rep(i, n) {
        xa[i] = a[i] ^ a[(i + 1) % n];
    }
    rep(i, n) {
        xb[i] = b[i] ^ b[(i + 1) % n];
    }
    RollingHash<int> rha(xa), rhb(xb);
    rep(i, n) {
        if (rha.get(i, n) == rhb.get(0, n - i) &&
            rha.get(0, i) == rhb.get(n - i, n)) {
            cout << i << " " << (a[i] ^ b[0]) << endl;
        }
    }
    return 0;
}

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

#define debug(x) cerr<<#x<<'='<<x<<' '
#define f first
#define s second

typedef long long ll;
typedef pair<int,int> pi;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n), orig(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) cin >> b[i];
	for (int i = 0; i < n; ++i) orig[i] = i+1;
	map<vector<int>,int > mp;
	int cnt = 0;
	do {
		mp[orig] = ++cnt;
	} while (next_permutation(orig.begin(),orig.end()));
	cout<<abs(mp[a]-mp[b]);
    return 0;
}


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

#define MAX 2000001
#define VMAX 10000

int main(){
	unsigned short *A,*B;
	int C[VMAX+1];
	int n,i,j;
	scanf("%d",&n);
	//cout<<(short *)malloc(sizeof(short)*n+1)<<endl;
	A=(unsigned short *)malloc(sizeof(short) * n + 1);
	B=(unsigned short *)malloc(sizeof(short) * n + 1);


	for ( i = 0; i <= VMAX; ++i) {C[i]=0;}
	for ( i = 0; i < n; ++i) {
		scanf("%hu",&A[i+1]);
		C[A[i+1]]++;
	}
	for ( i = 1; i <= VMAX; ++i) {
		C[i]=C[i]+C[i-1];
	}
	for (j = 1;  j <= n; j++) {
		B[C[A[j]]]=A[j];
		C[A[j]]--;
	}
	for ( i = 1; i <= n; ++i) {
		if(i>1)printf(" ");
		printf("%d",B[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 11060