akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BStringRotation {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string s, t;
	    in >> s >> t;
	    bool res = false;
	    int len = s.length();
	    for(int i=0; i<len; i++){
	        int cnt = 0;
	        int ind = i;
	        bool flg = true;
	        int indi = 0;
	        while(cnt < len){
	            if(s[ind] != t[indi]){
	                flg = false;
	                break;
	            }
	            ind++;
	            cnt++;
	            indi++;
	            if(ind >= len) ind = 0;
	        }
	        if(flg){
	            res = flg;
	            break;
	        }
	    }

	    ans(res, out);
	}
};


int main() {
	BStringRotation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  cout<<n-m+1<<endl;
}

int main(){
  solve();
  return 0;
}


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

using namespace std;

#define MAX_H 15
#define MAX_W 15
#define MAX_O 55
#define INF (1<<29)

struct State{
    int cost,x,y,o;
    State(){}
    State(int cost,int x,int y,int o) :
        cost(cost),x(x),y(y),o(o) {}

    bool operator < (const State &s)const{
        if(cost != s.cost){
            return cost > s.cost;
        }else{
            return o < s.o;
        }
    }
};

int main(){
    int W,H,f,m,o;
    while(cin >> W >> H, W){
        cin >> f >> m >> o;
        vector<vector<int> > G(H+1,vector<int>(W,0));
        for(int i = 1 ; i <= H ; i++){
            for(int j = 0 ; j < W ; j++){
                cin >> G[i][j];
            }
        }

        const int dx[] = {-1,0,1}, dy[] = {0,1,0};
        bool reachable = 0;
        
        priority_queue<State> Q;
        Q.push(State(0,0,0,o));
        
        int d[MAX_H][MAX_W][MAX_O];
        for(int i = 0 ; i < MAX_H ; i++){
            for(int j = 0 ; j < MAX_W ; j++){
                for(int k = 0 ; k < MAX_O ; k++){
                    d[i][j][k] = INF;
                }
            }
        }
        d[0][0][o] = 0;
        
        while(!Q.empty()){
            State s = Q.top(); Q.pop();
            int x = s.x,y = s.y; o = s.o;
            if(o == 0) continue;
            if(y == H){
                if(s.cost <= f){
                    reachable = 1;
                    cout << s.cost << endl;
                }
                break;
            }
            if(o == 1) continue;
            for(int i = 0 ; i < 3 ; i++){
                int nx = x + dx[i];
                int ny = y + dy[i];
                if(nx < 0 || nx >= W) continue;
                if(G[ny][nx] < 0){
                    if(d[y][x][o] - G[ny][nx] < d[ny][nx][o-1]){
                        d[ny][nx][o-1] = d[y][x][o] - G[ny][nx];
                        Q.push(State(d[ny][nx][o-1],nx,ny,o-1));
                    }
                }else if(G[ny][nx] > 0){
                    int no = min(o+G[ny][nx]-1,m);
                    if(d[y][x][o] < d[ny][nx][no]){
                        d[ny][nx][no] = d[y][x][o];
                        Q.push(State(d[ny][nx][no],nx,ny,no));
                    }
                }else{
                    if(d[y][x][o] < d[ny][nx][o]){
                        d[ny][nx][o] = d[y][x][o];
                        Q.push(State(d[ny][nx][o],nx,ny,o));
                    }
                }
            }
        }
        if(!reachable){
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3204
n,k  = map(int,input().split())
h = list(map(int,input().split()))
dp = [0] * n
dp[0] = 0 # 最初のdpのコストを0にする
  
for i in range(1, n):
    dp[i] = min(dp[j] + abs(h[j] - h[i]) for j in range(max(0, i-k), i))
print(dp[-1])

Measured memory_bytes: 53216
from heapq import heappop, heappush

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a].append(b)

S, T = map(lambda x: int(x)-1, input().split())

ans = -1
visited = set()  # 通常であればvisited = [False]*N
q = [(0, S)]
while q:
    c, v = heappop(q)  # cはカウント, vは頂点の番号
    key = (c % 3, v)
    if key in visited:
        continue
    visited.add(key)  # グラフのノードの番号だけでなく、カウントも記録していく
    if v == T and c % 3 == 0:
        ans = c//3
        break
    c += 1  # u, 0から伸びる辺はv, 1で、u, 1から伸びる辺はv, 2
    d = c % 3  # 三種類の状態を記録したいのでmod3
    for u in graph[v]:
        new_key = (d, u)
        if new_key in visited:
            continue
        heappush(q, (c, u))

print(ans)


Measured memory_bytes: 45384
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, v,flag = 0;
	cin >> n;
	vector<string> num(n),num2(n);
	for (int i = 0; i < n; i++) {
		cin >> num.at(i);
		num2.at(i) = num.at(i);
	}

	flag = 1;
	while (flag) {
		flag = 0;
		for (int i = 1; i < n; i++) {
			if (num[i][1] < num[i - 1][1]) {
				swap(num[i], num[i - 1]);
				flag = 1;
			}
		}
	}

	for (int k = 0; k < n; k++) {
		cout << num.at(k);
		if (k != n - 1)cout << ' ';
		else cout << endl;
	}
	cout << "Stable" << endl;

	for (int i = 0; i < n; i++) {
		v = i;
		for (int j = i + 1; j < n; j++) {
			if (num2[j][1] < num2[v][1]) {
				v = j;
			}
		}
		if (i != v) {
			swap(num2[i], num2[v]);
		}
	}

	for (int k = 0; k < n; k++) {
		cout << num2.at(k);
		if (k != n - 1)cout << ' ';
		else cout << endl;
	}

	for (int k = 0; k < n; k++) {
		if (num.at(k) != num2.at(k)) {
			cout << "Not stable" << endl;
			return 0;
		}
	}

	cout << "Stable" << endl;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

void prime(vector<int> &v)
{
    v.push_back(2);
    rep(i, 3, 201010)
    {
        bool flg = true;
        for (auto p : v)
        {
            if (i % p == 0)
            {
                flg = false;
                break;
            }
        }
        if (flg == true)
        {
            v.push_back(i);
        }
    }
}

int main()
{
    vector<int> v;
    prime(v);
    while (true)
    {
        map<int, bool> mp;
        int n, p;
        cin >> n >> p;
        if (n == -1 && p == -1)
        {
            break;
        }
        int q = p / 2; //sqrt(p) + 1;
        int start = upper_bound(v.begin(), v.end(), n) - v.begin();
        // cerr << start << endl;
        vector<int> ans;
        rep(i, start, start + 2 * p)
        {
            rep(j, i, start + 2 * p)
            {
                //   cerr << v[i] + v[j] << endl;
                // if (mp[v[i] + v[j]] == false)

                //                {
                ans.push_back(v[i] + v[j]);
                //                  mp[v[i] + v[j]] = true;
                //            }
            }
        }
        sort(ans.begin(), ans.end());

        //cerr << ans.size() << endl;
        //rep(i, ans.size())
        //{
        //    cerr << ans[i] << " ";
        //}
        // cerr << endl;
        cout << ans[p - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>

using namespace std;

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

  map<string, int> m;

  long long count = 0;
  for (int i = 0; i < n; i++) {
    char s[11];
    scanf("%s", s);

    sort(s, s + 10);

    if (m[s]) {
      count += m[s];
    }
    m[s] += 1;
  }

  cout << count << endl;
}


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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    int n, T;
    cin >> n >> T;
    
    int ans = INT_MAX;
    rep(i,n){
        int a, t;
        cin >> a >> t;
        if(t > T) continue;
        ans = min(a, ans);
    }
    
    if(ans != INT_MAX){
        cout << ans << endl;
    }else{
        cout << "TLE" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long A,B,C,K;
    cin >> A >> B >> C >> K;
    long ans = 0;
    if ( A >= K ) {
        ans = K;
    } else if (A + B >= K) {
        ans = A;
    } else {
        ans = A - (K - A - B);
    }
    cout << ans << endl;
    return 0;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int A, B;
    std::cin >> A >> B;

    if(B % A == 0) {
        std::cout << A + B << std::endl;
    }
    else {
        std::cout << B - A << std::endl;
    }

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int A[N + 1];
    int B[N];
    for(int i = 0; i < N + 1; i ++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i ++){
        cin >> B[i];
    }
    long long count = 0;
    for(int i = 0; i < N; i++){
            if(B[i] > A[i]){
                count += A[i];
                B[i] -= A[i];
                count += min(A[i + 1],B[i]);
                A[i + 1] = max(0,A[i + 1] - B[i]);
            }else {
                count += B[i];
            }
    }
    cout << count << endl;
}

Measured memory_bytes: 1024
import sys
from collections import deque

def main():
    input = sys.stdin.readline
    N = int(input())
    
    d = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b, c = map(int, input().split())
        a, b = a - 1, b - 1
        
        d[a].append((b, c))
        d[b].append((a, c))

    Q, K = map(int, input().split())
    K -= 1

    k_dist = [0 for _ in range(N)]
    start = deque()
    start.append(K)
    while len(start) > 0:
        s = start.popleft()
        for dest, cost in d[s]:
            if k_dist[dest] > 0:
                continue

            k_dist[dest] = k_dist[s] + cost
            start.append(dest)

    for _ in range(Q):
        x, y = map(int, input().split())
        print(k_dist[x-1] + k_dist[y-1])


if __name__ == '__main__':
    main()


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


struct item {
	int w;
	int v;
};

long long int findMin(item items[], int n, int w) {
	long long int cost[n+1][w+1];
	for(int i=0; i<n; i++)
		cost[i][0] = 0;
	for(int i=0;i<=w; i++)
		cost[0][i] = 0;

	for(int i=1; i<=n; i++) {
		for(int j=1; j<=w; j++) {
			cost[i][j] = cost[i-1][j];
			if(items[i-1].w <= j)
				cost[i][j] = max(cost[i-1][j], cost[i-1][j - items[i-1].w] + items[i-1].v);
		}
	}
	return cost[n][w];
}

int main() {
	int n, w;
	cin>>n>>w;
	item items[n];

	for(int i=0;i <n; i++)
		cin>>items[i].w>>items[i].v;


	cout<<findMin(items, n, w)<<endl;
}

Measured memory_bytes: 79104
n = list(map(int,input()))
a = len(n)
cnt = 0

if a == 1:
    cnt = n[0]
elif a == 2:
    cnt = n[1]
else:
    cnt = n[2]

if cnt == 0 or cnt == 1 or cnt == 6 or cnt == 8:
    print("pon")
elif cnt == 3:
    print("bon")
else:
    print("hon")

Measured memory_bytes: 9188
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		long k = Long.parseLong(sa[1]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		// 同じ値が出てくる次のインデックス
		int[] b = new int[n];
		Map<Integer, List<Integer>> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			if (map.containsKey(a[i])) {
				List<Integer> list = map.get(a[i]);
				b[list.get(list.size() - 1)] = i;
				list.add(i);
			} else {
				List<Integer> list = new ArrayList<>();
				list.add(i);
				map.put(a[i], list);
			}
		}
		for (Integer key : map.keySet()) {
			List<Integer> list = map.get(key);
			b[list.get(list.size() - 1)] = list.get(0);
		}

//		for (int i = 0; i < n; i++) {
//			System.out.println(b[i]);
//		}

		int i = 0;
		int cnt = 0;
		while (true) {
			if (i >= b[i]) {
				cnt++;
			}
			i = b[i] + 1;
			if (i == n) {
				cnt++;
				break;
			}
		}
//		System.out.println(cnt);

		k %= cnt;
		if (k == 0) k = cnt;
		i = 0;
		cnt = 0;
		while (cnt < k - 1) {
			if (i >= b[i]) {
				cnt++;
			}
			i = b[i] + 1;
		}

		Set<Integer> set = new HashSet<>();
		List<Integer> list = new ArrayList<>();
		for ( ; i < n; i++) {
			if (set.contains(a[i])) {
				while (true) {
					int x = list.get(list.size() - 1);
					set.remove(x);
					list.remove(list.size() - 1);
					if (x == a[i]) {
						break;
					}
				}
			} else {
				set.add(a[i]);
				list.add(a[i]);
			}
		}

		if (list.isEmpty()) {
			System.out.println();
		} else {
			StringBuilder sb = new StringBuilder();
			for (int j = 0; j < list.size(); j++) {
				sb.append(list.get(j)).append(' ');
			}
			sb.deleteCharAt(sb.length() - 1);
			System.out.println(sb.toString());
		}
	}
}


Measured memory_bytes: 106104
from copy import *

def init(N,node,unit,func):
  n=1
  while n<N:
    n<<=1
  for i in range(n*2-1):
    if len(node)<=i:
      node.append(deepcopy(unit))
    else:
      node[i]=deepcopy(unit)
  node.append(func)
  node.append(unit)
  node.append(n)

def upd(node,x,a):
  y=node[-1]+x
  node[y-1]=a
  while y>1:
    y=y>>1
    node[y-1]=node[-3](node[(y<<1)-1],node[y<<1])

def query(node,l,r):
  x,y=l,r
  z=node[-1]-1
  r=node[-2]
  while True:
    if x==y:
      return r
    if x&1:
      r=node[-3](r,node[x+z])
      x+=1
    if y&1:
      r=node[-3](r,node[y+z-1])
    x>>=1
    y>>=1
    z>>=1
    if z==0:
      return r

def bis_min_k(node,k,cond):
  x=k+1
  while True:
    if node[-1]<=x:
      return x-node[-1]
    if cond(node[(x<<1)-1]):
      x=x<<1
    else:
      x=(x<<1)+1

def bis_min(node,l,r,cond):
  x,y=l,r
  z=node[-1]-1
  for i in range(30):
    if x+(1<<i)>y:
      break
    if x&(1<<i):
      if cond(node[z+(x>>i)]):
        return bis_min_k(node,z+(x>>i),cond)
      x+=(1<<i)
    if z==0:
      break
    z>>=1
  for i in range(29,-1,-1):
    if i and ((node[-1]-1)>>(i-1))==0:
      continue
    if x+(1<<i)>y:
      continue
    if (y-x)&(1<<i):
      if cond(node[((node[-1]-1)>>i)+(x>>i)]):
        return bis_min_k(node,((node[-1]-1)>>i)+(x>>i),cond)
      x+=(1<<i)
  return node[-1]

N,Q=map(int,input().split())
A=list(map(int,input().split()))
X=[]
init(N+1,X,-1,lambda x,y:max(x,y))
for i in range(N):
  upd(X,i,A[i])
t,a,b=0,0,0
for i in range(Q):
  t,a,b=map(int,input().split())
  if t==1:
    upd(X,a-1,b)
  elif t==2:
    print(query(X,a-1,b))
  else:
    a=bis_min(X,a-1,N,lambda x:b<=x)
    if a>N:
      print(N+1)
    else:
      print(a+1)

Measured memory_bytes: 139244
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc =  new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int ans = 0, i, j;
		for(i = 0; i <= k; i++){
			for(j = 0; j <= k; j++){
				if( i + j <= s && s - (i + j) <= k){
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}

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

int main (){
  int n, temp;
  long long int count = 0;

  scanf("%d",&n);
  
  int a[n+1], b[n];
  
  for(int i = 0 ; i < n+1 ; ++i){
    scanf("%d", &a[i]);
  }
  for(int i = 0; i<n ; ++i){
    scanf("%d", &b[i]);
  }
  b[n] = 0;

  for(int i = 0; i<n ; ++i){
    if(a[i] > b[i]){count += b[i];}
    else{
      count += a[i];
      temp = b[i]-a[i];
      if(temp >= a[i+1]){
        count += a[i+1];
        a[i+1] = 0;
      }else{
        count += temp;
        a[i+1] -= temp;
      }
    }
  }
  printf("%lld\n", count);
  return 0;
}


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

#define all(x) x.begin(),x.end()
#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd+nd+1)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

inline int read(){
    int res=0, f=1;char ch=getchar();
    while(ch<'0'|ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
    return res*f;
}

const int MAXN = 200005;

const int MOD = 1000000007;

void addmod(int& a, int b){a+=b;if(a>=MOD)a-=MOD;}
int mulmod(int a, int b){return 1ll*a*b%MOD;}

template<typename T>
void chmin(T& a, T b){if(a>b)a=b;}

template<typename T>
void chmax(T& a, T b){if(b>a)a=b;}


int main(){
   double x;scanf("%lf",&x);
   printf("%f",x*2.0*3.1415926);

    return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	string s; cin >> s;
	int num1 = (s[0] - '0') * 10 + (s[1] - '0');
	int num2 = (s[2] - '0') * 10 + (s[3] - '0');
	if(num1 >= 1 && num1 <= 12 && num2 >= 1 && num2 <= 12){
		cout << "AMBIGUOUS";
	} else if(num2 >= 1 && num2 <= 12){
		cout << "YYMM";
	} else if(num1 >= 1 && num1 <= 12){
		cout << "MMYY";
	} else{
		cout << "NA";
	}
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3616
#include	<iostream>
#include	<cstdio>
#include	<cmath>

using namespace std;

int main(void) {
	int ds;
	
	cin >> ds;
	
	for(int i = 0; i < ds; i++) {
		cin.ignore();
		double X[3] = { 0 };
		double Y[3] = { 0 };
		double ans[3] = { 0 };
		
		double a1, b1, c1, a2, b2, c2;
		
		for(int j = 0; j < 3; j++) {
			cin >> X[j] >> Y[j];
		}
		
		a1 = 2 * (X[1] - X[0]);
		b1 = 2 * (Y[1] - Y[0]);
		c1 = X[0] * X[0] - X[1] * X[1] + Y[0] * Y[0] - Y[1] * Y[1];
		
		a2 = 2 * (X[2] - X[0]);
		b2 = 2 * (Y[2] - Y[0]);
		c2 = X[0] * X[0] - X[2] * X[2] + Y[0] * Y[0] - Y[2] * Y[2];
		
		ans[0] = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
		ans[1] = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
		ans[2] = sqrt( (ans[0] - X[0]) * (ans[0] - X[0]) + (ans[1] - Y[0]) * (ans[1] - Y[0]) );
		
		printf("%.3f %.3f %.3f\n", ans[0], ans[1], ans[2]);
	}
	
	return 0;
}

Measured memory_bytes: 1244
S=input()
ans='NA'
M_list=['01','02','03','04','05','06','07','08','09','10','11','12']
if S[0:2] in M_list:
	ans='MMYY'
if S[2:4] in M_list:
	if ans=='MMYY':
		ans='AMBIGUOUS'
	else:
		ans='YYMM'
print(ans)


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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int a, b; cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible\n";
  else cout << "Impossible\n";
  
  return (0);
}

Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
#define ll long long




struct act {
	int a, b, c;
};

ll find(vector<act> ar, ll n) {
	ll dp[n + 1][3];

	dp[1][0] = ar[1].a;
	dp[1][1] = ar[1].b;
	dp[1][2] = ar[1].c;


	for (int i = 2; i <= n; i++) {
		dp[i][0] = ar[i].a + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = ar[i].b + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = ar[i].c + max(dp[i - 1][1], dp[i - 1][0]);
	}

	return (max(dp[n][0], max(dp[n][1], dp[n][2])));

}

int main() {

	ll n;
	cin >> n;
	vector<act> ar(n + 1);

	for (ll i = 1; i <= n; i++) {
		cin >> ar[i].a >> ar[i].b >> ar[i].c;
	}

	cout << find(ar, n);

}

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

int main(){
    long long int x,y ;
    cin >> x >> y;
    
    if(y < x*2 || y > x*4){
        cout << "No" << endl;
    }else{
        if(y%2 == 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
}

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

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

    char tmp;
    int cnt = 1;
    int n = s.length();
    ll change = 0;
    ll a=0, b=0;
    for(int i=0; i<n; i++){
        if(i==0) tmp = s.at(i);
        else{
            if(s[i] == tmp){
                cnt++;
                if(s[i]==s[0] && i==n-1) b = cnt;
                if(i==n-1){
                    change += cnt/2;
                }
            }else{
                if(s[i-1]==s[0]) a = cnt;
                change += cnt/2;
                tmp = s[i]; cnt=1;
            }
        }
    }
    ll ans = change * k;
    if(s[0] == s[n-1]){
        ans -= (a/2 + b/2 - (a+b)/2) * (k-1);
    }
    if(s == string(s.size(),s[0])) {
        cout << s.size() * k / 2 << endl;
        return 0;
    }else
        cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3624
package main

import (
	"fmt"
)

func main() {

	var A, B, C string
	fmt.Scan(&A)
	fmt.Scan(&B)
	fmt.Scan(&C)

	turn := A[0]
	A = A[1:]
	for {
		switch turn {
		case byte('a'):
			if len(A) == 0 {
				fmt.Println("A")
				return
			}
			turn = A[0]
			A = A[1:]
		case byte('b'):
			if len(B) == 0 {
				fmt.Println("B")
				return
			}
			turn = B[0]
			B = B[1:]

		case byte('c'):
			if len(C) == 0 {
				fmt.Println("C")
				return
			}
			turn = C[0]
			C = C[1:]
		}
	}
}


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

const int INF = 9999999;

int N,K;
vector<int> h;
vector<int> dp;

int main(){
    cin >> N >> K;
    h.resize(N);
    dp.resize(N,INF);
    for(int i = 0;i < N;++i)cin >> h[i];

    dp[N-1] = 0;
    dp[N-2] = abs(h[N-2]-h[N-1]);

    for(int i = N-3;i >= 0;--i){
        dp[i] = abs(h[i]-h[i+1])+dp[i+1];
        for(int j = 2;i+j < N and j <= K;++j)
            dp[i] = min(dp[i],abs(h[i]-h[i+j])+dp[i+j]);
    }
    cout << dp[0] << endl;
}


Measured memory_bytes: 1024
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    int K,N;
    cin >> K >> N;
    vector<int> P(1000000);
    for(int i=0;i<N;i++){
        cin >> P[i];
    }
    vector<int> D(1000000);
    for(int i=0;i<N-1;i++){
        D[i]=P[i+1]-P[i];
    }
    D[N-1]=K-(P[N-1]-P[0]);
    sort(D.begin(),D.end(),greater<int>());
    cout << K-D[0] << endl;
}

Measured memory_bytes: 8064
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Data.Ord

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    [s,w] <- r'
    putStrLn $ if w >= s then "unsafe" else "safe"


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

int main() {
  int a; 
  cin >> a;
  vector<int> vec(21);
  for (int i = 0; i < a; i++) {
  cin >> vec.at(i);
	}
  int ans = 0;
  	for(int i=0;i < a-2;i++)
      if(vec.at(i) < vec.at(i+1) && vec.at(i+1) < vec.at(i+2))
   		ans++;
      else if(vec.at(i+2) < vec.at(i+1) && vec.at(i+1) < vec.at(i))
			ans++;
  cout << ans <<endl;
  
}


Measured memory_bytes: 256
S = input()

n_rainy_day = 0

for i in range(3):
  if S[i] == 'R':
    if n_rainy_day == 0:
      n_rainy_day += 1
    elif S[i-1] == 'R':
      n_rainy_day += 1
          
print(n_rainy_day)

Measured memory_bytes: 9032
import sys

N = int(input())
S = input()
RES = ''

for i in range(len(S)):
    if ord(S[i]) + N - 64 > 26:
        RES += chr(ord(S[i]) + N - 26)
    else:
        RES += chr(ord(S[i]) + N)

print(RES)

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

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;

#define mp make_pair
#define pb push_back


int main()
{
  int n, m;
  scanf("%d %d", &n, &m);
  int t = (n-m)*100+m*1900;
  for (int i = 0; i < m; ++i)
    t <<= 1;
  printf("%d\n", t);
}


Measured memory_bytes: 256
N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)

x = 0

A.each_with_index do |a, i|
  if i.even?
    x += a
  else
    x -= a
  end
end

x /= 2

ans = []
ans[0] = x

(A.size - 1).times do |i|
  ans[i + 1] = A[i] - ans[i]
end

puts ans.map { |n| n * 2 }.join(' ')


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

int gcd(int m, int n) {
    return (n == 0 ? m : gcd(n, m % n));
}

int a[100005]={0};

int main(){
    int n, k;
    cin >> n >> k;
    for(int i=0;i<n;++i)cin >> a[i];

    int tmp = a[0], maxi = a[0];
    for(int i=1;i<n;++i){
        tmp = gcd(tmp, a[i]);
        maxi = max(maxi, a[i]);
    }

    if(k % tmp == 0 && k <= maxi)cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;

int calc(string s, string t) {
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) ans++;
  }
  return ans;
}
int main() {
  string s, t;
  cin >> s >> t;

  int ans = 99999999;

  for (int i = 0; i < s.size() - t.size() + 1; i++) {
    string temp = s.substr(i, t.size());
    ans = min(calc(t, temp), ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main(){
  int a[4],b[4];
  while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
    int hit=0,blow=0;
    for(int i=0;i<4;i++){
      if(a[i]==b[i])
        hit++;
    }
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
        if(i==j);
        else{
          if(a[i]==b[j])
            blow++;
        }
      }
    }
  cout << hit << " " << blow << endl;  
  }
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define MAX 100001
#define MOD 1000000007
using namespace std;

 
int32_t main()
{
    int n;
    cin>>n;
    int a[n][n];
    for(int i=0;i<n;++i)
        for(int j=0;j<n;++j)
            cin>>a[i][j];

    int dp [(1<<n)] = {0};

    dp[0] = 1;



    // Base Case

    for (int i = 1; i < (1<<n); i++) 
    {
        int cnt = __builtin_popcount(i);
        for(int j=0;j<n;++j) 
        {
            if (i&(1<<j)) {

                dp[i] =  ( dp[i]  + ( dp[i^(1<<j)]*a[cnt-1][j]) ) %MOD;

            }
        }
    }

    cout << dp[(1<<n)-1];


    return 0;
}	

Measured memory_bytes: 16640
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int m;
	cin>>m;
	cout<<24+24-m<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<pair<int, int>, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;

    vector<int> t(N), v(N);
    for (int i = 0; i < N; ++i)
        cin >> t[i];
    for (int i = 0; i < N; ++i)
        cin >> v[i];

    vector<int> nv(N + 1);
    nv[N] = 0;
    for (int i = N - 1; i > 0; --i) {
        nv[i] = min(v[i], nv[i + 1] + t[i]);
        nv[i] = min(nv[i], v[i - 1]);
    }

    int nowv = 0;
    ld ans = 0;
    for (int i = 0; i < N; ++i) {
        if (nowv + t[i] <= nv[i + 1]) {
            ans += (ld)(2 * nowv + t[i]) * t[i] / 2;
            nowv += t[i];
        } else {
            ld tmp = (ld)(nv[i + 1] - nowv + t[i]) / 2;
            ld ma = nowv + tmp;
            ans += (nowv + ma) * tmp / 2;
            ans += (nv[i + 1] + ma) * (t[i] - tmp) / 2;
            if (ma > v[i]) {
                int d = t[i] - (2 * v[i] - nowv - nv[i + 1]);
                ans -= d * (ma - v[i]) / 2;
            }
            nowv = nv[i + 1];
        }
    }

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  //printf("%d\n",a);
  //printf("%d\n",b);
  //printf("%d\n",c);

  if ( a < b && b < c  ) {


    printf("Yes\n");
  }
  else{

    printf("No\n");}
return 0;
}



Measured memory_bytes: 2108
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, m: usize, sc: [[usize; 2]; m]};
    let mut is_valid = true;

    let ten: i64 = 10;

    if m > 0 {
        if n != 1 {
            for num in ten.pow((n - 1) as u32)..ten.pow(n as u32) {
                let mut judge = true;
                for sc_i in sc.iter() {
                    let s = sc_i[0];
                    let c = sc_i[1];

                    let ns = num.to_string();

                    if s == 1 && c == 0 && n != 1 {
                        judge = false;
                        break;
                    }

                    if &ns[s - 1..s] != c.to_string() {
                        judge = false;
                    }
                }

                if judge {
                    println!("{}", num);
                    is_valid = false;
                    break;
                }
            }

            if is_valid {
                println!("-1");
            }
        } else {
            for num in 0..10 {
                let mut judge = true;
                for sc_i in sc.iter() {
                    let s = sc_i[0];
                    let c = sc_i[1];

                    let ns = num.to_string();

                    if s == 1 && c == 0 && n != 1 {
                        judge = false;
                        break;
                    }

                    if &ns[s - 1..s] != c.to_string() {
                        judge = false;
                    }
                }

                if judge {
                    println!("{}", num);
                    is_valid = false;
                    break;
                }
            }

            if is_valid {
                println!("-1");
            }
        }
    } else {
        if n == 1 {
            println!("0");
        } else {
            println!("{}", ten.pow((n - 1) as u32))
        }
    }
}


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

int main() {
    int r;
    cin >> r;
    if(r < 1200) {
        cout << "ABC" << '\n';    
    } else if(r < 2800) {
        cout << "ARC" << '\n';
    } else {
        cout << "AGC" << '\n';
    }
    
     
    return 0;
}


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

int main() {
  int N; cin >> N;
  int a[101];
  for ( int i = 0; i  < N; i++ ) cin >> a[i];
  sort(a,a+N);
  cout << a[N-1] - a[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;
using namespace std;

typedef pair<int, int> pii;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



class A {
	int n;
public:
	A()
	{
		cin >> n;
	}
	void solve()
	{
		cout << n / 3 << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define ll long long
#define mod 998244353 
#define pb push_back
#define mb make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main(){
	IOS;
	string s,t; cin >> s >> t;
	int dp[s.length()+1][t.length()+1];
	// string a="";
	memset(dp,0,sizeof(dp));
	dp[0][0] = 0;
	string ans = "";
	for(int i=1;i<=s.length();i++){
		for(int j = 1; j <= t.length() ; j++){
			if(s[i-1]==t[j-1]){
				dp[i][j] = dp[i-1][j-1]+1;

			}
			else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	// for(int i=1;i<=s.length();i++){
	// 	for(int j=1;j<=t.length();j++)
	// 		cout << dp[i][j] << " ";
	// 	cout << endl;
	// }
	// cout << dp[s.length()][t.length()];
	int i = s.length(),j=t.length();
	while(i>0 and j>0){
		if(s[i-1]==t[j-1]){
			ans+=s[i-1];
			i--,j--;
		}
		else if(dp[i][j-1]>dp[i-1][j])
				j--;
		else
				i--;
		
		// cout << i << " " << j << " " << dp[i][j] << endl;
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;



	return 0;
}




Measured memory_bytes: 35456
#include<bits/stdc++.h>
#include<string>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main()
{
    long long n,sum=0,i;
    string num;
    cin>>num;
    n=num.size();
    for(i=0;i<n;i++)
        sum=sum+num[i]-'0';
    if(sum%9==0)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
    return 0;
}

Measured memory_bytes: 3716
/**
 Input:
 3
 1 2
 2 3
**/
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <algorithm>
#include <limits.h>
#include <bits/stdc++.h>
#define fw(x) freopen("x.txt","w",stdout)
#define For(i,a,b,c) for(int i = a;i < b;i+=c)
#define REP(i,n) for(int i = 0;i < n;++i)
#define mem(a,s) memset(a,s,sizeof a)
#define fast ios_base::sync_with_stdio(0)
#define pf printf
#define sc scanf
#define ll long long
#define N 100000+10
using namespace std;

 vector<int>adj[N];
 int mark[N];
 int n;

 void dfs(int x,int col)
 {
  // cout<<"HI\n";
   for(int i=0;i<adj[x].size();i++)
   {
     //cout<<"HI\n";
     if(col!=adj[x][i])
      dfs(adj[x][i],x);
    else
    continue;
   }
   if(!mark[x] && !mark[col])
    {
      mark[x]=1;
      mark[col]=1;
    }
 }
int main()
{
   // freopen("in11.txt","r",stdin);
   cin>>n;
   for(int i=1;i<n;i++)
   {
     int u,v;
     cin>>u>>v;
     adj[u].push_back(v);
     adj[v].push_back(u);
   }
   mark[0]=1;
   dfs(1,0);
   int flag=1;

   for(int i=0;i<=n;i++)
    if(mark[i]==0)
      flag=0;
    if(!flag)
      puts("First");
    else
      puts("Second");
  return 0;
}


Measured memory_bytes: 6272
n = int(input())
c = input()
count = 0

i, j = 0, n - 1
if c.count('W') == 0:
    count=0
elif c.count('R') == 0:
    count = 0
else:
    white_cnt = []
    red_cnt = []
    for i in range(n):
        if c[i] == 'W':
            white_cnt.append(i)
        else:
            red_cnt.append(i)
    while 1:
        white_num = white_cnt.pop(0)
        red_num = red_cnt.pop()
        if white_num < red_num:
            count += 1
        if len(white_cnt) == 0:
            break
        if len(red_cnt) == 0:
            break
print(count)


Measured memory_bytes: 17156
/*
 * @Author: your name
 * @Date: 2020-08-03 05:04:45
 * @LastEditTime: 2020-08-03 05:45:31
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /ACM_Introduction/2020.8.2/aoj0189.cpp
 */
#include <iostream>
#include <cstring>
using namespace std;

const int maxn = 15;
int d[maxn][maxn];
int n, a, b, c, len;
#define INF 0x3f3f3f3f
#define min(a,b) ((a) < (b) ? (a) : (b))
#define max(a,b) ((a) > (b) ? (a) : (b))
void floyd() {
    for(int k = 0; k <= len; ++k)
        for(int i = 0; i <= len; ++i)
            for(int j = 0; j <= len; ++j)
                d[i][j] = min(d[i][k] + d[k][j], d[i][j]);
}

int main() {
    while(scanf("%d", &n), n) {
        int ans = INF, pos = -1, sum = 0;
        memset(d, INF, sizeof(d));
        for(int i = 0; i < maxn; ++i) 
            d[i][i] = 0;
        len = -1;
        for(int i = 0; i < n; ++i) {
            scanf("%d%d%d", &a, &b, &c);
            len = max(max(a, b), len);
            d[a][b] = d[b][a] = c;
        }
        // printf("%d", len);
        floyd();
        for(int i = 0; i <= len; ++i) {
            sum = 0;
            for(int j = 0; j <= len; j++) 
                sum += d[i][j];
            if(ans > sum) {
                ans = sum;
                pos = i;
            }
        }
        printf("%d %d\n", pos, ans);
    }
    return 0;
} 


Measured memory_bytes: 3212
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, Q = MAP()
ab = [LIST() for _ in range(N-1)]
px = [LIST() for _ in range(Q)]

graph = [[] for _ in range(N)]
for a, b in ab:
	graph[a-1].append(b-1)
	graph[b-1].append(a-1)
#print(graph)

cnt = [0]*N
for p, x in px:
	cnt[p-1] += x

check = [1]*N
check[0] = 0

q = deque([0])

while q:
	p = q.popleft()
	for x in graph[p]:
		if check[x]:
			cnt[x] += cnt[p]
			check[x] = 0
			q.append(x)



print(*cnt)



Measured memory_bytes: 145556
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] input = new char[h][w];
        for (int i = 0; i < h; i++) {
            char[] row = sc.next().toCharArray();
            for (int j = 0; j < w; j++) {
                input[i][j] = row[j];
            }
        }
        char[][] result = new char[2 * h][w];
        for (int i = 0; i < 2 * h; i++) {
            for (int j = 0; j < w; j++) {
                int index = (i + 2) / 2 - 1;
                result[i][j] = input[index][j];
                System.out.printf("%c", result[i][j]);
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 40712