akhauriyash/Code-Regression huggingface dataset:
from typing import List

class Node:
    def __init__(self, node_id, parent_id):
        self.node_id = node_id
        self.parent_id = parent_id
        self.children = []
        
        self.depth = None
        self.node_type =None

    def __str__(self):
        return str(self.node_id)
    def __repr__(self):
        return self.__str__()
        
    
class Tree:
    def __init__(self, n):
        self.root = None
        self.n_node = n
        self.node_list = [None for _ in range(n)]
    
    def find_node(self, node_id: int):
        if self.node_list[node_id] != None:
            return self.node_list[node_id]
        return None
    
    def add_children_from_ids(self, node_id: int, children_ids: List[int]):
        # check parent already exists
        parent_node = self.find_node(node_id)
        if parent_node == None:
            # create new node from parent_id
            parent_node = Node(node_id = node_id, parent_id = -1)
            self.node_list[node_id] = parent_node
            
        if len(children_ids) > 0:
            # add all the children (unregistered)
            # register parent_id, node_id, children
            for child_id in children_ids:
                child_node = self.find_node(child_id)
                
                if child_node == None:
                    child_node = Node(node_id = child_id, parent_id = node_id)
                else:
                    child_node.parent_id = node_id
                    
                parent_node.children.append(child_node)
                self.node_list[child_id] = child_node
    
    def overwrite_node_type(self):
        # find root and overwrite node type
        
        for node in self.node_list:
            # root, internal node, leaf
            if node.parent_id == -1:
                node_type = "root"
                self.root = node
            else:
                if node.children != []:
                    node_type = "internal node"
                else:
                    node_type = "leaf"
                    
            node.node_type = node_type

    def overwrite_depth(self, node, depth):
        if node.children == []:
            node.depth = depth
            # print("node.id: ", node.node_id, ",  node.depth: ", node.depth)
            return None
        else:
            node.depth = depth
            for child_node in node.children:
                self.overwrite_depth(child_node, depth+1)
        return None

    def print_nodes(self):
        for node in self.node_list:
            print("node {}: parent = {}, depth = {}, {}, {}".format(
                node.node_id, node.parent_id, node.depth, node.node_type, node.children
            ))            
  
def main():
    n = int(input())
    tree = Tree(n)
    for _ in range(n):
        node_id, k, *children = map(int, input().split())
        tree.add_children_from_ids(node_id = node_id, children_ids = children)
    tree.overwrite_node_type()

    tree.overwrite_depth(tree.root, 0)
    tree.print_nodes()    
main()



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

int main(){
    ll n;
    cin >> n;
    ll a[n + 1], b[n];
    rep(i, n + 1) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll ans = 0;

    rrep(i, n){
        ll res = b[i] - a[i + 1];
        if (res >= 0){
            if (a[i] - res >= 0){
                ans += b[i];
                a[i] -= res;
            }
            else {
                ans += a[i + 1] + a[i];
                a[i] = 0;
            }
        }
        else {
            ans += b[i];
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiil;
typedef pair<pll, ll> pplll;
typedef pair<pli, int> pplii;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<pll>> vvpll;
#define rep(i, a, b) for (ll i=(a); i<(b); i++)
#define rrep(i, a, b) for (ll i=(a); i>(b); i--)
#define pb push_back
#define tostr to_string
#define mkp make_pair
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

void print(ld out) { cout << fixed << setprecision(15) << out << '\n'; }
template<typename T> void print(T out) { cout << out << '\n'; }
template<typename T1, typename T2> void print(pair<T1, T2> out) { cout << out.first << ' ' << out.second << '\n'; }
template<typename T> void print(vector<T> A) { rep(i, 0, A.size()) { cout << A[i]; cout << (i == A.size()-1 ? '\n' : ' '); } }
template<typename T> void print(set<T> S) { vector<T> A(S.begin(), S.end()); print(A); }

template<typename T> inline bool chmax(T &x, T y) { return (y > x) ? x = y, true : false; }
template<typename T> inline bool chmin(T &x, T y) { return (y < x) ? x = y, true : false; }

ll sum(vector<ll> A) { ll res = 0; for (ll a: A) res += a; return res; }
ll max(vector<ll> A) { ll res = -INF; for (ll a: A) chmax(res, a); return res; }
ll min(vector<ll> A) { ll res = INF; for (ll a: A) chmin(res, a); return res; }

ll toint(string s) { ll res = 0; for (char c : s) { res *= 10; res += (c - '0'); } return res; }
int toint(char c) { return c - '0'; }
char tochar(int i) { return '0' + i; }

inline ll pow(int x, ll n) { ll res = 1; rep(_, 0, n) res *= x; return res; }
inline ll pow(ll x, ll n, int mod) { ll res = 1; while (n > 0) { if (n & 1) { res = (res * x) % mod; } x = (x * x) % mod; n >>= 1; } return res; }

inline ll floor(ll a, ll b) { if (a < 0) { return (a-b+1) / b; } else { return a / b; } }
inline ll ceil(ll a, ll b) { if (a >= 0) { return (a+b-1) / b; } else { return a / b; } }

int popcount(ll S) { return __builtin_popcountll(S); }
ll gcd(ll a, ll b) { return __gcd(a, b); }

ll N;
vector<ll> A;
map<pll, ll> memo[2];

ll rec(ll i, ll j, bool f) {
    if (memo[f].find({i, j}) != memo[f].end()) {
        return memo[f][{i, j}];
    }
    if (i == N) {
        if (j == N/2) {
            return 0;
        } else {
            return -INF;
        }
    }
    ll k = ceil(N-i, 2);
    if (j+k < N/2) {
        return -INF;
    }
    ll res = -INF;
    chmax(res, rec(i+1, j, 0));
    if (!f) {
        chmax(res, rec(i+1, j+1, 1) + A[i]);
    }
    memo[f][{i, j}] = res;
    return res;
}

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

    cin >> N;
    A.resize(N);
    rep(i, 0, N) cin >> A[i];

    ll ans = rec(0, 0, 0);
    print(ans);
    return 0;
}


Measured memory_bytes: 67356
n = int(input())
stone = input()
red_stone = stone.count("R")
white_stone = n - red_stone

left_red_stone = stone[:red_stone].count("R")
right_white_stone = stone[-white_stone:].count("W")

if left_red_stone == red_stone:
  print(0)
elif left_red_stone < right_white_stone:
  print(red_stone-left_red_stone)
else:
  print(white_stone-right_white_stone)

Measured memory_bytes: 63148
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;cin>>N;
  
  for(int i=0;i<=N;i++){
    if(i*108/100==N){
      cout<<i<<endl;
      return 0;
    }
  }
  
  cout<<":("<<endl;
}


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

int main(){
int c1,c5,c10,c50,c100,c500,all;
bool change=false;
cin>>c1>>c5>>c10>>c50>>c100>>c500;
all=c1+c5*5+c10*10+c50*50+c100*100+c500*500;
if(all>=1000) change=true;
cout<<change<<endl;
return 0;
}

Measured memory_bytes: 1164
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        int count = 0;
        for (int i = 0; i < s.length; i++) {
            if (s[i] == t[i])
                count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

vector<bool> criv (1000010, false);

int main(){

    int n;
    cin >> n;

    vector<int> v (n);
    map<int, int> nums;

    for(int i = 0; i < n; i++){
        cin >> v[i];
        nums[v[i]]++;
    }

    sort(v.begin(), v.end());

    for(auto k: nums){

        if(criv[k.first] == false){
            //marcar tds os multiplos de k            
            for(int j = 2 * k.first; j <= 1000000; j += k.first){
                criv[j] = true;
            }
        }
    }

    int ans = 0;

    for(auto num: nums){

        if(num.second == 1 && criv[num.first] == false){
            ans++;
        }        
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13400
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	map<string, int> mp;
	mp["SUN"] = 0;
	mp["MON"] = 1;
	mp["TUE"] = 2;
	mp["WED"] = 3;
	mp["THU"] = 4;
	mp["FRI"] = 5;
	mp["SAT"] = 6;
	string s;
	cin >> s;
	int res = mp["SUN"] - mp[s];
	if (res <= 0) {
		res += 7;
	}
	cout << res << '\n';
	
 	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int X;
    cin >> X;
    if( X % 7 == 4){
        cout << "mon" << endl;
    } 
    else if( X % 7 == 5){
        cout << "tue" << endl;
    }
    else if( X % 7 == 6){
        cout << "wed" << endl;
    }
    else if( X % 7 == 0){
        cout << "thu" << endl;
    }
    else if( X % 7 == 1){
        cout << "fri" << endl;
    }
    else if( X % 7 == 2){
        cout << "sat" << endl;
    }
    else{
        cout << "sun" << endl;
    }
}



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

int n;
int main()
{
    while(cin >> n)
    {
        if(n < 1200)
            cout << "ABC" << endl;
        else if(n < 2800)
            cout << "ARC" << endl;
        else
            cout << "AGC" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
X, K, D = [int(i) for i in input().split()]

if abs(X // D) >= K:
  print(abs(abs(X)-K*D))
  exit()

tmp = abs(X) % D
if (K - abs(X) // D) % 2 == 0:
  print(tmp)
else:
  print(abs(tmp-D))


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repe(i, n) for (ll i = 0; i <= (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);
template <typename T>
void MACRO_VAR_Scan(T &t)
{
    std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &... rest)
{
    std::cin >> first;
    MACRO_VAR_Scan(rest...);
}

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define yes() printf("yes\n")
#define no() printf("no\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

ll ans = 0;
bool check = 0;
bool boo = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c, d, n, m = 0;
int x = 0, y = 0;
int sum;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;
    cin >> n;
    vi v(n), p(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    rep(i, n)
    {
        cin >> p[i];
    }
    rep(i, n)
    {
        if (v[i] - p[i] > 0)
            ans += v[i] - p[i];
    }

    
    pr(ans);

    return 0;
}


Measured memory_bytes: 3620
N=int(input())
List=[list(map(int,input().split())) for i in range(N)]
A,B,C=zip(*List)
dp=[[0]*3 for i in range(N)]
dp[0][0]=A[0]
dp[0][1]=B[0]
dp[0][2]=C[0]
for i in range(1,N):
  dp[i][0]=max(dp[i-1][1],dp[i-1][2])+A[i]
  dp[i][1]=max(dp[i-1][0],dp[i-1][2])+B[i]
  dp[i][2]=max(dp[i-1][0],dp[i-1][1])+C[i]
print(max(dp[-1]))

Measured memory_bytes: 86488
import re

def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

N = int(input())

acgt = ["A", "C", "G", "T"]
changed = [".*GAC.*", ".*ACG.*", ".*A.GC.*", ".*AG.C.*"]
bad = ".*AGC"


# initialize
dp = {}
for a in acgt:
    for b in acgt:
        for c in acgt:
            now = a+b+c
            
            if re.match(bad, now):
                dp[now] = 0
            elif any(map(lambda ch: re.match(ch, now), changed)):
                dp[now] = 0
            else:
                dp[now] = 1

N -= 3

MOD = int(1e9) + 7
# main
while N > 0:
    dpNow = {}
    for a in acgt:
        for b in acgt:
            for c in acgt:
                abc = (a + b + c)[:min(N, 3)]
                dpNow[abc] = 0
                for key, value in dp.items():
                    now = key + abc

                    if re.match(bad, now):
                        ()
                    elif any(map(lambda ch: re.match(ch, now), changed)):
                        ()
                    else:
                        dpNow[abc] += value
                        dpNow[abc] %= MOD
                        
    dp = dpNow
    N -= 3

ans = 0
for v in dp.values():
    ans += v
    ans %= MOD

print(ans)


Measured memory_bytes: 55132
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n, a;
  scanf("%d%d", &n, &a);
  printf("%d\n", n*n-a);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 入力値を取得
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		// 満足度満たすか否か
		int smile = 0;
		smile = b >= a * c ? c : b / a;
		// 出力
		System.out.println(smile);
		// クローズ
		sc.close();
	}

}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
const int dx[4]={1,0,0,-1};
const int dy[4]={0,1,-1,0};
int main() {
int h,w;
  cin>>h>>w;
  vector<string> s(h);
  rep(i,0,h) cin>>s[i];
  /////////////////////
  int ans=0;
  rep(i,0,h){
   rep(j,0,w){//(i,j)から
     if(s[i][j]=='#') continue;
     vector<vin> dist(h,vin(w,-1));
     queue<P> q;
     dist[i][j]=0;
     q.push(mp(i,j));
     while(!q.empty()){
       P now=q.front();
       q.pop();
       int a=now.first,b=now.second;
       rep(i,0,4){
         int na=a+dx[i];
         int nb=b+dy[i];
         if(na<0||nb<0||na>=h||nb>=w) continue;
         if(s[na][nb]=='#') continue;
         if(dist[na][nb]!=-1)continue;
         q.push(mp(na,nb));
         dist[na][nb]=dist[a][b]+1;
         ans=max(ans,dist[na][nb]);
       }
     }
     
     
     
     
     
     
     
     
     
   }
  }
  cout<<ans<<endl;
}//bfs で最大値

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

int main() {
	vector <int> v;
	int n, k;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; ++ i) {
		int h; scanf("%d", &h);
		v.push_back(h);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	long long ans = 0;
	for (int i = k; i < n; ++ i)
		ans += v[i];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define in1(n) cin>>n;
#define in2(n, k) cin>>n>>k;
#define in3(n, k, s) cin>>n>>k>>s;
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define inar(n, a) \
    rep(i, n)\
        cin>>a[i];
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)\
{\
return (a.second < b.second);\
}
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    fast
    string s;
    cin>>s;
    int mx = 0, cnt = 0;
    rep(i, s.length()){
        if(s[i] == 'R') cnt++;
        else cnt = 0;
        mx = max(mx, cnt);
    }
    cout<<mx;
    return 0;
}

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

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

int main() {
  long long int a,b,c,d;
  cin>>a>>b>>c>>d;
  a--;
  long long int e=c*d/gcd(c,d);
  long long int p=b/c+b/d-b/e;
  long long int q=a/c+a/d-a/e;
  cout<<(b-p)-(a-q)<<endl;
}

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

# define fr first
# define sc second
# define pb push_back
# define int long long
# define mk make_pair
# define sz(s) (int)s.size()
# define all(s) s.begin(), s.end()
using namespace std;
const int N = 1e6+12,INF = 1000000007;
int a[N];
main(){
    string s;cin>>s;
    int i,n=s.size(),m,j;
    vector <int> v;
    if (s[0]=='<'){
        a[0]=0;
        v.pb(0);
    }
    else {
        a[0]=1;
    }
    s.pb('<');
    for (i=1;i<n;++i){
        if (s[i]=='>' && s[i+1]=='<')v.pb(i+1);
    }
    for (i=0;i<v.size();++i){
        int c=1,j=v[i]+1;
        while (s[j]=='<'){
            if (a[j]!=0 && c<a[j]){

                break;
            }
            a[j]=c;
            c++;
            j++;
        }
        a[j]=c;
        c=1,j=v[i]-1;
        while (s[j]=='>'){
            if (a[j]!=0 && c<a[j]){

                break;
            }
            else {
                a[j]=c;
                c++;
                j--;
            }
        }
    }
    int ans=0;
    for (i=0;i<=n;++i){
        ans+=a[i];
    }
    cout <<ans;
}



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

int main(void){
	int i,j,n,th,tm,ts,s[10000],g[10000],flg[10000];
	int max,sum;
	char c;

	while(cin>>n && n){
		max = sum = 0;

		for(i=0;i<n;i++){
			cin>>th>>c>>tm>>c>>ts;
			s[i] = ts + tm * 60 + th * 3600;
			cin>>th>>c>>tm>>c>>ts;
			g[i] = ts + tm * 60 + th * 3600;
		}

		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				if(s[i] > s[j] || s[i] == s[j] && g[i] > g[j]){
					swap(s[i],s[j]);
					swap(g[i],g[j]);
				}
			}
		}

		for(i=0;i<n;i++){
			for(j=0;j<i;j++){
				if(s[i] >= g[j] && flg[j]){
					sum--;
					flg[j] = 0;
				}
			}
			sum++;
			flg[i] = 1;
			if(max < sum) max = sum;
		}
		cout<<max<<endl;
	}

	return 0;
}

Measured memory_bytes: 984
#include <stdio.h>

int main()
{
	int a, b, c, temp;
	
	scanf("%d %d %d", &a, &b, &c);
	
	temp=a;
	a=b;
	b=temp;
	
	temp=a;
	a=c;
	c=temp;
	
	printf("%d %d %d", a, b, c);
	
return 0;
}

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

int main()
{
    int w,b,c;
    cin >> w >> b >> c;
    if (b < c)
        cout << ((c-(b+w)) < 0 ? 0 : c-(b+w));
    else
        cout << (b-(c+w)<0?0:b-(c+w));
    return 0;
}


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

using namespace std;

using ll = long long;

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

    constexpr ll MOD = 1e9 + 7;

    int n;
    string s;
    cin >> n >> s;

    vector<ll> cur(n + 1, 1), nxt(n + 1);
    cur[0] = 0;

    for (int i = 2; i <= n; ++i) {
        for (int j = 1; j <= n - i + 2; ++j) {
            cur[j] += cur[j - 1];
            nxt[j] = 0;
        }

        for (int j = 1; j <= n - i + 1; ++j) {
            if (s[i - 2] == '<') (nxt[j] += (cur[j] - cur[0] + MOD)) %= MOD;
            else (nxt[j] += (cur[n - i + 2] - cur[j] + MOD)) %= MOD;
        }
        swap(cur, nxt);
    }

    cout << cur[1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef  long long ll;
int gcd(int f , int s){if(s==0)return f;else return gcd(s,f%s);}
int const N = 1000006;
ll const M = 998244353;
long double const ep = .000000000000000001;
ll arr[N];
ll get(ll f , ll s){
	if(f <= 0 && s >= 0){
		return min(abs(f) , s) + s - f;
	}
	if(f <= 0 && s <= 0){
		return abs(f);
	}
	if(s >= 0 && f >= 0){
		return s;
	}
}
int main() {
	
	int a , b;
	cin >> a >> b;
	if(a == 1){
		int t;cin >> t;
		printf("%d\n", abs(t));
		return 0;
	}
	for(int i = 0 ; i < a ; i++)scanf("%lld",arr+i);
	ll ans = 1e18;
	for(int i = 0 ; i < a - b + 1 ; i++){
		ll curr = get(arr[i] , arr[i+b-1]);
		ans = min(curr , ans);
	}
	printf("%lld\n", ans);
	return 0;	
}

Measured memory_bytes: 1024
YM = input()
left = int(YM) // 100
right = int(YM) % 100

if((left > 12 and right < 1) or (left > 12 and right > 12) or (left < 1 and right < 1) or (left < 1 and right > 12)):
    print("NA")
elif(left <= 12 and left >= 1  and right <= 12 and right >= 1):
    print("AMBIGUOUS")
elif((left > 12 and right <= 12 and right >= 1) or (left < 1 and right <= 12 and right >= 1)):
    print("YYMM")
else:
    print("MMYY")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int K; cin >> K;
    REP(_, K) cout << "ACL";
    cout << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#define il inline
#define vd void
#define rg register
#define mn 200005
#define p 998244353
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
int n,sum,m,ans,s,pw[mn],b[mn<<1],c[mn<<1];
struct P{int x,y;}a[mn];
il vd Add(int x){while(x<=m) ++c[x],x+=x&-x;}
il int Sum(int x){int ans=0; while(x) ans+=c[x],x-=x&-x; return ans;}
il int cmp1(P a,P b){return a.x<b.x||(a.x==b.x&&a.y>b.y);}
il int cmp2(P a,P b){return a.y<b.y||(a.y==b.y&&a.x<b.x);}
il vd Inc(int &a,int b){if((a+=b)>=p) a-=p;}
il vd Dec(int &a,int b){if((a-=b)<0) a+=p;}
int main(){
    n=rd(),pw[0]=1;
    rep(i,1,n) a[i].x=rd(),a[i].y=rd(),pw[i]=(pw[i-1]<<1)%p,b[++m]=a[i].x,b[++m]=a[i].y;
    sort(b+1,b+m+1),m=unique(b+1,b+m+1)-b-1;
    rep(i,1,n){
        a[i].x=lower_bound(b+1,b+m+1,a[i].x)-b,a[i].y=lower_bound(b+1,b+m+1,a[i].y)-b;
    }
    sort(a+1,a+n+1,cmp1),ans=1ll*n*(pw[n]-1+p)%p;
    rep(i,1,n) Dec(ans,pw[Sum(a[i].x-1)]),Add(a[i].x);
    rep(i,1,m) c[i]=0;
    drp(i,n,1) Add(a[i].x),Dec(ans,pw[Sum(m)-Sum(a[i].x)]);
    rep(i,1,m) c[i]=0;
    rep(i,1,n) Inc(ans,pw[Sum(a[i].y-1)]),Add(a[i].y);
    rep(i,1,m) c[i]=0;
    drp(i,n,1) Add(a[i].y),Inc(ans,pw[Sum(m)-Sum(a[i].y)]);
    sort(a+1,a+n+1,cmp2);
    rep(i,1,m) c[i]=0;
    rep(i,1,n) Dec(ans,pw[Sum(a[i].y-1)]),Add(a[i].y);
    rep(i,1,m) c[i]=0;
    drp(i,n,1) Add(a[i].y),Dec(ans,pw[Sum(m)-Sum(a[i].y)]);
    rep(i,1,m) c[i]=0;
    rep(i,1,n) Add(a[i].x),Inc(ans,pw[Sum(m)-Sum(a[i].x)]);
    rep(i,1,m) c[i]=0;
    drp(i,n,1) Inc(ans,pw[Sum(a[i].x-1)]),Add(a[i].x);
    rt((ans)%p);
    return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
    while(!isdigit(c=gc())&&c!='-');
    int f=c=='-'?c=gc(),1:0,x=c^48;
    while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
    return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

Measured memory_bytes: 10240
N = int(input())
T, A = map( int, input().split())
H = list( map( int, input().split()))
         
K = []
Ksorted=[]
tmp=[]
 
for i in range(N):
  tmp.append( T - H[i] * 0.006)
  K.append(abs( A - tmp[i]))
  Ksorted = sorted(K)
  
T = K.index(Ksorted[0])
print(T+1)

Measured memory_bytes: 3064
S = input()
T = input()
assert len(S) == len(T)

def normalized(S):
    dic = {}  # char -> occurence order
    last = -1
    T = []
    for s in S:
        if s not in dic:
            last += 1
            dic[s] = last
        T.append(dic[s])
    return T

print("Yes" if normalized(S) == normalized(T) else "No")

Measured memory_bytes: 6832
#include <iostream>
#include <vector>
#include <utility>
#include <string>
using namespace std;
 
int main() {
 
	//数字
	int A,B;
	int N[3]={1,1,1};
  cin >> A >> B;
  N[A-1]=0;
  N[B-1]=0; 
  for(int i=0;i<3;i++){
    if(N[i]>0) cout << i+1 << endl;; 
  }
}

Measured memory_bytes: 256
/*input
10
1
10
100
1000000007
10000000000
1000000009
999999999
999
999
999
*/
#include <bits/stdc++.h>
using namespace std;

const int N = 100005;

int cnt, n;
int primes[9600], ok[N];
map<long long, bool> sqr;
map<long long, pair<int, int> > freq;

// <x after dividing it by all its cubic divisors, the one that pairs with newx>
pair<long long, long long> lulw(long long x) {
	long long y = 1, z = 1;
	for(int i = 0; i < cnt; ++ i) {
		if(1ll * primes[i] * primes[i] * primes[i] > x) break;
		if(x % primes[i]) continue;

		int cur = 0;
		while(x % primes[i] == 0) ++ cur, x /= primes[i];

		cur %= 3;
		if(cur == 0) continue;
		for(int j = 0; j < cur; ++ j) z *= primes[i];
		for(int j = cur; j < 3; ++ j) y *= primes[i];
	}

	if(x > 1) {
		if(sqr.count(x)) z *= x, y *= (int)sqrtl(x);
			else z *= x, y *= x * x;
	}
	return make_pair(z, y);
}

int main() {
	for(int i = 2; i < N; ++ i) if(!ok[i]) {
		primes[cnt ++] = i;
		sqr[1ll * i * i] = 1;
		for(long long j = 1ll * i * i; j < N; j += i) ok[j] = 1;
	}

	iostream::sync_with_stdio(false);
	
	cin >> n;
	for(int i = 0; i < n; ++ i) {
		long long a; cin >> a;

		auto cur = lulw(a);
		if(cur.first < cur.second) ++ freq[cur.first].first;
			else ++ freq[cur.second].second;
		// cout << a << ' ' << cur.first << ' ' << cur.second << endl;
	}

	int Ans = 0;
	for(auto it = freq.begin(); it != freq.end(); ++ it) {
		if(it->first == 1) ++ Ans;
			else Ans += max(it->second.first, it->second.second);
	}
	cout << Ans << '\n';
}


Measured memory_bytes: 10908
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define TLong long long 

int main(int argc, char const *argv[]){
	int player = 0,turn[3] = {0,-1,-1};
	char card[3][111];
	scanf("%s %s %s",card[0],card[1],card[2]);
	for (int i = 0; i < strlen(card[0]) + strlen(card[1]) + strlen(card[2]); ++i){
		switch(card[player][turn[player]]){
			case 'a':
				player = 0;
				break;
			case 'b':
				player = 1;
				break;
			case 'c':
				player = 2;
				break;
		}
		if(++turn[player] > strlen(card[player])){
			printf("%c\n", (player + 0x41));
			return 0;
		}
	}
	printf("%c\n", (player + 0x41));
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

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

    while(1){
        scanf("%d%d",&h,&w);
        if(h==0&&w==0) break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2100
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int n,a,b;
	cin>>n>>a>>b;
	int ans=min(b-1,n-a);
	if(!(a-b&1))ans=min(ans,(b-a)/2);
	else ans=min(ans,(b-a-1)/2+min(a,n-b+1));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b=0,c;
    char ara[4];
    scanf("%s",ara);
    for(a=0;a<3;a++){
    if(ara[a]=='o'){
    b++;

    }



    }

  c=700+b*100;
    printf("%d\n",c);

    return 0;

}


Measured memory_bytes: 128
/*===================*\
|ID : harryPotter_421  |
|      LANG: C++       |
\*====================*/
#include <iostream>
#include<bits/stdc++.h>
#define lli long long int
#define pb push_back
#define ld  double
#define f(j,m,n) for(lli j=m;j<n;j++)
#define harry ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define forn(n) for(i=0;i<n;i++);
using namespace std;
int prime[1000005];

void seive(lli n)     //to generate all prime no less than or equal to n
           {prime[0]=0;
            prime[1]=0;
            for(lli i=2;i<=n;i++)
                 prime[i]=1;
            for(lli i=2;i<=sqrt(n);i++)
               {if(prime[i])
                    {
                        for(lli j=i*i;j<=n;j+=i)
                             prime[j]=0;
                    }

               }
             }
vector<lli> prime_factor(lli n)             //Tp generate all prime factors of a given number n
                   {if(n==1)
                       {vector<lli> v;
                        v.pb(1);
                        return v;}
                     if(prime[n])
                       {
                         vector<lli> v;
                         v.pb(1);
                         v.pb(n);
                         return v;
                        }
                    else
                        {
                          for(lli i=2;i<=sqrt(n);i++)
                                {if(prime[i]&&n%i==0)
                                    {

                                       vector<lli> vec=prime_factor(n/i);
                                       vec.pb(i);
                                       return vec;
                                    }

                                }


                        }

                      }






int main()
        {lli n;
         cin>>n;
         map<lli,lli> mp;
         lli sum=0;



            while (n % 2 == 0)
               {
                 mp[2]++;
                  n = n/2;
               }


          for (lli i = 3; i <= sqrt(n); i = i + 2)
               {  while (n % i == 0)
                 {
                  mp[i]++;
                  n = n/i;
                 }
               }


                 if (n > 2)
                    mp[n]++;


        for(auto x:mp)
          {if(x.first!=1)
             {lli p=x.second;
                 lli a=sqrt(1+8*p);
                  a--;
                  a=a/2;
               sum+=(a);
             }
           }
        cout<<sum;

        }










Measured memory_bytes: 3608
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll ans = 1000*(n/500);
    ll z = n%500;
    ans += 5*(z/5);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;

class Point {
    public:
    double x, y;
    
    Point(double x = 0, double y = 0): x(x), y(y) {}
    
    Point operator + (Point p) {return Point(x + p.x, y + p.y); }
    Point operator - (Point p) {return Point(x - p.x, y - p.y); }
    Point operator * (double a) {return Point(a * x, a * y); }
    Point operator / (double a) {return Point(x / a, y / a); }
    
    double abs() { return sqrt(norm()); }
    double norm() { return x * x + y * y; }
    
    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }
    
    bool operator == (const Point &p) const {
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; 
    }
};

struct Segment {
    Point p1, p2;
};

typedef Segment Line;

class Circle {
    public:
    Point c;
    double r;
    Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

typedef Point Vector;

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

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

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

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

bool isOrthogonal(Vector a, Vector b) {
    return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
    return isOrthogonal(a1 - a2, b1 - b2);
}

bool isOrthogonal(Segment s1, Segment s2) {
    return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

bool isParallel(Vector a, Vector b) {
    return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2) {
    return isParallel(a1 - a2, b1 - b2);
}

bool isParallel(Segment s1, Segment s2) {
    return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}



int main() {
    int n;
    double x0, y0, x1, y1, x2, y2, x3, y3;
    Segment s1, s2;
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> x0 >> y0 >> x1 >> y1
            >> x2 >> y2 >> x3 >> y3;
        s1.p1 = Point(x0, y0); s1.p2 = Point(x1, y1);
        s2.p1 = Point(x2, y2); s2.p2 = Point(x3, y3);
        if ( isOrthogonal(s1, s2) ) {
            cout << 1 << endl;
            continue;
        }
        if ( isParallel(s1, s2) ) {
            cout << 2 << endl;
            continue;
        }
        cout << 0 << endl;
    }
    
    return 0;
}


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

using namespace std;

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

	for (int i = 0; i <= N / 4; i++) {
		for (int j = 0; j <= N / 7; j++) {
			if (4 * i + 7 * j == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
n=int(input())
count=0
for i in range(1,n+1): #1からNまでのすべての数について判定する
   if i%3!=0 and i%5!=0: #i番目の数が3の倍数でも5の倍数でもない場合¥¥条件式
       count+=i #上がtrueのときansに足す
print(count)

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

using namespace std;
typedef long long ll;

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

int main(){
// ここに処理を記述

    int K, S;

    cin >> K >> S;

    // K^3 = (5^6)*(10^6) = (125^2)*(10*6) = 15625*10^6
    // 愚直探索はびみょい…

    // 別解を考えてみる
    // 2数決まるともう1数は条件によって決定できる
    // もっというと1数決まれば残り2数の組み合わせは自動決定できる

    int ans = 0;

    REP(i,K+1){
        int combo = S - i;
        if( (combo < 0) || (combo > 2*K) ){
            continue;
        }
        else{
            if(combo <= K) ans += combo + 1;
            else ans += 2*K - combo + 1; 
        }
    }
    
    cout << ans << "\n";

return 0;
}

Measured memory_bytes: 256
/*
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

void solve(int, int, string, string);
string getsex(int);

int main(){
  cin.tie(0);
	ios::sync_with_stdio(false);
  int n, ans; cin >> n; //人数

  string s=getsex(0), e=getsex(n-1); //両サイドの性別チェック

  solve(0, n-1, s, e);

  return 0;
}

void solve(int s, int e, string ssex, string esex){
  int start=s, end=e, m, n=0;
  string startsex=ssex, endsex=esex, msex;

  while(true){
    m=(s+e)/2;
    msex = getsex(m);

    if(((m-s)%2==0 && ssex==msex) || ((m-s)%2==1 && ssex!=msex))s=m, ssex=msex;
    else  e=m, esex=msex;
  }
}

string getsex(int num){
  string res;
  cout << num << endl;
  cin >> res;

  if(res=="Vacant") exit(0);
  return res;
}
*/

#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

void solve(int, int, string, string);
string getsex(int);

int main(){
  cin.tie(0);
	ios::sync_with_stdio(false);
  int n, ans; cin >> n; //人数

  string s=getsex(0), e=getsex(n-1); //両サイドの性別チェック
  if(s=="Vacant" || e=="Vacant"){
    return 0;
  }else{
    solve(0, n-1, s, e);
  }

  return 0;
}

void solve(int s, int e, string ssex, string esex){
  int start=s, end=e, m, n=0;
  string startsex=ssex, endsex=esex, msex;

  while(true){
    m=(s+e)/2;
    msex = getsex(m);
    if(msex=="Vacant") return;

    if(((m-s)%2==0 && ssex!=msex) || ((m-s)%2==1 && ssex==msex)) e=m, esex=msex;
    else s=m, ssex=msex;

    n++; if(n==20) return;
  }
}

string getsex(int num){
  string res;
  cout << num << endl;
  fflush(stdout);
  cin >> res;

  return res;
}


Measured memory_bytes: 852
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A = sorted(il())
    print(A[0]+A[1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<numeric>

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

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

	int pre_t = 0, pre_x = 0, pre_y = 0;
	int t, x, y;
	REP(i, N) {
		cin >> t >> x >> y;

		int rest_t = t - pre_t;
		// まず最低限必要な時間
		rest_t -= abs(x - pre_x) + abs(y - pre_y);
		if (rest_t < 0) {
			cout << "No" << endl;
			return 0;
		}
		else if (rest_t % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}

		// update
		pre_t = t;
		pre_x = x;
		pre_y = y;
	}

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

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  int cnt = 0;
  ll ans = 0;
  rep(i, 10000000) {
    int x = i + 1;
    if (x % 15 == 0) {
      cnt++;
    } else if (x % 3 == 0) {
    } else if (x % 5 == 0) {
    } else {
      ans += x;
    }
    if (x == n) break;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

typedef pair<int,int> pii;

int N;
vector<pii> A;
vector<pii> V;
long long int ans[100010] = {0};

void solve()
{
    int now = 1;
    for(int i = 1; i < A.size(); i++)
    {
        if(V[now].first < A[i].first)
        {
            ans[V[now].second] += (V[now].first - V[now - 1].first) * (A.size() - i);
            now++;
        }
        ans[V[now].second] += A[i].first - V[now - 1].first;
    }
    for(int i = 0; i < N; i++)
    {
        printf("%lld\n",ans[i]);
    }
    return;
}

int main()
{
    scanf("%d",&N);
    V.push_back(make_pair(0,0));
    A.push_back(make_pair(0,0));
    for(int i = 0; i < N; i++)
    {
        int a;
        scanf("%d",&a);
        A.push_back(make_pair(a,i));
        if(V[V.size() - 1].first < a)
        {
            V.push_back(make_pair(a,i));
        }
    }
    sort(A.begin(),A.end());
    solve();
    return 0;
}


Measured memory_bytes: 3692