akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real()*a.real() + a.imag()*a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size();++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
int n;
int input[200000] = {};
int visited[200000] = {};
int findings(int a) {
	while (visited[a] != 2) {
		visited[a] = 2;
		a += input[a];
		a %= n;
	}
	return 0;
}
int moved(int a) {
	visited[a] = 1;
	if (visited[(a + input[a]) % n] == 0) {
		moved((a + input[a]) % n);
	}
	else if (visited[(a + input[a]) % n] == 1) {
		findings(a);
	}
	if(visited[a] == 1){
		visited[a] = 3;
	}
	return 0;
}
int main(){
	cin >> n;
	REP(i, n) {
		cin >> input[i];
	}
	REP(i, n) {
		if (visited[i] == 0) {
			moved(i);
		}
	}
	int ans = 0;
	REP(i, n) {
		if (visited[i] == 2) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5416
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define all(s) s.begin(), s.end()
#define fuck_you_scanf ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define si size()
 
const int N = 1e6 + 5;
bool visited[N];

int32_t main()
{
    int n;
    cin >> n;
    multiset<double> m;
    for(int i = 0; i < n; i++)
    {
        double data;
        cin >> data;
        m.insert(data);
    }
    int t = n - 1;
    while(t--)
    {
        auto it1 = m.begin();
        auto it2 = it1;
        it2++;
        double a = *it1;
        double b = *it2;
        m.erase(it1);
        m.erase(it2);
        m.insert(((a + b) * 1.0) / 2.0);
    }
    std::cout << std::setprecision(6) << fixed;
    cout << *m.begin() << '\n';
}

Measured memory_bytes: 256
/*

#      #      #####   ##   ##  #####      ##     #  #      #   #  #####
#      #      #   #  #  ###  # #          # ##   #  #      #   #  #   #
#      #      #   #  #   #   # #          #  ##  #  #      #   #  #   #
#      #      #   #   #     #  #####      #   #  #  #       ###   #####
#      #      #   #    #   #   #          #  ##  #  #        #    #   #
#      #      #   #     ###    #          # ##   #  #        #    #   #
#      #####  #####      #     #####      ##     #  #####    #    #   #

*/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define pb push_back
#define np next_permutation
#define bs binary_search
#define mp make_pair
#define all(x) x.begin(), x.end()
#define bp __builtin_popcountll
#define sqr(x) ((llong)sqrt (x))
#define b_ctz __builtin_ctzll
#define b_clz __builtin_clzll

#define y1 road_to_respa_top_6
#define prev road_to_respa_top_6
#define Abdrakhman abcdefghijklmnopqrstuvwxyzRakhman
#define left kotoriy_levee_chem_right
#define right kotoriy_pravee_chem_left

#define android ios_base::sync_with_stdio(0), cin.tie (0), cout.tie (0)
#define fn ""

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

typedef vector <llong> vl;
typedef vector <string> vs;
typedef vector <vector <llong>> matrix;

typedef pair <llong, llong> pll;

typedef map <llong, llong> mll;

typedef set <llong> sl;

const llong MXN = 1e6 + 1;
const llong MNN = 1e3 + 1;
const llong MOD = 1e9 + 7;
const llong INF = 1e18;
const llong MAGIC = 1000;
const ldouble EPS = 1e-9;
const ldouble PI = 3.1415926536;
const string TIME = "rovno_ushten_push_ketti";

inline llong log2 (llong x) {return 64 - b_clz (x) - 1;};
inline llong __lcm (llong a, llong b) {return a / __gcd (a, b) * b;};

llong n;
llong a[3][MXN], dp[3][MXN];

int main () {
    android;
    random_device rand;
    #ifdef I_LOVE_DILYA
        freopen ("input.txt", "r", stdin);
    #endif
    cin >> n;
    for (llong i = 1; i <= 2; ++ i) {
        for (llong j = 1; j <= n; ++ j) {
            cin >> a[i][j];
        }
    }
    for (llong i = 1; i <= 2; ++ i) {
        for (llong j = 1; j <= n; ++ j) {
            dp[i][j] = max (dp[i - 1][j], dp[i][j - 1]) + a[i][j];
        }
    }
    cout << dp[2][n];
    return 0;
}

Measured memory_bytes: 8448
def resolve():
	N = int(input())
	# set A and B arrays.
	A = []
	B = []
	for _ in range(N):
		A_i, B_i = map(int, input().split())
		A.append(A_i)
		B.append(B_i)
	# count median
	if N%2==1: # odd
		i = int((N-1)/2)
		median_min = sorted(A)[i]
		median_max = sorted(B)[i]
	else:
		i_0 = int((N/2)-1)
		i_1 = int(N/2)
		ordered_A = sorted(A)
		ordered_B = sorted(B)
		median_min = ordered_A[i_0] + ordered_A[i_1] # 2 times of median of A
		median_max = ordered_B[i_0] + ordered_B[i_1]
	print(median_max - median_min +1)
    
resolve()

Measured memory_bytes: 28644
// http://kmjp.hatenablog.jp/entry/2019/09/28/1030

import java.util.*;

public class Main {
  static Map<Integer, List<Integer>> edgeE = new HashMap<>();
  static List<Integer> vStack = new ArrayList<>(); // stack in DFS
  static int[] vStackState; // state of DFS.
  static List<Integer> cycle = new ArrayList<>();
  static Integer[] cycleSeqId; // id of cycle member.

  static void dfs(int cur) {
    if (vStackState[cur] == 2) { // Found node visited in current dfs. (a cycle)
      if (cycle.isEmpty()) {
        for (int i = 0; i < vStack.size(); i++) {
          if (vStack.get(i) == cur) { // Find starting point to avoid circle shape of `6`.
            for (int j = i; j < vStack.size(); j++) {
              cycle.add(vStack.get(j));
              cycleSeqId[vStack.get(j)] = j - i;
            }
            break;
          }
        }
      }
      return;
    }
    if (vStackState[cur] == 1) return;
    vStackState[cur] = 2;
    vStack.add(cur);
    for (Integer e : edgeE.get(cur)) {
      dfs(e);
    }
    vStack.remove(vStack.size() - 1);
    vStackState[cur] = 1;
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    for (int i = 1; i <= N; i++) {
      edgeE.put(i, new ArrayList<>());
    }
    int M = sc.nextInt();
    for (int i = 0; i < M; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      edgeE.get(a).add(b);
    }
    cycleSeqId = new Integer[N + 1];
    vStackState = new int[N + 1]; // 1-indexed (skip 0-th)
    Arrays.fill(cycleSeqId, -1);
    /* Search cycle. */
    for (int i = 1; i <= N; i++) { // if cycle is already found, loop is useless?
      Arrays.fill(vStackState, 0);
      vStack.clear();
      dfs(i);
    }
    if (cycle.isEmpty()) {
      System.out.println("-1");
      return;
    }
    retry:
    for (int idxStart = 0; idxStart < cycle.size(); idxStart++) {
      Integer nodeIdxFrom = cycle.get(idxStart);
      for (Integer to : edgeE.get(nodeIdxFrom)) {
        if (
        /*member of cycle */ cycleSeqId[to] != -1
            && /* If path split. This is smaller cycle. */
          cycleSeqId[to] != (cycleSeqId[nodeIdxFrom] + 1) % cycle.size()) {
          List<Integer> C2 = new ArrayList<>();
          int newStartIdxInCycle = cycleSeqId[to]; // New starting point to avoid circle shape of `6`.
          Arrays.fill(cycleSeqId, -1);
          for (int j = 0; j < cycle.size(); j++) {
            Integer nodeIdx = cycle.get((newStartIdxInCycle + j) % cycle.size());
            C2.add(nodeIdx);
            cycleSeqId[nodeIdx] = j;
            if (nodeIdx.equals(nodeIdxFrom)) break;
          }
          List<Integer> tmp = cycle;
          cycle = C2;
          idxStart = 0;
          continue retry;
        }
      }
    }
    System.out.println(cycle.size());
    for (Integer c : cycle) {
      System.out.println(c);
    }
  }
}


Measured memory_bytes: 57452
#include <iostream>
#include <set>
using namespace std;
long long f(long long x){
    if(x <= 0) return 0;
    long long res = 0;
    for(long long i = (x/4)*4; i <= x; i++){
        res ^= i;
}
    return res;
}
int main() {
    long long a, b;
    cin >> a >> b;
    cout << (f(a-1) ^ f(b)) << endl;
    
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  double N;
  cin>>N;
  double x[8], y[8];
  for(int i=0; i<N; i++) {cin>>x[i]; cin>>y[i];}
  double sum=0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
     sum+=sqrt(pow(x[j]-x[i],2)+pow(y[j]-y[i],2));
    }}
  double ans=(2*sum)/N;
  cout<<fixed<<setprecision(30)<<ans<<endl;
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,j,k,l,m,x,a,b;
    cin >> x;
    for(i=-1000; i<1000; i++)
    {
        for(j=-1000; j<1000; j++)
        {
            if(i*i*i*i*i - j*j*j*j*j == x)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3676
#include <stdio.h>
#include <string.h>
int main(){
	char s[200123], end = 'Z', start = 'A';
	char *lastend, *firststart, *last;
	scanf("%s", s);
	last = firststart = strchr(s, start);
	while(last!=NULL){
		lastend = last;
		last = strchr(last + 1, end);
	}
	printf("%lu\n", lastend + 1 - firststart);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
#include <vector>
using namespace std;
#define i64 int64_t
void d()
{
  i64 a, b;
  cin >> a >> b;
  i64 count[64];
  memset(count, 0, sizeof(count));
  for (i64 i = a; i <= b; i++)
  {
    for (int j = 0; j < 64; j++)
    {
      if (i & (1ll << j))
      {
        count[j]++;
      }
    }
  }
  i64 sum = 0;
  for (int i = 0; i < 64; i++)
  {
    if (count[i] % 2 != 0)
    {
      sum += (1ll << i);
    }
  }
  cout << sum;
}
void c()
{
  i64 n, m;
  cin >> n >> m;
  map<i64, i64> ab;
  for (int i = 0; i < n; i++)
  {
    i64 a, b;
    cin >> a >> b;
    auto itr = ab.find(a);
    if (itr == ab.end())
    {
      ab[a] = b;
    }
    else
      ab[a] += b;
  }
  i64 sum_x = 0;
  i64 sum_y = 0;
  for (auto itr = ab.begin(); itr != ab.end(); itr++)
  {
    //cout << itr->first << " " << itr->second << endl;
    if (m - sum_x - itr->second > 0)
    {
      sum_x += itr->second;
      sum_y += itr->second * itr->first;
    }
    else
    {
      sum_y += (m - sum_x) * itr->first;
      sum_x += m - sum_x;
    }
    if (sum_x == m)
      break;
  }
  cout << sum_y;
}

int main(void)
{
  c();
  //d();
  return 0;
}


Measured memory_bytes: 6528
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
const MOD: u64 = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        N: usize, x: usize,
        A: [usize; N]
    }
    let mut ans = 0;
    let mut B = vec![0; N];

    B[0] = if A[0] > x {
        ans += A[0] - x;
        x
    } else {
        A[0]
    };

    for i in 1..N {
        B[i] = if B[i-1] + A[i] > x {
            ans += B[i-1] + A[i] - x;
            x - B[i-1]
        } else {
            A[i]
        };
    }
    println!("{:?}", ans);
}

Measured memory_bytes: 6396
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

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

	int x_1, x_2;
	cin >> x_1 >> x_2;
	cout << abs(x_1 - x_2) << endl;
}


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

int main() {
  int is5 = 0;
  int is7 = 0;
  for (int i = 0; i < 3; i++){
    int x;
    cin >> x;
    if (x == 5)
      is5++;
    else if (x == 7)
      is7++;
  }
  if (is5 == 2 && is7 == 1)
    cout << "YES";
  else
    cout << "NO";
  cout << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	while(1){
		char C[101];
		int N=0;
		int P[11];
		int B=0;
		int A=0;
		cin>>N;
		if(N==0){
			break;
		}
		for(int i=0;i<10;i++){
			P[i]=0;
		}
		for(int i=0;i<100;i++){
			cin>>C[i];
		}
		for(int i=0;i<100;i++){
			if(C[i]=='M'){
				A=i%N;
				P[A]++;
			}
			if(C[i]=='L'){
				A=i%N;
				P[A]=P[A]+B;
				P[A]++;
				B=0;
			}
			if(C[i]=='S'){
				A=i%N;
				B=B+P[A];
				B++;
				P[A]=0;
			}
		}
		sort(P,P+N);
		for(int i=0;i<N;i++){
			cout<<P[i]<<" ";
		}
		cout<<B<<endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
bool check(string s){
    int nf = 0;
//    cout << s << endl;
    map<char, int> table;
    rep(i, s.size()){
        if(s[i] == '~') nf = 1;
        if((s[i] >= 'a' && s[i] <= 'z')||(s[i] >= 'A' && s[i] <= 'Z')){
            if(table.find(s[i]) != table.end() && table[s[i]] != nf) return false;
            table[s[i]] = nf;
            nf = 0;
        }
    }
    return true;
}

int main() {
    string s;
    while(cin >> s, s != "#"){
        int bf = -1;
        bool ans = false;
        rep(i, s.size()){
            if(s[i] == '|'){
                ans |= check(s.substr(bf+2, i-bf-3));
                bf = i;
            }
        }
        ans |= check(s.substr(bf+2, s.size()-bf-3));
        cout << (ans?"yes":"no") << endl;        
    }

    return 0;
}

Measured memory_bytes: 1188
n = int(input())
a = list()
for i in range(n):
	x, y = input().split()
	y = int(y)
	if x == "S":
		a.append(y + 0)
	if x == "H":
		a.append(y + 13)
	if x == "C":
		a.append(y + 26)
	if x == "D":
		a.append(y + 39)
for i in range(1, 53):
	if not (i in a):
		if i <= 13:
			print("S {}".format(i - 0))
		elif i <= 26:
			print("H {}".format(i - 13))
		elif i <= 39:
			print("C {}".format(i - 26))
		else:
			print("D {}".format(i - 39))


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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(){
  double r;cin>>r;
  cout <<setprecision(10)<< 2*r*3.14159266<<endl;
}


Measured memory_bytes: 3784
//package com.beginner.b048;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) throws Exception
    {
        Scanner sc = new Scanner(System.in);
        char []a;
        a=sc.next().toCharArray();int n=a.length;
        if(a[0]==a[n-1] && n%2==0)
        {
            System.out.println("First");
        }
        else if(a[0]==a[n-1] && n%2!=0)
        {
            System.out.println("Second");
        }
        else if(a[0]!=a[n-1] && n%2==0)
        {
            System.out.println("Second");
        }
        else
        {
            System.out.println("First");
        }
        sc.close();
    }

}


Measured memory_bytes: 13984
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
char a[100];
int main()
{
    int n,i,j;
    scanf("%d",&n);
    int ci=0;
    ci+=n/500*1000;
    n=n%500;
    ci+=n/5*5;
    printf("%d\n",ci);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 10000000000000000;
const int mod = 1000000007;
int test[12345678], kari[345678], aa[12345678];
signed main() {
	int n, a, b, c, ans = 0; cin >> a >> b >> c >> n;
	for (int h = 0; h <= 3000; h++) {
		for (int i = 0; i <= 3000; i++) {
			if (n - (h * a) - (i * b) >= 0 && (n - (h * a) - (i * b)) % c == 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int n; cin >> n;
    int a;
    a = n/100;
    int ans = a*100+a*10+a;
    if(ans>=n){
        cout << ans << endl;
    }else{
        cout << ans+111 << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	long N,d,x,y,count=0;
	cin>>N>>d;
	long max=d*d;
	for(int i=0;i<N;i++)
	{
		cin>>x>>y;
		if(x*x+y*y<=max)
			count++;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3620
n = int(input())
s = input()

MOD = 10 ** 18 + 7
A = 123456

def ok(l):
    rolling_hash = 0
    strings = {}
    for i in range(n):
        rolling_hash *= A
        rolling_hash += ord(s[i])
        if i - l >= 0: rolling_hash -= ord(s[i-l]) * pow(A, l, MOD)
        rolling_hash %= MOD
        if i < l-1:continue
        if rolling_hash not in strings:
            strings[rolling_hash] = []
        strings[rolling_hash].append(i)

    for string in strings:
        if strings[string][-1] - strings[string][0] >= l:
            return True
    return False
    

bottom, top = 0, n

while top - bottom > 1:
    mid = (top + bottom) // 2
    if ok(mid): bottom = mid
    else: top = mid

print(bottom)

Measured memory_bytes: 4144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int fr[100002]; 
int main() {
	int n;
	cin >> n;
	rep(i, n) {
		int a; cin >> a;
		a--;
		fr[i] = a;
	}
	ll cnt = 0;
	rep(i, n) {
		int j = fr[i];
		if (fr[j] == i) cnt++;
	}
	cnt /= 2;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val inputs = readLine()!!.split(" ").map { it.toInt() }

    val sorted = inputs.sorted()

    val midL = (sorted.size - 1) / 2
    val midR = (sorted.size - 1) / 2 + 1

    if (midL != midR) {
        println(sorted[midR] - sorted[midL])
        return
    }

    println(0)
}

Measured memory_bytes: 54148
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
 
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
 
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() {
   int P,Q,R,ans;
   cin >> P >> Q >> R;
   ans = min(R+P,min(P+Q,Q+R));

   cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include<vector>
using namespace std;
int main()
{
	string a,b,s;
	int A,B;
	cin>>a>>b;
	cin>>A>>B;
	cin>>s;
	if(s==a)
		A--;
	else
		B--;
	cout<<A<<" "<<B<<endl;
	return 0;
}

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

const int N = 3001;
int n;
double memo[N][2*N] , p[N];

double get(int i = 0 , int j = 0)
{
    if(i == n) return j > 0;
    if(memo[i][j + 3000] == memo[i][j + 3000]) return memo[i][j + 3000];

    return memo[i][j + 3000] = p[i] * get(i+1 , j + 1) + (1 - p[i]) * get(i+1 , j - 1);
}
int main()
{
    cin >> n;
    for(int i = 0 ; i < n ; i++)
        cin >> p[i];

    memset(memo , -1 , sizeof(memo));
    cout << fixed << setprecision(10) << get() << endl;
    return 0;
}


Measured memory_bytes: 141184
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

ll n;
ll res;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    cin>>n;
    rep(v, n) {
        res += (n - v) * (v + 1);
    }
    rep(e, n-1) {
        ll u,v; cin>>u>>v; u--; v--;
        if (u > v) { swap(u,v); }
        res -= (n - v) * (u + 1);
    }
    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 3636
N = int(input())

dic = {}
for i in range(N):
    s = input()

    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

mm = 0
li = []

for i in dic:
    if dic[i] > mm:
        li = [i]
        mm = dic[i]
    elif dic[i] == mm:
        li.append(i)

li.sort()
for i in range(len(li)):
    print(li[i])


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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;

template<typename X, typename Y> ostream &operator<< (ostream &fout, const pair<X, Y> &p)
{ fout << '{' << p.first << ", " << p.second << "} "; return fout; }

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e3 + 5;

int main()
{
    ll res = 0;
    ll n; cin >> n;
    string ss = "MARCH";
    ll v[5] = {0};
    for (ll i = 0; i < n; i++) {
        string s; cin >> s;
        for (ll j = 0; j < 5; j++) {
            if (s[0] == ss[j]) {
                v[j]++;
                break;
            }
        }
    }

    for (ll i = 0; i < 5; i++) {
        for (ll j = i + 1; j < 5; j++) {
            for (ll k = j + 1; k < 5; k++) {
                res += v[i] * v[j] * v[k];
            }
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
using namespace std;

typedef long long ll;

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

int m[1010];

int main() {
  int n;
  cin >> n;
  char tmp;
  for (int i = 0; i < n; ++i) {
    cin >> tmp;
    if (tmp == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<iomanip>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    string m ="aiueo";
    string ans = "consonant";
    for(int i=0; i<5; i++){
        if(s[0]==m[i]){
            ans ="vowel";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	m := iScan()
	a := SScan(n)
	b := SScan(m)
	ans := "No"
	for i := 0; i <= n-m; i++ {
		for j := 0; j <= n-m; j++ {
			f := false
			for k, v := range a[i : i+m] {
				f = f || (v[j:j+m] != b[k])
			}
			if !f {
				ans = "Yes"
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1780
A, B = map(int, input().split())

ans = [[None for _ in range(100)] for _ in range(100)]
for i in range(100):
    for j in range(100):
        ans[i][j] = '#' if i < 50 else '.'

A -= 1
B -= 1

i, j = 0, 0
while A > 0:
    ans[i][j] = '.'
    A -= 1

    j += 2
    if j >= 100:
        j = 0
        i += 2

i, j = 51, 0
while B > 0:
    ans[i][j] = '#'
    B -= 1

    j += 2
    if j >= 100:
        j = 0
        i += 2

print(100, 100)
for i in range(100):
    print(*ans[i], sep='')


Measured memory_bytes: 4852
n= int(input())

def is_unique(seq):
    return len(seq) == len(set(seq))

warray = []
for i in range(n):
    warray.append(input())

torf = True

if not is_unique(warray):
    torf = False

for i in range(len(warray) - 1):
    if warray[i][-1] != warray[i+1][0]:
        torf = False

if torf:
    print("Yes")
else :
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<ll,ll> x,pair<ll,ll> y)
{
    return x.first>y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}

void solve()
{   
    int n;
    cin>>n;
    vector< pair<ll,ll> > p(n);
    for(int i=1;i<=n;i++){
        p[i-1].first=i;
        cin>>p[i-1].second;
    }
    sort(p.begin(),p.end(),comp);
    vector<ll> v1(n);
    vector<ll> v2(n);
    for(int i=0;i<n;i++){
        //cout<<p[i].first<<' '<<p[i].second<<'\n';
        v1[i]=p[i].first-p[i].second;
        v2[i]=p[i].first+p[i].second;
    }
    sort(v2.begin(),v2.end());
    ll ans=0;
    for(int i=0;i<n;i++){
        auto up=upper_bound(v2.begin(),v2.end(),v1[i]);
        auto low=lower_bound(v2.begin(),v2.end(),v1[i]);
        up--;
        if(low==v2.end()) continue;
        if(*low!=v1[i] || *up!=v1[i]) continue;

        ans+=(up-low+1);
        if(p[i].first==p[i].second)
            ans--;
    }
    cout<<ans;
    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Measured memory_bytes: 9556
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long h = sc.nextInt();
    long w = sc.nextInt();
    long ans = 0;
    
    if(h == 1 || w == 1){
      ans = 1;
    }else{
      ans = (h*w)/2;
      if((h*w)%2 == 1){
        ans++;
      }
    }

    System.out.println(ans);
    
  }
}

Measured memory_bytes: 35592
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
bool check(vector<int>&B){
    for(int i = 0; i < B.size(); i++){
        if(B[i] != i + 1)return 0;
    }
    return 1;
}
int main(){
	int n;
	vector<int> T;
	for(int i = 0; i < 200; i++)T.push_back(i*(i+1)/2);
	while(cin >> n,n){
	    vector<int> B;
	    int cnt = 0;
	    int temp;
        for(int i = 0; i < n; i++){
            cin >> temp;
            cnt += temp;
            B.push_back(temp);
        }
        int ans = -1;
        if(binary_search(T.begin(),T.end(),cnt)){
            for(n=0;n <= 10000;n++){
                if(check(B)){
                    ans = n;
                    break;
                }
                else{
                    int a = B.size();
                    for(int i = 0; i < a; i++){
                        B[i]--;
                    }
                    B.erase(remove(B.begin(),B.end(),0),B.end());
                    B.push_back(a);
                }
            }
        }
        cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
def main():
    #x = int(input())
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    A = [0]*M
    B = [0]*M
    for i in range(0,M):
        A[i], B[i] = map(int, input().split())

    best_pos = [1]*N
    for i in range(0,M):
        if H[A[i]-1] > H[B[i]-1]:
            best_pos[B[i]-1] = 0
        elif H[A[i]-1] < H[B[i]-1]:
            best_pos[A[i]-1] = 0
        else:
            best_pos[A[i]-1] = 0
            best_pos[B[i]-1] = 0

    ans = 0
    for best in best_pos:
        ans += best
    print(ans)

if __name__ == '__main__':
    main()


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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define modInv(a) binExp(a,mod-2)
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    string n;
    cin>>n;

    int sum = 0;
    for(auto x : n)
    {
        sum += (x-48);
    }
    cout<<(sum%9==0?"Yes":"No");
}

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

int main() {
  int N; cin >> N;
  string str = "";
  while (N != 0) {
    /* N を 2 で割ったあまりを求める */
    int r = N % 2;
    if (r < 0) r += 2; // N がマイナスだと r がマイナスになったりするので 2 を足す

    /* N から余りを取り除いて -2 で割る */
    N = (N - r) / (-2);

    /* 答えに追加 */
    str += (char)('0' + r);
  }
  /* 向きが逆なので反転 */
  reverse(str.begin(), str.end());
  if (str == "") str = "0"; // N = 0 のときは空文字列になってしまうので例外処理
  cout << str << endl;
}

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



int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n){
  cin >> h.at(i);
  }
  
  vector<int> dp(1000000, inf);
  
  rep(i,n){
    if (i == 0) {dp.at(i) = 0; continue;}
    dp.at(i) = min(dp.at(i), dp.at(i-1)+abs(h.at(i)-h.at(i-1)));
    if(i > 1) dp.at(i) = min (dp.at(i), dp.at(i-2)+abs(h.at(i)-h.at(i-2)));
  }
  cout << dp.at(n-1) << endl;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
inline int read() {
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		s=s*10+ch-'0';
		ch=getchar();
	}
	return s*w;
}
inline void write(int x) {
	if(x<0) {
		putchar('-');
		x=-x;
	}
	if(x>9) write(x/10);
	putchar(x%10+'0');
	return ;
}
int n,t,Max;
char c;
main() {
    n=read();
    while(n--) {
        scanf("%c",&c);
        if(c=='I') t++;
        else t--;
        Max=max(Max,t);   
    }
    write(Max),puts("");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int a, b, c, d; cin>>a>>b>>c>>d;

    int ta = (c + b - 1) / b;
    int ao = (a + d - 1) / d;

    cout << (ta <= ao ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3644
while True:
    h,w = map(int, input().split())
    if h == 0: break
    if h == 1 or w == 1:
        print('#')
        break
    print(('#'*w)+ '\n' + ('#' + '.'*(w-2)+ '#\n')*(h-2)+ ('#'*w))
    print()


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

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

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    string t; cin >> t;

    rep(i, t.size()){
        if(t[i]=='?') t[i] = 'D';
    }

    cout << t << endl;

    return 0;
}

Measured memory_bytes: 3752
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

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

int main() {
	string s;
	int a;
	cin >> a >> s;
	if (a < 3200) {
		cout << "red";
	}
	else {
		cout << s;
	}
}
	


Measured memory_bytes: 3084
#include<stdio.h>
#include<string.h>
int main(void)
{
	int K, N, A[101], i, j, d[101], k, count = 0;
	scanf("%d %d", &N, &K);
	
	for (i = 1; i <= N; i++)
	{
		A[i] = 0;
	}
	
	
	for (i = 1; i <= K; i++)
	{
		scanf("%d", &d[i]);               
		
		for (j = 1; j <= d[i]; j++)
		{
			scanf("%d", &k);
			A[k]++;

		}
	}
	for (i = 1; i <= N; i++)
	{
		if (A[i] == 0)
		{
			count++;
		}
	}
	printf("%d\n", count);

	return 0;
}

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

int main()
{

    string A;
    cin >> A;
    int sz1 = A.size();

    string B;
    cin >> B;
    int sz2 = B.size();
    string C;
    cin >> C;


    if (A[sz1 -1] == B[0] && B[sz2-1] == C[0])
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

struct P{
  int x,y,z;
  P(int x,int y, int z):x(x),y(y),z(z){}
  bool operator<(const P&a)const {
    return x==a.x?y<a.y:x<a.x;
  }
  ll cal(){
    return (y-x-1)*ll(z-2);
  }
};

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
 int n,m;
 cin>>n>>m;
 int curr = n, curc = n;
 set<P>str, stc;
 for(int i=0;i<m;i++){
   int tt, x;
   cin>>tt>>x;
   if(tt==1){
     if(x<curc){
       stc.insert(P(x, curc, curr));
       curc = x;
     } else {
       auto it = stc.lower_bound(P(x,x,0));
       --it;
       auto pp = *it;
       stc.erase(it);
       stc.insert(P(pp.x,x,pp.z));
       stc.insert(P(x,pp.y,pp.z));
     }
   } else {
     if(x<curr){
       str.insert(P(x,curr,curc));
       curr = x;
     } else {
       auto it = str.lower_bound(P(x,x,0));
       --it;
       auto pp = *it;
       str.erase(it);
       str.insert(P(pp.x,x,pp.z));
       str.insert(P(x,pp.y,pp.z));
     }
   }
 }
 ll ret = 0;
 if(curr>2&&curc>2){
   ret += (curc-2)*ll(curr-2);
 }
  for(auto it = str.begin();it!=str.end();++it){
    auto pp = *it;
    ret += pp.cal();
  }
  for(auto it = stc.begin();it!=stc.end();++it){
    auto pp = *it;
    ret += pp.cal();
  }
 cout<<ret<<endl;
 return 0;
}


Measured memory_bytes: 16140