akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
    int month,day;
    int sum;
    int i;
    
    scanf("%d %d",&month,&day);
    while(month!=0){
        sum=0;
        //通算日数の計算
        for(i=1;i<month;i++){
            switch(i){
                case 2:
                    sum=sum+29;
                    break;
                case 4:
                    sum=sum+30;
                    break;
                case 6:
                    sum=sum+30;
                    break;
                case 9:
                    sum=sum+30;
                    break;
                case 11:
                    sum=sum+30;
                    break;
                default:
                    sum=sum+31;
                    break;
            }
        }
        sum=sum+day;
        
        //曜日の判定
        switch(sum%7){
            case 0:
                printf("Wednesday\n");
                break;
            case 1:
                printf("Thursday\n");
                break;
            case 2:
                printf("Friday\n");
                break;
            case 3:
                printf("Saturday\n");
                break;
            case 4:
                printf("Sunday\n");
                break;
            case 5:
                printf("Monday\n");
                break;
            case 6:
                printf("Tuesday\n");
                break;
        }
        
        scanf("%d %d",&month,&day);
    }
    
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long d[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>d[i];
	}
	long long ans=0LL;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i+1; j < n; ++j)
		{
			ans+=d[i]*d[j];
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
const int INF = 1000000000;
int dp[1002][1002];

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> t(n);
	for(int i = 0; i < n; ++i){ cin >> t[i]; }
	sort(t.begin(), t.end());
	if(n == 1){
		cout << t[0] << endl;
		return 0;
	}else if(n == 2){
		cout << t[1] << endl;
		return 0;
	}
	for(int i = 0; i <= n; ++i){
		for(int j = 0; j <= n; ++j){ dp[i][j] = INF; }
	}
	dp[0][0] = dp[1][1] = dp[2][2] = 0;
	for(int i = 0; i <= n; ++i){
		for(int j = i; j >= 0; --j){
			if(i + 2 <= n){
				dp[i + 2][j + 1] = min(
					dp[i + 2][j + 1], dp[i][j] + t[i + 1] + t[j]);
			}
			if(i + 1 <= n && j >= 1){
				dp[i + 1][j] = min(
					dp[i + 1][j], dp[i][j] + t[i] + t[0]);
			}
			if(i + 2 <= n && j >= 2){
				dp[i + 2][j] = min(
					dp[i + 2][j], dp[i][j] + t[i + 1] + t[1] + t[0] + t[1]);
			}
			if(j >= 2){
				dp[i][j - 1] = min(
					dp[i][j - 1], dp[i][j] + t[j - 1] + t[0]);
			}
		}
	}
	cout << dp[n][1] - t[0] << endl;
	return 0;
}


Measured memory_bytes: 5132
X,N=map(int,input().split())
if N>0:
  P=list(map(int,input().split()))
  for i in range(N+1):
    if X-i not in P:
      print(X-i)
      break
    elif X+i not in P:
      print(X+i)
      break
else:
  print(X)

Measured memory_bytes: 9116
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N, M = read_values() 
    A = read_list()

    print(max(-1, N - sum(A)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 10776
<?php
fscanf(STDIN, "%s", $s);
$l = str_split($s);
$str = [];
foreach ($l as $v) {
    if ($v == 'B') {
        $b = array_pop($str);
    } else {
        $str[] = $v;
    }
}
foreach ($str as $v) {
    echo $v;
}


Measured memory_bytes: 3576
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve(string A) {
  const int n = A.size();
  vector<vector<int>> next(n + 1, vector<int>(26));
  vector<int> max_len(n + 2);
  REP(i,26) next[n][i] = n;
  for (int i = n - 1; i >= 0; --i) {
    REP(j,26) {
      if (A[i] == j + 'a') next[i][j] = i;
      else next[i][j] = next[i+1][j];
    }
  }
  max_len[n+1] = 0;
  max_len[n] = 1;
  for (int i = n - 1; i >= 0; --i) {
    int mi = 1e9;
    REP(j,26) {
      mi = min(mi, max_len[next[i][j] + 1] + 1);
    }
    max_len[i] = mi;
  }
  // for (int i: max_len) cout << i << " ";
  // cout << endl;
  string res;
  int pos = 0;
  for (int len = max_len[0] - 1; len >= 0; --len) {
    REP(i,26) {
      if (max_len[next[pos][i] + 1] == len) {
        res += char('a' + i);
        // cout << res << endl;
        pos = next[pos][i] + 1;
        break;
      }
    }
  }
  cout << res << endl;
  // cout << max_len[0] << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	string A;
	cin >> A;
	solve(A);
	return 0;
}


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int MAX = 10000;
int mas[100][10010];

vector<pair<int, pair<int, int>>> graph[100010];

signed main(){
	int n, m, s;
	cin >> n >> m >> s;

	chmin(s, MAX);

	int u, v;
	for(int i = 0;i < m;i++){
		int a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		graph[u].push_back({v, {a, b}});
		graph[v].push_back({u, {a, b}});
	}

	int c[100], d[100];
	for(int i = 0;i < n;i++){
		cin >> c[i] >> d[i];
	}

	int ans[100];
	for(int i = 0;i < n;i++) ans[i] = LLONG_MAX;
	typedef pair<int, pair<int, int>> P;
	priority_queue<P, vector<P>, greater<P>> que;
	for(int i = 0;i < n;i++){
		for(int j = 0;j <= MAX;j++){
			mas[i][j] = LLONG_MAX;
		}
	}

	for(int i = 0;i <= s;i++){
		mas[0][i] = 0;
		que.push({0, {0, i}});
	}


	while(!que.empty()){
		int cost = que.top().first;
		int idx = que.top().second.first;
		int coin = que.top().second.second;
		que.pop();
		if(mas[idx][coin] < cost) continue;
		if(coin < MAX){
			int ncoin = min(coin+c[idx], MAX);
			if(cost + d[idx] < mas[idx][ncoin]){
				mas[idx][ncoin] = cost+d[idx];
				chmin(ans[idx], mas[idx][ncoin]);
				que.push({cost+d[idx], {idx, ncoin}});
			}
		}

		for(auto e : graph[idx]){
			if(coin - e.second.first < 0) continue;
			int ncoin = coin - e.second.first;
			int nidx = e.first;
			int ncost = cost + e.second.second;
			if(ncost < mas[nidx][ncoin]){
				mas[nidx][ncoin] = ncost;
				chmin(ans[nidx], mas[nidx][ncoin]);
				que.push({ncost, {nidx, ncoin}});
			}
		}
	}

	for(int i = 1;i < n;i++){
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 15832
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    for (int i = 0; i <= n; i++) {
        int m = i * 1.08;
        if (n == m) {
            cout << i << '\n';
            return 0;
        }
    }

    cout << ":(\n";
    return 0;
}

Measured memory_bytes: 888
// #pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int inf = 0x3f3f3f3f;
#define LOCAL
const int maxn = 1e6 + 7;
int read(){
    int x = 0; int zf = 1; char ch = ' ';
    while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}

int main(int argc, char * argv[]) 
{
	int n;
	cin >> n;
	bool ans = 0;
	for (int i = 1; i <= 9; i++){
		if (n % i == 0 && n / i <= 9){
			ans = 1;
			break;
		} 
	}
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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")
    };
}

#[inline]
#[allow(dead_code)]
fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }

    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }

        m = n;
        n = k;
    }
}

#[inline]
#[allow(dead_code)]
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}

macro_rules! eprint(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = write!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! eprintln(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! dbg {
    ($val:expr) => {
        // Use of `match` here is intentional because it affects the lifetimes
        // of temporaries - https://stackoverflow.com/a/48732525/1063961
        match $val {
            tmp => {
                eprintln!("[{}:{}] {} = {:#?}",
                          file!(), line!(), stringify!($val), &tmp);
                tmp
            }
        }
    }
}

fn main() {
    input!{
        n: usize,
        a_v: [i64; n],
    }

    let a_v_sum: Vec<_> = a_v.iter().scan(0, |state, &a| {
        *state = *state + a;
        Some(*state)
    })
        .collect();

    let mut answer = u64::max_value();
    for b_begin in 1..n {
        let a_sum = a_v_sum[b_begin - 1];
        let b_sum = a_v_sum[n - 1] - a_sum;

        // dbg!(a_sum);
        // dbg!(b_sum);

        let difference = (a_sum - b_sum).abs() as u64;
        answer = std::cmp::min(answer, difference);
    }

    println!("{}", answer);
}


Measured memory_bytes: 8444
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int inf = 1e17;
typedef pair<int, int> P;
typedef pair<int, P> PP;

signed main() {
	string s; cin >> s;
	if (s == "SUN")cout << 7 << endl;
	if (s == "MON")cout << 6 << endl;
	if (s == "TUE")cout << 5 << endl;
	if (s == "WED")cout << 4 << endl;
	if (s == "THU")cout << 3 << endl;
	if (s == "FRI")cout << 2 << endl;
	if (s == "SAT")cout << 1 << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int A=in.nextInt();
    int B=in.nextInt();
    int H=in.nextInt();
    int M=in.nextInt();
    
    double t=(2*3.141592654*H)/12+(2*3.141592654*M)/(12*60);
    
    double t1=(2*3.141592654*M)/60;
    
    double p=Math.abs(t-t1);
    double y=Math.cos(p);
    double k=((y*2*A*B)-(A*A)-(B*B))*-1;
    double h=Math.sqrt(k);
    System.out.println(h);
  }
}
  


    
    
    


Measured memory_bytes: 36040
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, i, sum, hasa;
    String s;
    char c;
    char[] d;
    d = new char[8];
    for(n = sc.nextInt();n-- > 0;){
      sum = 0; hasa = 0;
      for(i = 0;i < 2;i++){
        s = sc.next(); c = s.charAt(0);
        if(c >= '2' && c <= '9')sum += (int)(c - '0');
        else if(c == 'A'){ sum += 11; hasa++; }
        else sum += 10;
      }
      for(i = 0;i < 8;i++){ s = sc.next(); d[i] = s.charAt(0); }

      if(sum == 21)out.println("blackjack");
      else{
        if(sum == 22){ sum -= 10; hasa--; }
        for(i = 0;i < 8;i++){
          if(sum > 17 || (sum == 17 && hasa == 0)){
            out.println(sum); break;
          }else{
            if(d[i] >= '2' && d[i] <= '9')sum += (int)(d[i] - '0');
            else if(d[i] == 'A'){ sum += 11; hasa++; }
            else sum += 10;
            if(sum > 21 && hasa > 0){
              sum -= 10; hasa--;
            }else if(sum > 21){
              out.println("bust"); break;
            }
          }
        }
        if(i == 8)out.println(sum);
      }
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 20428
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

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


int main(){
  ll x,y,z; cin >> x >> y >> z;
  cout << (x-z)/(y+z) << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n; cin >> n;
    ll a[200001]; INITA(a, 0, 200000, 0);
    ll total = 0;
    REP(i, n) {
        cin >> a[i];
        total += a[i];
    }
    ll a_total = 0;
    ll res = 10e12;
    REP(i, n-1) {
        // n-1までのカードをA, Bでわける
        a_total += a[i];
        res = min(res, abs((total-a_total) - a_total));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5200
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define PI 3.14159265359

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    vi arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        arr[i]--;
    }
    vi vis(n, -1);
    int at = 0, d = 0;
    while (true) {
        if (vis[at] != -1) break;
        vis[at] = d++;
        at = arr[at];
        if (d == k) {
            cout << at + 1 << endl;
            return 0;
        }
    }
    k -= vis[at];
    k %= (d - vis[at]);
    while (k--) {
        at = arr[at];
    }
    cout << at + 1 << endl;

    return 0;
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    int N; cin>>N;

    int t,x,y; t=x=y=0;
    bool ok=true;
    REP(i,N){
        int nt,nx,ny; cin>>nt>>nx>>ny;
        int dt=nt-t,dx=abs(nx-x),dy=abs(ny-y);

        if(dt<dx+dy or dt%2!=(dx+dy)%2){
            ok=false; break;
        }
        t=nt,x=nx,y=ny;
    }
    cout<<(ok? "Yes":"No")<<endl;
    
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>
#include <bitset>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

const int N = 2000 * 2000 + 7;

bitset <N> dp;

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    vector <int> a(n);
    int s = 0;
    dp[0] = 1;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        dp |= dp << a[i];
        s += a[i];
    }
    double p = s * 0.5;
    int ans = 1e9;
    int ret = p;
    for (int i = N - 1; i >= 0; i--)
    {
        if (dp[i] && (abs(i - p) < ans))
        {
            ans = abs(i - p);
            ret = i;
        }
    }
    cout << ret << '\n';
    /*
    while (true)
    {
        int n = 5;
        vector <int> a;
        for (int i = 0; i < n; i++)
        {
            a.push_back(rnd() % 2000 + 1);
        }
        for (int i = 0; i < n; i++)
        {
            cout << a[i] << ' ';
        }
        cout << '\n';
        cout << solve(a) << ' ' << _solve(a) << endl;
    }
    */
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
 string s;
  cin>>s;
  
  vector<ll> vec;
  for(int i=0;i<s.size();i++){
    
    if(s[i]=='A'){
      vec.push_back(1);
    continue;}
    
    if(s[i]=='B'){
      if(i+1<s.size()){
      if(s[i+1]=='C'){
        vec.push_back(2);
        i++;
      continue;}
        if(s[i+1]!='C'){
          vec.push_back(0);
        continue;}
      }
      else{
        vec.push_back(0);
        continue;
      }
    }
    
    if(s[i]=='C'){
      vec.push_back(0);
      continue;}
    
  }
  
  int si=vec.size();
  

  
  ll ans=0;
  ll kosu2=0;
  for(int i=si-1;i>=0;i--){
    if(vec[i]==1){
      ans+=kosu2;}
    if(vec[i]==2){
      kosu2++;}
    if(vec[i]==0){
      kosu2=0;}
  }
  
  cout<<ans<<endl;
  return 0;
  
  
  
  
 
}

Measured memory_bytes: 2680
#include<stdio.h>
#include<math.h>

int isPrime(int);

int main(){
  int n, i, j = 0;
  int A[10000];

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
    if(isPrime(A[i]) == 1) j++;
      }

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

  return 0;
}

int isPrime(int x){
  int i = 3;

  if(x == 2) return 1;

  if(x < 2 || x % 2 == 0) return 0;

  while(i <= sqrt(x)){
    if(x % i == 0) return 0;
    i = i + 2;
  }

  return 1;
}

Measured memory_bytes: 632
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <list>
#include <ctime>
#include <memory.h>
#include <bitset>
#include <climits>
#include <iostream>
#include <stdlib.h>

#define F first
#define S second
#define endl "\n"
#define pb push_back
#define mp make_pair
#define bs 1000000007
#define pi 3.141592653589793
#define y1 kjdfshnvoavaofobiopj
using namespace std;

string st;
int n;
bool foundn, founds, foundw, founde;

int main(){
//freopen("input.txt", "r", stdin);
ios_base::sync_with_stdio(0);
cin.tie(0);

cin>>st;
n = st.size();
for(int i = 0; i < n; i++)
	if(st[i] == 'N')
		foundn = true;
	else if(st[i] == 'S')
		founds = true;
	else if(st[i] == 'W')
		foundw = true;
	else
	founde = true;

if((foundn && !founds) || (!foundn && founds))
	cout<<"No"<<endl;
else if((foundw && !founde) || (!foundw && founde))
	cout<<"No"<<endl;
else
	cout<<"Yes"<<endl;

return 0;}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc065/tasks/arc076_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N, M, c, cnt;
int main()
{
  c = 1000000007;
  cin >> N >> M;

  cnt = 0;
  if (abs(N - M) <= 1)
  {
    cnt = N == M ? 2 : 1;
    REP(i, N)
    {
      cnt = (cnt * (i + 1) % c);
    }
    REP(i, M)
    {
      cnt = (cnt * (i + 1) % c);
    }
  }

  cout << cnt << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#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 = 1001001001;

int main() {
    int n;
    cin >> n;
    
    bool isSeven = false;

    if (n % 10 == 7) {
        isSeven = true;
    }

    while (isSeven == false) {
        if (n % 10 == 7) {
            isSeven = true;
            break;
        }

        if (n > 10) {
            n /= 10;
        }
        else {
            break;
        }
    }

    cout << ((isSeven) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	string s;
	cin>>n>>s;
	ll ans=0;
	for(ll i=0;i<n-2;i++){
		string t;
		for(ll j=0;j<3;j++){
			char now=s[j+i];
			t.push_back(now);
		}
	//	cout << t<<endl;
		if(t=="ABC"){
			ans++;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

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

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

typedef complex<ld> cl;
vector<cl> v;

bool check(cl p, ld r) {
    bool ret = true;
    for(auto i : v) {
        if(abs(i - p) > r + EPS) ret = false;
        if(!ret) break;
    }
    return ret;
}

void solve() {
    ll n;
    cin >> n;
    for(ll i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        v.push_back(cl(x, y));
    }
    ld ans = 10000.0;
    for(ll i = 0; i < n-1; i++) {
        for(ll j = i+1; j < n; j++) {
            ld r = abs(v[i] - v[j]) / 2.0;
            bool ok = check((v[i] + v[j]) / (ld)2.0, r);
            if(ok) chmin(ans, r);
        }
    }
    for(ll i = 0; i < n-2; i++) {
        for(ll j = i+1; j < n-1; j++) {
            for(ll k = j+1; k < n; k++) {
                cl a = v[j] - v[i];
                cl b = v[k] - v[i];
                cl c = b * conj(a) - a * conj(b);
                if(abs(c) < EPS) continue;
                cl z = a * b * (conj(a) - conj(b)) / c;
                bool ok = check(z + v[i], abs(z));
                if(ok) chmin(ans, abs(z));
            }
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
  
  public static void main (String[] args){
    
    Main main = new Main();
    main.solve();
  }
  
  private void solve(){
    
    Scanner scanner = new Scanner (System.in);
    
    String S = scanner.nextLine();
    StringBuffer sb = new StringBuffer(S);
    int count = 0;
    
    for (int index=0; index<sb.length();index++){
      if (sb.charAt(index)=='1'){
        count++;
      } else {
        count--;
      }
    }
    
    System.out.println((sb.length()-(Math.abs(count))));
  }
}

Measured memory_bytes: 26896
/*
 * AOJ 2214: Warp Hall
 * ?¢??????????(1,1)?????°??????(m,n)???????¬??????????????????°?????????????????°????´???????????????´??\??°???????????????????´????????????????????°??§??????????
 * ?±????????????°DP
 * ???????????????????´?i(ai,bi)??°(ci,di)???(1,1)??°(ai,bi)???????????°???di??????????????\????´???????????????¢????????????????????????????????£???L??????????????????di????°?????´??????????DP?±???°?????°??????????´???\??£???????????°???
 */


#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long LL;

const LL MOD = 1000000007ll;

inline LL add(LL a, LL b) { return (a + b) % MOD; }

inline LL sub(LL a, LL b) { return (a - b + MOD) % MOD; }

inline LL mul(LL a, LL b) { return a * b % MOD; }

LL f[200010];

LL Inverse(LL a, LL p = MOD) {
  if (a == 1) return 1;
  return sub(0, mul(p / a, Inverse(p % a, p)));
}

LL C(LL a, LL b) {
  return mul(mul(f[a], Inverse(f[b])), Inverse(f[a - b]));
}

struct Warp {
  int sx, sy, tx, ty;

  bool operator<(const Warp &w) const {
    if (sx != w.sx) return sx < w.sx;
    return sy < w.sy;
  }
} w[1010];

LL d[1010];
int m, n, k;

LL Gao(LL sx, LL sy, LL tx, LL ty) {
  if (sx > tx || sy > ty) return 0;
//  printf("%lld %lld %lld %lld\n", sx, sy, tx, ty);
  return C(tx - sx + ty - sy, tx - sx);
}

int main() {
  f[0] = 1;
  for (LL i = 1; i <= 200000; ++i) {
    f[i] = mul(f[i - 1], i);
  }
  while (scanf("%d%d%d", &m, &n, &k) != EOF && m + n + k > 0) {
    for (int i = 0; i < k; ++i) {
      scanf("%d%d%d%d", &w[i].sx, &w[i].sy, &w[i].tx, &w[i].ty);
      --w[i].sx;
      --w[i].sy;
      --w[i].tx;
      --w[i].ty;
    }
    memset(d, 0, sizeof(d));
    sort(w, w + k);
    w[k].sx = m - 1;
    w[k].sy = n - 1;
    for (int i = 0; i <= k; ++i) {
      d[i] = C(w[i].sx + w[i].sy, w[i].sx);
//      printf("%d %lld\n", i, d[i]);
      for (int j = 0; j < i; ++j) {
//        printf("--%d %d\n", i, j);
        d[i] = add(d[i],
                   mul(d[j],
                       sub(Gao(w[j].tx, w[j].ty, w[i].sx, w[i].sy),
                           Gao(w[j].sx, w[j].sy, w[i].sx, w[i].sy))));
//        printf("--%d %d\n", i, j);
      }
//      printf("%d %lld\n", i, d[i]);
    }
    printf("%lld\n", d[k]);
  }

  return 0;
}

Measured memory_bytes: 4344
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Q = sc.nextInt();
        int[][] rec = new int[510][510];
        for(int i=1;i<=M;i++){
            int L = sc.nextInt();
            int R = sc.nextInt();
            rec[L][R] += 1;
        }
        int[][] head = new int[510][510];
        for(int row=1;row<=N;row++){
            head[row][row] = rec[row][row];
            for(int col=row+1;col<=N;col++){
                head[row][col] = head[row][col-1]+rec[row][col];
            }
        }
        int[][] dp = new int[510][510];
        for(int col=N;col>=1;col--){
            dp[col][col]=rec[col][col];
            for(int row=col-1;row>=1;row--){
                dp[row][col] = dp[row+1][col]+head[row][col];
            }
        }
        for(int j=1;j<=Q;j++){
            int p = sc.nextInt();
            int q = sc.nextInt();
            System.out.println(dp[p][q]);
        }
    }
}


Measured memory_bytes: 163936
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MOD = 1e9+7;

signed main(){
    string s;
    cin >> s;
    if(s[0] <=  'Z'){
        cout << "A" << endl;
    }
    else{
        cout << "a" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
typedef long long int ll ;


#define INF 2000000000

int main(void){
    
    int array[3][3];
    int i,j,k,N;
    int num[10];
    string res;
    
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
        cin >> array[i][j];
        }
    }

    cin >>  N ;
    for(i=0;i<N;i++){
        cin >> num[i];
    }

     for(i=0;i<N;i++){
        for(j=0;j<3;j++){
            for(k=0;k<3;k++){
                
                if(array[j][k]==num[i]) {
                    array[j][k]= 0;
                }
            }
        }   
     }

    if(array[0][0]==0 && array[0][1]==0 && array[0][2]==0 ) res = "Yes" ;
    if(array[1][0]==0 && array[1][1]==0 && array[1][2]==0 ) res = "Yes" ;
    if(array[2][0]==0 && array[2][1]==0 && array[2][2]==0 ) res = "Yes" ;

    if(array[0][0]==0 && array[1][0]==0 && array[2][0]==0 ) res = "Yes" ;
    if(array[0][1]==0 && array[1][1]==0 && array[2][1]==0 ) res = "Yes" ;
    if(array[0][2]==0 && array[1][2]==0 && array[2][2]==0 ) res = "Yes" ;

    if(array[0][0]==0 && array[1][1]==0 && array[2][2]==0 ) res = "Yes" ;
    if(array[2][0]==0 && array[1][1]==0 && array[2][0]==0 ) res = "Yes" ;

    if(res != "Yes") res = "No" ;
    
    cout << res ;
    
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll A,B;
    cin >> A >> B;

    if(A > 12)cout << B << endl;
    else if(A < 6)cout << 0 << endl;
    else cout << B / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <functional>
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H,W;
  cin >> H >> W;
  vector<string> G(H);
  for(int i=0; i<H; i++){
    cin >> G[i];
  }
  vector<vector<ll>> O(H,vector<ll> (W+1,0));
  vector<vector<ll>> I(H+1,vector<ll> (W,0));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      O[i][j+1] += O[i][j] + (G[i][j] == 'O');
      I[i+1][j] += I[i][j] + (G[i][j] == 'I');
    }
  }
  ll ans = 0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(G[i][j] == 'J'){
        ans += (O[i][W] - O[i][j]) * (I[H][j] - I[i][j]);
      }
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 153924
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
from collections import deque

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

n = i_i()
a = i_l()

d = deque()

for i in range(n):
    if i % 2 != 0:
        d.append(a[i])
    else:
        d.appendleft(a[i])

if n % 2 == 0:
    print(*list(reversed(d)))
else:
    print(*d)

Measured memory_bytes: 25424
#include <stdio.h>

int main(){
  int X,Y,Z;
  scanf("%d %d %d" ,&X,&Y,&Z);
  int T;
  T=X;
  X=Y;
  Y=T;
  T=Z;
  Z=X;
  X=T;
  printf("%d %d %d\n",X,Y,Z);
  return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int H, A;
  cin >> H >> A;
  int ans = (H + A - 1) / A;
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	vector<string>W(N);
	rep(i, N) {
		cin >> W[i];
	}
	rep(i, N - 1) {
		if (W[i][W[i].size() - 1] != W[i + 1][0]) {
			cout << "No";
			return 0;
		}
	}
	sort(W.begin(), W.end());
	rep(i, N - 1)if (W[i] == W[i + 1]) {
		cout << "No";
		return 0;
	}
	cout << "Yes";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<iomanip>
#include<list>
using namespace std;

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

	if (a == b) {
		for (int i = 1; i <= a; i++) {
			cout << a;
		}
	}
	else {
		int big = max(a, b);
		int small = min(a, b);

		for (int i = 1; i <= big; i++) {
			cout << small;
		}
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <climits>
#include <functional>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)
#define all(a) begin(a),end(a)

signed main()
{
	string a, b; cin >> a >> b;
	int x=a[0]-'0',y=b[0]-'0';
	string A="",B="";
	{
		rep(i, y) A += a;
		rep(i, x) B += b;
	}

	if (A <= B) {
		cout << A << endl;
	} else {
		cout << B << endl;
	}
}


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

const ll INF = 1LL << 60;

ll N;
string S;
int main() {
    cin >> N >> S;
    vector<ll> R(N + 1), G(N + 1), B(N + 1);
    R[0] = 0;
    G[0] = 0;
    B[0] = 0;
    
    rep(i, S.size()) {
        if (S[i] == 'R') {
            R[i + 1] = R[i] + 1;
            G[i + 1] = G[i]; 
            B[i + 1] = B[i];
        } else if (S[i] == 'G') {
            R[i + 1] = R[i];
            G[i + 1] = G[i] + 1;
            B[i + 1] = B[i];
        } else {
            R[i + 1] = R[i];
            G[i + 1] = G[i];
            B[i + 1] = B[i] + 1;
        }
    }

    // rep(i, N + 1) {
    //     cout << R[i] << " ";
    // }
    ll ans = 0;
    for (int i = 1; i <= N - 1; i++) {
        if (S[i] == 'R') {
            // 左 G, 右 B
            ll tmp1 = (G[i] - G[0]) * (B[N] - B[i]);

            // 左 B, 右 G 
            ll tmp2 = (B[i] - B[0]) * (G[N] - G[i]);
            ans += tmp1;
            ans += tmp2;
            
        } else if (S[i] == 'G') {
            // 左 R 右 B
            ll tmp1 = (R[i] - R[0]) * (B[N] - B[i]);

            // 左 B, 右 R 
            ll tmp2 = (B[i] - B[0]) * (R[N] - R[i]);
            // cout << tmp1 << " " << tmp2 << endl;

            ans += tmp1;
            ans += tmp2;
        } else {
            // 左 R 右 G 
            // 左 G 右 R 
            ll tmp1 = (R[i] - R[0]) * (G[N] - G[i]);
            ll tmp2 = (G[i] - G[0]) * (R[N] - R[i]);

            ans += tmp1;
            ans += tmp2;
        }
    }

    ll c;
    // 距離 
    rep(k, N) {
        // 始点
        // cout << k << endl;
        // 中点
        for (int j = 1; j <= N - 1; j++) {
            if (j - k - 1 < 0) continue;
            if (j + k + 1 >= N) continue; 

            if (S[j] != S[j - k - 1] && S[j] != S[j + k + 1] &&
                S[j - k - 1] != S[j + k + 1]) {
                // cout << j - k - 1 << " " << j << " " << j + k + 1 << endl;
                ans--;
                // c++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0, x = 0;
    REP(i, n){
        if(s[i] == 'I') x++;
        else x--;
        ans = max(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int N;
    cin >> N;
    cout << N*N*N << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//vector<vector<int>> a(5, vector<int>(5, 0)) 5*5-0
int main(){
    long long int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    long long int step = 0;
    for(int i = 1; i < n; i++){
        if(a.at(i - 1) > a.at(i)){
            step += a.at(i - 1) - a.at(i);
            a.at(i) = a.at(i - 1);
        }
    }

    cout << step << endl;
}

Measured memory_bytes: 3956
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication32
{
    class Program
    {  
      static void Main()
      { while(true)
		  {
			  int a=int.Parse(Console.ReadLine());
	       if(a==0)break;
	       for(int b=0;b<9;b++){
			   a-=int.Parse(Console.ReadLine());
			   }
			   Console.WriteLine(a);
	  }
		  }
		  }
		  }

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

#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)

using ll = long long;

string func(ll n,ll m){
    method(digit,int,ll x){
        int res = 0;
        while(x){
            ++res;
            x /= 10;
        }
        return res;
    };
    method(count_sum,ll,ll p){
        if(p==0)return 0;
        ll res = 0;
        ll maxs;
        for(maxs=10;maxs<=p;maxs*=10){
            res += (maxs-maxs/10) * digit(maxs-1);
        }
        maxs /= 10;
        res += (p-maxs+1) * digit(p);
        return res;
    };


    ll lp = 1;
    ll rp = n;
    while(lp<rp){
        ll mid = (lp+rp) / 2;
        if(count_sum(mid)<=n){
            lp = mid+1;
        }else{
            rp = mid;
        }
    }
    for(int i=0;i<10;++i){
        if(count_sum(lp)<=n)++lp;
    }
    --lp;
    vector<int> ans;
    for(int i=0;i<m+100;++i){
        string str = to_string(lp+i);
        for(auto c:str)ans.emplace_back(c-'0');
    }
    string res = "";
    int p = count_sum(lp) - digit(lp);
    for(int i=0;i<ans.size();++i){
        if(n<=p+i+1 and p+i+1<n+m)res+= ans[i] + '0';
    }
    return res;
}

int main(){
    ll n,m;
    while(true){
        cin >> n >> m;
        if(n==0 and m==0)break;
        cout << func(n,m) << endl;
    }
    return 0;
}



Measured memory_bytes: 3120
// ABC169C
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
int main() {
	long long a,v,b,w,t;

	cin>>a>>v;
	cin>>b>>w;
	cin>>t;

	long long d=abs(a-b);
	long long d2=v-w;
	if (a==b){
		cout <<"YES"<<endl;
		return 0;
	}
	if (d2<=0){
		cout <<"NO"<<endl;
		return 0;
	}
	if (d2>d){
		cout <<"NO"<<endl;
		return 0;
	}
	if (t*d2 >= d ){
		cout <<"YES"<<endl;
		return 0;

	}
	cout << "NO" <<endl;
	return 0;
}


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

int main(void) {
    int prime[50000],n_prime=5;
    prime[0] = 2, prime[1] = 3, prime[2] = 5, prime[3] = 7, prime[4] = 11;
    for (int i = 3; i <= 100010; i += 2) {
        if ((i % 3) * (i % 5) * (i % 7) * (i % 11) > 0) {
            bool t = true;
            for (int j = 5; j < n_prime; j++) {
                if (i % j == 0) t=false;
            }
            if (t) prime[n_prime] = i, n_prime++;
        }
    }

    int x, ans = 0;
    cin >> x;
    for (int i = 0; i < n_prime; i++) {
        if (prime[i] >= x && ans == 0) ans = prime[i];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#define MAX 400
int cards[MAX];
void RiffleShuffle(int n, int cards[]){
  int NC[MAX];
  for(int i = 0; i < 2*n; i+=2){
    NC[i] = cards[i/2];
  }
  for(int i = 1; i < 2*n; i+=2){
    NC[i] = cards[n+i/2];
  }
  for(int i = 0; i < 2*n; ++i){
    cards[i]=NC[i];
  }
}
void Cut(int n, int k, int cards[]){
  int NC[MAX];
  for(int i = 0; i < k; ++i){
    NC[2*n-1-i]=cards[k-1-i];
  }
  for(int i = 0; i < 2*n-k; ++i){
    NC[i] = cards[k+i];
  }
  for(int i = 0; i < 2*n; ++i){
    cards[i] = NC[i];
  }
}


int main()
{
  while(true){
    int n;
    scanf("%d",&n);
    if( n==0 )break;
    int cards[MAX];
    for(int i = 0; i < 2*n; ++i){
      cards[i]=i+1;
    }
    int m;
    scanf("%d", &m);
    for(int i = 0; i < m; ++i){
      int k;
      scanf("%d",&k);
      if( k == 0 )
	RiffleShuffle(n,cards);
      else
	Cut(n,k,cards);
    }
    for(int i = 0; i < 2*n; ++i){
      printf("%d\n",cards[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 0