akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	
	string str;
	int y,m,d;
	while(cin >> str,str[0] != '#'){
		cin >> y >> m >> d;
		if(y > 31 || (y == 31 && m >= 5)){
			cout << '?' << ' ' << y - 30 << ' ' << m << ' ' << d << endl;
		}
		else{
			cout << str << ' ' << y << ' ' << m << ' ' << d << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int,int>;
constexpr ll mod = 1000000007;
void pPRINTl(ostream& ost) { ost << endl; }
template <class T>void pPRINTL(ostream& ost,T t){ost<<t<<endl;}
template <class T, class... U>void pPRINTl(ostream& ost, T t, U... u) {ost << t << " ";pPRINTl(ost, u...);}
template <class... T>void PRINTl(T... t) { pPRINTl(cout, t...); }
//#define PRINTl //
void pPRINT(ostream& ost) {}
template <class T>void pPRINT(ostream& ost, T t){ost<<t;}
template <class T, class... U>void pPRINT(ostream& ost, T t, U... u) {ost << t << " ";pPRINT(ost, u...);}
template <class... T>void PRINT(T... t) { pPRINT(cout, t...); }

//#define DEBUG PRINTl("DEBUG line:",__LINE__)
#define DEBUG 
 
int main(){
  
  ll n;
  cin>>n;
  bool a[n];
  REP(i,n){cin>>a[i];}
  
  ll b[n];
  bool c[n];
  ll count=0;
  bool f = false;
  for(int i=n;i>0;i--){
    ll index = i-1;
    DEBUG;
    if(n/i==1){
      c[index]=a[index];
      if(c[index]){
        b[count]=i;
      	count++;
      }
    }
    else{
      ll m=n/i;
      bool t = 0;
      DEBUG;
      for(int j=2;j<=m;j++){
        t=(t!=c[j*i-1]);
      }
      DEBUG;
      c[index]=(t!=a[index]);
      if(c[index]){
        b[count]=i;
        count++;
      }
    }
  }

  PRINTl(count);
  REP(i,count)PRINT(b[i]," ");
  
  
  return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<vector>

#define INF 999999999
#define ll long long

using namespace std;

const int MAX_N = 100000;
const int MAX_M = 500000;

struct edge
{
	int from;  //?????????
	int to;    //??°??????
	int cost;  //??????
};

int d[MAX_N];
edge es[MAX_M];
bool flag;	//???????????????????????????

void shortest_path(int n,int m,int s)	//s???????????????????????????????????????????????¢????±???????
{
	int cnt = 0;
	fill(d,d+n,INF);
	d[s] = 0;
	while(true && cnt < n){
		bool update = false;
		for(int i=0;i<m;i++){
			edge e = es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if(!update) break;
		cnt++;
	}
	if(cnt == n){
		flag = true;
	}
}

int main()
{
	int i,n,m,s;
	cin >> n;  //????????°
	cin >> m;  //?????°
	cin >> s;  //???????????????
	for(int i=0;i<m;i++){
		scanf("%d",&es[i].from);
		scanf("%d",&es[i].to);
		scanf("%d",&es[i].cost);
	}
	flag = false;
	shortest_path(n,m,s);
	if(!flag){
		for(int i=0;i<n;i++){
			if(d[i] == INF){
				cout << "INF\n";
			}else{
				cout << d[i] << "\n";
			}
		}
	}else{
		cout << "NEGATIVE CYCLE\n";
	}
}

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

int n;
int s;
int m[20];

bool visited[(1<<14)][20];
int mem[(1<<14)][20];

int solve(int s,int id){
  if(visited[s][id]){
    return mem[s][id];
  }

  visited[s][id]=1;
  
  if( s==0 ){
    return mem[s][id]=id%2;
  }

  
  if(id%2==1){

    for(int i=1;i<=m[id];i++){
      if( solve( max(s-i,0) , (id+1)%(n+n) ) == 1 ){
        return mem[s][id]=1;
      }
    }
    return mem[s][id]=0;
    
  }else{

    for(int i=1;i<=m[id];i++){
      if( solve( max(s-i,0) , (id+1)%(n+n) ) == 0 ){
        return mem[s][id]=0;
      }
    }
    return mem[s][id]=1;
  }

  assert(0);
  return mem[s][id]=-1;  
}

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    memset( visited, false , sizeof(visited));
    cin>>s;
    for(int i=0;i<n+n;i++)cin>>m[i];
    cout<<1-solve(s,0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 4108
string = input()
l_idx = 0
r_idx = len(string) - 1
ans = 0
while l_idx <= r_idx:
    l = string[l_idx]
    r = string[r_idx]
    if l == r:
        l_idx += 1
        r_idx -= 1
    else:
        if l == 'x':
            l_idx += 1
            ans += 1
        elif r == 'x':
            r_idx -= 1
            ans += 1
        else:
            print(-1)
            exit()
print(ans)

Measured memory_bytes: 9008
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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 <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// 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 <atomic>
#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>
#endif

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

int main()
{
  int k;
  cin >> k;
  if(k%2==0)cout << k / 2 * k / 2 << endl;
  else cout<<k/2*(k+1)/2<<endl;

  return 0;
}


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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

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

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int a[13] = {-1, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

	int x = in(), y = in();

	if (a[x] == a[y]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int a1 = (int)Math.pow(a,2);
    int a2 = (int)Math.pow(a,3);
    System.out.println(a+a1+a2);
  }
}

Measured memory_bytes: 35736
def f():
    global s
    if s[-1] == x:
        return
    s = s[:-1]
    return f()

s = input()
ans = 0
while s and not s =="W"*len(s) and not s == "B"*len(s):
    if   s[-1] == "W":
        x = "B"
        y = "W"
    elif s[-1] == "B":
        x = "W"
        y = "B"
    f()
    ans += 1
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#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 all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,now = 0,x = 0,y = 0,t,nx,ny;
    bool ok = 1;
    cin >> n;
    rep(i,n){
        cin >> t >> nx >> ny;
        int d = abs(x-nx)+abs(y-ny);
        if (d > (t-now)) ok = 0;
        else{
            if ((t-now-d)%2) ok = 0;
        }
        now = t;
        x = nx;
        y = ny;
    }
    if (ok) PRINT("Yes");
    else PRINT("No");
}


Measured memory_bytes: 256
n=int(input())
v_list = list(map(int,input().split()))
odd_list = []
even_list = []

for i in range(n):
    if i % 2 == 0:
        odd_list.append(v_list[i]) 
    else:
        even_list.append(v_list[i])

import collections

odd_list_c = collections.Counter(odd_list)
even_list_c = collections.Counter(even_list)

if odd_list_c.most_common()[0][0] != even_list_c.most_common()[0][0]:
    ans = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[0][1]
else:
    if len(even_list_c) == 1 and len(odd_list_c) == 1:
        ans = n // 2
    else: 
        ans1 = n - odd_list_c.most_common()[0][1] - even_list_c.most_common()[1][1]
        ans2 = n - odd_list_c.most_common()[1][1] - even_list_c.most_common()[0][1]
        ans = min(ans1, ans2)

print(ans)

Measured memory_bytes: 19040
#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N, K, Q;
ll A[100010];
ll point[100010];
int main(){
	cin >> N >> K >> Q;
	REP(i,0,Q){
		cin >> A[i];
		A[i]--;
	}
	REP(i,0,Q){
		point[A[i]]++;
	}
	REP(i,0,N){
		if(Q-point[i]>=K){
			p("No");
		}else{
			p("Yes");
		}
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
ll A, B, Q;
ll T[100005], S[100005];

ll solve(ll x) {
    ll s = 0, t = 0;
    {
        ll ng = A;
        while (abs(s - ng) > 1) {
            ll mid = (ng + s) / 2;
            if (S[mid] <= x)
                s = mid;
            else
                ng = mid;
        }
    }
    {
        ll ng = B;
        while (abs(t - ng) > 1) {
            ll mid = (ng + t) / 2;
            if (T[mid] <= x)
                t = mid;
            else
                ng = mid;
        }
    }

    ll ret = INF;
    vector<ll> ps, pt;
    ps.push_back(S[s]);
    s = std::min(s + 1, A - 1);
    ps.push_back(S[s]);
    pt.push_back(T[t]);
    t = std::min(t + 1, B - 1);
    pt.push_back(T[t]);

    ret = std::min({ret,
                    abs(x - ps[0]) + abs(ps[0] - pt[0]),
                    abs(x - ps[0]) + abs(ps[0] - pt[1]),
                    abs(x - pt[0]) + abs(pt[0] - ps[0]),
                    abs(x - pt[0]) + abs(pt[0] - ps[1]),
                    abs(x - ps[1]) + abs(ps[1] - pt[0]),
                    abs(x - ps[1]) + abs(ps[1] - pt[1]),
                    abs(x - pt[1]) + abs(pt[1] - ps[0]),
                    abs(x - pt[1]) + abs(pt[1] - ps[1])});

    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> A >> B >> Q;
    REP(i, A) {
        cin >> S[i];
    }
    REP(i, B) {
        cin >> T[i];
    }
    sort(S, S + A);
    sort(T, T + B);

    REP(i, Q) {
        ll x;
        cin >> x;
        cout << solve(x) << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    long long t = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    for (int i = 1; i < n; i++) {
        t += a[i >> 1];
    }
    cout << t << endl;
}


Measured memory_bytes: 4036
#include <stdio.h>
int main(){ 
 int n; 
 scanf("%d",&n); 
 long long ans=0; 
 for(int i=1;i<=n;i++){ 
 if(i%3!=0 && i%5!=0)ans+=i; 
 } 
 printf("%lld\n",ans); 
 }

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 80;
int p;
void inc(int &x, int y) {(x += y) >= p ? x -= p : 0;};
int work(int n, int k, int p) {
    int dp[2][N] {};
    dp[0][0] = 1;
    int cur = 0, pre = 1;
    for (int i = 0; i < n; ++i) {
        swap(cur, pre);
        memset(dp[cur], 0, sizeof(dp[cur]));
        for (int j = 0; j <= k; ++j) {
            inc(dp[cur][0], dp[pre][j]);
            if (j < k)
                inc(dp[cur][j + 1], dp[pre][j]);
        }
    }
    int ans = 0;
    for (int i = 0; i <= k; ++i)
        inc(ans, dp[cur][i]);
    return ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k >> p;
    if (k % 2 == 0) {
        cout << 1LL * work(n / 2, k / 2, p) * work((n + 1) / 2, k / 2, p) % p << endl;
        return 0;
    }
    int dp[2][N][N][N] {};
    int m = (n + 1) / 2 + 1;
    dp[0][0][0][m] = 1;
    int cur = 0, pre = 1;
    for (int i = 0; i < n; ++i) {
        swap(cur, pre);
        memset(dp[cur], 0, sizeof(dp[cur]));
        for (int x = 0; x <= (i + 1) / 2; ++x) {
            for (int y = 0; y <= i / 2; ++y) {
                for (int z = max(x, y) + 1; z <= m; ++z) {
                    if (dp[pre][x][y][z] == 0)
                        continue;
                    inc(dp[cur][0][x][x > y ? z : m], dp[pre][x][y][z]);
                    if (2 * x >= k + 1)
                        inc(dp[cur][y + 1][x][min(z, max(0, x + (k - 2 * y + 1) / 2))], dp[pre][x][y][z]);
                    else
                        inc(dp[cur][y + 1][x][z], dp[pre][x][y][z]);
                }
            }
        }
    }
    int ans = 0;
    for (int x = 0; x <= m; ++x)
        for (int y = 0; y <= m; ++y)
            for (int z = max(x, y) + 1; z <= m; ++z)
                inc(ans, dp[cur][x][y][z]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	vector<int> v(n);
	rep(i, n) cin >> v[i];

	vector<int> t;
	t.push_back(0);
	REP(i, 1, n) {
		if(v[i-1] == v[i]) {
			t.push_back(i);
		}
	}
	t.push_back(n);

	int ans = 0;
	rep(i, t.size()-1) {
		ans = max(ans, t[i+1] - t[i]);
	}

	// cout << " -------- t ------ " << endl;
	// rep(i, t.size()-1) {
	// 	cout << t[i] << " <-> " << t[i+1] << "  : " << t[i+1] - t[i] << endl;
	// }

	rep(i, n) {
		int j = upper_bound(t.begin(), t.end(), i) - t.begin();
		int res = t[j+1] - t[j-2];
		ans = max(ans, res);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1804
#include "bits/stdc++.h"
using namespace std;

int main() {
    
	string s;
	cin >> s;
	set<char> x;
	for (int i=0; i<s.size(); i++) x.insert(s[i]);
	if (x.size() == s.size()) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}
    
}


Measured memory_bytes: 256
n=int(input())
a0=input().split()

sum0=0
al=[0 for i in range(100001)]

for i in range(n):
  al[int(a0[i])]+=1
  sum0+=int(a0[i])

q=int(input())

for i in range(q):
  b0=input().split()
  zen=int(b0[0])
  go=int(b0[1])
  changes=al[zen]
  al[zen]=0
  al[go]+=changes
  sum0+=changes*(go-zen)
  print(sum0)

Measured memory_bytes: 17668
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n,m;
  cin >> n;
  vector<int> t(n);
  rep(i,n){cin>>t[i];}
  cin >> m;
  vector<int> p(m),x(m);
  rep(i,m){cin>>p[i]>>x[i]; p[i]--;}

  int ans=accumulate(t.begin(),t.end(),0);
  rep(i,m){
    int cur=ans;
    cur += x[i]-t[p[i]];
    cout << cur << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    dp = [[0] * 13 for _ in range(len(s))]
    for i in range(len(s)):
        ts = s[-i-1]
        if i == 0:
            if ts == "?":
                for j in range(10):
                    dp[i][j] += 1
            else:
                dp[i][int(ts)] += 1
        else:
            mult = pow(10, i, 13)
            if ts == "?":
                for j in range(13):
                    for k in range(10):
                        dp[i][(k * mult + j) % 13] += dp[i-1][j]
            else:
                num = int(ts)
                for j in range(13):
                    dp[i][(num * mult + j) % 13] += dp[i-1][j]
            for j in range(13):
                dp[i][j] %= mod
    print(dp[-1][5] % mod)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 63784
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int x = sc.nextInt();
		
		int ans = 0;
		
		for(int i = 0; i <= a; i++) {
			for(int k = 0; k <= b; k++) {
				for(int j = 0; j <= c; j++) {
					if((i * 500) + (k * 100) + (j * 50) == x) {
						ans++;
					}
				}
			}
		}
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////
ll dp[100100][13];
int main() {
	string S; cin >> S;
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 0; i < S.size(); ++i) {
		int c;
		if (S[i] == '?')c = -1;
		else c = S[i] - '0';
		for (int j = 0; j < 10; ++j) {
			if (c != -1 && c != j)continue;
			for (int ki = 0; ki < 13; ++ki) {
				dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki];
			}
		}
		for (int j = 0; j < 13; ++j) {
			dp[i + 1][j] %= INF;
		}
	}
	cout << dp[S.size()][5] << endl;
	return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}
 
int main(){
    string S;
    cin >> S;
    int ans = 0;
    int cnt = 0;
    REP(i, S.length()){
        if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T') cnt++;
        else cnt = 0;
        if(cnt > ans) ans = cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, T = input().split(' ')
N = int(N)
T = int(T)
x = [i for i in range(N+1)]
t = input()
cnt = 0
for ti in t.split(' '):
    x[cnt] = int(ti)
    cnt += 1
x[cnt] = -1
ans = 0
prev = -1
for ti in x:
    if ti == -1:
        ans += T
    elif prev != -1:
        if ti-prev > T:
            ans += T
        else:
            ans += ti-prev
    prev = ti
print (ans)


Measured memory_bytes: 28236
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll A;
    string b; //小数点を誤差なく受け取るために、一度文字列で受け取る
    cin >> A >> b;

    //誤差なく計算するために100倍して整数値として扱う
    ll B = stoi(b.substr(0, 1)) * 100 + stoi(b.substr(2, 1)) * 10 + stoi(b.substr(3, 1));

    //掛け算した後に100で割って戻す
    //long longでキャストすることで小数点以下の切り捨てを実現
    ll ans = ll((A * B) / 100);

    cout << setprecision(17) << ans << endl;

    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define FIND(c, e) ((c).find(e) != (c).end())
#define NFIND(c, e) ((c).find(e) == (c).end())
#define ALL(t) (t).begin(),  (t).end()
#define ALLR(t) (t).rbegin(), (t).rend()
#define MP make_pair
template<class T> T max(T a,T b,T c){return max(max(a,b),c);}
template<class T> T min(T a,T b,T c){return min(min(a,b),c);}
const int N = int( 1e5 ) + 42;

const int INF = 1e8;
int n, m, r;
int rr[8];
int dis[201][201];
int from, to, d;
int ans;
void __answer()
{
    ans = INF;
    cin >> n >> m >> r;
    for(int i = 0; i < r; i++) {
        cin >> rr[i];
    }
    for(int i = 0; i < 201; i++) {
        fill(dis[i], dis[i] + 201, INF);
    }
    for(int i = 0; i < m; i++) {
        cin >> from >> to >> d;
        dis[from][to] = min(dis[from][to], d);
        dis[to][from] = min(dis[to][from], d);
    }
    for(int k = 1; k <= n; k++) {
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }
    sort(rr, rr + r);
    int path = 0;
    do {
        path = 0;
        for(int i = 0; i + 1 < r; i++) {
            path += dis[rr[i]][rr[i + 1]];
        }
        ans = min(ans, path);
    } while(next_permutation(rr, rr + r));
    cout << ans;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cout << setprecision(11) << fixed;
    #ifdef LOCAL
        freopen("TEST.txt", "r", stdin);
    #endif
    __answer();
    return 0;
}


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int pdx[] = {-1, 0, 1, -2, 2, -2, 2, -2, 2, -1, 0, 1};
const int pdy[] = {-2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2};
const int wdx[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
const int wdy[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};

int main() {
    int x, y;
    while (cin >> x >> y, x|y) {
        int n;
        cin >> n;
        vector<pii> water(n);
        REP(i, n) {
            int wx, wy;
            cin >> wx >> wy;
            water[i] = {wx, wy};
        }
        bool G[10][10] = {};
        queue<pii> que;
        que.push({x, y});
        que.push({-1, -1});
        G[y][x] = true;
        int cnt = 0;
        while (1) {
            pii p = que.front(); que.pop();
            int x = p.first, y = p.second;
            if (x == -1 && y == -1) {
                if (que.empty()) {
                    cout << (cnt == n ? "OK" : "NA") << endl;
                    break;
                }
                que.push({-1, -1});
                cnt++;
                continue;
            }
            REP(i, 12) {
                int px = x + pdx[i], py = y + pdy[i];
                if (0 <= px && px < 10 && 0 <= py && py < 10) {
                    REP(j, 9) {
                        int wx = water[cnt].first + wdx[j], wy = water[cnt].second + wdy[j];
                        if (px == wx && py == wy) {
                            if (!G[py][px]) {
                                G[py][px] = true;
                                que.push({px, py});
                            }
                        }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 1188
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Fri Dec 28 14:58:13 2018
//
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var N, M, X int
	fmt.Scan(&N, &M, &X)

	arr := make([]int, N+1)
	for i := 0; i < M; i++ {
		var a int
		fmt.Scan(&a)
		arr[a]++
	}

	tmp1 := 0
	for i := X; i < len(arr); i++ {
		tmp1 += arr[i]
	}

	tmp2 := 0
	for i := X; i >= 0; i-- {
		tmp2 += arr[i]
	}

	fmt.Println(min(tmp1, tmp2))
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9 + 7;

int main() {
    ll q, h, s, d;
    cin >> q >> h >> s >> d;
    ll n; cin >> n;

    h = min(2 * q, h);
    s = min(2 * h, s);

    if(2 * s <= d){
        cout << min(2 * min(2 * q, h), s) * n << endl;
    }else{
        cout << (n / 2) * min({8 * q, 4 * h, 2 * s, d}) + (n % 2) * min({4 * q, 2 * h, s}) << endl;
    }


    return 0;
}


Measured memory_bytes: 3600
#!/usr/bin/env python
# -*- coding: utf-8 -*-


from sys import stdin
import math

L,R  = [int(x) for x in stdin.readline().rstrip().split()]

diff = R - L

min_val = 2019



min_val = 2019

sur_L = L % 2019
sur_R = R % 2019

if diff > 2019:
    print(0)

elif sur_R < sur_L:
    print(0)
else:
    if sur_R < sur_L:
        tmp = sur_R
        sur_R = sur_L
        sur_L = tmp
        

    for i in range(sur_L,sur_R+1):
        for j in range(i+1, sur_R+1):
            amari = ( i * j) % 2019
            if min_val > amari:
                min_val = amari

    print(min_val)


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

int main(){
  int a, b, k, cnt = 0;
  std::cin >> a >> b >> k;
  for (int i = max(a, b); i >= 0; i--) {
    if((a%i == 0) and (b%i == 0))cnt++;
    if(cnt == k){
      std::cout << i << std::endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	S := ReadString()
	if len(S) >= 4 && S[:4] == "YAKI" {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int main(){
  long long int n;
  cin >> n;
  long long int ans = 0;
  for(long long int i = 1; i <= n; i++){
    if(i % 3 != 0 && i % 5 != 0) ans += i;
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	int n=s.size();
	for (int i=0; i<n; i+=2)
		cout << s[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 592
def turn(d,dir)
  case dir
  when "North" then d[0],d[1],d[5],d[4] = d[1],d[5],d[4],d[0]
  when "South" then d[0],d[1],d[5],d[4] = d[4],d[0],d[1],d[5]
  when "West" then d[0],d[2],d[5],d[3] = d[2],d[5],d[3],d[0]
  when "East" then d[0],d[2],d[5],d[3] = d[3],d[0],d[2],d[5]
  when "Right" then d[1],d[2],d[4],d[3] = d[2],d[4],d[3],d[1]
  when "Left" then d[1],d[2],d[4],d[3] = d[3],d[1],d[2],d[4]
  end
  d
end

while true
  n = gets.to_i
  break if n == 0
  d = Array.new(6){|i| i+1}
  ans = 1
  n.times do
    dir = gets.chomp 
    d = turn(d,dir)
    ans += d[0]
  end
  puts ans
end

Measured memory_bytes: 8788
N, A, B = [int(_) for _ in input().split()]
H = [int(input()) for i in range(N)]

from math import ceil

t = sum(H)

def enough(t):
    r = 0
    for h in H:
        r += ceil(max(h - t * B, 0) / (A - B))
    # print("*", t, r)
    return r <= t

lo = ceil(t / (A + B * (N - 1))) - 1
hi = ceil(t / B)

while lo + 1 != hi:
    t = (lo + hi) // 2
    r = enough(t)
    # print(lo, hi, t, r)
    if r:
        hi = t
    else:
        lo = t

print(hi)


Measured memory_bytes: 7072
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

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

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n, k = input_list()
  ans = 0
  for i in range(1, n+1):
    t = 1.0
    while i < k:
      i *= 2
      t /= 2
    ans += t
  print(ans/n)
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Measured memory_bytes: 68204
import java.util.*;

//6 and 7 is WA or RE

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int h = Integer.parseInt(sc.next());
      int w = Integer.parseInt(sc.next());
      int k = Integer.parseInt(sc.next());

      //char[][] c = new char[h][w];
      int[][] ans = new int[h][w];
      int cnt = 1;
      for(int i=0;i<h;i++){
        String s = sc.next();
        for(int j=0;j<w;j++){
          char c = s.charAt(j);
          if(c=='#'){
            ans[i][j] = cnt;
            cnt++;
          }
        }
      }
      cnt=0;

      //same as hidari
      for(int i=0;i<h;i++){
        for(int j=1;j<w;j++){
          if(ans[i][j]==0){
              ans[i][j] = ans[i][j-1];
          }
        }
      }
      //same as migi
      for(int i=0;i<h;i++){
        for(int j=(w-2);j>=0;j--){
          if(ans[i][j]==0){
              ans[i][j] = ans[i][j+1];
          }
        }
      }

      //nanimonai
      for(int i=1;i<h;i++){
        cnt = 0;
        for(int j=0;j<w;j++){
          cnt += ans[i][j]; // calc all sum in i;
        }
        if(cnt==0){ // all 0
          for(int j=0;j<w;j++){
            ans[i][j] = ans[i-1][j]; //ue wo copy
          }
        }
      }

      //nanimonai2
      for(int i=(h-2);i>=0;i--){
        cnt = 0;
        for(int j=0;j<w;j++){
          cnt += ans[i][j]; // calc all sum in i;
        }
        if(cnt==0){ // all 0
          for(int j=0;j<w;j++){
            ans[i][j] = ans[i+1][j]; //shita wo copy
          }
        }
      }





      output(ans,h,w);
    }


    public static void output(int[][] ans,int h,int w){
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          System.out.print(ans[i][j]+" ");
        }
        System.out.println("");
      }
    }
}


Measured memory_bytes: 42932
#include <bits/stdc++.h>
using namespace std;
template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

int main() {
  double r;
  cin >> r;
  cout << 6.28318530717958623200*r << endl;
  return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long x;
    cin >> x;
    long long ans = x / 11;
    x -= 11 * ans;
    ans *= 2;
    if(x == 0){
    }
    else if(x <= 6)
        ans += 1;
    else
        ans += 2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

s = input()[:-1]; n = len(s)
print('Yes' if s == s[::-1] and s[:(n-1)//2] == s[:(n-1)//2][::-1] and s[(n+1)//2:] == s[(n+1)//2:][::-1] else 'No')

Measured memory_bytes: 61660
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
using namespace std;

const unsigned long long BASE = 1e9 + 7;

int f(int a, int b)
{
    if (a < b)
        std::swap(a, b);
    while (b > 0)
    {
        int t = a % b;
        a = b;
        b = t;
    }
    return a;
}

int main()
{
    int n;
    cin >> n;
    int a, b;
    cin >> a;
    for (int i = 1; i < n; i++)
    {
        cin >> b;
        a = f(a, b);
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

string func(int n){
	string ans="";
	rep(i,2*n+1){
		if(i%2==0){
			ans+='I';
		}else{
			ans+='O';
		}
	}
	return ans;
}

int main(){
	int n,m;
	string s;
	while(cin>>n,n){
		cin>>m>>s;
		string check=func(n);
		int cnt=0;
		rep(i,m-check.size()+1){
			string alt=s.substr(i,check.size());
			if(alt==check)cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 2124
package main

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

const N = 100

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func answer(reader io.Reader) string {
	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	var p [N]int
	var m [N + 1][N + 1]int
	for i := 1; i <= n; i++ {
		sc.Scan()
		p[i-1], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		p[i], _ = strconv.Atoi(sc.Text())
	}

	for l := 2; l <= n; l++ {
		for i := 1; i <= n-l+1; i++ {
			j := i + l - 1
			m[i][j] = (1 << 21)
			for k := i; k <= j-1; k++ {
				m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
			}
		}
	}

	return fmt.Sprintf("%d", m[1][n])
}

func main() {
	fmt.Println(answer(os.Stdin))
}



Measured memory_bytes: 1248
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);

using ll = int64_t;
using ull = uint64_t;

using namespace std;

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

    int k, a, b;
    cin >> k >> a >> b;

    for (int i = a; i <= b; ++i) {
        if (i % k == 0) {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
    return 0;
}


Measured memory_bytes: 3648
import itertools
n = int(input())
p = list(map(int, input().strip().split()))
q = list(map(int, input().strip().split()))

#print(p)
#print(q)
r = list(range(1,n+1))
E = list(itertools.permutations(r))
#print(r)
#print(e)
pi = 0
qi = 0
for i in range(0,len(E)):
    if p == list(E[i]):
        pi = i
        #print(pi)
    if q == list(E[i]):
        qi = i
        #print(qi)

print(abs(pi - qi))


Measured memory_bytes: 8052
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;


void solve(long long N){
  op(N/3)
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <fstream>
using namespace std;
typedef long long ll;

#define _ { \
	ios_base::sync_with_stdio(false); \
    cin.tie(NULL); \
}


int main(){
   _;
  int n,k;cin>>k>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  sort(v.begin(),v.end());
  if(v[n-1]>k/2)  v.push_back(v[0]+k);
  int m=0;
  for(int i=1;i<=n;i++)m=max(m,v[i+1]-v[i]);
  cout<<k-m;
  
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(string,s);

  map<char,int> mp;
  EACH(si,s){
    mp[si]++; 
  }
  int n = s.size();;
  int ans = n*(n-1)/2+1;
  EACH(mi,mp){
    ans -= mi.second*(mi.second-1)/2;
  }
  OUT(ans)BR;
  return 0;
}


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

std::vector<std::vector<long long>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main(){
  int N, M;
  cin >> N >> M;
  int ans = 0;
  ans = comb(N, 2)[N][2] + comb(M, 2)[M][2];
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pii pair<int, int>
#define fir first
#define sec second
#define lson (rt << 1)
#define rson (rt << 1 | 1)
#define ll long long
using namespace std;
const int MAXN = 2e5 + 7;
ll T[MAXN << 2], lazy[MAXN << 2];
void pushup(int rt) {T[rt] = max(T[lson], T[rson]);}
void upd(int rt, ll v) {T[rt] += v; lazy[rt] += v;}
void pushdown(int rt)
{
    if (!lazy[rt]) return;
    upd(lson, lazy[rt]); 
    upd(rson, lazy[rt]);
    lazy[rt] = 0;
}
void update(int rt, int l, int r, int L, int R, ll v)
{
    if (L <= l && r <= R) {upd(rt, v); return;}
    int mid = (l + r) >> 1;
    pushdown(rt);
    if (L <= mid) update(lson, l, mid, L, R, v);
    if (mid <  R) update(rson, mid + 1, r, L, R, v);
    pushup(rt);
}
ll query(int rt, int l, int r, int L, int R)
{
    if (L <= l && r <= R) return T[rt];
    int mid = (l + r) >> 1; ll res = 0;
    pushdown(rt);
    if (L <= mid) res = max(res, query(lson, l, mid, L, R));
    if (mid <  R) res = max(res, query(rson, mid + 1, r, L, R));
    return res;
}
vector<pii>p[MAXN];
int main()
{
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 1, x, y, w; i <= m; i++)
    {
        scanf("%d%d%d", &x, &y, &w);
        p[y].emplace_back(x, w);
    }
    for (int i = 1; i <= n; i++)
    {
        update(1, 1, n, i, i, query(1, 1, n, 1, i));
        for (auto x : p[i]) update(1, 1, n, x.fir, i, x.sec);
    }
    printf("%lld\n", max(query(1, 1, n, 1, n), 0ll));
    return 0;
}

Measured memory_bytes: 22912
class Dictionary
  def initialize
    @words = []
    @orders = []
  end

  def insert(word, line)
    @words << [word, line]
  end

  def find(word, line)
    @orders << [word, line]
  end

  def b_search(array, f)
    if array.size == 1
      return array[0]
    else
      if array[array.size / 2 - 1][0] >= f
        return b_search(array[0...array.size / 2], f)
      else
        return b_search(array[array.size / 2..-1], f)
      end
    end
  end

  def exp
    @words.sort!
    @words.uniq!{|f|f[0]}
    if @words.size == 0
      puts "no"
    else
      @orders.each{|o|
        sus = b_search(@words, o[0])
        if sus[0] == o[0] and sus[1] < o[1]
          puts "yes"
        else
          puts "no"
        end      
      }
    end
    @orders = []
  end
end
def main(input = $stdin)
  dic = Dictionary.new
  n = input.gets.to_i
  n.times do |line|
    dic.send(*input.gets.split(" "), line)
    if line % 500000 == 0
      dic.exp
    end
  end
  dic.exp
end
main

Measured memory_bytes: 485100
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main() {
  char a[2][2];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0; i<3;i++) cout <<a[i][i];


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
long long ans;
vector<int> p;
long long to_num(string x)
{
	long long n=0;
	while(x.size())
	{
		n*=10;
		n+=x[0]-'0';
		x=x.substr(1);
	}
	return n; 
}
void dfs(int n)
{
	if(n==s.size())
	{
		p.push_back(n);
		for(int i=1;i<p.size();i++)ans+=to_num(s.substr(p[i-1],p[i]-p[i-1]));
		p.erase(p.end()-1);
		return;
	}
	dfs(n+1);
	p.push_back(n+1);
	dfs(n+1);
	p.erase(p.end()-1);
}
int main()
{
	cin>>s;
	p.push_back(0);
	dfs(0);
	cout<<ans/2;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int fib(int);
#define LIMIT 45


int main(){
  int n;

  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}

int fib(int n){
  if(n==0||n==1) return 1;
  int F[LIMIT];
  int i;
  F[0]=1;
  F[1]=1;
  for(i=2;i<LIMIT;i++) F[i]=F[i-2]+F[i-1];
  return F[n];
}



Measured memory_bytes: 2048
#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
#define int long long int
#define mod 1000000007
int power(int a,int b)
{
     if(b==0)
       return 1;
     else
     {
		 int r=power(a,b/2);
		 if(b%2==0)
		 {
			 return (r*r)%mod;
		 }
		 else
		 {
			 int x=(r*r)%mod;
			 return (a*x)%mod;
		 }
	 }
}
int function(vector<int> &v,int initial,int final)
{
	if(initial>final)
	  return 0;
	else
	{
		int x=v[initial]+function(v,initial+1,final);
		int y=v[initial]-1+9*(final-initial);
		return max(x,y);
	}
}
int32_t main()
{
	int n;
	cin>>n;
	int d=0;
	int temp=n;
	while(temp!=0)
    {
		d++;
		temp/=10;
	}
	int answer2=9*(d-1);
	vector<int> v;
	while(n!=0)
	{
		v.push_back(n%10);
		n/=10;
	}
	reverse(v.begin(),v.end());
	n=v.size();
    int answer=function(v,0,n-1);
    answer=max(answer,answer2);
    cout<<answer<<endl;
}


Measured memory_bytes: 256