akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N,  sum = 0;
  vector<int> ans;
  cin >> N;

  for(int i = 1; i <= N; i++){
    sum += i;
    ans.push_back(i);
    if(sum >= N) break;
  }

  for(auto x : ans){
    if(x != sum - N) cout << x << endl; 
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if(n*2 >= m)
        ans = m/2;
    else {
        ll c = m - n*2;
        ans = n + c/4;
    }
    cout << ans << endl;
    return 0;
}


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

using ll = long long;
using ld= long double;
using ull= unsigned long long;
#define endl "\n"

const ll maxn=3e5+100;

const ll maxx=1e13;
const ll mod=1000000007;


map<ll,ll> mp;
ll f[maxn];
ll a[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
   ll n, k;
   cin>>n>>k;
   for (int i=1;i<=n;i++)
   {
       cin>>a[i];
       a[i]=a[i]-1+k;
       a[i]%=k;
   }
   f[0]=0;
   for (int i=1;i<=n;i++)
   {
      f[i]=(f[i-1]+a[i])%k;
   }
   /*for (int i=1;i<=n;i++) cout <<f[i]<<" ";
   cout <<endl;*/
   ll kq=0;
   for (int i=1;i<=n;i++)
   {
       ll t=i-k;
       if (t>0)
       {
           mp[f[t]]--;
       }
       if (f[i]==0)
       {
           kq=kq+mp[0];
           if (i<k) kq++;

       }
       else
       {
           kq=kq+mp[f[i]];
       }
       mp[f[i]]++;
   }
   cout << kq;
}


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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if ( a[a.size()-1] == b[0] && b[b.size()-1] == c[0] )
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using pii = std::pair<int, int>;
using namespace std;

constexpr auto NIL = make_pair(numeric_limits<int>::max() / 2, numeric_limits<int>::max() / 2);
constexpr array<int, 4> dx = {0, 1, 0, -1};
constexpr array<int, 4> dy = {-1, 0, 1, 0};
int H, W;
vec<vec<char>> s;
vec<vec<int>> d;
vec<vec<pii>> pi;

int path(int d, int x, int y, int b) {
  if (x == 0 && y == 0) {
    return W * H - d - b;
  }
  else {
    tie(x, y) = pi[y][x];
    return path(d + 1, x, y, b);
  }
}

int bfs() {
  int b = 0;
  REP(y, H) {
    REP(x, W) {
      pi[y][x] = NIL;
      if (s[y][x] == '#') {
        b++;
      }
    }
  }
  queue<pii> q;
  q.emplace(0, 0);

  while (!q.empty()) {
    const auto xy = q.front();
    q.pop();
    const auto x = xy.first, y = xy.second;
    REP(i, 4) {
      const int nx = x + dx[i], ny = y + dy[i];
      if (0 <= nx && nx < W && 0 <= ny && ny < H && s[ny][nx] != '#' && pi[ny][nx] == NIL) {
        pi[ny][nx] = make_pair(x, y);
        q.emplace(nx, ny);
      }
    }
  }
  if (pi[H-1][W-1] == NIL) {
    return -1;
  }
  else {
    return path(1, W-1, H-1, b);
  }
}

int main() {
  cin >> H >> W;
  s.resize(H);
  d.resize(H);
  pi.resize(H);
  REP(y, H) {
    s[y].resize(W);
    d[y].resize(W);
    pi[y].resize(W);
    REP(x, W) {
      cin >> s[y][x];
    }
  }
  cout << bfs() << endl;
  return 0;
}


Measured memory_bytes: 256
import heapq


class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N # 最初はそれぞれのノードが誰ともUnionをつくってないから木の深さが０
        self.count = 0 # unite回数
    def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            # 親を見に行く
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self, a, b):
        return self.root(a) == self.root(b)
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return 
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
        self.count += 1

N = int(input())
xy = [None] * N
yx = [None] * N

for i in range(N):
    x,y = map(int, input().split())
    xy[i] = (x, y, i)
    yx[i] = (y, x, i)


xy.sort()
yx.sort()


q = []
for i in range(N-1):
    heapq.heappush(q, (abs(xy[i][0] - xy[i+1][0]), xy[i][2], xy[i+1][2]))
    heapq.heappush(q, (abs(yx[i][0] - yx[i+1][0]), yx[i][2], yx[i+1][2]))

uf = UnionFind(N)
ans = 0

while q:
    c, a, b = heapq.heappop(q)
    if not uf.is_same(a,b):
        uf.unite(a, b)
        ans += c

print(ans)

Measured memory_bytes: 57796
#include<stdio.h>
int main()
{
	int a = 0,i;
	char s[4];
	scanf("%s",s);
	for(i=1;i<4;i++)
	{
		if(s[i-1] == s[i])
			a = 1;
	}
	if(a == 1)
		printf("Bad\n");
	else
		printf("Good\n");
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
typedef long long LL;
using namespace std;
int a[100005];
int main(){
	int n, p, q;
	LL ans;
	scanf("%d", &n);
	for(int i = 1;i <= n;i++){
		scanf("%d", &a[i]);
	}
	sort(a + 1, a + 1 + n);
	p = 1;
	q = n;
	ans = abs(a[1] - a[n]);
	for(int i = 2;i <= n / 2;i++){
		ans += (LL)abs(a[p] - a[n - i + 1]) + (LL)abs(a[q] - a[i]);
		p++;
		q--;
	}
	if(n & 1){//n是奇数
		ans += (LL) max(abs(a[n / 2 + 1] - a[q]), abs(a[n / 2 + 1] - a[p]));
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 512
x, n = map(int, input().split())
try:
    p = list(map(int, input().split()))
    
    num = 0
    while True:
        if not x-num in p:
            print(x-num)
            break

        if not x+num in p:
            print(x+num)
            break
        num += 1

except:
    print(x)


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

#define pb push_back 

ll const mod=1e9+7;





int main()
{

string s,t;
cin>>s>>t;

int ans=mod;
for(int i=0;i<s.size();i++)
{
	if(i+t.size()>s.size())break;
	int cnt=0;
	for(int j=i,k=0;j<(i+t.size());j++,k++)
	{
		if(s[j]!=t[k])cnt++;
	}
	ans=min(ans,cnt);
}

cout<<ans;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n, l;
char d[100];
int p[100];
set<int> table[110];

void print() {
	rep(i, n) {
		cout << i << " " << d[i] << " " << p[i] << endl;
	}
	cout << endl;
}

int main() {
	while (cin >> n >> l&&n + l) {
		rep(i, 100)table[i].clear();
		rep(i, n) {
			cin >> d[i] >> p[i];
			table[p[i]].insert(i);
		}
		int num = -1;
		int ans = 0;
		while (1) {
			int pp = -1;
			int cnt = 0;
			rep(i, n) {
				if (p[i] < 1 || l <= p[i])continue;
				if (p[i] == 1 || p[i] == l - 1) {
					if (pp == -1) {
						num = i;
						pp = p[i];
					}
					else {
						if (p[i] == 1)num = i;
					}
				}
				cnt++;
				table[p[i]].erase(i);
				if (d[i] == 'R')p[i]++;
				else p[i]--;
				if (p[i] >= 1 && l > p[i])table[p[i]].insert(i);
			}
			//print();
			if (cnt == 0)break;
			ans++;
			rep(i, l) {
				if (table[i].size() == 2) {
					auto it = table[i].begin();
					auto it2 = it;
					it2++;
					swap(d[*it], d[*it2]);
				}
			}
		}
		cout << ans << " " << num + 1 << endl;
	}
}

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

int main() {
    string a, b, c; cin >> a >> b >> c;
    transform(a.begin(), a.end(), a.begin(), ::toupper);
    transform(b.begin(), b.end(), b.begin(), ::toupper);
    transform(c.begin(), c.end(), c.begin(), ::toupper);
    
    cout << a[0] << b[0] << c[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

int main() {
  string s;
  ll k;
  cin >> s >> k;
  ll n = (ll)s.size();
  rep(i, 0, min(n, k)) {
    if (i == k - 1 || s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }
  }

  return 0;
}

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

int main() {
	ll a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	ll n;
	cin>>n;
	n--;
	cout<<a[n];
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
n = int(input())
minute_list = []
for i in range(5):
    minute_list.append(int(input()))
a = min(minute_list)
#print(a)
if n % a == 0:
    ans = 5 + (n/a - 1)
else:
    ans = 5 + ((n - n%a))/a
print(int(ans))

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n, a;
  cin >> n >> a;
  int m = n % 500;
  cout << (m <= a ? "Yes" : "No") << '\n';
  return 0;
}


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

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

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long N, std::vector<long long> A) {
    map<int, int> mp;
    rep(i, N) mp[A[i]]++;

    int sum = 0;
    for (auto p : mp) {
        int x = p.second;
        sum += x * (x - 1) / 2;
    }

    rep(i, N) {
        cout << sum - max(mp[A[i]] - 1, 0LL) << endl;
    }
}

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

    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long

int main() {
	intt N, M; std::cin >> N >> M;
	std::vector<intt> s(M);
	std::vector<intt> c(M);
	for (int i = 0; i < M; ++i) {
		std::cin >> s[i] >> c[i];
		if (s[i] == 1 && c[i] == 0 && N != 1) {
			std::cout << -1 << std::endl;
			return 0;
		}
	}
	for (int i = 0; i < M; ++i) {
		if (s[i] > N) {
			std::cout << -1 << std::endl;
			return 0;
		}
		for (int j = 0; j < M; ++j) {
			if (s[i] == s[j] && c[i] != c[j]) {
				std::cout << -1 << std::endl;
				return 0;
			}
		}
	}
	intt ans = 0;
	bool m1 = false;
	bool m2 = false;
	bool m3 = false;
	int p1 = 0;
	int p2 = 0;
	int p3 = 0;

	for (int i = 0; i < M; ++i) {
		if (s[i] == 1) {
			m3 = true;
			p3 = i;
		}
		if (s[i] == 2) {
			m2 = true;
			p2 = i;
		}
		if (s[i] == 3){
			m1 = true;
			p1 = i;
		}
	}
	if (N == 3) {
		if (m3 == true)
			ans += c[p3] * 100;
		if (m2 == true)
			ans += c[p2] * 10;
		if (m1 == true)
			ans += c[p1];
	}
	else if (N == 2) {
		if (m3 == true)
			ans += c[p3] * 10;
		if (m2 == true)
			ans += c[p2];
	}
	else if (N == 1) {
		if (m3 == true)
			ans += c[p3];
	}

	if (N == 3 && ans < 100)
		ans += 100;
	if (N == 2 && ans < 10)
		ans += 10;

	std::cout << ans << std::endl;

	return 0;
}

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

int main() {
	int N;
  	cin>>N;
    int dp[200000]; //整数　個数
  	int a[N];
  	long long int sum=0;
  	rep(i,N){
      cin>>a[i];
      dp[a[i]]++;
      sum+=a[i];
    }
  	
  	
  	int Q;
  	cin>>Q;
  	rep(i,Q){
     	int num=0;
      	int B,C;
      	cin>>B>>C;
      	num=dp[B];
      	dp[B]=0;
      	dp[C]+=num;
      	sum+=num*(C-B);
      	cout<<sum<<endl;
    }
  
  	
 
}



Measured memory_bytes: 4384
n = int(input())
h_sigma = [int(x) for x in input().split()]


is_decrement = False
for i in range(0, n - 1):
    if h_sigma[i] - h_sigma[i + 1] > 1:
        print('No')
        break
    elif h_sigma[i] - h_sigma[i + 1] == 1:
        if is_decrement:
            print('No')
            break
        is_decrement = True
    elif h_sigma[i] - h_sigma[i + 1] == 0:
        pass
    else:
        is_decrement = False
else:
    print('Yes')



Measured memory_bytes: 14396
#include <stdio.h>

int main(void)
{
	float x1, y1, x2, y2, x3, y3, x4, y4;
	float abx, aby, cdx, cdy;
	float ans, ans2;
	int n;
	int a;
	
	scanf("%d", &n);
	
	for (a = 0; a < n; a++) {
		scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
		abx = x2 - x1;
		aby = y2 - y1;
		cdx = x4 - x3;
		cdy = y4 - y3;
		
		ans = aby / abx;
		ans2 = cdy / cdx;
		
		if (ans == ans2) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	return (0);
}	

Measured memory_bytes: 616
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> d(100001);
  for(int i=0;i<n;i++) cin >> d[i];
  sort(d.begin(),d.begin()+n);
  cout << d[n/2] - d[n/2-1] << "\n";
  return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)
#define int long long

using namespace std;
typedef pair<int, int> pii;

int n,a[3010]={0},dp[3010][3010]={0};

int cal(int i,int j){
    if(j<=i){
        return dp[i][j]=0;
    }
    else{
        if(dp[i][j]!=-1){
            return dp[i][j];
        }
        else{
            return dp[i][j]=max(a[i]-cal(i+1,j),a[j-1]-cal(i,j-1));
        }
    }
}

signed main() {
	cin>>n;
    rep(i,n){
        cin>>a[i];
    }

    rep(i,n+1){
        rep(j,n+1){
            dp[i][j]=-1;
        }
    }
	
    cout<<cal(0,n)<<endl;
	
	return 0;
}


Measured memory_bytes: 71040
import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;
import std.numeric;
import std.bigint;
import core.bitop;


void main() {
  auto input = readln.split.map!(to!int);
  auto N = input[0].to!int;
  auto K = input[1].to!int;
  auto P = iota(N).map!(_ => readln[0]).array;
  auto cnt = new int[](26);
  foreach (p; P) cnt[p-'A']++;

  if (N < K) {writeln(0); return;}
  foreach (i; 1..N/K+1)
    if (cnt.map!(c => min(c, i)).sum < i*K) {
      writeln(i-1);
      return;
    }
  writeln(N/K);
}


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  string s; cin>>s;
  rep(i,0,3){
    cout<<s[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3580
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   // setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cassert> // assert
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  // abs, sin, cos, tan
#include <ctime> // clock

// __builtin_popcountll

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ld, ll, ll>> vtll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  str s, t; cin >> s >> t;
  ll ans = 0;
  ll n = s.size();
  rep(i, n)
  {
    if(s[i] == t[i]) ans++;
  }
  fin(ans);
  return;
}

//前処理
int main()
{
  int ti = clock();
  srand((unsigned)time(NULL));
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); //0埋め４桁
  Main();
  //cout << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl; // 実行時間計測
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    System.out.println(check(N));
  }
  public static String check(int n){
    String ans="";
    for (int i=1; i<=9; i++){
      if ((n%i==0)&&(n/i<=9)){
        ans="Yes";
        break;
      }
      else{
        ans="No";
      }
    }
    return ans;
  }
}

Measured memory_bytes: 23764
#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>;

int main(){
  ll n,sum,sum3,sum5,sum15,ans;
  cin >> n;
  sum = n*(n+1)/2;
  sum3 = (n/3)*((n/3)*3+3)/2;
  sum5 = (n/5)*((n/5)*5+5)/2;
  sum15= (n/15)*((n/15)*15+15)/2;
  ans = sum - sum3 -sum5 + sum15;
  cout << ans << endl;
}



Measured memory_bytes: 3672
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskB {
		int step;
		int leaf1;
		int leaf2;

		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int m = in.nextInt();
			List<Integer>[] adj = new List[n];
			for (int i = 0; i < n; i++) {
				adj[i] = new ArrayList<>();
			}
			for (int i = 0; i < m; i++) {
				int a = in.nextInt() - 1;
				int b = in.nextInt() - 1;
				adj[a].add(b);
				adj[b].add(a);
			}
			boolean[] was = new boolean[n];
			int[] p = new int[n];
			Arrays.fill(p, -1);
			leaf1 = -1;
			step = 0;
			dfs(0, adj, was, p);
			Arrays.fill(was, false);
			List<Integer> path1 = new ArrayList<>();
			for (int i = leaf1; i >= 0; i = p[i]) {
				path1.add(i);
				was[i] = true;
			}

			Arrays.fill(p, -1);
			was[0] = false;
			step = 1;
			dfs(0, adj, was, p);

			List<Integer> path2 = new ArrayList<>();
			for (int i = leaf2; i >= 0; i = p[i]) {
				path2.add(i);
			}
			if (!path2.isEmpty()) {
				path2.remove(path2.size() - 1);
			}
			Collections.reverse(path2);
			path1.addAll(path2);
			out.println(path1.size());
			for (int i = 0; i < path1.size(); i++) {
				if (i > 0) {
					out.print(" ");
				}
				out.print(path1.get(i) + 1);
			}
			out.println();
		}

		private void dfs(int i, List<Integer>[] adj, boolean[] was, int[] p) {
			was[i] = true;
			boolean any = false;
			for (int j : adj[i]) {
				if (was[j]) {
					continue;
				}
				any = true;
				p[j] = i;
				dfs(j, adj, was, p);
			}
			if (any) {
				return;
			}
			if (step == 0) {
				leaf1 = i;
			} else {
				leaf2 = i;
			}
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 68408
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int[]array = new int[10];

    public static void main(String[] args) {
        while(read()){
            solve();
        }
    }
    static boolean read(){
        if(!sc.hasNext())
            return false;
        for(int i = 0; i < 10; i++){
            array[i] = 0;
        }
        String line = sc.next();
        for(int i = 0; i < 10; i++){
            array[i] = line.charAt(i) - '0';
        }
        return true;
    }
    static void solve(){
        for(int k = 0; k < 9; k++){
            for(int i = 0; i < 9; i++){
                array[i] = (array[i] + array[i+1])%10;
            }
        }
        System.out.println(array[0]);
    }

}

Measured memory_bytes: 0
x = input()
s = 0
t = 0
for i in range(len(x)):
    if x[i] == "T":
        s = max(0, s-1)
    else:
        s += 1
    if x[-i-1] == "S":
        t = max(0, t -1)
    else:
        t += 1
print(s+t)


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  string s;
  cin >> s;

  regex exp(R"(^YAKI)");

  string ans = "No";
  if (regex_search(s, exp)) {
    ans = "Yes";
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
char s[N];
bool pd(int l,int r) {
	if(l==r)return 1;
	while(l<r&&s[l]==s[r]) {
		l++,r--;
	}
	if(l>=r)return 1;
	else return 0;
}
int main()
{
	//cwk;
	scanf("%s",s+1);
	int n=strlen(s+1);
	if(pd(1,n)&&pd(1,(n-1)/2)&&pd((n+3)/2,n)) {
		puts("Yes");
	}else {
		puts("No");
	}

	return 0;
}

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

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;



long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}


//約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
	vector<int> ret;
	for (int i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			ret.push_back(i);
			if (i*i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return ret;
}



int main() {

	long long ans;
	int N, a[1000];

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

	ans = 0;

	for (int i = 0; i < N; i++) {
		if (i % 2 == 0 && a[i] % 2 == 1) {
			ans++;
		}
	}


	cout << ans << endl;

	cin >> ans;

	return 0;


}

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

int main() {
	// your code goes here
	string s, t;
	cin >> s >> t;
	int l1 = s.length();
	int l2 = t.length();
	int dp[l1+1][l2+1];
	for(int i=0; i<=l1; i++) {
		for(int j=0; j<=l2; j++) {
			if(i == 0 || j == 0) {
				dp[i][j] = 0;
			}
			else if(s[i-1] == t[j-1]) {
				dp[i][j] = 1 + dp[i-1][j-1];
			}
			else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	int count = dp[l1][l2];
	char lcs[count+1];
	lcs[count] = '\0';
	int i=l1, j=l2;
	while(i>0 && j>0) {
		if(s[i-1] == t[j-1]) {
			lcs[count-1] = s[i-1];
			i--;
			j--;
			count--;
		}
		else if(dp[i-1][j] > dp[i][j-1]) {
			i--;
		} else {
			j--;
		}
	}
	cout << lcs;
	return 0;
}

Measured memory_bytes: 35456
/*
Hanit Banga
Problem: 
*/

#include <iostream>
#include <vector>

using namespace std;

#define pb(x) push_back(x)

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

const int N = 1e5 + 5;

int main()
{	
	int n;
	string s;

	cin >> s;

	n = s.length();

	if (s[0] != s[n-1])
	{
		if (n%2)
			cout << "First";

		else
			cout << "Second";
	}

	else if (n%2)
		cout << "Second";

	else
		cout << "First";
}	

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

typedef double db;
typedef int in;
typedef long int li;
typedef long long int lli;
typedef long ld;
typedef long lld;

#define pi M_PI
#define in scanf
#define out printf
#define inf INT_MAX
#define rep(i,n) for(int i=0;i<n;++i)
#define debugd(d) printf("%d\n",d)
#define debugs(s) printf("%s\n",s)
#define debugc(c) printf("%c\n",c)
#define debugf(f) printf("%f\n",f)

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int compare_intr(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}


int main (void)
{
  int n;
  in("%d\n",&n);
  int a[n],b[n];
  rep(i,n)
  {
    in("%d %d\n",&a[i],&b[i]);
  }
  qsort(a,n,sizeof(int),compare_int);
  qsort(b,n,sizeof(int),compare_intr);
  printf("%d \n",a[n-1]+b[n-1]);
  return 0;
}

Measured memory_bytes: 1396
N = gets.to_i
A = (0...N).map{ gets.split.map &:to_i }
es = (0..N**2).map{ [] }
rs = (0..N**2).map{ 0 }
M = []
mns = {}
A.each_with_index{ |ai,i|
  M << ai.map{ |j|
    x,y = i,j-1
    x,y = y,x if x > y
    m = x*N+y
    mns[m] = 1
    m
  }
}
M.each{ |ms|
  a,b = nil,ms[0]
  ms[1..-1].each{ |m|
    a, b = b,m
    es[a] << b
    rs[b] += 1
  }
}

stack = mns.keys.select{ |m| rs[m] == 0 }
sorted = []
while m = stack.pop do
  sorted << m
  es[m].each{ |n|
    if (rs[n] -= 1) == 0
      stack << n
    end
  }
end

#p M, sorted

if sorted.size != N*(N-1)/2
  p -1; exit
end

dp = Array.new((N+1)**2, 1)
sorted.each{ |m|
  d = dp[m] + 1
  es[m].each{ |n|
    dp[n] = d if d > dp[n]
  }
}

p dp.max


Measured memory_bytes: 132272
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
#define N 4010
using namespace std;

ll a, b, c, n, m, num;
char s[N];

inline ll read(){ 
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read(); 
	REP(i, 1, n){
		s[i] = getchar();
		if (s[i] == 'R') a++;
		else if (s[i] == 'G') b++;
			else c++;
	}
	num = a * b * c, m = (n - 3) >> 1;
	REP(i, 0, m)
		for (ll j = 1; j + 2 * i + 2 <= n; ++j)
			if (s[j] != s[j + i + 1] && s[j + i + 1] != s[j + 2 * i + 2] && s[j + 2 * i + 2] != s[j]) num--;
	printf("%lld\n", num);
}

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

Measured memory_bytes: 3740
n=int(input())
l=list(map(int,input().split()))

l.sort(reverse=True)
ans=0

for i in range(0,n-2):
  for j in range(i+1,n-1):
    left = j
    right = n
    while right-left>1:
      mid = (left + right)//2
      
      if l[i]+l[j]>l[mid] and l[i]+l[mid]>l[j] and l[mid]+l[j]>l[i]:
        left = mid
      else:
        right = mid
    #print(i,j,left)
    ans+=(left-j)
      
print(ans)

Measured memory_bytes: 74128
#include <iostream>
using namespace std;
int main(void){
    int n;
    scanf("%d", &n);
    int arr[n];
    
    for(int i = 0; i < n; i += 1){
        int a;
        scanf("%d", &a);
        arr[i] = a;
    }
    
    while(true){
        int min = 1000000001;
        int index;
        int count = 0;
        for(int i = 0; i < n; i += 1){
            if(min > arr[i] && 0 < arr[i]){
                min = arr[i];
                index = i;
            }
        }
        
        for(int i = 0; i < n; i += 1){
            if(i != index){
                arr[i] = arr[i] % min;
                if(arr[i] <= 0){
                    count += 1;
                }
            }
        }
        if(count == n - 1){
            printf("%d", min);
            break;
        }
    }
    
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int N,i,ans=0,j;
	long temp;
	vector<long> A,GCD;
	cin>>N;
	for(i=0;i<N;i++){
		cin>>temp;
		A.push_back(temp);
	}
	sort(A.begin(),A.end());
	for(i=1;i<=A[0];i++){
		if(A[0]%i==0){
			if(A[0]/i>i){
				GCD.push_back(i);
				GCD.push_back(A[0]/i);
			}else if(A[0]/i==i){
				GCD.push_back(i);
				break;
			}else{
				break;
			}
		}
	}
	sort(GCD.begin(),GCD.end());
	i=GCD.size();
	j=1;
	while(ans==0){
		i--;
		while(A[j]%GCD[i]==0){
			j++;
			if(j==N){
				ans=GCD[i];
				break;
			}
		}
	}
	cout<<ans;
	return 0;
	
}


Measured memory_bytes: 1400
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();

    let mut a : i32 = iter.next().unwrap().parse().unwrap();
    let mut b : i32 = iter.next().unwrap().parse().unwrap();

    let mut ans : i32 = 0 ;
    for i in 0..2 {
        if a < b { ans += b; b-=1; }
        else { ans += a; a-=1; }
    }

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


Measured memory_bytes: 4352
s = input()

dicts = {i: False for i in range(ord('a'), ord('z') + 1)}

for i in s:
    if not dicts[ord(i)]:
        dicts[ord(i)] = True

for i in range(ord('a'), ord('z') + 1):
    if not dicts[i]:
        print(chr(i))
        exit()
print('None')


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  
  int A=1;
  for(int i=0;i<N-1;i++){
    if(vec.at(i)<vec.at(i+1)){A++;}
  }  
  cout << A << endl;
}


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

int main() {
    string s, t;
    cin >> s >> t;

    int n = sz(s), m = sz(t);
    vector< vector<int> > is(26);

    rep(i, n) is[s[i]-'a'].push_back(i);
    rep(i, n) is[s[i]-'a'].push_back(i+n);

    int p = 0;
    ll ans = 0;
    rep(i, m) {
        int c = t[i] - 'a';
        if (sz(is[c]) == 0) {
            cout << -1 << endl;
            return 0;
        }
        p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
        if (p >= n) {
            p -= n;
            ans += n; //1周期終えるごとにans更新
        }
    }

    ans += p; //最後に進んでるpだけans更新
    cout << ans << endl;

}

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

int main(void){
	int N, M, X;
	cin >> N >> M >> X;
	int C[N];
	int A[N][M];
	rep(i,N){
		cin >> C[i];
		rep(j,M) cin >> A[i][j];
	}
	
	ll cost_min = 0;
	rep(i,N) cost_min += C[i];

	int buy_all = 0;
	int k = 1;
	rep(i,N) {
		buy_all += k;
		k *= 2;
	}

	int mast_all = 1;
	ll und[M];

	for (int i = 0; i <= buy_all; i++) {
		rep(j,M) und[j] = 0;
		ll cost = 0;

		rep(j,N) {
			if (i>>j & 1) {
				cost += C[j];
				rep(k,M) und[k] += A[j][k];
			}
		}
		
		mast_all = 1;
		rep(j,M) {
			if (und[j] < X) {
				mast_all = 0;
				break;
			}
		}
		if (mast_all == 1 && cost <= cost_min) cost_min = cost;
	}

	if (mast_all == 0) cout << -1 << endl;
	else cout << cost_min << endl;

return 0;
}


Measured memory_bytes: 3632
# ABC133E - Virus Tree 2
from collections import deque


def main():
    N, K, *AB = map(int, open(0).read().split())
    MOD = 10 ** 9 + 7
    G = [[] for _ in range(N + 1)]
    for v, u in zip(*[iter(AB)] * 2):
        G[v].append(u), G[u].append(v)
    queue = deque([1])
    seen = [0] * (N + 1)
    seen[1] = 1
    ans, cand = K, K - 1
    while queue:
        v = queue.popleft()
        for u in G[v]:
            if not seen[u]:
                seen[u] = 1
                ans = (ans * cand) % MOD
                cand -= 1
                queue.append(u)
        cand = K - 2
    print(ans)


if __name__ == "__main__":
    main()

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

typedef long long int ll;
typedef vector<int> vi;            
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int>     pii;
typedef vector<bool> vb;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#ifdef LOCAL
    #include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

void solve(){
    int h, w, m; cin>>h>>w>>m;
    vi rows(h+1, 0);
    vi cols(w+1, 0);
    map<pii, bool> mp;
    for(int i = 0; i<m; i++){
        int x, y; cin>>x>>y;
        rows[x]++; cols[y]++;
        mp[{x, y}] = true;
    }

    int cs = 0;

    set<int> t1;
    set<int> t2;
    int temp = 0;
    for(auto &e: rows) temp = max(temp, e);
    for(int i = 0; i<sz(rows); i++) if(rows[i]==temp) t1.in(i);
    cs += temp;

    temp = 0;
    for(auto &e: cols) temp = max(temp, e);
    for(int i = 0; i<sz(cols); i++) if(cols[i]==temp) t2.in(i);
    cs += temp;

    ll cntr = sz(t1)*sz(t2);
    for(auto &p: mp)
        if(t1.count(p.F.F)&&t2.count(p.F.S)) cntr--;

    if(cntr) cout<<cs<<endl;
    else cout<<cs-1<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef LOCAL
        freopen(".inp.txt", "r", stdin);
        freopen(".out.txt", "w", stdout);
        freopen(".err.txt", "w", stderr);
    #endif
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 52492
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	
int n, m, c;

cin >> n >> m >> c;
int B[m], A[n][m];
for(int j = 0;j<m;j++){
 cin >> B[j];
}

int count = 0;
int total;

for(int i = 0;i<n;i++){
	for(int j = 0;j<m;j++){
		cin >> A[i][j];
	}
}
for(int i = 0;i<n;i++){
	total = c;
	for(int j = 0;j<m;j++){
		total += A[i][j] * B[j];
	}
	if(total > 0)
	count++;
}
cout<< count <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int sosu(int a)
{
    switch(a){
        case 1 : return  2; break;
        case 2 : return  3; break;
        case 3 : return  5; break;
        case 4 : return  7; break;
        case 5 : return 11; break;
        case 6 : return 13; break;
        case 7 : return 17; break;
        case 8 : return 19; break;
        case 9 : return 23; break;
        case 10: return 29; break;
        case 11: return 31; break;
        case 12: return 37; break;
        case 13: return 41; break;
        case 14: return 43; break;
        case 15: return 47; break;
        case 16: return 53; break;
        case 17: return 59; break;
        case 18: return 61; break;
        case 19: return 67; break;
        case 20: return 71; break;
        case 21: return 73; break;
        case 22: return 79; break;
        case 23: return 83; break;
        case 24: return 89; break;
        case 25: return 97; break;
        default : return 0;
    }
}

int main(void)
{
    int a[24];
    int ans1 = 0; int ans2 = 0; int ans3 = 0;
    int no, n, i, j, k, l, ans;
    scanf("%d",&no);
    ans = 0;
    for(j = 0; j <= 24; j++){
        a[j] = 0;
    }
    printf("\n");
    for(i = 1; i <= no; i++){
        n = i;
        for (j = 1; j <=25; j++) {
            while(n % sosu(j) == 0){
                a[j - 1] += 1;
                n /= sosu(j);
            }
        }
    }
    for(j = 0; j <= 24; j++){
        for(k = 0; k <= 24; k++){
            for(l = 0; l <= 24; l++){
                if(j < k && j != l && k != l){
                    if(a[j] >= 4 && a[k] >= 4 && a[l] >= 2){
                        ans++;
                    }
                }
            }
            if(j != k){
                if(a[j] >= 14 && a[k] >= 4){
                    ans++;
                }
                if(a[j] >= 24 && a[k] >= 2){
                    ans++;
                }
            }
        }
        if(a[j] >= 74){
            ans++;
        }
    }
    printf("%d",ans);
    
    return 0;
}



Measured memory_bytes: 128
N,L = list(map(int,input().split()))

a = list(map(int,input().split()))

a_list = []
for i in range(N-1):
    a_list.append([a[i]+a[i+1],i])
    
a_list=sorted(a_list,key=lambda x:x[0],reverse=True)

if a_list[0][0]>=L:
    n=a_list[0][1] 
    print("Possible")
    for i in range(n):
        print(i+1)
    for i in range(N-2-n):
        print(N-1-i)
    print(n+1)
else:
    print("Impossible")

Measured memory_bytes: 26696
(n,k),p,c=[[*map(int,t.split())]for t in open(0)]
a=-9e9
for i in range(n):
 s=f=m=0;x,*l=i,
 while~f:x=p[x]-1;s+=c[x];l+=s,;m+=1;f-=x==i
 for j in range(min(m,k)):a=max(a,l[j]+(~j+k)//m*s*(s>0))
print(a)

Measured memory_bytes: 117160
s = input()
plus = ''
ans = 0
if len(s) == 1:
    print(s)
else:
    for i in range(2**(len(s)-1)):
        for j in range(len(s)):
            plus += s[j]
            if ((i >> j) & 1):
                ans += int(plus)
                plus = ''
            if j == len(s) - 1 and len(plus) != 0:
                ans += int(plus)
                plus = ''
    print(ans)

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

int main() {
  int h, w;
  cin >> h >> w;
  char a[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c;
      cin >> c;
      a[i][j] = c;
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] == '#') {
        cout << '#';
        continue;
      } else {
        int count = 0;
        if (i > 0 && j > 0 && a[i - 1][j - 1] == '#') {
          count++;
        }
        if (i > 0 && a[i - 1][j] == '#') {
          count++;
        }
        if (i > 0 && j + 1 < w && a[i - 1][j + 1] == '#') {
          count++;
        }
        if (j > 0 && a[i][j - 1] == '#') {
          count++;
        }
        if (j + 1 < w && a[i][j + 1] == '#') {
          count++;
        }
        if (i + 1 < h && j > 0 && a[i + 1][j - 1] == '#') {
          count++;
        }
        if (i + 1 < h && a[i + 1][j] == '#') {
          count++;
        }
        if (i + 1 < h && j + 1 < w && a[i + 1][j + 1] == '#') {
          count++;
        }
        cout << count;
      }
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sec second
#define fir first
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(ll (i)=(m);(i)<(n);(i)++)
// #define all(a) (a).begin(),(a).end()
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define MOD 998244353
int n, k, c;
set<ll>st;
std::vector<ll> a,b;
void cnt(string x)
{

	int g = 0;
	for (int i = 0; i < n ; i++ )
	{
		if (x[i] == 'o')
		{
			g++;
			a.pb(i);
			i += c ;
		}

	}
	g = 0;
	for (int i = n - 1; i >= 0 ; i-- )
	{
		if (x[i] == 'o')
		{
			g++;
			b.pb(i);
			i -= (c);
		}

	}

	// for (auto el : st)
	// 	cout << el << endl;


	for(int i=0;i<k;i++)
	{
		if(a[i]==b[k-1-i])
			cout<<a[i]+1<<endl;
	}
	return ;
}
void solve()
{
	string s;
	cin >> n >> k >> c;
	cin >> s;
	cnt(s);
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	fast
	int T;
	// cin >> T;
	T = 1;
	while (T--)
	{
		solve();
	}
	return 0;
}


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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){
	
	while(1){
		string a, b; cin >> a >> b;
		if(a == "0") break;
		bool used[4] = {};
		int aa = 0;
		int bb = 0;
		for(int i = 0; i < 4; i++){
			if(a[i] == b[i]){
				aa++;
				used[i] = true;
			}
		}

		for(int i = 0; i < 4; i++){
			if(used[i]) continue;
			for(int j = 0; j < 4; j++){
				if(i == j) continue;
				if(used[j]) continue;
				if(a[i] == b[j]){
					bb++;
				}
			}
		}

		cout << aa << " " << bb << endl;

	}
	return 0;
}




Measured memory_bytes: 3140
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
	int h1,m1,h2,m2,k;scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
	printf("%d",max(0,h2*60+m2-h1*60-m1-k));
}

Measured memory_bytes: 1732
#include <iostream>

using namespace std;

int main() {
    int n[31];
    n[0] = 0;
    n[1] = 1;
    n[2] = 2;
    n[3] = 4;
    for(int i = 4; i < 31; i++)
    {
        n[i] = n[i-1] + n[i-2] + n[i-3];
    }
    int d;
    while(cin >> d && d != 0)
    {
        cout << n[d] / (365 * 10) + 1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3044
import sys

for line in sys.stdin:
    a,b,c,d,e,f=list(map(int,line.split()))
    x=(c*e-b*f)/(a*e-b*d)
    y=(a*f-c*d)/(a*e-b*d)
    print("{0:.3f} {1:.3f}".format(x+0.0,y+0.0))

Measured memory_bytes: 7592
A, B, C, X, Y = map(int, input().split())
AB = C

ans = 0
if 2*AB < A+B:
    if X < Y:
        ans += 2*AB * X
        Y -= X
        if 2*AB < B:
            ans += 2*AB * Y
        else:
            ans += B*Y
    else:
        ans += 2*AB * Y
        X -= Y
        if 2*AB < A:
            ans += 2*AB * X
        else:
            ans += A*X
else:
    ans = A*X + B*Y

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, l, r) for (__typeof(l) i = (l); i <= (r); ++i)
#define per(i, r, l) for (__typeof(r) i = (r); i >= (l); --i)
using namespace std;
typedef long long ll;
const int mod = 998244353;
int read() {
	int f = 1, x = 0; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return f * x;
}
int qpow(int a, int b) { int res = 1; while (b) { if (b & 1) res = (ll)res * a % mod; a = (ll)a * a % mod; b >>= 1; } return res; }

ll n;
ll calc(ll n) {
	ll ans = 0;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			++ans;
			if (i * i < n) ++ans;
		}
	}
	return ans-1;
}
int main() {
	ll n;
	cin >> n;
	if (n == 1) return puts("0"), 0;
	ll res = calc(n - 1);
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		ll r = n;
		while (r % i == 0) r /= i;
		if ((r - 1) % i == 0) ++res;
		r = n;
		while (r % (n / i) == 0) r /= (n / i);
		if ((r - 1) % (n / i) == 0 && i * i < n) ++res;
	}
	cout << res + 1 << endl;
	return 0;
}


Measured memory_bytes: 256