akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//桁dの用意をグローバルにとる
ll dp[105][4][2];

int main(){
    //文字列で使うと扱いやすい　→ 桁数はs.size()で管理.
    string s; cin >> s;
    int n = s.size();

    int K; cin >> K;

    //空集合の時は一致している.
    dp[0][0][0] = 1;
    //配っていく
    rep(i,n)rep(j,4)rep(k,2){
        //今の桁
        int nx = s[i] - '0';
        rep(d,10){

            int ni = i+1, nj= j, nk = k;
            if (d != 0) nj++;
            if (nj > K) continue;

            if (k == 0){
                if(d > nx) continue;
                if(d < nx) nk = 1;
            }

            dp[ni][nj][nk] += dp[i][j][k];
        }
    }

    dunk(dp[n][K][0] + dp[n][K][1]);
}





    

Measured memory_bytes: 256
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 2147483647;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  vector<int> vec;
  int v;
  for (int i = 0; i < n; i++) {
    cin >> v;
    vec.pb(v);
  }
  map<ll, int> mp;
  ll ans = 0;
  mp[vec[0]] = 1;
  for (int i = 1; i < n; i++) {
    ans += mp[i - vec[i]];
    mp[vec[i] + i]++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 26724
import sys

a, b, c = map(int,input().split())

if (a == 5 or a == 7):
  if (b == 5 or b == 7):
    if (c == 5 or c == 7):
      d = a * b * c
      if (d == 175):
        print("YES")
      else: print("NO")
    else: print("NO")
  else: print("NO")
else:
  print("NO")

Measured memory_bytes: 3060
from _collections import deque


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
#https://atcoder.jp/contests/arc081/tasks/arc081_b
#D - Coloring Dominoes
"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
x = gi()
A = [0] * N

for i in range(N):
    A[i] = gi()

ans = 0
if (A[0] > x):
    ans += A[0] - x
    A[0] = x

for i in range(1, N):
    diff = A[i] + A[i - 1] - x
    if diff > 0:
        cost = min(diff, A[i])
        A[i] -= cost
        ans += cost

    diff = A[i] + A[i - 1] - x
    if diff > 0:
        cost -= min(diff, A[i - 1])
        A[i - 1] -= cost
        ans += cost
print(ans)


Measured memory_bytes: 23932
let () =
    let n = read_int () in
    let arr = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    Array.sort compare arr;
    let rec loop i prev =
        if i = n then "YES" else
            if arr.(i) = prev then "NO" else loop (i + 1) arr.(i)
    in
    loop 1 arr.(0) |>  print_endline

Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
int main(){
  int n;cin>>n;
  int a[n];rep(i,n)cin>>a[i];
  int b[n];
  if(n % 2 == 0){
    for(int i = 0; n/2 > i; i++){
      b[i] = n-(i*2);
    }
    for(int i = 0; n/2 > i; i++){
      b[n/2+i] = i*2+1;
    }
  }else {
    for(int i = 0; n/2+1 > i; i++){
      b[i] = n-(i*2);
    }
    for(int i = 0; n/2 > i; i++){
      b[n/2+1+i] = i*2+2;
    }
  }
  rep(i,n){
    cout << a[b[i]-1];
    if(i != n-1)cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 3712
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define LLINF 100000000000000005LL
#define INF (int)1e9+1

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

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

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

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

int main() {
	IOS;
	int n; cin >> n;
	string s; cin >> s;
	for (int i = 0; i < s.length(); i++) {
		s[i] = (s[i] - 'A' + n) % 26 + 'A';
		cout << s[i];
	}
}

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

int array[10000001];
int N = 10000000;

void Eratosthenes(){
  for(int i = 0; i < N; i++){
    array[i] = 1;
  }

  for(int i = 2; i < sqrt(N); i++){
    if(array[i]){
      for(int j = 0; i * (j + 2) < N; j++){
	array[i *(j + 2)] = 0;
      }
    }
  }
  
}


int main()
{
  int n;
  Eratosthenes();
  while( cin >> n, n ) {
    while( 1 ) {
      if( array[n] && array[n-2] && array[n-6] && array[n-8] ) {
	cout << n << endl;
	break;
      }
      n--;
    }
  }
}

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

int main()
{
    int a = 0, b = 0, d = 0, r = 0;
    double f = 0.0, fa = 0.0, fb = 0.0;

    cin >> a >> b;

    if(b == 0)
    {
        return 0;
    }

    d = a / b;
    r = a % b;
    fa = a;
    fb = b;
    f = fa / fb;

    cout << d << " " << r << " " ;
    cout << fixed << std::setprecision(6) << f << endl;
 
    return 0;
}


Measured memory_bytes: 3288
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL N; cin >> N;
  string S;
  while (N > 0) {
    LL x = N % 26LL - 1LL;
    if (x < 0) x += 26LL;
    char c = 'a' + x;
    S = c + S;

    N = (N - x) / 26;
  }
  cout << S << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int32_t r, c;

    cin >> r >> c;

    vector<vector<int32_t>> table(r + 1, vector<int32_t>(c + 1, 0));

    for (int32_t i = 0; i < r; i++) {
        for (int32_t j = 0; j < c; j++) {
            cin >> table[i][j];
            table[i][c] += table[i][j];
            table[r][j] += table[i][j];
            table[r][c] += table[i][j];
        }
    }

    for (int32_t i = 0; i < r + 1; i++) {
        for (int32_t j = 0; j < c + 1; j++) {
            cout << table[i][j];
            if (j != c) {
                cout << " ";
            } else {
                cout << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3132
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
hw = [[0 for i in range(w)] for j in range(h)]

k = 0
l = 0
ary = []
for i in range(n):
	loop = a[i]
	j = 0
	b = [i+1 for j in range(a[i])]
	ary.extend(b)
c = 0
for i in range(0,h*w,w):
	if c%2 == 1:
		d = ary[i:i+w]
		del ary[i:i+w]
		d.reverse()
		ary[i:i] = d
	e = ary[i:i+w]
	print (*e)
	c += 1

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vll vector<ll>
#define mp make_pair
#define el cout<<"\n";
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);    cout.tie(NULL);
#define foor(i,a,b) for (ll i = (a); i < (b); ++i)
#define foo(i,a,b) for (ll i = (a-1); i >= (b); --i)
#define mem(ar,a)    memset(ar,a,sizeof(ar));

void seive()
{
    int isprime[1000001];
ll spf[1000001];
    spf[1]=1;
    ll n=1000000;
    mem(isprime,1);
    for(ll i=2;i<=n;i++)
    spf[i]=i;
    for(ll i=4;i<=n;i+=2)
    {
        spf[i]=2;
        isprime[i]=0;
    }
    for(ll i=3;i<=n;i+=2)
    {
        if(isprime[i])
        for(ll j=i*i;j<=n;j+=2*i)
        {
            isprime[j]=0;
            if(spf[j]==j)
            spf[j]=i;
        }
    }
}
 bool comp(pii a,pii b)
 {
    
     return a.first>b.first;
    
    }
 ll ex(ll n,ll ans)
{
    if(n==1)
    return ans;
  else  if(n%2)
    return (ans%((1000000007))*ex(n/2,(ans*ans)%(1000000007)))%(1000000007);
    else
    return ex(n/2,(ans*ans)%(1000000007));
}
ll kmp(string x,ll m)
{
      
      vector<ll> pi(m,0);
      pi[0]=0;ll ma=0;ll j=0;
      for(ll i=1;i<m;i++)
        {
        j=pi[i-1];
        while(j>0 && x[i]!=x[j])
        j=pi[j-1];
        if(x[j]==x[i])
        j++;
        pi[i]=j;
        }
        return j;
    }
    void dfs(vll adj[],int arr[],ll i,vector<pii > &h,ll parent[])
    {
    arr[i]=1;
        foor(j,0,adj[i].size())
        { 
            if(arr[adj[i][j]]==0)
            {
                h[adj[i][j]].first=h[i].first+1;
                h[adj[i][j]].second=adj[i][j];
                
                 
                 parent[adj[i][j]]=i;
                 dfs(adj,arr,adj[i][j],h,parent);
                
            }
        }
    }
  
int main()
{
    fast;
  ll t=1;
//cin>>t;string s;int n;
//map<ll,string> m; map<string,ll> k;
while(t--)
   {
      ll n;
      cin>>n;ll a;
      ll cnt[n+1]={0};
      foor(i,0,n-1)
      {
          cin>>a;
          cnt[a]++;
      }
      foor(i,1,n+1)
      cout<<cnt[i]<<"\n";
   }
    
       
       
   }

Measured memory_bytes: 5168
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

bool array_equal(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return false;
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return false;
    }
  }
  return true;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

int main() {
  std::cout << std::setprecision(9);
  char a;
  cin >> a;

  if (isupper(a)) {
    cout << 'A' << endl;
  }
  else {
    cout << 'a' << endl;
  }
}

Measured memory_bytes: 3596
s = input().split()

A = int(s[0])
B = int(s[1])
C = int(s[2])

K = int(input())

result = False

for i in range(K+1):
  if A < B * (2 ** i):
    if (B * (2 ** i)) < C * (2 ** (K - i)):
      result = True
      break
    
if result:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int c0=0,c1=0,c2=0,c3=0,n;
	string s;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		if(s=="AC")
		c0++;
		if(s=="WA")
		c1++;
		if(s=="TLE")
		c2++;
		if(s=="RE")
		c3++;
	}
	cout<<"AC x "<<c0<<endl<<"WA x "<<c1<<endl<<"TLE x "<<c2<<endl<<"RE x "<<c3<<endl;
return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  cin>>s;
  vector<string> v(4);
  v[0]="dream";
  v[1]="dreamer";
  v[2]="erase";
  v[3]="eraser";
  reverse(all(s));
  rep(i,4)reverse(all(v[i]));
  rep(i,s.size()){
    bool c=false;
    rep(j,4){
      int t=v[j].size();
      if(i+t<=s.size()&&s.substr(i,t)==v[j]){
	i+=t-1;
	c=true;
	break;
      }
    }
    if(c==false){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;

}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath> 
#include <cctype>

using namespace std;

int main() {
    int N, M;
    int sum = 0;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++) {
        cin >> s.at(i);
    }

    cin >> M;
    vector<string> t(M);
    for (int i = 0; i < M; i++) {
        cin >> t.at(i);
    }

    for (int i = 0; i < N; i++) {
        int count = 0;
        string temp = s.at(i);
        for (int j = 0; j < N; j++) {
            if (temp == s.at(j)) {
                count++;
            }
        }
        for (int k = 0; k < M; k++) {
            if (temp == t.at(k)) {
                count--;
            }
        }
        sum = max(sum, count);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<algorithm>

using namespace std;
static const int N = 100;

void print(int A[], int n) {
    for(int i = 0; i < n; i++) {
        if(i) printf(" ");
        printf("%d", A[i]);
    }
}

int bubbleSort(int A[], int n) {
    int i,j, num = 0;
    for(i = 0; i < n; i++) {
        for(j = n-1; j >= i+1; j--) {
            if(A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                num++;
            }

        }
    }
    return num;
}


int main() {
    int n, A[N+1];
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    int num = bubbleSort(A, n);
    print(A, n);
    printf("\n%d\n", num);
    return 0;
}

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

int main() {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	int a = x - r;
	int b = x + r;
	int c = y - r;
	int d = y + r;
	if(a >= 0 && b <= w && c >= 0 && d <= h) {
		std::cout << "Yes" << endl;
	}
	else {
				std::cout << "No" << endl;

	}
}


Measured memory_bytes: 3120
#include <stdio.h>
int main()
{
    int data[100],i,n,step,temp;
    for(i=0;i<5;++i)
    {

        scanf("%d",&data[i]);
    }

    for(step=0;step<5-1;++step)
    for(i=0;i<5-step-1;++i)
    {
        if(data[i]<data[i+1])
        {
            temp=data[i];
            data[i]=data[i+1];
            data[i+1]=temp;
        }
    }
    for(i=0;i<4;++i)
         printf("%d ",data[i]);
    printf("%d\n",data[4]);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
source:
    ll n;
    cin >> n;
    ll t[n], v[n];
    rep(i, n) { cin >> t[i]; }
    rep(i, n) { cin >> v[i]; }

    ll time_max = 0;
    rep(i, n) { time_max += t[i]; }

    double speed_max[2 * time_max + 1];
    memset(speed_max, 0, sizeof speed_max);

    ll index = 0;
    rep(i, n) {
        ll num = t[i] * 2;
        if (i != 0) {
            speed_max[index] = min(v[i - 1], v[i]);
        } else {
            speed_max[index] = 0;
        }
        rep(j, num) {
            index++;
            speed_max[index] = v[i];
        }
    }
    speed_max[2 * time_max] = 0;

    repd(i, 1, 2 * time_max + 1) {
        speed_max[i] = min(speed_max[i - 1] + 0.5, speed_max[i]);
    }

    repd(i, 1, 2 * time_max + 1) {
        ll j = 2 * time_max - i;
        speed_max[j] = min(speed_max[j + 1] + 0.5, speed_max[j]);
    }
    /* rep(i, 2 * time_max + 1) { cout << speed_max[i] << " "; } */
    /* cout << endl; */

    double ans = 0;
    rep(i, 2 * time_max) { ans += speed_max[i] + speed_max[i + 1]; }

    ans /= 4.0;
    printf("%.5lf\n", ans);

    return 0;
}



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

int main(void) {
  int n, k;
  string s;
  cin >> n >> k >> s;
  for(int i = 0; i < n; i++) {
    cout << ((i == k-1) ? char(tolower(s[i])) : s[i]);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)



signed main(){
    rep(i, 5){
        int x;
        cin >> x;
        if(x == 0) cout << i+1 << endl;
    }
}

Measured memory_bytes: 3632
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc;
	public void run(){
		sc = new Scanner(System.in);
		
		while(sc.hasNextInt()){
			int value = sc.nextInt();
			int value2 = sc.nextInt();
			if(value == 0 && value2 == 0){
				break;
			}
			else{
				calc(value, value2);
			}
		}
	}
	public void calc(int n, int p){
		int[] kouho = new int[n];
		for(int i = 0; i < n; i++){
			kouho[i] = 0;
		}
		int wan = p;
		int i = 0;
		while(true){
		  if(wan != 0){
			  kouho[i] = kouho[i]+1;
			  wan = wan -1;
			  if(wan == 0 && kouho[i] == p){
				  System.out.println(i);
				  break;
			  }
			  i = i + 1;
			  if(i == n) i = 0;
		  }
		  else{
			  wan = kouho[i];
			  kouho[i] = 0;
			  i = i + 1;
			  if(i == n) i = 0;
		  }
		}
	}
	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 20248
K=int(input())
a=7
for i in range(1,K+1):
    if a%K==0:
        print(i)
        exit()
    else:
        a=(a*10+7)%K
print(-1)
        










        

    









    

        




    















    



    





    






        






    
















        


























            
    


    


    
    














    


    














Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    int N, a = 1;
    cin >> N;
    while(a <= N) {
        a *= 2;
    }
    cout << a / 2 << endl;
}

Measured memory_bytes: 384
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int k = sc.nextInt();
        List<String> list = new ArrayList<String>();
        for (int i = 1; i <= k; i++) {
            for (int j = 0; j <= s.length() - i; j++) {
                list.add(s.substring(j, j + i));
            }
        }
        Collections.sort(list);
        if (k == 1) {
            System.out.println(list.get(0));
        } else {
            int count = 1;
            int i = 1;
            String str = list.get(0);
            while (count != k) {
                if (!list.get(i).equals(str)) {
                    count++;
                    str = list.get(i);
                }
                i++;
            }
            System.out.println(str);
        }

    }

}

Measured memory_bytes: 25248
N=int(input())
A=list(map(int,input().split()))

n = 0
ended = False
while True:
    for i in range(N):
        if A[i] % 2 == 1:
            ended = True
            break
        else:
            A[i] //= 2
    if ended:
        break
    n += 1

print(n)



Measured memory_bytes: 63692
#include<iostream>

using namespace std;

const int N(1009);
const int mod(1e9 + 7);

int n, m, ans;
int f[N][N];
char a[N][N];

int main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			cin>>a[i][j];
		}
	}
	f[1][1] = 1;
	for (int i=2;i<=n;i++)
	{
		if (a[i][1] == '.')
		{
			f[i][1] = f[i-1][1];
		}
	}
	for (int j=2;j<=m;j++)
	{
		if (a[1][j] == '.')
		{
			f[1][j] = f[1][j-1];
		}
	}
	for (int i=2;i<=n;i++)
	{
		for (int j=2;j<=m;j++)
		{
			if (a[i][j] == '.')
			{
				f[i][j] = (f[i - 1][j] + f[i][j - 1]) % mod;
			}
		}
	}
/*	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			cout<<f[i][j]<<' ';
		}
		cout<<endl;
	}*/
	cout<<f[n][m]<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

int h1,m1,h2,m2,k; 
int main(){
	int t;
	cin>>h1>>m1>>h2>>m2>>k;
	t = m2 - m1 + 60 * (h2 - h1);
	if (t <= k){
		cout<<0<<'\n';
		return 0;
	}
	cout<<t-k<<'\n';
	return 0;
}

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

using namespace std;

#define mp(a,b) make_pair(a,b)

#define ff first

#define setp(a) setprecision(a)<<fixed

#define ss second

#define fori(v) for(ll i=0; i<v; i++)

#define forj(v) for(ll j=0; j<v; j++)

#define fork(v) for(ll k=0; k<v; k++)

#define forl(v) for(ll l=0; l<v; l++)

#define fort(v) for(ll t=0; t<v; t++)

#define forz(v) for(ll z=0; z<v; z++)

#define forx(v) for(ll x=0; x<v; x++)

#define fory(v) for(ll y=0; y<v; y++)

#define ll long long

#define double long double

#define pb(a) push_back(a)

#define MAX (int)(2*pow(10,5) + 10)

const ll INF = 0x3f3f3f3f;

const ll inf = pow(10,18);

ll modulo = pow(10,9)+7;



ll pow_mod(ll a, ll b){
	a = a%modulo;
	ll mx = 0;
	ll has = 1;
	for(ll i = 62; i>-1; i--){
		has*=has;
		has%=modulo;
		if(((ll)1<<i)&b)
			has*=a, has%=modulo;
	}
	return has;
}


ll inv(ll a){
	return pow_mod(a, modulo-2);
} 

 

ll fkt[MAX];
ll invfkt[MAX];

void pre(){
	fkt[0] = 1, invfkt[0] = 1;
	for(ll i = 1; i<MAX; i++){
		fkt[i] = ( fkt[i-1] * i ) % modulo;
		invfkt[i] = inv(fkt[i]);
	}
}

ll kmb(ll i, ll j){
	return fkt[i] * invfkt[j] % modulo * invfkt[i-j] % modulo;
}



 

void deal(){
	pre();
	ll n, k;
	cin>>n>>k;
	k = max(n-k, (ll)1);
	ll s = 0;
	for(ll i = k; i<=n; i++){
		s+=kmb(n,i) * kmb(n-1,i-1);
		s%=modulo;
	}
	cout<<s;

}

  

  

  

  

  

int main(){

	cin.tie(0);

	ios_base::sync_with_stdio(0);

	deal();

}

Measured memory_bytes: 3328
#include<cstdio>

int main(){
    int h_1,m_1,h_2,m_2,k;
    scanf("%d %d %d %d %d", &h_1, &m_1, &h_2, &m_2, &k);
    int pos = (h_2*60 + m_2) - (h_1*60 + m_1);
    int ans = pos - k;
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 1732
import sys, itertools

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))

S = list(itertools.accumulate(A))

mini = 10 ** 18
for i in range(N):
    mini = min(mini, abs(S[N - 1] - 2 * S[i]))

print(mini)


Measured memory_bytes: 25748
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,M = MI()


class UnionFind:
    def __init__(self,n):
        self.par = [i for i in range(n+1)]  # 親のノード番号
        self.rank = [0]*(n+1)
    def find(self,x):  # xの根のノード番号
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def same_check(self,x,y):  # x,yが同じグループか否か
        return self.find(x) == self.find(y)
    def unite(self,x,y):  # x,yの属するグループの併合
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            x,y = y,x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.par[y] = x


U = UnionFind(N)
for i in range(M):
    a,b = MI()
    U.unite(a,b)

A = U.par
for i in range(1,N+1):
    A[i] = U.find(A[i])

del A[0]


from collections import Counter

c = Counter(A)
print(max(c.values()))


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

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

size_t N, M;
auto g = make_v(false, 50, 50);
vector<bool> seen;

void dfs(size_t now_node) {
    seen[now_node] = true;
    for (size_t node = 0; node < N; ++node) {
        if (!seen[node] && g[now_node][node]) {
            dfs(node);
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N >> M;

    vector<size_t> a(M), b(M);
    for (size_t i = 0; i < M; ++i) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        g[a[i]][b[i]] = g[b[i]][a[i]] = true;
    }

    size_t res = 0;
    for (size_t i = 0; i < M; ++i) {
        g[a[i]][b[i]] = g[b[i]][a[i]] = false;
        seen.assign(N, false);
        dfs(0);
        for (size_t node = 0; node < N; ++node) {
            if (!seen[node]) {
                res++;
                break;
            }
        }
        g[a[i]][b[i]] = g[b[i]][a[i]] = true;
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {

    int m;
    cin >> m;

    cout << (48 - m) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

Vl sosuu;

void sosu(){
    Rep(i, 11, 100000){
        if(i%2 == 0 || i%3 == 0 || i%5 == 0 || i%7 == 0) continue;
        bool f = false;
        Rep(j, 2, sqrt(i)){
            if(i%j == 0){ f = true; break;}
        }
        if(f) continue;
        sosuu.push_back(i);
    }
}

int main() {
    sosuu = {1, 2, 3, 5, 7};
    sosu();

    // co(sz(sosuu));

    Vl like;
    rep(i, 0, sz(sosuu)){
        ll ne = (sosuu[i] + 1)/2;
        bool f = false;
        Rep(j, 2, sqrt(ne)){
            if(ne%j == 0){ f = true; break;}
        }
        if(f) continue;
        if(sosuu[i]==1 || sosuu[i]==2)continue;
        like.push_back(sosuu[i]);
    }
    // co(sz(like));
    // rep(i, 0, 10) cout << like[i] << " ";
    // coel;

    Vl ans;
    ll q; cin >> q;
    rep(i, 0, q){
        ll l, r; cin >> l >> r;
        r++;
        // co(lower_bound(ALL(like), r) - lower_bound(ALL(like), l));
        ans.push_back(lower_bound(ALL(like), r) - lower_bound(ALL(like), l));
    }

    rep(i, 0, q) co(ans[i]);

    return 0;
}


Measured memory_bytes: 1652
//@source: 
//@create: 19:24:50 Sunday 02/08/2020
//@author: nghethuat102
#include <bits/stdc++.h>
using namespace std;

#define len(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define discrete(x) sort(all(x), x.erase(unique(all(x)), x.end())

struct BIT {
    vector<int> bit;
    int n;
    BIT(int nn) : n(nn + 1) {
        bit.assign(n, 0);
    }
    void up(int x) {
        while (x < n) {
            bit[x] ++;
            x += x & -x;
        }
    }
    int get(int x) {
        int ans = 0;
        while (x > 0) {
            ans += bit[x];
            x -= x & -x;
        }
        return ans;
    }
};

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    vector<int> nxt(n + 1, n + 1);
    vector<int> last(n + 1, n + 1);
    for (int i = n; i >= 1; --i) {
        nxt[i] = last[a[i]];
        last[a[i]] = i;
    }
    vector<pair<int, int>> qr(q);
    vector<int> index(q);
    vector<int> ans(q);
    for (int i = 0; i < q; ++i) {
        cin >> qr[i].first >> qr[i].second;
        index[i] = i;
    }
    sort(all(index), [&](int i, int j) {
        return qr[i].first > qr[j].first;
    });
    int cur = n;
    BIT bit(n);
    for (int i = 0; i < q; ++i) {
        int u = qr[index[i]].first;
        int v = qr[index[i]].second;
        while (cur >= u) {
            bit.up(nxt[cur]);
            cur --;
        }
        int l = bit.get(v) - bit.get(u - 1);
        ans[index[i]] = (v - u + 1 - l);
    }
    for (int i = 0; i < q; ++i) {
        cout << ans[i] << "\n";
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    for (int it = 1; it <= t; ++it) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 19448
#include "bits/stdc++.h"
#define ll long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM 1000000000
#define line printf("-----------------\n");
using namespace std;
int SET(int N, int pos) { return N = N | (1 << pos); }
int RESET(int N, int pos) { return N = N & ~(1 << pos); }
bool CHECK(int N, int pos) { return (bool)(N & (1 << pos)); }
template <typename T>
inline T __lcm(T a, T b)
{
    return (a * b) / __gcd(a, b);
}
struct node
{
    int x, y, i;
};
int dx[] = {0, 1, 0, -1, -1, 1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};

struct DisJointSet
{
    vector<ll> size_;
    vector<ll> parent;

    DisJointSet(ll n)
    {
        size_.resize(n + 1, 1);
        parent.resize(n + 1);

        for (int i = 1; i <= n; i++)
            parent[i] = i;
    }
    ll findSet(ll x)
    {
        if (parent[x] == x)
            return x;
        return parent[x] = findSet(parent[x]);
    }
    void unionSet(int a, int b)
    {
        a = findSet(a);
        b = findSet(b);
        if (a != b)
        {
            if (size_[a] < size_[b])
            {
                swap(a, b);
            }
            parent[b] = a;
            size_[a] += size_[b];
        }
    }
};
ll fun(ll n)
{
    return n * (n - 1) / 2;
}
void solve()
{
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> v;

    vector<ll> v2;

    for (int i = 0; i < m; i++)
    {
        ll x, y;
        cin >> x >> y;
        v.push_back({x, y});
    }
    reverse(v.begin(), v.end());
    DisJointSet dsu(n);
    ll ans = (n - 1) * n / 2;

    v2.push_back(ans);

    for (int i = 0; i < m - 1; i++)
    {
        //int temp = ans;
        ll x, y;
        x = v[i].first;
        y = v[i].second;
        //cout<<x<<" "<<y<<endl;
        ll sizex = dsu.size_[dsu.findSet(x)];
        ll sizey = dsu.size_[dsu.findSet(y)];
        //cout<<sizex<<" + "<<sizey<<endl;
        if (dsu.findSet(x) != dsu.findSet(y))
        {
            dsu.unionSet(x, y);
            int sizexy = dsu.size_[dsu.findSet(x)];
            //cout<<fun(sizexy)<<" "<<fun(sizex)<<" "<<fun(sizey)<<endl;
            ans -= (fun(sizexy) - fun(sizex) - fun(sizey));
            v2.push_back(ans);
        }
        else
        {
            v2.push_back(ans);
        }
        
    }

    for (int i = m-1; i >= 0; i--)
    {
        cout << v2[i] << endl;
    }
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("inputf.txt", "r", stdin);
    //freopen("outputf.txt", "w", stdout);
#endif // ONLINE_JUDGE
    solve();
    return 0;
}

Measured memory_bytes: 6256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int p[100000];
int par[100000];

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

void unite(int x, int y)
{
  int rx = root(x);
  int ry = root(y);
  if (rx == ry)
    return;
  par[rx] = ry;
}

int same(int x, int y)
{
  int rx = root(x);
  int ry = root(y);
  return rx == ry;
}

int main()
{
  int n, m, ans = 0;
  scanf("%d%d", &n, &m);
  // for (int i = 1; i <= n; i++)
  for (int i = 0; i < n; i++)
    scanf("%d", p + i);
  for (int i = 0; i < n; i++)
    par[i] = i;
  for (int i = 0; i < m; i++)
  {
    int x, y;
    scanf("%d%d", &x, &y);
    unite(x - 1, y - 1);
  }
  // for (int i = 1; i <= n; i++)
  for (int i = 0; i < n; i++)
  {
    if (same(i, p[i] - 1))
      ans++;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 896
// mai iss duniyaa ka sbse bada chutiyaaa huu

#include<bits/stdc++.h> 
#include <chrono> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl '\n'
#define p_b push_back
#define m_p make_pair
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
using namespace std::chrono; 

template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less_equal<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;

char alphabet[26] = {'a','b','c','d','e','f','g','h','i',
       'j','k','l','m','n','o','p','q','r','s','t','u','v',
       'w','x','y','z'};

// rectangle intersection
// x5 = max(x1, x3);
// y5 = max(y1, y3);
// x6 = min(x2, x4);
// y6 = min(y2, y4); 

const int mx = 500005;

// char get_next(char c) {
// 	for(int i=0; i<25; i++) if(c == alphabet[i]) return alphabet[i+1];
// 	return 'a';
// }

struct no {
	int l, r, id;
}q[mx];

int bl[mx];
int col[mx];
int mp[mx];

void get_blocks(int n) {
	int sqroot = sqrt(n)+1;
	for(int i=0; i<=n; i++) bl[i] = i/sqroot;
}
bool mo_sort(no a, no b) {
	return bl[a.l] == bl[b.l] ? a.r < b.r : bl[a.l] < bl[b.l];
}
int diff = 0;
void add(int id) {
	if(!mp[col[id]]) diff++;
	mp[col[id]]++;
}
void rem(int id) {
	mp[col[id]]--;
	if(mp[col[id]] == 0) diff--;
}
int32_t main() {
 	fastIO;
	int tc;
	// cin >> tc;
	tc = 1;
	while(tc --) {
		int n, qry;
		cin >> n >> qry;
		get_blocks(n);
		for(int i=0; i<n; i++) cin >> col[i];
		for(int i=0; i<qry; i++) {
			cin >> q[i].l >> q[i].r;
			q[i].id = i;
		}
		int ans[qry];
		sort(q, q+qry, mo_sort);
		int curl = 0, curr = -1;
		for(int i=0; i<qry; i++) {
			int l = q[i].l - 1, r = q[i].r - 1;
			while(curl > l) {
				curl--;
				add(curl);
			}
			while(curr < r) {
				curr++;
				add(curr);
			}
			while(curl < l) {
				rem(curl);
				curl++;
			}
			while(curr > r) {
				rem(curr);
				curr--;
			}
			ans[q[i].id] = diff;
		}
		for(int i=0; i<qry; i++) cout << ans[i] << endl;
  	}     
}



Measured memory_bytes: 31172
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  int n;
  cin>>n;
  rep(k,n){
    cin.ignore();
    vector<string> v(10);
    rep(i,8)
      cin>>v[i];
    int x,y;
    cin>>x>>y;
    x--;y--;
    queue<pii> q;
    q.push(pii(x,y));
    while(q.size()){
      x=q.front().first;
      y=q.front().second;
      q.pop();
      v[y][x]='0';
      for(i=1;i<4;i++){
        if(y-i>=0 && v[y-i][x]=='1')q.push(pii(x,y-i));
        if(y+i<8 && v[y+i][x]=='1')q.push(pii(x,y+i));
        if(x-i>=0 && v[y][x-i]=='1')q.push(pii(x-i,y));
        if(x+i<8 && v[y][x+i]=='1')q.push(pii(x+i,y));
      }
    }
    cout<<"Data "<<k+1<<':'<<endl;
    rep(i,8)
      cout<<v[i]<<endl;
  }
}

Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    ll ans = 0;
    int maxe = 1;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        int add = (a - 1) / maxe;
        ans += add;
        if(add != 0)    a = 1;
        chmax(maxe, a + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

#define N 2010

//head

int n;
int a;
bitset<N*N> bits;
int s;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	bits.set(0);
	cin >> n;
	rep(i, n) {
		cin >> a;
		bits = (bits<<a)|bits;
		s += a;
	}
	for(int i = (s+1)>>1;; i++) {
		if(bits.test(i)) {
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 5108
from collections import defaultdict
import sys

dd=defaultdict(lambda:0)
n=int(input())
a=list(sys.stdin.read().split())
for aa in a:
  dd[aa]+=1
ANSL=["AC", "WA", "TLE", "RE"]

ans=""
for w in ANSL:
  ans+=f"{w} x {dd[w]}\n"
print(ans)

Measured memory_bytes: 17592
n = int(input())
h = list(map(int, input().split()))
count_memory = 0
count = 0
for i in range(1, len(h)):
    if h[i - 1] >= h[i]:
        count += 1
    else:
        count = 0
    if count > count_memory:
        count_memory = count
print(count_memory)

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

int main() {

    int n;
    cin >> n;

    set<int> els;

    for(int i = 0; i < n; i++) {
        int x; cin >> x;
        els.insert(x);
    }

    if(els.size() == n) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }
    int C[200000]{0};
    for (int a : A){
        ++C[a];
    }
    sort(C, C + N, greater<>());
    cout << N - accumulate(C, C + K, 0) << endl;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    int N, M;

    cin >> N >> M;

    if(N == M){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << "\n";
    }


return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a, b;
	cin >> a >> b;

	if(a%3==0 || b%3==0 || (a+b)%3==0)
		cout << "Possible" << endl;
	else
		cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    vvi numw(h, vi(w, 0));
    vvi numh(h, vi(w, 0));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (j == 0) {
                if (s[i][j] == '.')
                    numw[i][j] = 1;
            } else {
                if (s[i][j] == '.') {
                    numw[i][j] = numw[i][j - 1] + 1;
                } else {
                    numw[i][j] = 0;
                }
            }
        }
    }

    for (int i = 0; i < h; ++i) {
        for (int j = w - 2; j >= 0; --j) {
            if (s[i][j] == '.') {
                chmax(numw[i][j], numw[i][j + 1]);
            }
        }
    }
    for (int i = 0; i < w; ++i) {
        for (int j = 0; j < h; ++j) {
            if (j == 0) {
                if (s[j][i] == '.')
                    numh[j][i] = 1;
            } else {
                if (s[j][i] == '.') {
                    numh[j][i] = numh[j - 1][i] + 1;
                } else {
                    numh[j][i] = 0;
                }
            }
        }
    }

    for (int i = 0; i < w; ++i) {
        for (int j = h - 2; j >= 0; --j) {
            if (s[j][i] == '.') {
                chmax(numh[j][i], numh[j + 1][i]);
            }
        }
    }

    int ret = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            chmax(ret, numh[i][j] + numw[i][j] - 1);
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 35712
n = int(input())
S = [str(input()) for _ in range(n)]
m = int(input())
T = [str(input()) for _ in range(m)]

from collections import Counter
cs = Counter(S)
ct = Counter(T)

ans = -10**18
for k, v in cs.items():
    if k in ct:
        temp = v - ct[k]
    else:
        temp = v
    ans = max(ans, temp)
print(max(ans, 0))


Measured memory_bytes: 66980