akhauriyash/Code-Regression huggingface dataset:
// to be build tomorrow
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main ()
{
    ll t = 1;
    while (t--)
    {
        ll X, N;
        cin >> X >> N;
        ll a[N];
        map <ll, ll> m, p;
        for (ll i = 0 ; i < N ; i++)
        {
            cin >> a[i];
            m[abs(a[i]-X)]++;
            p[a[i]]++;
        }
        ll count = 0;
        ll answer ;
        while (1)
        {
            if (!m[count])
            {
                answer = X-count;
                break;
            }
            else 
            {
                if (!p[X-count])
                {
                    answer = X-count;
                    break;
                }
                else if (!p[X+count])
                {
                    answer = X+count;
                    break;
                }
            }
            count++;
        }
        cout << answer;
    }
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[][] array = new int[n + 1][d + 1];

		//入力値を配列に代入
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < d; j++) {
				array[i][j] = sc.nextInt();
			}
		}
		
		//i < j の場合の全ての組み合わせで距離を計算する
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++ ) {
				int norm = 0;
				for (int k = 0; k < d; k++) {
					int diff = array[i][k] - array[j][k];
					norm += diff * diff;
				}
				//整数かどうかチェックする
				boolean flag = false;
				for (int k = 0; k <= norm; k++) {
					if (k * k == norm) {
						flag = true;
					}
				}
				if (flag == true) {
					ans++;
				}
			}
		}
		System.out.println(ans);

	}
}


Measured memory_bytes: 23252
N = gets.to_i
s = gets.chomp
t = gets.chomp

dup = 0
for i in 0..N do
  if s[i..-1] == t[0..(-1-i)]
    dup = N - i
    break
  end
end
ans = (N - dup) * 2 + dup
puts ans

Measured memory_bytes: 1788
def main():
    from sys import exit
    s=input()
    x,y=map(int,input().split())

    def groupby(a):
        a2=[[a[0],1]]
        for i in range(1,len(a)):
            if a2[-1][0]==a[i]:
                a2[-1][1]+=1
            else:
                a2.append([a[i],1])
        return a2

    s=groupby(s)
    a,b=[],[]
    turn=True
    #初めまっすぐの場合
    if s[0][0]=="F":
        x-=s[0][1]
        s.pop(0)
    for i in s:
        if i[0]=="F":
            if turn:
                a.append(-i[1])
            else:
                b.append(-i[1])
        elif i[1]%2==1:
            turn=not turn
    a.sort()
    b.sort()
    for i in a:
        x=abs(x)-abs(i)
    if x!=0:
        print("No")
        exit()
    for i in b:
        y=abs(y)-abs(i)
    if y!=0:
        print("No")
        exit()
    print("Yes")
main()

    

Measured memory_bytes: 40816
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,I##_N=N;I<I##_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
int main() {
  R(N);RL(dummy);
  std::unordered_map<std::string,int> dict;
  F(I,N){
    RL(line);
    dict[line]=1;
  }
  P(dict.size());
  return 0;
}


Measured memory_bytes: 17796
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int N, M;
vector<int> G[52];
bool used_v[52], used_e[52][52];
int ord[52], lowlink[52];
int k = 0;

void dfs(int v){
	used_v[v] = true;
	ord[v]=lowlink[v]=k++;
	REP(i, G[v].size()){
		if(!used_v[G[v][i]]){
			used_e[v][G[v][i]]=true;
			dfs(G[v][i]);
			lowlink[v] = min(lowlink[v], lowlink[G[v][i]]);
		}else if(!used_e[G[v][i]][v]){
			lowlink[v] = min(lowlink[v], ord[G[v][i]]);
		}
	}
}


int main(void){
	cin >> N >> M;
	REP(i, M){
		int a, b;
		cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0);
	int cnt = 0;
	REP(i, N){
		REP(j, G[i].size()){
			if(ord[i] < lowlink[G[i][j]]){
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))

num_li = [0]*n

for i in range(n):
    num_li[i] = (p[i]+1)/2

num = sum(num_li[:k])
ans = num

for j in range(n-k):
    num = num-num_li[j]+num_li[j+k]
    ans = max(num, ans)

print(ans)

Measured memory_bytes: 25060
# A - Frog 1
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]+=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13908
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b,k; cin >> a >> b >> k;
    set<ll> st;
    rep(i,0,k){
        if(a + i > b)break;
        st.insert(a + i);
        st.insert(b - i);
    }

    for(auto t : st){
        cout << t << "\n";
    }
}

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

#define pb push_back
#define ppp pop_back
#define pii pair<int,int>
#define fi first
#define se second

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
	int n, k, s;
	cin >> n >> k >> s;
	for (int i=1; i<=k; i++) cout << s << " ";
	int lol;
	if (s == 1e9) lol = 1e9 - 1;
	else lol = 1e9;
	for (int i=k+1; i<=n; i++) cout << lol << " ";
	cout << "\n";
    return 0;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    ll n=0;
    rep(i,2){
        if(s[i] == 'R' && s[i+1]=='R') n++;
    }
    if(n!=0){
        n++;
    }else{
        rep(i,3){
            if(s[i]=='R') n=1;
        }
    }

    cout << n;

    return 0;
}

Measured memory_bytes: 3648
import math

while True:
    n = int(input())
    if n == 0:
        break
    s = list(map(int, input().split()))
    s_ = sum(s) / n
    alpha = 0
    for i in s:
        alpha += (i - s_) ** 2
    print(format(math.sqrt(alpha/n), '.8f'))


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

int main()
{
  int n;
  cin >> n;
  vector<int> d(n);
  int i;
  for(i = 0; i < n; i++)
  {
    cin >> d.at(i);
  }
  int m;
  cin >> m;
  vector<int> t(m);
  for(i = 0; i < m; i++)
  {
    cin >> t.at(i);
  }
  int k = 0;
  bool ok = true;
  sort(d.begin(), d.end());
  sort(t.begin(), t.end());
  for(i = 0; i < m; i++)
  {
    while(d.at(k) < t.at(i) && k < n)
    {
      k++;
    }
    if(k == n)
    {
      ok = false;
      break;
    }
    if(d.at(k) > t.at(i))
    {
      ok = false;
      break;
    }
    k++;
  }
  if(ok)cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define MAX_V 100000

#define MOD 1000000007L
#define INF 2147483647

signed main() {
	int n, m;
	cin >> n;
	int t[n];
	for (size_t i = 0; i < n; i++) {
		cin >> t[i];
	}
	cin >> m;
	for (size_t i = 0; i < m; i++) {
		int p, x;
		cin >> p >> x;
		p--;
		int sum = 0;
		for (size_t j = 0; j < n; j++) {
			if (j == p) {
				sum += x;
			} else {
				sum += t[j];
			}
		}
		cout << sum << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int D[15];
int num[15];

int main() {

	int N, K;

	scanf("%d %d",&N,&K);

	int i;

	for (i = 0; i < K; i++) {
		scanf(" %d",&D[i]);
		num[D[i]] = 1;
	}

	int tmp;

	for (i = N;; i++) {
		tmp = i;
		int flag = 1;
		while (1) {
			if (tmp == 0) { break; }
			if (num[tmp % 10] == 1) { flag = 0; break; }
			tmp /= 10;
		}
		if (flag == 1) { printf("%d\n", i); break; }
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  int r,d,x;
  cin>>r>>d>>x;
  rep(i,10){
    x=r*x-d;
    cout<<x<<endl;}
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        double count = 0;
        for(int i = 0; i < N; i++){
            int temp = Integer.parseInt(sc.next());
            if(temp % 4 == 0){
                count += 1.0;
            } else if (temp % 2 == 0){
                count += 0.5;
            }
        }

        if((int)count >= N / 2){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 58716
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
#define pb push_back
#define MP(a,b) make_pair((a),(b))
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
const int INF = 1<<30;
const ll LINF = 1LL<<60;
const int MOD = 1e9+7;

int main(){
    string S;
    cin >> S;
    if(S[2]==S[3]&&S[4]==S[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			int t = sc.nextInt();
			if (n % x == 0) {
				System.out.println((n / x) * t);
			} else {
				System.out.println((n / x + 1) * t);
			}
		}
	}
}

Measured memory_bytes: 35612
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<set>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
#define Y first
#define X second
const int INF = INT_MAX;

int h, n;
int my[] = {-1, -1, 0, 0, 1, 1};
int mx[] = {-1, 0, -1, 1, 0, 1};
vector< vector<bool> > used;
vector< vector<int> > v;

class C{
  public:
    int num;
    vector<P> v;
    set<P> zero;
    C(int _n, vector<P> _v, set<P> _z){
      num = _n;
      v = _v;
      zero = _z;
    }
};

bool isOK(int y, int x){
  if(y < 0 || x < 0 || y >= h || x > y) return false;
  return true;
}

vector<P> make_group(int num, int y, int x, vector<P> pv){
  pv.push_back( P(y, x) );
  used[y][x] = true;
  REP(i, 6){
    int ny = y + my[i], nx = x + mx[i];
    if(!isOK(ny, nx) || used[ny][nx] || num != v[ny][nx]) continue;
    pv = make_group(num, ny, nx, pv);
  }
  return pv;
}

vector<C> make_c(){
  vector<C> ret;
  REP(i, h){
    REP(j, i + 1){
      if(used[i][j] || v[i][j] == 0) continue;
      vector<P> pv = make_group(v[i][j], i, j, vector<P>());
      set<P> s;
      REP(k, pv.size()){
        P now = pv[k];
        REP(m, 6){
          int ny = now.Y + my[m], nx = now.X + mx[m];
          if(!isOK(ny, nx)) continue;
          if(v[ny][nx] == 0) s.insert( P(ny, nx) );
        }
      }
      ret.push_back( C(v[i][j], pv, s) );
    }
  }
  return ret;
}

//void disp_cv(vector<C> cv){
//  REP(i, cv.size()){
//    cout <<"num = " <<cv[i].num <<endl;
//    REP(j, cv[i].v.size()) cout <<cv[i].v[j].Y <<", " <<cv[i].v[j].X <<endl;
//    cout <<"--" <<endl;
//    for(set<P>::iterator it = cv[i].zero.begin(); it != cv[i].zero.end(); it++) cout <<(*it).Y <<", " <<(*it).X <<endl;
//    cout <<"----------" <<endl;
//  }
//}

int main(){
  while(cin >>h >>n && h){
    used = vector< vector<bool> >(h, vector<bool>(h, false));
    v = vector< vector<int> >(h, vector<int>(h, -1));
    REP(i, h){
      REP(j, i + 1){
        cin >>v[i][j];
      }
    }
    vector<C> cv = make_c();
    int ans = INF * -1;
    REP(y, h){
      REP(x, y + 1){
        if(v[y][x] != 0) continue;
        int tmpans = 0;
        used = vector< vector<bool> >(h, vector<bool>(h, false));
        v[y][x] = n;
        vector<C> cv = make_c();
        REP(i, cv.size()){
          if(cv[i].zero.size() == 0) tmpans = (cv[i].num == n? tmpans - cv[i].v.size() : tmpans + cv[i].v.size());
        }
        ans = max(ans, tmpans);
        v[y][x] = 0;
      }
    }
    cout <<ans <<endl;
  }
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MX = 100005;

int main() {
	int n;
	cin >> n;
	vector<ll> cnt(MX);
	rep(i,n) {
		int a;
		cin >> a;
		cnt[a]++;
	}
	ll tot = 0;
	rep(i,MX) tot += i*cnt[i];
	
	int q;
	cin >> q;
	rep(i,q) {
		int b, c;
		cin >> b >> c;
		tot -= b*cnt[b];
		tot -= c*cnt[c];
		cnt[c] += cnt[b];
		cnt[b] = 0;
		tot += b*cnt[b];
		tot += c*cnt[c];
		cout << tot << endl;
	}
	return 0;
}


Measured memory_bytes: 4024
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int h,a; cin >> h >> a;
    cout << h/a + (h%a != 0) << endl; return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
using namespace std;
 
int main()
{
	int32_t h, w;
	cin >> h >> w;
 
	char temp;
	int32_t count{ 0 };
	for (auto i = 0; i < h * w; ++i) {
		cin >> temp;
		count += (temp == '#' ? 1 : 0);
	}
 
	cout << (count == h + w - 1 ? "Possible" : "Impossible") << endl;
}


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

int A[100];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k, sum = 0;
    cin>>n>>k;

    for(int i = 0; i < n; i++)
        cin>>A[i];

    sort(A, A + n, greater<int>());

    for(int i = 0; i < k; i++)
        sum += A[i];

    cout<<sum<<"\n";

    return 0;
}

Measured memory_bytes: 256
// Tenshi ni Fureta yo!

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

// END tpl.

const int MAXN = 100;

int n;

vector<int> adj[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i < n; ++i)
	{
		int u = read<int>(), v = read<int>();
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

int cnt[MAXN + 5];

inline int dfs(int u, int fa, int d)
{
	chkmax(cnt[d], SZ(adj[u]) - (fa != 0));

	int res = 1;
	for(auto v : adj[u]) if(v != fa) chkmax(res, dfs(v, u, d + 1) + 1);
	return res;
}

inline void solve()
{
	pil ans(INT_MAX, LLONG_MAX);
	for(int i = 1; i <= n; ++i)
	{
		memset(cnt, 0, sizeof cnt);
		pil res(dfs(i, 0, 1), 1ll);
		for(int j = 1; j < res.fst; ++j) res.snd = res.snd * cnt[j];
		chkmin(ans, res);
	}
	for(int u = 1; u <= n; ++u) for(auto v : adj[u])
	{
		memset(cnt, 0, sizeof cnt);
		pil res(max(dfs(u, v, 1), dfs(v, u, 1)), 2ll);
		for(int j = 1; j < res.fst; ++j) res.snd = res.snd * cnt[j];
		chkmin(ans, res);
	}
	printf("%d %lld\n", ans.fst, ans.snd);
}

int main()
{
#ifdef K_ON
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 256
n=int(input())
s=input();t=input()
a=0
if s == t:
    print(n)
    exit()
for i in range(1,n+1):
    if s[0:i] == t[-i:]:
        a=i
b = 0
for i in range(1,n+1):
    if s[-i:] == t[0:i]:
        b=i
a = max(a,b)
print(n*2-a)

Measured memory_bytes: 38384
from collections import *
import sys

cnt1 = Counter()
cnt2 = Counter()
for s in sys.stdin:
    if s == "\n": break
    n,d = map(int,s.split(","))
    cnt1[n] += 1
for s in sys.stdin:
    if s == "\n": break
    n,d = map(int,s.split(","))
    cnt2[n] += 1
for e in cnt1:
    if cnt2[e]: print e,cnt1[e]+cnt2[e]

Measured memory_bytes: 4600
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

void yes(){
  cout << "YES" << endl;
  exit(0);
}

void no(){
  cout << "NO" << endl;
  exit(0);
}

int main(){
  vector<ll> a(3);
  REP(i,3) cin >> a[i];
  sort(ALL(a));
  if(a[0]==5 && a[1]==5 && a[2]==7) yes();
  else no();
}



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

int main() {

	int a, b, c; cin >> a >> b >> c;
	int k; cin >> k;
	int cnt = 0;
	while (b <= a) {
		b *= 2;
		cnt++;
	}
	while (c <= b) {
		c *= 2;
		cnt++;
	}
	if (cnt <= k) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3540
i = list(map(int, input().split("/"))) 

if i[0] >= 2019 and i[1] >= 5:
  print("TBD")
elif i[0] == 2019 and i[1] == 4 and i[2] == 31:
  print("TBD")
else:
  print("Heisei")

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

using namespace std;

int main(){
	string s, t;
	cin >> s;
	t = s;
	if(s.size() < 26){
		map <int, int> used;
		for(auto u : s) used[u] = 1;
		char f;
		for(int i = 'a'; i <= 'z'; ++i){
			if(!used[i]){
				f = i;
				break;
			}
		}
		cout << s << f << endl;
		return 0;
	}
	bool f = next_permutation(s.begin(), s.end());
	if(f == false){
		cout << -1 << endl;
	}
	else{
		for(int i = 0; i < s.size(); ++i){
			cout << s[i];
			if(s[i] != t[i]) break;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 768
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextInt();
		double b = sc.nextInt();
		sc.close();
		double x = (a + b) / 2.0;
		System.out.println(x % 1 == 0 ? (int) x : "IMPOSSIBLE");
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}


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

long long* binarySearch(long long x, long long* left, long long* right){
    
    while(right - left > 1){
        long long *ptr = left + (right - left) / 2;
        if( x < *ptr ){
            right = ptr;
        }else{
            left = ptr;
        }  
    }
    if(*left < x)return right;
    else return left;
}

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

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

    long long dp[N];
    int last = 1;
    dp[0] = a[0];
    for(int i = 1; i < N; i++) {
        // for(int j = 0; j <= last; j++) {
        //     cout << dp[j] << " ";
        // }
        // cout << endl;

        if(dp[last-1] < a[i]){
            dp[last++] = a[i];
            continue;
        }
        //*lower_bound(dp,dp+last,a[i])=a[i];
        //long long* p = upper_bound(dp, dp+last-1, a[i]);
        long long* p = binarySearch(a[i], dp, dp+last);
        *p = a[i];
    }

    cout << last << endl;
    return 0;
}


Measured memory_bytes: 4564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,k;
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
	if (k%2==1) a=b-a;
	else a=a-b;
	if (abs(a)>(1e18)) printf("Unfair\n");
	else printf("%lld\n",a);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  string s;
  cin >> n >> k >> s;
  
  if(s.at(k-1) == 'A'){
    s.at(k-1) = 'a';
  }else if(s.at(k-1) == 'B'){
    s.at(k-1) = 'b';
  }else if(s.at(k-1) == 'C'){
    s.at(k-1) = 'c';
  }
  
  cout << s << endl;
  
}

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

const int MOD=1e9+7;
int add(int&x,int y){return(x+=y)<MOD?x:x-=MOD;}

char num[10005];
int dp[10005][105][2];

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  int D;
  cin>>num+1>>D;
  dp[0][0][0]=1;
  int n=strlen(num+1);
  reverse(num+1,num+n+1);
  for(int i=1;i<=n;++i){
    for(int j=0;j<D;++j){
      for(int k=0;k<10;++k){
        add(dp[i][(j+k)%D][0],dp[i-1][j][0]);
        if(k<num[i]-'0'){
          add(dp[i][(j+k)%D][1],dp[i-1][j][0]);
        }
      }
    }
  }
  int sum=0;
  int sol=MOD-1;
  for(int i=n;i;--i){
    add(sol,dp[i][(D-sum)%D][1]);
    sum=(sum+num[i]-'0')%D;
  }
  cout<<sol+!(sum%D)<<'\n';
}


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

int main(){
    int n,m;
    string s;
    cin >> n >> m >> s;
    stack<int> ans;
    int i=n;
    while(i){
        int j = max(0, i - m);
        for(;i>j;j++){
            if(s[j] == '0'){
                ans.push(i-j);
                break;
            }
        }
        if(i == j){
            puts("-1");
            return 0;
        }
      i = j;
    }
    while(!ans.empty()){
        cout << ans.top() << " ";
        ans.pop();
    }
    return 0;
}


Measured memory_bytes: 868
#include <bits/stdc++.h>
#define inf (long long)(1e18)
using namespace std;



int main(void){
    int N;
    scanf("%d", &N);
    long long a[N];
    long long sum[N+1];
    sum[0]=0;
    for(int i=0;i<N;i++){
        scanf("%lld", &a[i]);
        sum[i+1] = sum[i] + a[i];
    }
    long long ans = inf;
    for(int i=1;i<N;i++){
        ans = min(ans, abs(sum[i] - (sum[N]-sum[i])));
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  for(int a4 = 0; a4*4<=100; a4 ++){
    for(int a7 =0; a4*4+a7*7 <= 100; a7 ++){
      if(a4*4+a7*7 == N){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

using namespace std;

int main() {
  int n,L[1100],r[1100],sum = 0;
  cin >> n;

  for(int i = 0; i < n; i++) {
    cin >> L[i] >> r[i];
    sum += (r[i]-L[i]+1);
  }
  cout << sum << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main() 
{
	string S;
	cin >> S;
	int A, B, C, D;
	A = S[0] - '0'; B = S[1] - '0'; C = S[2] - '0'; D = S[3] - '0';
	if (A + B + C + D == 7) cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
	else if (A + B + C - D == 7) cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
	else if (A + B - C + D == 7) cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
	else if (A + B - C - D == 7) cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
	else if (A - B + C + D == 7) cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
	else if (A - B + C - D == 7) cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
	else if (A - B - C + D == 7) cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
	else if (A - B - C - D == 7) cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;


ll power(ll x, ll n)
{
  ll ans=1;
  while(n)
  {
    if(n&1) ans = (ans*x)%MOD;
    n>>=1;
    x = (x*x)%MOD;
  }
  return ans;
}

ll sum(ll n)
{
  return (n*(n+1)/2)%MOD;
}

int main()
{
  fastio
  ll n, k;
  ll ans=0;
  cin >> n >> k;
  for(ll i=k; i<=n+1; i++)
  {
    ll temp = sum(n) - sum(n-i) - sum(i-1) + 1;
    if(temp < 0 ) temp += MOD;
    temp%=MOD;
    /* cout << temp << "\n"; */  
    ans = (ans + temp)%MOD;
  }
  cout << ans;
  return 0;
}




Measured memory_bytes: 3648
using System;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int[] L = new int[2 * N];
        for(int i = 0; i < L.Length; i++)
        {
            L[i] = int.Parse(input[i]);
        }
        Array.Sort(L);
        int sum = 0;
        for(int i = 0; i < L.Length; i = i + 2)
        {
            sum += Math.Min(L[i], L[i + 1]);
        }
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 11220
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
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)))


INF = float("inf")
MOD = 10**9 + 7

class Combination(object):
    def __init__(self, N, mod=MOD):
        fac, finv, inv = [0] * (N + 1), [0] * (N + 1), [0] * (N + 1)
        fac[:2] = 1, 1
        finv[:2] = 1, 1
        inv[1] = 1
        for i in range(2, N + 1):
            fac[i] = fac[i - 1] * i % mod
            inv[i] = -inv[mod % i] * (mod // i) % mod
            finv[i] = finv[i - 1] * inv[i] % mod
        self.N = N
        self.MOD = mod
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def __call__(self, n, k):
        return self.C(n, k)

    def C(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        fac = self.fac
        finv = self.finv
        mod = self.MOD
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod

    def P(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.fac[n] * self.finv[n - k]


def main():
    N, M = MAP()
    cmb = Combination(M)

    ans = 0
    for i in range(N + 1):
        buf = (-1) ** i * cmb(N, i)
        buf %= MOD
        buf *= cmb.P(M, i)
        buf %= MOD
        buf *= pow(cmb.P(M - i, N - i), 2, MOD)
        buf %= MOD
        ans += buf
        ans %= MOD
    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 85684
import bisect

N, M = map(int,input().split())
AB = []
for m in range(M):
    a,b = map(int,input().split())
    AB.append((a,b))

AB = sorted(AB)

first = []
for a,b in AB:
    if a == 1:
        first.append(b)
    else:
        break

AB = sorted(AB, key=lambda x:x[1], reverse=True)
sec = []
for a,b in AB:
    if b == N:
        sec.append(a)
    else:
        break

if len(sec) >= 100:
    for f in first:
        ind = bisect.bisect_left(sec, f, 0, len(sec))
        if sec[ind] == f:
            print('POSSIBLE')
            exit()
else:
    for f in first:
        if f in sec:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')


Measured memory_bytes: 34600
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

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

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        cin >> N;
        int ki = 0, gu = 0;
        for (int i = 1; i <= N; ++i) {
            if (i % 2) ki++;
            else gu++;
        }

        double ans = 1. * ki / N;
        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <functional>
#include <numeric>

using namespace std;

typedef long long ll;

const ll MIN_V = -1e7;
const int MAX_N = 60;

int main(int argc, char const *argv[])
{
    int n, k;
    vector<ll> v;

    cin >> n >> k;

    for (int i = 0; i < n; ++i){
        ll vi;
        cin >> vi;
        v.push_back(vi);
    }

    ll ans = 0;
    for (int a = 0; a <= min(n,k); ++a) {
        vector<ll> rag_a;
        for (int i = 0; i < a; ++i) {
            rag_a.push_back(v[i]);
        }
        for (int b = 0; a+b <= min(n,k); ++b) {
            vector<ll> rag = rag_a;
            for (int i = 0; i < b; ++i) {
                rag.push_back(v[n-1-i]);
            }
            sort(rag.begin(), rag.end());
            ll sum = 0;
            for (int i = 0; i < rag.size(); ++i) {
                sum += rag[i];
            }
            for (int i = 0; i < k-(a+b) && i < rag.size(); ++i) {
                if (rag[i]>=0) break;
                sum -= rag[i];
            }
            ans = max(ans, sum);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
x, y, z, k = map(int, input().split())
a = map(int, input().split())
b = list(map(int, input().split()))
c = map(int, input().split())
d = sorted((ai + bi for ai in a for bi in b), reverse=True)[:k]
e = sorted((ci + di for ci in c for di in d), reverse=True)[:k]
print(*e)


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

using namespace std;

typedef long long int lli;

lli calc(pair<int, lli> v) {
    if (v.first != 0) v.second--;

    return (v.second * (v.second+1)) / 2;
}

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

    int n, m;
    lli a[100000];

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

    lli sum = 0;
    map<int, lli> mp;
    for (int i=0; i<n; i++) {
        sum += a[i];
        sum %= m;
        mp[sum]++;
    }

    lli ans = 0;
    for (auto itr=mp.begin(); itr!=mp.end(); itr++) {
        // cout << itr->first << " " << itr->second << endl;
        ans += calc(*itr);
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

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

  if (N == 0) {
    cout << 0 << endl;
    return 0;
  }

  string ans = "";
  while (N != 0) {
    if (N % 2 == 0) {
      ans = "0" + ans;
    } else {
      ans = "1" + ans;
      N--;
    }
    N /= -2;
  }

  cout << ans << endl;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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


void func(std::string S){

}

int main(){

    std::string S;
    std::cin >> S;
    if(S=="ABC"){
        cout << "ARC" << endl;
    }

    else if(S=="ARC"){
        cout << "ABC" << endl;
    }
    return 0;
}


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

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

  char ans[200]={};
  for(int i=0;i<a.size();i++)ans[i*2] = a[i];
  for(int i=0;i<b.size();i++)ans[i*2+1] = b[i];
  cout<<ans<<endl;


  return 0;
}


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

int main()
{
  int len[3];
  int type[3] = {0};

  while (~scanf("%d%d%d", &len[0], &len[1], &len[2])){
    sort(len, len + 3);

    if (len[0] + len[1] <= len[2]) break;
    else if (len[0] * len[0] + len[1] * len[1] == len[2] * len[2]){
      type[0]++;
    }
    else if (len[0] * len[0] + len[1] * len[1] > len[2] * len[2]){
      type[1]++;
    }
    else if (len[0] * len[0] + len[1] * len[1] < len[2] * len[2]){
      type[2]++;
    }
  }

  printf("%d %d %d %d\n", type[0] + type[1] + type[2], type[0], type[1], type[2]);

  return (0);
}

Measured memory_bytes: 1208
n = int(input())
b = []
s1, s2 = input(), input()
now = 0
while now < n:
  if s1[now] == s2[now]:
    b.append(1)
    now += 1
  else:
    b.append(0)
    now += 2
if b[0]:
  ans = 3
else:
  ans = 6
for i in range(len(b)-1):
  if b[i]:
    ans *= 2
  elif not b[i+1]:
    ans *= 3
  ans %= 10**9+7
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<pair<int, int>> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i].first >> a[i].second;
	sort(a.begin(), a.end());
	ll num = 0, i = 0, keep;
	while (num < k) {
		num += a[i].second;
		keep = a[i].first;
		i++;
	}
	cout << keep << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		int N=c.length;
		long ans=0L;
		for(int i=0; i<(1<<N-1); i++){
			long sub_sum=0;
			int offset = 0;
			for(int j=0; j<N-1; j++){
				if((1 & i>>j) == 1){
					char[] sub = Arrays.copyOfRange(c, offset, j+1);
					sub_sum += deci_sum(sub);
					offset = j+1;
				}
			}
			char[] sub = Arrays.copyOfRange(c, offset, c.length);
			sub_sum += deci_sum(sub);
			ans += sub_sum;
		}
		System.out.println(ans);
		sc.close();
	}
	
	//各桁の数が格納された配列をlong型にする
	public static long deci_sum(char[] number){
		String str = new String(number);
		return Long.parseLong(str);
	}
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;cin>>n;
  cout<<n/3<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1e6+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
//inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
char s[MAXN];int n,a[MAXN],Min[MAXN];
inline int Solve(int lim){
	static int b[MAXN];int cnt=0;
	Rep(i,1,n){
		if(s[i]=='?'&&Min[i]-2*cnt-2>=lim)cnt++;
		b[i]=a[i]-2*cnt;
	}int Max=0;Rep(i,1,n)Max=max(Max,b[i]);
	return Max-lim;
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	scanf("%s",s+1),n=strlen(s+1);
	Rep(i,1,n)if(s[i]=='0')a[i]=a[i-1]-1;else a[i]=a[i-1]+1;
	Min[n+1]=n+5;Red(i,n,0)Min[i]=min(Min[i+1],a[i]);
	cout<<min(Solve(Min[0]),Solve(Min[0]-1));
	return 0;
}




Measured memory_bytes: 16436
main = readAndDo

readAndDo = do
  line <- getLine
  if line == "0 0" then return ()
  else do
    solve . input $ line
    putStrLn ""
    readAndDo

-- 入力
input :: String -> [Int]
input = (map read) . words

-- 解答
solve [0, b] = return ()
solve [a, b] = do
  putStrLn $ foldr (++) "" $ replicate b "#"
  solve [a-1, b]



Measured memory_bytes: 4128
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                for (int i = 0; i < 3; i++) {
                        int start = sc.nextInt() * 3600 + sc.nextInt() * 60 + sc.nextInt();
                        int stop = sc.nextInt() * 3600 + sc.nextInt() * 60 + sc.nextInt();
                        int time = stop - start;
                        System.out.println(time / 3600 + " " + time % 3600 / 60 + " " + time % 60);
                }
        }
}

Measured memory_bytes: 26080
#include<stdio.h>

int main(void)
{
	int i,n,k,tall;
	
	scanf("%d%d",&n,&k);
	
	int count=0;
	
	for(i=0;i<n;i++){
		scanf("%d",&tall);
		if(tall>=k)
			count++;
	}
	
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n; cin >> n;
  int p1[3];
  for(auto &e: p1) cin >> e;
  int p2[3] = {p1[0],p1[1],p1[2]};
  for(int i=1;i<n;i++) {
    int dc[3];
    for(auto &e: dc) cin >> e;
    for(int i=0;i<3;i++) {
      for(int j=0;j<3;j++) {
        if (i==j) continue;
        p2[i] = max(p2[i],p1[j] + dc[i]);
      }
    }
    for(int i=0;i<3;i++) p1[i] = p2[i];
  }
  cout << max(p2[0],max(p2[1],p2[2]));
  return 0;
}

Measured memory_bytes: 256
N = int(input())
evi_list = [[] for _ in range(N)]
for n in range(N):
    A = int(input())
    for _ in range(A):
        evi_list[n].append([int(xy) for xy in input().split()])

max_honest = 0
for c in range(1, 2**N):
    index = 0
    honest_count = 0
    for bit in reversed(list(bin(c))[2:]):
        if bit == "1":
            is_honest = True
            for evi in evi_list[index]:
                judge = c & (1 << (evi[0]-1))
                if (judge == 0 and evi[1] == 1) or (judge >= 1 and evi[1] == 0):
                    is_honest = False
                    break
            if is_honest:
                honest_count += 1
            else:
                honest_count = 0
                break
        index += 1
    max_honest = max(max_honest, honest_count)

print(max_honest)

Measured memory_bytes: 3064
#ABC115D-Christmas.py

from sys import stdin

input = stdin.readline

N, X = list(map(int, input().split()))

def l(n):
    return 2**(n+2)-3

def p(n):
    return 2**(n+1)-1

def f(N, X):
    if X == 0:
        return 0
    elif X <= l(N-1) + 1:
        return f(N-1,X-1)
    elif X == l(N-1) + 2:
        return 1 + p(N-1)
    elif X <= 2 * l(N-1) + 2:
        return 1 + p(N-1) + f(N-1, X-l(N-1)-2)
    else:
        return 1 + 2 * p(N-1)

print(f(N,X))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define MAX INT_MAX
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
set <int> s;
bool ar[100001];
void seive() {
	ar[0] = ar[1] = true;

	for(int p=2; p*p<=100001; p++) {
		if(ar[p] == false) {
			for(int i=p*p;i<=100001;i+=p)
				ar[i] = true ;
		}
	}

	for(int p=2;p<=100001;p++) {
		if(ar[p] == false)
			s.insert(p);
	}
}
void solve() {
	int n;
	cin >> n;
	vector <int> v(n);
	for(int i=0;i<n;i++)
		cin >> v[i];
	sort(v.begin(), v.end());
	for(int i=0;i<n-1;i++) {
		if(v[i] == v[i+1]) {
			cout << "NO" << endl;
			return ;
		}
	}
	cout << "YES" << endl;
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}

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

int main(){
    string s;
    cin>>s;
    stack<char> stk;
    int ans=0;
    for(auto it:s){
        if(stk.empty()){
            stk.push(it);
        }
        else{
            if(it=='1'){
                if(stk.top()=='0'){
                    stk.pop();
                    ans+=2;
                }
                else{
                    stk.push(it);
                }
            }
            else{
                if(stk.top()=='1'){
                    stk.pop();
                    ans+=2;
                }
                else{
                    stk.push(it);
                }   
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int n, m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main(){
    let s: String = read();
    let mut n0 = false;
    let mut w0 = false;
    let mut s0 = false;
    let mut e0 = false;
    for i in s.chars() {
        match i {
            'N' => n0 = true,
            'W' => w0 = true,
            'S' => s0 = true,
            _   => e0 = true,
        }
    }
    println!("{}", if n0 == s0 && w0 == e0 {"Yes"} else {"No"});
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
import collections
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
str = []
for i in range(n):
    str.append(''.join(sorted(input())))

c = collections.Counter(str)

count = 0
for k, v in c.items():
    if v > 1:
        count += combinations_count(v, 2)

print(count)

Measured memory_bytes: 19760