akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int res = sc.nextInt();
		
		int n = 4;
		int digit[] = new int[n];
		int cnt = 0;
		
		while(res > 0) {
			digit[cnt] = res % 10;
			res /= 10;
			cnt += 1;
		}
		
		if((digit[0] == digit[1] && digit[1] == digit[2] 
				|| (digit[1] == digit[2] && digit[2] == digit[3]))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

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

int main(){
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    vector<unsigned long> dp(N, 1);
    const auto& multiplies = [&N, &M, &dp](unsigned long a){
        vector<unsigned long> ans(N);
        for(unsigned long i{0}; i < N; ++i)for(unsigned long j{0}; i + j * a < N; ++j)ans[i + j * a] += dp[i];
        for(auto& i : ans)i %= M;
        copy(ans.begin(), ans.end(), dp.begin());
    };
    for(unsigned long i = 2; i < N; ++i)multiplies(min(i, N - i + 1));
    vector<unsigned long> coef(N);
    iota(coef.rbegin(), coef.rend(), 1UL);
    cout << inner_product(coef.begin(), coef.end(), dp.begin(), 0UL) % M << endl;
    return 0;
}

Measured memory_bytes: 384
using System;

public class hello
{
    public static void Main()
    {
        var times = 0;
        for (int i = 0; i < 4; i++)
            times +=  int.Parse(Console.ReadLine().Trim());
        Console.WriteLine("{0}\n{1}", times / 60, times - times / 60 * 60);
    }
}

Measured memory_bytes: 9176
#define _SCL_SECURE_NO_WARNINGS

#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n, m;
    while (cin >> n >> m && n | m){
        static int l[10000];
        static int r[10000];
        for (int i = 0; i < n; i++)cin >> l[i];
        for (int i = 0; i < m; i++)cin >> r[i];
        static int all[20001];
        all[0] = 0;
        merge(l, l + n, r, r + m, all + 1);
        int res = 0;
        for (int i = 0; i < n + m; i++){
            res = max(res, all[i + 1] - all[i]);
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 1320
/**
*    created: 04.07.2020 21:13:15
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    map<int,int> mp;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
        mp[a[i]]++;
        mp[a[i]-1]++;
        mp[a[i]+1]++;
    }
    int mx = -1;
    for (auto p : mp) chmax(mx,p.second);
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 9940
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n,ans[maxn],vis[maxn];
vector<int>g[maxn],v[2];
void dfs(int u = 1, int fa = 0, int t = 0)
{
	v[t].push_back(u);
	for(int i = 0; i < (int) g[u].size(); ++i) 
	{
		int v = g[u][i];
		if(v==fa) 	continue;
		dfs(v,u,1-t);
	}
}
int main()
{
	int i,u,t;
	scanf("%d",&n);
	for(i=1;i<n;++i) 
	{
		scanf("%d %d",&u,&t);
		g[u].push_back(t);
		g[t].push_back(u);
	}
	dfs();
	if(v[0].size()>v[1].size()) 	swap(v[0],v[1]);
	int sum = n/3;
	if(v[0].size() <= sum) 
	{
		for(i=1;i<=n;++i)
		{
			if(!v[0].size()) break;
			if(i % 3 == 0) 
			{
				t = v[0].back();
				ans[t] = i;
				v[0].pop_back();
				vis[i]++;
			}
		}
	}
	else
	{
		for(i=1;i<=n;++i) 
		{
			if(!v[0].size()) break;
			if(i % 3 == 1) 
			{
				t = v[0].back();
				ans[t] = i;
				v[0].pop_back();
				vis[i]++;
			}
		}
		for(i=1;i<=n;++i) 
		{
			if(!v[0].size()) break;
			if(i%3==0) 
			{
				t = v[0].back();
				ans[t] = i;
				v[0].pop_back();
				vis[i]++;
			}
		}
	}
	for(i=1;i<=n;++i) 
	{
		if(!v[1].size()) 	break;
		if(!vis[i])
		{
			t = v[1].back();
			ans[t] = i;
			v[1].pop_back();
			vis[i]++;
		}
	}
	for(i=1;i<=n;++i) 	printf("%d ",ans[i]);
}


Measured memory_bytes: 22516
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int x, y;
  cin >> x >> y;
  int a, b, c;
  cin >> a >> b >> c;
  priority_queue<int> p, q, r;
  vector<int> vp(a), vq(b);
  rep(i, a){
    cin >> vp.at(i);
  }
  rep(i, b){
    cin >> vq.at(i);
  }
  rep(i, c){
    int in;
    cin >> in;
    r.push(in);
  }

  ll ans = 0;
  sort(ALL(vp), greater<int>()); sort(ALL(vq), greater<int>());
  rep(i, x){
    ans += vp.at(i);
    p.push(vp.at(i) * -1);
  }
  rep(i, y){
    ans += vq.at(i);
    q.push(vq.at(i) * -1);
  }
  while(!r.empty()){
    int np = 2e9, nq = 2e9, nr;
    if(!p.empty()) np = p.top() * -1;
    if(!q.empty()) nq = q.top() * -1;
    nr = r.top();
    if(nr <= np && nr <= nq) break;
    if(np < nq){
      ans += nr - np;
      p.pop(); r.pop();
    }else{
      ans += nr - nq;
      q.pop(); r.pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5408
//InTheNameOfGod
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
const int maxn = 1;
int n,a,b;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n>>a>>b;
    if((b-a-1)%2)
    {
        cout<<"Alice";
    }
    else cout<<"Borys";
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>	
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef unsigned long long uLL; 
typedef vector<int> vii; 
const int maxn = 1e4 + 5;
const int M = 1e9 + 7;
LL d[maxn][105];

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	int K;
	cin >> s >> K;
	reverse(all(s));
	int n = (int)s.size();
	d[0][0] = 1;
	for(int i = 0; i < 10; ++i){
		++d[1][i % K];
	}
	for(int i = 2; i < n; ++i){
		for(int j = 0; j < K; ++j){
			for(int k = 0; k < 10; ++k){
				d[i][j] = (d[i][j] + d[i - 1][(j - k + 1000 * K) % K]) % M;
			}
			// cout << d[i][j] << ' ';
		}
		// cout << endl;
	}
	LL res = 0, num = 0;
	for(int i = n - 1; i >= 0; --i){
		int x = s[i] - '0';
		for(int j = 0; j < x; ++j){
			int t = (K - (num + j) % K) % K;
			res = (res + d[i][t]) % M;
			// cout << res << endl;
		}
		num += x;
	}
	res = (res - 1 + M) % M;
	if(num % K == 0) res = (res + 1) % M;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 8448
#include <stdio.h>

int main()
{
  int n,b, sum=0, d;
  scanf("%d", &n);
  b = n;
  while(n){
    d = n%10;
    sum = sum + d;
    n = n/10;
  }
  
  if(b%sum==0)printf("Yes\n");
  else printf("No\n");
  
  return 0;
}


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

using namespace std;

int main(void){
  string S;
  cin >> S;
  int upper = 0;
  if(S[0] != 'A') goto wa;
  for(char c : S){
    if('A' <= c && c <= 'Z') upper++;
  }
  if(upper != 2) goto wa;
  for(int i = 2; i < S.length() - 1; i++){
    if(S[i] == 'C') goto ac;
  }
  
  wa:;
  cout << "WA" << endl;
  return 0;
  
  ac:;
  cout << "AC" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define maxN 200007
using namespace std;
ll maxm(ll a, ll b, ll c) {
  return max(a, max(b, c));
}
int main() {
  fastio;
  ll n = 0;
  cin >> n;
  ll ar[n][3];
  for (ll i = 0; i < n; ++i) {
    for (ll j = 0; j < 3; ++j) {
      cin >> ar[i][j];
    }
  }
  ll dp[n][3];
  memset(dp, sizeof(dp), 0);
  for (ll j = 0; j < 3; ++j)
    dp[0][j] = ar[0][j];
  for (ll i = 1; i < n; ++i) {
    dp[i][0] = ar[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
    dp[i][1] = ar[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
    dp[i][2] = ar[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
  }
  cout << maxm(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]);
}

Measured memory_bytes: 8316
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_N = 100005;

int main() {
    int n, l;
    unsigned long long max_time = 0;
    vector<int> lens(MAX_N, 0);
    vector<int> valleys;

    scanf("%d %d", &n, &l);
    for (int i = 1; i <= n; i++) {
        int ai;
        scanf("%d", &ai);
        lens[i] = ai;
    }

    valleys.push_back(1);
    for (int i = 2; i <= n - 1; i++) {
        if (lens[i] < lens[i - 1] && lens[i] < lens[i + 1]) {
            valleys.push_back(i);
        }
    }
    valleys.push_back(n);

    for (auto& pos: valleys) {
        auto left_pos = pos - 1, right_pos = pos + 1;
        auto left_time = l - lens[pos], right_time = l - lens[pos];
        auto now_pos = pos;
        while (lens[left_pos] > lens[now_pos]) {
            left_time += l - lens[left_pos];
            left_pos--;
            now_pos--;
        }
        now_pos = pos;
        while (lens[right_pos] > lens[now_pos]) {
            right_time += l - lens[right_pos];
            right_pos++;
            now_pos++;
        }
        if (left_time > max_time) { max_time = left_time; }
        if (right_time > max_time) { max_time = right_time; }
    }

    printf("%llu\n", max_time);

    return 0;
}

Measured memory_bytes: 3164
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;


namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var Ai = new long[N];
            for (var i = 0; i < N; ++i)
            {
                Ai[i] = Sarray()[0];
            }
            shellSort(Ai);
        }


        static long insertionSort(long[] Ai, long n, long g)
        {
            var cnt = 0;
            for (var i = g; i < n; ++i)
            {
                var v = Ai[i];
                var j = i - g;
                while (0 <= j && v < Ai[j])
                {
                    Ai[j + g] = Ai[j];
                    j = j - g;
                    ++cnt;
                }
                Ai[j + g] = v;
            }
            return cnt;
        }
        static void shellSort(long[] Ai)
        {
            var n = Ai.Length;
            var cnt = 0L;
            var G = new List<long>();
            var h = 1;
            while (h <= n)
            {
                G.Add(h);
                h = 3 * h + 1;
            }
            G.Reverse();
            foreach (var g in G)
            { cnt += insertionSort(Ai, n, g); }
            WriteLine(G.Count);
            WriteLine(string.Join(" ", G));
            WriteLine(cnt);
            foreach(var a in Ai)
            { WriteLine(a); }
        }
    }
}


Measured memory_bytes: 27876
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#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>
#include <cstring>


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

using namespace std;
using ll = long long;

const ll mod = 1000000007;
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(){
  map<ll, int> mp;
  ll N, M, a, b;
  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    cin >> a;
    mp[a]++;
  }
  for(int i = 0; i < M; i++) {
    cin >> b;
    mp[b]++;
  }

  int and_cnt = 0, or_cnt = 0;
  for(auto itr : mp){
    or_cnt++;
    if(mp[itr.first] == 2) and_cnt++;
  }
  cout << and_cnt << " " << or_cnt << endl;

  for(auto itr : mp){
    if(itr.second == 2) cout << itr.first << endl;
  }
  for(auto itr : mp){
    cout << itr.first << endl;
  }
  return 0;
}



Measured memory_bytes: 16544
#include <bits/stdc++.h>
using namespace std;
#define printvector(v,n) for(int i=1;i<=n;i++) cout<<v[i]<<" "; cout<<ln;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for int64)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define RFOR(i,b,a) for(int i=b; i>=a; i--)
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define setPresent(x,s) (s.find(x)!=s.end())
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
#pragma GCC optimize ("-O2")
template<class T> using min_heap = priority_queue<T, std::vector<T>, std::greater<T> >; 
const int LM=1e5;
ll a[LM+2],b[LM+2],c[LM+2];
int n;
v64 v1,v2;
int main()
{    
    ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	FOR(i,1,n) cin>>a[i];
	FOR(i,1,n) cin>>b[i];
	FOR(i,1,n){
		c[i]=a[i]-b[i];
		if(c[i]<0) v1.pb(c[i]);
		else v2.pb(-c[i]);
	}
	ll s=0;
	sort(v2.begin(),v2.end());
	int cn=v1.size();
	for(auto u:v1) s-=u;
	for(auto u:v2){
		if(s<=0) break;
		cn++;
		s+=u;
	}
	if(s<=0) cout<<cn<<endl;
	else cout<<"-1\n";
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define LL long long
#define PLL pair<LL, LL>
#define x first
#define y second 
using namespace std;
//const LL INF = (LL) 1e9 + 5;
//const LL MOD = (LL) 1e9 + 7;
const int MAXN = 200005;

int n, timer, col[MAXN], tin[MAXN], tout[MAXN];
LL ans[MAXN], sz[MAXN];
set<PLL> ord[MAXN];
vector<int> G[MAXN];

LL way(LL k) {
	return k * (k - 1) / 2 + k;
}

void dfs(int v, int p) {
	sz[v] = 1;
	tin[v] = ++timer;
	for (int to : G[v]) {
		if (to == p) continue;
		dfs(to, v);
		sz[v] += sz[to];
		
//		if (col[to] != col[v]) {
			LL tot = sz[to];
			auto it = ord[col[v]].lower_bound(PLL(tin[to], -1));
			while (it != ord[col[v]].end() && it->x <= tout[to]) {
				tot -= it->y;
				it = ord[col[v]].erase(it);
			}
			ans[col[v]] -= way(tot);
//		}
	}
	
	tout[v] = timer;
	ord[col[v]].insert(PLL(tin[v], sz[v]));
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> col[i];
		ans[i] = way(n);
	}
	for (int i = 1; i <= n - 1; i++) {
		int u, v;
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	dfs(1, 1);
	for (int i = 1; i <= n; i++) {
		if (i != col[1]) {
			LL tot = n;
			for (auto p : ord[i]) {
				tot -= p.y;
			}
			ans[i] -= way(tot);
		}
	}
	
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 68460
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n,k;
    cin >> n >> k;

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

    SORT(h);

    int ans = INF;
    REP(i, n-k+1){
        ans = min(ans, h[k+i-1]-h[i]);
    }
    pr(ans);
}

Measured memory_bytes: 640
def solve():
    [N, K] = [int(x) for x in input().split()]

    count = dict()
    for i in range(N):
        [a, b] = [int(x) for x in input().split()]
        count[a] = count.get(a, 0) + b

    idx = 0
    # print(count)

    keys = sorted(count.keys())

    K = K - 1
    for k in keys:
        n = count[k]
        if idx <= K < idx + n:
            return k
        idx += n

    return 0


if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 10592
#include <bits/stdc++.h>
using namespace std;
char a[1009][1009];
long long d[1008][1005],n,m,i,j;
long long dp(int i,int j){
    if(i==n&&j==m) return 1;
    if(i>n||j>m||a[i][j]=='#') return 0;
    if(d[i][j]!=-1) return d[i][j];
    return d[i][j]=(dp(i+1,j)+dp(i,j+1))%1000000007;
}
int main()
{
    cin>>n>>m;
    memset(d,-1,sizeof d);
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
            cin>>a[i][j];
    cout<<dp(1,1);
    return 0;
}


Measured memory_bytes: 9216
#include <stdio.h>
int main(void)
{
  int n;
  int a=0;
  int b;
  int c;

  scanf("%d",&n);

  c=n;
  while(c!=0)
  {
    b=c%10;
    a=a*10+b;
    c/=10;
  }

  if(a==n)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }

  return 0;
}


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

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

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

  long long min,max,sum=0;
  min = a[0];
  max = a[0];
  for(int i=0;i<n;i++){
    if(min > a[i])
      min = a[i];

    if(max < a[i])
      max =  a[i];

    sum += a[i];
  }

  cout << min << " " << max << " " << sum << endl;
  return 0;
}



Measured memory_bytes: 3172
#pragma GCC optimize("Ofast")

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

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    string n;
    cin >> n;

  if(    n[0] == '7' || n[1] == '7' ||n[2] == '7' ){
        cout << "Yes"<< "\n"; 
  }else{
      cout << "No"<< "\n";
  }




    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  long long a,b,n,x,t,res=0;
  cin >> a >> b >> n;
  x=min(b-1,n);
  res=(long long)floor(a*x/b);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll x;
	cin>>x;
	if(x<500)
	{
	    cout<<(5*(x/5));
	}
	else
	{
	    ll q1 = x/500;
	    x-=(500*q1);
	    ll q2 = x/5;
	    cout<<(q1*1000 + q2*5);
	}
}

Measured memory_bytes: 256
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	ll a , b ;
	cin>> a>> b ;
	ll ans= max({a+b , a-b , a*b});
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

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

using namespace std;

int main(){
    int N, K;
    int ans = 0;
    cin >> N >> K;
    int* sunuke = new int[N];
    rep(i, N) {
        sunuke[i] = 0;
    }

    rep(i, K) {
        int d;
        cin >> d;
        rep(j, d) {
            int tmp;
            cin >> tmp;
            sunuke[tmp-1]++;
        }
    }

    rep(i, N) {
        if (sunuke[i] == 0) ans++;
    }
    cout << ans << endl;

   return 0;
}



Measured memory_bytes: 3164
def bfs(arr, limit)
  queue = [*1..9]

  until queue.empty?
    x = queue.shift
    arr << x

    if arr.length == limit
      puts arr.last
      return
    end

    d = x % 10

    if d == 0
      queue << 10 * x
      queue << 10 * x + 1
    elsif d == 9
      queue << 10 * x + d - 1
      queue << 10 * x + d
    else
      queue << 10 * x + d - 1
      queue << 10 * x + d
      queue << 10 * x + d + 1
    end
  end
end

k = gets.to_i

bfs([], k)


Measured memory_bytes: 4884
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<pll> A(N);
    for(int i = 0; i < N;i++){
        cin >> A[i].first;
        A[i].second = i;
    }
    sort(A.rbegin(),A.rend());
    
    for(int i = 0; i < N;i++){
        if(A.front().second == i){
            cout << A[1].first << endl;
        }else{
            cout << A[0].first << endl;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 4736
/*
    OUTLAW!!
           ---SIDHU MOOSEWALA
                                */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1000000007;   
lli INF=1e17;
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,q,z,y,k,m;
const double pi1=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
//lli tot=0;
vector<lli> pf(string s) {
    int n = (int)s.length();
    vector<lli> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//map<ll,lli> dp;
//set<lli> s[100005];
//lli dp[3005][3005];
//ost s[500005];
ll freq[500005];
bool cmp(ll a,ll b)
{
    if(a.first==b.first)
    return a.second<b.second;
    return a.first<b.first;
}
//string sdp[3005][3005];
int main()
{
    ios_base::sync_with_stdio(0);
    lli a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;
    lli x1=a/c;
    lli x2=b/c;
    x2=x2-x1;
    lli y1=a/d;
    lli y2=b/d;
    y2=y2-y1;
    lli aa=(c*d);
    aa/=__gcd(c,d);
    lli z1=a/aa;
    lli z2=b/aa;
    z2-=z1;
    lli ans=b-a-(x2+y2-z2);
    cout<<ans;
    //for(int i=1;i<=n;i++)
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    A, B, C = map(int, input().split())

    if A == B == C and A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        print(-1)
    else:
        res = 0
        while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
            a = B // 2 + C // 2
            b = A // 2 + C // 2
            c = A // 2 + B // 2
            A, B, C = a, b, c
            res += 1

        print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main(){
  int H, W, K;
  int ans = 0;
  int num = 0;
  string S = "";
  cin >> H >> W >> K;
  vector<vector<int>> c(H, vector<int>(W));
  vector<int> binH(H);
  vector<int> binW(W);
  
  for (int i = 0; i < H; i++){
    binH[i] = pow(2, i);
  }
  for (int i = 0; i < W; i++){
    binW[i] = pow(2, i);
  }
   
  for (int i = 0; i < H; i++){
    S = "";
    cin >> S;
    for (int j = 0; j < W; j++){
      if(S.c_str()[j] == '.'){
        c[i][j] = 0;
      }else if(S.c_str()[j] == '#'){
        c[i][j] = 1;
      }
    }
  }
  int maxH = pow(2, H);
  int maxW = pow(2, W);
  
  for (int iH = 0; iH < maxH; iH++){
    for (int iW = 0; iW < maxW; iW++){
      num = 0;
      for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
          if(c[i][j] * ((iH / binH[i]) % 2) * ((iW / binW[j]) % 2) == 1){
            num += 1;
          }
        }
      }
      if (num == K) ans += 1;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4040
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100000, MAX_M = 100000;
int N, M;
int A[MAX_N], B[MAX_N];
                            
struct edge { int to, cost; };
const int MAX_V = 100000, INF = 1e9;

// Vの初期化を忘れない。
int V;
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int v, int u, int cost) {
  G[v].push_back((edge){u, cost});
  G[u].push_back((edge){v, cost});
}

void dfs(int v, vector<int> &vec) {
  vec.push_back(v);
  used[v] = true;

  for (int i = 0; i < G[v].size(); ++i) {
    int u = G[v][i].to;
    if (!used[u]) {
      dfs(u, vec); break;
    }
  }

  return;
}


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

  cin >> N >> M;
  rep(i, M) cin >> A[i] >> B[i];
  rep(i, M) {--A[i]; --B[i];}
  V = N;

  rep(i, M) add_edge(A[i], B[i], 1);

  vector<int> vec1, vec2;
  dfs(0, vec1);

  for (int i = 0; i < G[0].size(); ++i) {
    int u = G[0][i].to;
    if (!used[u]) {
      dfs(u, vec2); break;
    }
  }

  reverse(all(vec1));
  
  cout << vec1.size() + vec2.size() << endl;
  for (int i = 0; i < vec1.size(); ++i) {
    cout << vec1[i]+1 << (i+1 == vec1.size() && vec2.size() == 0 ? '\n' : ' ');
  }
  for (int i = 0; i < vec2.size(); ++i) {
    cout << vec2[i]+1 << (i+1 == vec2.size() ? '\n' : ' ');
  }

  return 0;
}



Measured memory_bytes: 7672
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<string, int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

#define MAX_N 200000

int par[MAX_N];
int rnk[MAX_N];

// 初期化
void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		rnk[i] = 0;
	}
}

// x の親を返す
int find(int x){
	if(par[x] == x){
		return x;
	}
	return par[x] = find(par[x]);
}

// x と y を併合する
void unite(int x, int y){
	int x_par = find(x);
	int y_par = find(y);
	if(x_par == y_par){
		return;
	}
	
	par[x_par] = y_par;
}

// x, y が同じグループか判定
bool same(int x, int y){
	return (find(x) == find(y));
}

int p[MAX_N];
bool flag[MAX_N];

int main(){
	
	while(true){
		
		int N, Q;
		
		cin >> N >> Q;
		if(N == 0){
			break;
		}
		flag[0] = true;
		for(int i = 1; i < N; i++){
			cin >> p[i];
			p[i]--;
			flag[i] = false;
		}
		vector<P> v;
		for(int i = 0; i < Q; i++){
			P p;
			cin >> p.first >> p.second;
			p.second--;
			if(p.first == "M"){
				if(flag[p.second]){
					continue;
				}
				flag[p.second] = true;
			}
			v.push_back(p);
		}
		init(N);
		for(int i = 1; i < N; i++){
			if(!flag[i]){
				unite(i, p[i]);
			}
		}
		reverse(v.begin(), v.end());
		long long int ans = 0;
		
		for(int i = 0; i < v.size(); i++){
			if(v[i].first == "M"){
				unite(v[i].second, p[v[i].second]);
			}else{
				ans += find(v[i].second) + 1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 9700
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> inline void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> inline void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }
TPL<TNM T> inline void UNIQUE(vector<T>& vec) { sort(ALL(vec)); vec.erase(unique(ALL(vec)), vec.end()); }
inline bool range2d(int x, int y, int W, int H) { return (x >= 0) && (y >= 0) && (W > x) && (H > y); }


int main(void) {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vec<int> x(N);
	vec<int> y(M);
	REP(i, N) {
		cin >> x[i];
	}
	REP(i, M) {
		cin >> y[i];
	}

	
	for (int z = X + 1; z <= Y; ++z) {
		bool war = false;
		REP(i, N) {
			if (x[i] >= z) {
				war = true;
			}
		}
		REP(i, M) {
			if (y[i] < z) {
				war = true;
			}
		}
		if (!war) {
			OUT("No War");
			return 0;
		}
	}
	OUT("War");
	return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			while (sc.hasNextBigDecimal()) {

				BigDecimal a = sc.nextBigDecimal();
				BigDecimal b = sc.nextBigDecimal();
				int n = sc.nextInt();

				// divide
				String s = String.valueOf(a.divide(b, n, RoundingMode.DOWN));

				// add
				char[] array = s.substring(s.indexOf(".") + 1).toCharArray();
				int result = 0;
				for (char c : array) {
					result += Integer.parseInt(String.valueOf(c));
				}

				System.out.println(result);
				result = 0;
			}
		} finally {
			sc.close();
		}
	}

}

Measured memory_bytes: 28756
n,k = map(int,input().split())
a = []
for i in range(n):
    m,o = map(int,input().split())
    a.append([m,o])
a.sort()
ans = 0
remain = k
for j in a:
    remain -= j[1]
    if remain <= 0:
        ans = j[0]
        break
print(ans)

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

int main(){
	int N, M, C;
	int r=0;
	cin >> N>> M>>C;
	int m= M;

	vector<int> B;
	
	while (M--){
		int b;
		cin>>b;
		B.push_back(b);
	}	
	while (N--){
		int sum=0;
		for (int i=0; i<m; ++i){
			int a;
			cin >>a;
			sum += a*B[i];}
		if (sum > C*-1)
			++r;
	}
	cout << r<< '\n'; 
}

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

const int maxn = 100010;
int n, q, cnt, op[maxn], u[maxn], v[maxn], fa[maxn];
long long m;

int find(int x) {
    return x == fa[x] ? x : fa[x] = find(fa[x]);
}

int main() {
    scanf("%d %lld %d", &n, &m, &q), cnt = n;
    for (int i = 0; i < n; i++) {
        fa[i] = i;
    }
    bool flag = 0;
    for (int i = 1; i <= q; i++) {
        scanf("%d %d %d", &u[i], &v[i], &op[i]);
        if (!op[i]) {
            u[i] = find(u[i]), v[i] = find(v[i]);
            if (u[i] == v[i]) continue;
            fa[u[i]] = v[i], cnt--, m--;
        } else {
            flag = 1;
        }
    }
    if (m == n - 1 && flag) {
        printf("No\n"), exit(0);
    }
    for (int i = 1; i <= q; i++) {
        if (op[i] && find(u[i]) == find(v[i])) {
            printf("No\n"), exit(0);
        }
    }
    if (cnt <= 2 && flag) {
        printf("No\n"), exit(0);
    }
    if (m > 1LL * cnt * (cnt - 1) / 2) {
        printf("No\n"), exit(0);
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	vector<int>a;
	int b[100005];
	for (int i = 0; i < 100005; i++)b[i] = 0;
	int c, d;
	int k;
	int n, m;
	int s, t;
	int x, y, z;

	scanf("%d", &n);

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

	sort(a.begin(), a.end());
	m = 0;
	for (int i = 0; i < n; i++){
		x = a[i];
		s = b[x - 2] + b[x - 1] + b[x];
		if (m < s)m = s;
		s = b[x - 1] + b[x] + b[x + 1];
		if (m < s)m = s;
		s = b[x] + b[x + 1] + b[x + 2];
		if (m < s)m = s;
	}

	printf("%d\n", m);

	return 0;
}



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

// flagを用いたバブルソート
int bubbleSort(int A[],int N) {
    int sw = 0;
    bool flag = 1;
    for(int i=0;flag;i++) {
        flag = 0;
        for(int j=N-1;j>=i+1;j--) {
            if(A[j]<A[j-1]) {
                swap(A[j],A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(void) {
    int A[100], N, sw;
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    sw = bubbleSort(A,N);

    for(int i=0;i<N;i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout <<sw << endl;

    return 0;
}


Measured memory_bytes: 3116
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			String str = sc.next();
			int n = sc.nextInt();
			int cnt = 0;
			for(int i=0; i<n; i++) {
				String input = sc.next();
				String search = input + input;
				if(search.indexOf(str) != -1) {
					cnt++;
				}
			}
			System.out.println(cnt);
			
			

			
		}
	}
}






Measured memory_bytes: 26404
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;



int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall


	ini(n);
	int tmp = 0;
	vi morty;
	vi morty1;
	FOR(i,0,n){
		ini(x);
		morty.push_back(x);
		tmp-=x;
	}
	FOR(i,0,n){
		ini(x);
		morty1.push_back(x);
		tmp+=x;
	}
	int tmp1=  0;
	FOR(i,0,n){
		if(morty[i]<morty1[i]){tmp1+=((morty1[i]-morty[i])+1)/2;}
	}
	if(tmp >= tmp1)out("Yes");
	else out("No");
	
	





	return 0;
}


Measured memory_bytes: 512
n, k = map(int, input().split())
ans = 0
for i in range(1, n+1):
  if i >= k:
    ans += 1/n
  else:
    for j in range(1, 20):
      if k <= i * int(pow(2, j)):
        ans += 1/n * pow(1/2, j)
        break
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include "fstream"
using namespace std;
//#define O freopen("in.txt","r",stdin);

int main()
{



 //freopen("in.txt","r",stdin);
	int rem;
	int n=101;
	cin>>n;
	//cout<<n;

	if(n%2==0)
		cout<<-1;
	else
	{
	    int i=1;
		rem=n;

		int cnt=0;
		while(rem)
		{
			cnt++;
			rem=rem*10+7;

			rem=rem%n;

		    if(cnt>n)
		    {
		    	cout<<-1;
		    	return 0;
		    }
		}
		cout<<cnt<<endl;
	}


	return 0;
}

Measured memory_bytes: 3608
$" = "";
my $input = <STDIN>;
chomp $input;
my @x = split //, $input;
for ($i=0; $i<3; $i++) {
  if ($x[$i]==1){
    $x[$i]=9;
  } else { 
    $x[$i]=1;
  }
}
print "@x\n";

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  double n,score[1000],sum,a2;
  while(true){
      sum=0;
      a2=0;
      cin>>n;
      if(n==0)
        break;
      for(int i=0;i<n;i++){
          cin>>score[i];
          sum+=score[i];
      }
      double avr=sum/n;
      for(int i=0;i<n;i++){
          a2+=pow(avr-score[i],2);
      }
      a2/=n;
      cout<<fixed<<setprecision(10)<<sqrt(a2)<<endl;
  }
}


Measured memory_bytes: 3276
x,y=gets.split.map &:to_i
#c=[*(0..x)].repeated_permutation(2).to_a
#p c
flg=false
(x+1).times do |i|
  com=(2*i+4*(x-i))
  if com == y
    flg=true
    break
  end
end
puts flg ? 'Yes' : 'No'

Measured memory_bytes: 14272
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    transform(s1.begin(), s1.end(), s1.begin(), ToUpper());
    dump(s1);

    transform(s2.begin(), s2.end(), s2.begin(), ToUpper());
    transform(s3.begin(), s3.end(), s3.begin(), ToUpper());

    char tmp1 = s1.at(0);
    char tmp2 = s2.at(0);
    char tmp3 = s3.at(0);

    cout << s1.at(0) << tmp2 << tmp3 << endl;

    return 0;
}


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

// グラフクラス
struct Graph {
    // 辺クラス
    // rev: 逆辺 (to, from) が G[to] の中で何番目の要素か
    // cap: 辺 (from, to) の容量
    struct Edge {
        int rev, from, to, cap;
        Edge(int r, int f, int t, int c) :
            rev(r), from(f), to(t), cap(c) {}
    };

    // 隣接リスト
    vector<vector<Edge>> list;

    // N: 頂点数
    Graph(int N = 0) : list(N) { }

    // グラフの頂点数取得
    size_t size() {
        return list.size();
    }
    
    // Graph インスタンスを G として，
    // G.list[v] を G[v] と書けるようにしておく
    vector<Edge> &operator [] (int i) {
        return list[i];
    }

    // 辺 e = (u, v) の逆辺 (v, u) を取得する
    Edge& redge(const Edge &e) {
        return list[e.to][e.rev];
    }

    // 辺 e = (u, v) に流量 f のフローを流す
    // e = (u, v) の流量が f だけ減少する
    // このとき逆辺 (v, u) の流量を増やす
    void run_flow(Edge &e, int f) {
        e.cap -= f;
        redge(e).cap += f;
    }

    // 頂点 from から頂点 to へ容量 cap の辺を張る
    // このとき to から from へも容量 0 の辺を張っておく
    void addedge(int from, int to, int cap) {
        int fromrev = (int)list[from].size();
        int torev = (int)list[to].size();
        list[from].push_back(Edge(torev, from, to, cap));
        list[to].push_back(Edge(fromrev, to, from, 0));
    }
};

struct FordFulkerson {
    static const int INF = 1 << 30; // 無限大を表す値を適切に
    vector<int> seen;

    FordFulkerson() { }

    // 残余グラフ上で s-t パスを見つける (深さ優先探索)
    // 返り値は s-t パス上の容量の最小値 (見つからなかったら 0)
    // f: s から v へ到達した過程の各辺の容量の最小値
    int fodfs(Graph &G, int v, int t, int f) {
        // 終端 t に到達したらリターン
        if (v == t) return f;

        // 深さ優先探索
        seen[v] = true;
        for (auto &e : G[v]) {
            if (seen[e.to]) continue;

            // 容量 0 の辺は実際には存在しない
            if (e.cap == 0) continue;

            // s-t パスを探す
            // 見つかったら flow はパス上の最小容量
            // 見つからなかったら f = 0
            int flow = fodfs(G, e.to, t, min(f, e.cap));

            // s-t パスが見つからなかったら次辺を試す
            if (flow == 0) continue;

            // 辺 e に容量 flow のフローを流す
            G.run_flow(e, flow);

            // s-t パスを見つけたらパス上最小容量を返す
            return flow;
        }

        // s-t パスが見つからなかったことを示す
        return 0;
    }

    // グラフ G の s-t 間の最大流量を求める
    // ただしリターン時に G は残余グラフになる
    int solve(Graph &G, int s, int t) {
        int res = 0;

        // 残余グラフに s-t パスがなくなるまで反復
        while (true) {
            seen.assign((int)G.size(), 0);
            int flow = fodfs(G, s, t, INF);

            // s-t パスが見つからなかったら終了
            if (flow == 0) return res;

            // 答えを加算
            res += flow;
        }

        // no reach
        return 0;
    }
};

int main() {
    // グラフの入力
    // N: 頂点数、M: 辺数
    int N, M;
    cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int u, v, c;
        cin >> u >> v >> c;

        // 容量 c の辺 (u, v) を張る
        G.addedge(u, v, c);
    }

    // Ford-Fulkerson 法
    FordFulkerson ff;
    int s = 0, t = N - 1;
    cout << ff.solve(G, s, t) << endl;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using Int = long long int;
using namespace std;

int main(){
  Int n, v[100], c[100];
  cin >> n;
  vector<Int> cv;
  for(Int i=0; i<n; i++){
    cin >> v[i];
  }
  for(Int i=0; i<n; i++){
    cin >> c[i];
  }
  for(Int i=0; i<n; i++){
    cv.push_back(v[i]-c[i]);
  }
  
  sort(cv.begin(), cv.end());
  
  Int sum = 0;
  for(Int i=cv.size()-1; i>=0; i--){
    if(cv[i] <= 0){
      break;
    }
    sum += cv[i];
  }
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
/**
 * @author pr4shan7 (प्रशांत)
 */
// #define _DEBUG

#ifndef _DEBUG
#define NDEBUG
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

// #define int long long
// #define double long double

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_set;
typedef unordered_set<int> usi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef set<int> si;
typedef long long ll;
#define pb push_back
#define endl '\n'
#define x first
#define y second
#define cai static_cast<int>
#define cad static_cast<double>
#define cal static_cast<long long>
#define tr(cont, itm) for (auto &&itm : cont)
#define rep(in, beg, sz) for (int in = beg; in < sz; in++)
#define rrep(in, sz, beg) for (int in = sz - 1; in >= beg; in--)
#define rtr(cont, itr) for (auto itr = cont.end() - 1; itr >= cont.begin(); itr--)
#define deb(z) cout << "// " << #z << " = " << z << endl;
const int N = 1e5 + 5;
const int INF = 1e9;
const int MV = 1e9 + 7;

int32_t main() {
  ios_base::sync_with_stdio(false);
  // cin.tie(NULL);

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

  ll n, a, b;
  cin >> n >> a >> b;
  a = min(a, b);
  b = max(a, b);
  ll dif = b - a;
  if (dif & 0x1) {
    ll ed = min(a - 1, n - b);
    dif--;
    cout << ed + 1 + (dif >> 1);
  } else {
    cout << (dif >> 1);
  }

  return 0;
}


Measured memory_bytes: 256