akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
string str;
int si;

int hoge(char x, int j) {
	static int ro[30];
	if (j == 0) for (int i = 0; i < 30; i++) ro[i] = 0;
	ro[0] = 1;
	if (x == 'z' + 1) return 0;
	if (ro[x - 'a']) {
		if (x != str[j]) return 0;
	}
	else {
		if ((x - 1) != str[j]) return 0;
		ro[x - 'a'] = 1;
	}

	return 1;
}

int main() {
	int ni, j, t;
	string temp;

	while (1) {
		vector <string> vst = {};
		int ans = 0;
		cin >> str;

		if (str == "#") break;

		si = str.size();
		ni = pow(2, si);

		for (int i = 0; i < ni;) {
			temp = str;
			for (j = 0; j < si; j++) {
				t = si - j - 1;
				if ((i >> t) & 1) temp[j]++;//temp[j] += (temp[j] == 'z') ? 0 : 1;
				if (!hoge(temp[j], j)) break;
			}
			i += 1 << t;
			if (j == si) {
				ans++;
				vst.push_back(temp);
			}
		}

		sort(vst.begin(), vst.end());

		cout << ans << endl;

		if (ans > 10) {
			for (int i = 0; i < 5 && i < vst.size(); i++) cout << vst.at(i) <<  endl;
			for (int i = vst.size() - 5; i < vst.size(); i++) cout << vst.at(i) << endl;
		}
		else for (int i = 0; i < ans; i++) cout << vst.at(i) << endl;

	}

	return 0;
}


Measured memory_bytes: 4388
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char *argv[])
{
	int x[10], y[10];
	int N;

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

	double d = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			d += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
		}
	}

	printf("%.9lf\n", d * 2 / N);

	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long r,c;
    cin>>r>>c;
    unsigned long long a;
    if(r==1 || c==1){
        a=1;
    } 
    else if(r%2&&c%2) a=((r*c)/2)+1;
    else a=r*c/2;
    cout<<a;
    return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int BIT[SIZE];
void ins(int x,int v){
    for(;x<SIZE;x+=x&-x)BIT[x]=max(BIT[x],v);
}
int qq(int x){
    int res=0;
    for(;x;x-=x&-x)res=max(BIT[x],res);
    return res;
}
int LIS(int a[],int N){
    static int d[SIZE];
    REP(i,N)
        d[i]=a[i];
    sort(d,d+N);
    int m=unique(d,d+N)-d;
    REP(i,N){
        a[i]=lower_bound(d,d+m,a[i])-d+1;
    }
    int an=0;
    REP(i,N){
        int me=qq(a[i]-1)+1;
        an=max(an,me);
        ins(a[i],me);
    }
    return an;
}
int aa[SIZE];
int main(){
    VPII pp;
    DRII(x1,y1);DRII(x2,y2);
    DRI(N);
    REP(i,N){
        DRII(x,y);
        if((x-x1)*(LL)(x-x2)>0)continue;
        if((y-y1)*(LL)(y-y2)>0)continue;
        pp.PB(MP(abs(x-x1),abs(y-y1)));
    }
    if(x1==x2||y1==y2){
        if(SZ(pp)==1)printf("%.15f\n",100.*(abs(x1-x2)+abs(y1-y2))-20+10*acos(-1));
        else printf("%.15f\n",100.*(abs(x1-x2)+abs(y1-y2)));
        return 0;
    }
    sort(ALL(pp));
    REP(i,SZ(pp))aa[i]=pp[i].S;
    int center=LIS(aa,SZ(pp));
    if(center<min(abs(x1-x2),abs(y1-y2))+1){
        printf("%.15f\n",100.*(abs(x1-x2)+abs(y1-y2))-center*(20-5*acos(-1)));
    }
    else{
        printf("%.15f\n",100.*(abs(x1-x2)+abs(y1-y2))-(center-1)*(20-5*acos(-1))-20+10*acos(-1));
    }
    return 0;
}


Measured memory_bytes: 10992
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b)
{
    return *(long int *)a - *(long int *)b;
}
int dis(const void *a, const void *b)
{
    return *(long int *)b - *(long int *)a;
}
int main()
{
    int n;
    int a;
    int i;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &a);
        if (a % 2 == 0 && (a % 3) * (a % 5) != 0)
        {
            break;
        }
    }
    if (i == n)
    {
        printf("APPROVED");
    }
    else
    {
        printf("DENIED");
    }
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var p = cin.ReadIntArray(n);
            var ans = 0;
            for(int i = 1; i < n - 1; i++)
            {
                var max = Max(p[i - 1], p[i + 1]);
                var min = Min(p[i - 1], p[i + 1]);
                if (max > p[i] && min < p[i])
                {
                    ans++;
                }
            }
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[2] * 10 + a[1] + a[0]);
        sc.close();
    }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var r = Console.ReadLine().Split();
            for (int i = 0; i < N; i++)
            {
                Console.Write(r[0][i].ToString() + r[1][i].ToString());
            }
        }
    }
}

Measured memory_bytes: 13140
//accept
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define mp make_pair
typedef long long ll;
using namespace std;
const int inf=1025352128;
int n,d;
int a[200005];
int f[200005];
int rk[200005];
vector <pair<ll,pair<int,int> > >vec;

int find(int x)
{
	if(f[x]==x)
	{
		return x;
	}
	else
	{
		rk[x]=1;
		return f[x]=find(f[x]);
	}
}

void merge(int x,int y)
{
	x=find(x);
	y=find(y);
	if(rk[x]==rk[y])
	{
		if(rand()&1)
		{
			rk[x]++;
			f[y]=x;
		}
		else
		{
			rk[y]++;
			f[x]=y;
		}
		return;
	}
	if(rk[x]>rk[y])
	{
		f[y]=x;
		return;
	}
	if(rk[y]>rk[x])
	{
		f[x]=y;
		return;
	}
}

void init()
{
	for(int i=0;i<n;i++)
	{
		f[i]=i;
		rk[i]=1;
	}
}

inline ll cost(int i,int j)
{
	return 1LL*a[i]+1LL*a[j]+1LL*(j-i)*d;
}

void add(int l,int r)
{
	if(r-l<=1) return;
	int m=l+r>>1;
	ll minx=inf,tl,tr;
	for(int i=l;i<m;i++)
	{
		if(1LL*a[i]-1LL*i*d<minx)
		{
			minx=1LL*a[i]-1LL*i*d;
			tl=i;
		}
	}
	minx=1LL*inf*inf;
	for(int i=m;i<r;i++)
	{
		if(1LL*a[i]+1LL*i*d<minx)
		{
			minx=1LL*a[i]+1LL*i*d;
			tr=i;
		}
	}
	for(int i=l;i<m;i++)
	{
		vec.push_back(mp(cost(i,tr),mp(i,tr)));
	}
	for(int i=m;i<r;i++)
	{
		vec.push_back(mp(cost(tl,i),mp(tl,i)));
	}
	add(l,m);
	add(m,r);
}

int main()
{
	scanf("%d%d",&n,&d);
	init();
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
	}
	add(0,n);
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	ll res=0;
	int s=1;
	for(int i=0;i<vec.size();i++)
	{
		pair<ll,pair<int,int> > x=vec[i];
		if(find(x.second.first)==find(x.second.second)) continue;
		merge(x.second.first,x.second.second);
		s++;
		res+=x.first;
		if(s==n) break;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 70240
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))

    res = 0
    bk = 5
    for i in range(n):
        res += b[a[i]-1]
        if a[i] == bk + 1:
            res += c[a[i]-2]
        bk = a[i]

    print(res)

if __name__ == '__main__':
    main()

    

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String str = sc.nextLine();
			if (str.equals("-"))
				break;
			int m = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < m; i++) {
				String nextStr = sc.nextLine();
				str = new StringBuilder()
						.append(str.substring(Integer.parseInt(nextStr)))
						.append(str.substring(0, Integer.parseInt(nextStr)))
						.toString();
			}
				System.out.println(str);
		}
		sc.close();
	}
}

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

using namespace std;

typedef pair<int,int> pii;


vector<int> d[10001];
bool passed[10001];

void dfs(int s){
	if(passed[s])
		return;
	passed[s]=true;
	for(int i = 0; i < d[s].size(); i++){
		int to=d[s][i];
		dfs(to);
	}
}

int main(){

	int n;
	while(cin>>n){
		for(int i = 0; i < 10001; i++){
			d[i].clear();
			passed[i]=false;
		}
		int cnt[10001];
		fill(cnt,cnt+10001,0);
		vector<pii> v;
		int ss;
		for(int i = 0; i < n; i++){
			pii p;
			string str;
			cin>>str;
			p.first=str[0]-'0';
			p.second=str[1]-'0';
			v.push_back(p);
			cnt[p.first]++;
			cnt[p.second]++;
			ss=p.first;
			d[p.first].push_back(p.second);
			d[p.second].push_back(p.first);
		}

		dfs(ss);
		bool f=false;
		for(int i = 0; i <= 6; i++){
			if(cnt[i]==0||passed[i])
				continue;
			else{
				f=true;
				break;
			}
		}
		if(f){
			cout<<"No"<<endl;
			continue;
		}
		int cc=0;
		for(int i = 0; i <= 6; i++){
			if(cnt[i]%2!=0){
				cc++;
			}
		}
		if(cc==2){
			cout<<"Yes"<<endl;
		}
		else if(cc==0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}

	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {

  ll D; cin >> D;
  vector<ll> c(26);
  REP(i, 26)cin >> c[i];
  vector<vector<ll>> s(D, vector<ll>(26));
  REP(i, D)REP(j, 26)cin >> s[i][j];
  vector<ll> last(26, 0);

  // vector<ll> t(D);
  // REP(i, D){
  //   cin >> t[i];
  //   t[i]--;
  // }

  ll ans = 0;


  REP(i, D){
    ll max_ = 0;
    ll q;
    REP(k, 26){
      //i日目に増えるスコア
      ll score;
      score = s[i][k];
      last[k] = i+1;
      // cout << score << endl;

      //i日目に減るスコア
      ll bye_score = 0;
      REP(j, 26){
        bye_score += c[j] * (i+1-last[j]);
      }
      if(score - bye_score > max_){
        max_ = score - bye_score;
        q = k+1;
      } 
      max_ = max(max_, score - bye_score);
      // cout << ans << endl;
      // break;
    }
    cout << q << endl;
    ans += max_;
    // cout << ans << endl;
  }
  


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3708
n = int(input())
a = [0]*n
x = []
y = []
aa = 0
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        b,c = map(int,input().split())
        x.append(b)
        y.append(c)

for i in range(2**n):
    sw = [0]*n
    for j in range(n):
        if (i >> j) & 1:
            sw[j] = 1
    s = 0
    q = 1
    for j in range(n):
        if sw[j] == 1:
            for k in range(a[j]):
                if sw[x[s]-1] != y[s]:
                    q = 0
                    break
                s += 1
        else:
            s += a[j]

    if q == 1:
        su = sum(sw)
        aa = max(aa,su)
print(aa)

Measured memory_bytes: 45532
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>

struct Edge {
	int from, to, cost;
};
int main(){
	const auto comparator = [](std::pair<int, int> a, std::pair<int, int> b) { return a.second > b.second; };
	using Queue = std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, decltype(comparator)>;
	while (true) {
		int n, m, c; std::cin >> n >> m >> c; if (n == 0 && m == 0 && c == 0) break;
		std::vector<std::vector<Edge>> nodes(n);
		for (auto i = 0; i < m; ++i) {
			int f, t, cost; std::cin >> f >> t >> cost; --f, --t;
			nodes[f].push_back(Edge{ f, t, cost });
		}
		std::vector<std::vector<int>> min_cost(2, std::vector<int>(n, INT_MAX));
		Queue queue(comparator);
		min_cost[0][0] = 0;
		queue.emplace(0, 0);
		while (!queue.empty()) {
			const auto top = queue.top(); queue.pop();
			if (min_cost[0][top.first] != top.second) continue;
			for (const auto e : nodes[top.first]) {
				if (min_cost[0][e.to] > e.cost + top.second) {
					min_cost[0][e.to] = e.cost + top.second;
					queue.emplace(e.to, e.cost + top.second);
				}
			}
		}
		for (auto i = 1; i <= n; ++i) {
			const auto current = i & 1;
			const auto prev = current ^ 1;
			std::copy(min_cost[prev].begin(), min_cost[prev].end(), min_cost[current].begin());
			for (const auto node : nodes) {
				for (const auto e : node) {
					if (min_cost[current][e.to] > min_cost[prev][e.from]) {
						min_cost[current][e.to] = min_cost[prev][e.from];
						queue.emplace(e.to, min_cost[current][e.to]);
					}
				}
			}
			while (!queue.empty()) {
				const auto top = queue.top(); queue.pop();
				if (min_cost[current][top.first] != top.second) continue;
				for (const auto e : nodes[top.first]) {
					if (min_cost[current][e.to] > e.cost + top.second) {
						min_cost[current][e.to] = e.cost + top.second;
						queue.emplace(e.to, e.cost + top.second);
					}
				}
			}
			if (min_cost[current].back() <= c) {
				std::cout << i << '\n';
				break;
			}
		}
	}
}



Measured memory_bytes: 3152
using System;

namespace Calculation_of_Area
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            double a = double.Parse(input[0]);
            double b = double.Parse(input[1]);
            double n = 3.305785;
            Console.WriteLine(a * b / n);
            

        }
    }
}



Measured memory_bytes: 15960
n,a,b = map(int,input().split())
ans = pow(2,n,1000000007)

bunbo = 1
bunsi = 1
for i in range(1,a+1):
    bunbo *= i
    bunbo = bunbo%1000000007
    bunsi *= (n+1-i)
    bunsi = bunsi%1000000007
bunbo = pow(bunbo,1000000005,1000000007)
nca = (bunsi*bunbo)%1000000007

bunbo = 1
bunsi = 1
for i in range(1,b+1):
    bunbo *= i
    bunbo = bunbo%1000000007
    bunsi *= (n+1-i)
    bunsi = bunsi%1000000007
bunbo = pow(bunbo,1000000005,1000000007)
ncb = (bunsi*bunbo)%1000000007

ans = (ans-1-nca-ncb)%1000000007
print(ans)

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong x;
	cin >> x;
	string s[7] = {"thu", "fri", "sat", "sun", "mon", "tue", "wed"};

	cout << s[x%7] << endl;

	return 0;
}


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

bool vis[100001];
int f[100001];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	vis[1] = true;
	f(i, 1, n + 1)f[i] = 1;
	while (m--) {
		int a, b;
		scanf("%d%d", &a, &b);
		if (vis[a])vis[b] = true;
		--f[a];
		++f[b];
		if (!f[a])vis[a] = false;
	}
	int an = 0;
	f(i, 1, n + 1)an += vis[i];
	printf("%d", an);
}

Measured memory_bytes: 768
#include <iostream>
#include<stdio.h>
#include<iomanip>
#include<math.h>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
	double r;
scanf("%lf",&r);
printf("%.5f %.5f\n", r*r*M_PI, 2*r*M_PI);

return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)

using namespace std;

void solve(long long x, long long y){
    if(abs(x) == abs(y)){
        cout << 1 << endl;
    }else if(abs(x) < abs(y)){
        cout << (x<0 ? 1 : 0)+(abs(y)-abs(x))+(y<0 ? 1 : 0) << endl;
    }else if(abs(x) > abs(y)){
        cout << (x>0 ? 1 : 0)+(abs(x)-abs(y))+(y>0 ? 1 : 0) << endl;
    }
}

int main(){
    long long x;
    scanf("%lld",&x);
    long long y;
    scanf("%lld",&y);
    solve(x, y);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int x[5];
  for(int i = 0; i < 5; i++){
    cin >> x[i];
  }
  for(int i = 0; i < 5; i++){
    if(x[i] == 0){
      cout << i + 1 << endl;
      return 0;
    }
  }
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,n,m) for(ll i = (n); i <(m); i++)
#define rrep(i,n,m) for(ll i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using tiii = tuple<ll, ll, ll>;
const int MAX_M = 5000;
const ll INF = 10000000000000;

vector<tiii> edges;
vector<int> to[2505];
vector<int> rto[2505];
bool reachable[2505];
bool reachable_rev[2505];

void dfs(int v)
{
    // cout << v << endl;
    if (reachable[v]) return;
    reachable[v] = true;
    for (int u : to[v])
        dfs(u);
}

void dfs_rev(int v)
{
    if (reachable_rev[v]) return;
    reachable_rev[v] = true;
    for (int u : rto[v])
        dfs_rev(u);
}

int main()
{
    ll n, m, p;
    cin >> n >> m >> p;

    rep(i, 0, m)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        edges.emplace_back(a, b, c - p);
        to[a].push_back(b);
        rto[b].push_back(a);
    }

    dfs(0);
    dfs_rev(n-1);

    vector<ll> dis(n, -INF);
    vector<bool> divers(n, false);

    dis[0] = 0;
    rep(i, 0, n)
    {
        for (auto edge: edges)
        {
            ll from, to, cost;
            tie(from, to, cost) = edge;

            if (dis[from] != -INF and dis[to] < dis[from] + cost)
            {
                dis[to] = dis[from] + cost;
                if (i == n - 1)
                    divers[to] = true;
            }
        }
    }

    bool divergence = false;
    rep(i, 0, n)
    if(reachable[i] and reachable_rev[i] and divers[i])
        divergence = true;

    if (dis[n - 1] == -INF or divergence)
        cout << -1 << endl;
    else
        cout << max(0LL, dis[n-1]) << endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define DBG(x) cerr << #x << " = " << x << endl

using namespace std;
typedef long long LL;

int main(int argc, char **argv) {
    string s;
    while (cin >> s) {
        for (auto &c : s) {
            if (c == '?') c = 'D';
        }
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3728
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

ll N, M, V, P;

bool isOK(vector<ll> A, ll key) {
    if (key < P)
        return true;
    A[key] += M;
    ll tmp = A[key];
    if (A[P - 1] > tmp)
        return false;
    ll score = 0;
    score += (P - 1) * M;
    score += (N - key) * M;
    for (int i = P - 1; i < key; i++) {
        score += min(M, max(0LL, tmp - A[i]));
    }

    return score >= M * V;
}

int main() {
    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }

    sort(all(A), greater<ll>());
    ll ok = -1, ng = N;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (isOK(A, mid))
            ok = mid;
        else
            ng = mid;
    }

    cout << ok + 1 << endl;
    return 0;
}

Measured memory_bytes: 4844
#include<stdio.h>

int main()
{
    int x,y,z;

    scanf("%d%d%d",&x,&y,&z);

    x=x+y;
    y=x-y;
    x=x-y;

    x=x+z;
    z=x-z;
    x=x-z;

    printf("%d %d %d",x,y,z);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    int n,m;cin>>n>>m;int ans=0;vector<int> k(m),s,p(m);
//入力
    for(int i=0;i<m;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            int a;cin>>a;
            s.push_back(a);
        }
    }
    for(int i=0;i<m;i++) cin>>p[i];
//計算
    for(int bit=0;bit<(1<<n);bit++){
        vector<int> sc;
        for(int i=0;i<n;i++){//scにbitの二進数の場所を入れた
            if(bit&(1<<i)) sc.push_back(i+1);
        }
        //cout<<"scの中身が{ ";
        //for(int i=0;i<sc.size();i++) cout<<sc[i]<<", ";
        //cout<<"}のとき"<<endl; 

        int point=0,sum=0;
        for(int i=0;i<m;i++){//iはk,p,sの場所
            int cnt=0;
            //cout<<"　i="<<i<<"の時sの中身は{";
            for(int j=0;j<k[i];j++){
                //cout<<s[j+point]<<", ";
                for(int l=0;l<sc.size();l++){
                    if(sc[l]==s[j+point]){
                        cnt++;
                    }
                }
            }
            //cout<<"}でcntは"<<cnt<<"となりp["<<i<<"]="<<p[i]<<"となる"<<endl;
            point+=k[i];
            if(cnt%2==p[i]) sum++;
        }
        if(sum==m) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  string s; cin >> s;
  int sz = s.size();
  if (s.front() == s.back()) --sz;
  if (sz%2) cout << "First\n";
  else cout << "Second\n";
  return 0;
}


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

int main(void){
    int n;
    string s,t,t1;
    cin >> n >> s;
    t = s.substr(0,n/2);
    t1 = s.substr(n/2,n/2);
    if(t == t1 && n % 2 == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++){
    cin >> v[i];
  }
  sort(v.rbegin(),v.rend());
  long long ret = 1;
  for(int i=0; i<n; i++){
    int j = v[i] - i/4;
    if(j > 0) ret += j;
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int N;
int a[410];
vector<int> acc = {0};
int memo[410][410];

int rec(int i, int j) {
    if (memo[i][j]!=-1) return memo[i][j];
    if (i==j) return memo[i][j] = 0;
    int res = 1e14;
    for (int k=i; k<j; k++) res = min(res, rec(i, k)+rec(k+1, j)+acc[j+1]-acc[i]);
    return memo[i][j] = res;
}

signed main() {
    cin >> N;
    rep(i, N) cin >> a[i];
    rep(i, N) acc.pb(acc[acc.size()-1]+a[i]);
    rep(i, N) rep(j, N) memo[i][j] = -1;
    cout << rec(0, N-1) << endl;
}

Measured memory_bytes: 1536
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/abc082/editorial.pdf
　　　https://atcoder.jp/contests/abc082/submissions/3930644
・メモリ節約のため、dictをsetにした。
・さらに使い終わった1つ前はもういらないので消すことにした。
・あとちょっと初期化調整
"""

S = input()
X, Y = map(int, input().split())

S2 = []
tmp = 0
# 連続するF毎にまとまるように文字列Sを変形させる
for i in range(len(S)):
    if S[i] == 'F':
        tmp += 1
    # T毎に区切る
    else:
        S2.append(tmp)
        tmp = 0
S2.append(tmp)

# あるかないか分かればいいので、dictじゃなくてsetにする
dpx = [set() for _ in range(len(S2))]
dpy = [set() for _ in range(len(S2))]
# xの初期化：step0は右移動固定
dpx[0].add(S2[0])
# yの初期化：step0は何も動かないので座標0
dpy[0].add(0)
for i in range(1, len(S2)):
    # 左右に移動する
    for v in dpx[i-1]:
        if i % 2 == 0:
            # 到達可能な位置から+-した位置に送る
            dpx[i].add(v-S2[i])
            dpx[i].add(v+S2[i])
        else:
            # yをやる時はxはそのまま
            dpx[i].add(v)
    # 1つ前は使い終わったので削除
    dpx[i-1] = set()
    # 上下に移動する
    for v in dpy[i-1]:
        if i % 2 == 1:
            dpy[i].add(v-S2[i])
            dpy[i].add(v+S2[i])
        else:
            dpy[i].add(v)
    dpy[i-1] = set()

# 最後のstepでXとYが到達可能ならOK
if X in dpx[len(S2)-1] and Y in dpy[len(S2)-1]:
    print('Yes')
else:
    print('No')


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

int m,n,k;

int main()
{
    cin>>m>>n>>k;
    if(k%m==0||k%n==0)
    {
        cout<<"Yes";
        return 0;
    }
    for(int i=1;i<=m;i++)
    {
        int tmp=m-2*i;
        if(i*n<k&&tmp>0&&(k-i*n)%tmp==0&&(k-i*n)/tmp<=n)
        {
            cout<<"Yes";
            return 0;
        }
        if(i*n>k&&tmp<0&&(i*n-k)%(-tmp)==0&&(i*n-k)/(-tmp)<=n)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}


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

const int mod = 100000;

int main(){
    int n, m, s;
    while(cin >> n >> m >> s, n+m+s){
        vector<vector<int>> dp(n*n+1, vector<int>(s+1,0));
        dp[0][0] = 1;
        for(int i = 1; i <= m; i++){  // 今採用することを検討している数
            vector<vector<int>> dp2 = dp;
            for(int j = n*n; j >= 1; j--){ // iを含めて、選択した要素数
                for(int k = s; k >= 0; k--){ // 今iを採用した時の選択した要素数の総和
                    if(k >= i)  dp2[j][k] = (dp2[j][k] + dp[j-1][k-i])%mod; // iを使う
                }
            }
            dp = dp2;
        }
        cout << dp[n*n][s] << endl;
    }
    return 0;
}


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

int main(){
  vector<int> vec(3);
  for(int i=0; i<3; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  
  int ans = 0;
  
  int a = (vec.at(2) - vec.at(1) ) %2;
  int b = (vec.at(2) - vec.at(0) ) %2;
  
  if(a == 0 && b == 0){
    ans = (vec.at(2) - vec.at(1) ) /2 + (vec.at(2) - vec.at(0) ) /2;
  }
  else if(a == 1 && b == 1){
    ans = (vec.at(2) - vec.at(1) -1) /2 + (vec.at(2) - vec.at(0) -1) /2 +1;
  }
  else if(a == 0 && b == 1){
    ans = (vec.at(2) - vec.at(1) ) /2 + (vec.at(2)+1 - vec.at(0) ) /2 +1;
  }
  else{
    ans = (vec.at(2)+1 - vec.at(1) ) /2 + (vec.at(2) - vec.at(0) ) /2 +1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		while ((line = br.readLine()) != null) {
			int a, b, gcm;
			a = Integer.parseInt(line.substring(0, line.indexOf(" ")));
			b = Integer.parseInt(line.substring(line.indexOf(" ") + 1));
			gcm = getGCD(a, b);
			System.out.println(gcm + " " + getLCM(a, b, gcm));
		}
	}

	public static int getGCD(int a, int b) {

		int mod;
		int gt = a >= b ? a : b;
		int lt = a <= b ? a : b;

		do {
			mod = gt % lt;
			gt = lt;
			lt = mod;
		} while (mod != 0);

		return gt;
	}

	public static long getLCM(int a, int b, int gcm) {
		return (long) a * (long) b / gcm;
	}
}

Measured memory_bytes: 16868
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	count := 0
	ans := 0
	for _, r := range s {
		if r == '0' {
			if count > 0 {
				ans += 2
			}
			count--
		} else {
			if count < 0 {
				ans += 2
			}
			count++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1280
#include<cstdio>
#include<iostream>
using namespace std;
const int N=1e2+10;
const int K=1e5+10;
int n,k,a[N];bool dp[K][2];
int main(){
	scanf("%d%d",&n,&k);
	for(register int i=1;i<=n;i++)scanf("%d",&a[i]);
	dp[0][0]=false;dp[0][1]=true;
	for(register int i=1;i<=k;i++){
		dp[i][0]=false;dp[i][1]=true;
		for(register int j=1;j<=n&&a[j]<=i;j++)
			dp[i][0]|=dp[i-a[j]][1],dp[i][1]&=dp[i-a[j]][0];
	}
	if(dp[k][0])puts("First");else puts("Second");
	return 0;
}

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

int func(int N){
    int sum=0;
    while(N){
        sum+=N%10;
        N/=10;
    }
    return sum;
}

int main(){
    int N; cin>>N;
    if(N%func(N)==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int64_t mod = 1000000007;

int64_t ctoi(char c) {
  assert(c - '0' >= 0 && c - '0' <= 9);
  return c - '0';
}

int main(void) {
  std::string s;
  cin >> s;
  int64_t dp[100001][13] = {};
  if (s.back() == '?') {
    for (int64_t i = 0; i < 10; i++) {
      dp[0][i] = 1;
    }
  } else {
    dp[0][ctoi(s.back())] = 1;
  }

  int64_t exp_mod = 1;
  for (int64_t i = s.size() - 2; i >= 0; i--) {
    exp_mod *= 10;
    exp_mod %= 13;
    int64_t a = s.size() - i - 1;
    if (s[i] == '?') {
      for (int64_t digit = 0; digit <= 9; digit++) {
        int64_t add_mod = (exp_mod * digit % 13);
        for (int b = 0; b < 13; b++) {
          int64_t target = (add_mod + b) % 13;
          dp[a][target] += dp[a - 1][b];
          dp[a][target] %= mod;
        }
      }

    } else {
      int64_t digit   = ctoi(s[i]);
      int64_t add_mod = (exp_mod * digit % 13);
      for (int64_t b = 0; b < 13; b++) {
        int64_t target = (add_mod + b) % 13;
        dp[a][target] += dp[a - 1][b];
        dp[a][target] %= mod;
      }
    }
    }

  cout << dp[s.size() - 1][5] % mod << endl;

  return 0;
}


Measured memory_bytes: 10624
N,*as=$<.read.split.map(&:to_i)

count = 0
i = 0
while i < N
    n = as[i]
    i += 1 while i < N && n == as[i]
    if i == N
        count += 1
        break
    end
    if n < as[i]
        while i < N && n <= as[i]
            n = as[i]
            i += 1
        end
    else
        while i < N && as[i] <= n
            n = as[i]
            i += 1
        end
    end
    count += 1
end

puts count

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  
  int total = 700;
  if (S.at(0)=='o') total+=100;
  if (S.at(1)=='o') total+=100;
  if (S.at(2)=='o') total+=100;
 
  cout << total << endl;
  
  return 0;
}

Measured memory_bytes: 256
// 2011/07/20 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int cnt[10];
		for(int i=0; i<10; i++)
			cnt[i] = 0;		// 0ツづ渉可甘コツ可サ

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

		for(int i=0; i<10; i++)
			if(cnt[i]==0){
				cout << '-' << endl;
			}
			else{
				for(int j=0; j<cnt[i]; j++)
					cout << '*';
				cout << endl;
			}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> k(m), p(m);
    vector<vector<int>> s(m, vector<int>(n, 0));
    for (int i = 0; i < m; i++) {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++) {
            cin >> s[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 0; i < (1<<n); i++) {
        bitset<10> sw(i);
        bool all = true;
        for (int j = 0; j < m; j++) {
            int cnt = 0;
            for (int l = 0; l < k[j]; l++) {
                cnt += sw[s[j][l]-1];
            }
            if (cnt%2 != p[j]) {
                all = false;
                break;
            }
        }
        if (all) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
 {  fast();
	string s,t;
	cin>>s>>t;
	if(t.length()==s.length()+1&&t.substr(0,s.length())==s)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	  
	}

Measured memory_bytes: 3652
n=int(input())
a=input()
b=input()
c=input()
ans=0
for i in range(n):
  aa,bb,cc=a[i],b[i],c[i]
  if aa==bb:
    if cc!=aa:
      ans+=1
  else:
    if cc!=aa and cc!=bb:
      ans+=2
    else:
      ans+=1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

ll n,w;
vector<ll> wei(110),val(110);
vector<vector<ll>> dp(110,vector<ll>(100010));
//ll dp[110][100010];

int main(){
    cin>>n>>w;
    rep(i,n) cin>>wei[i]>>val[i];

    rep(i,n){
        for(int j=0;j<=w;j++){
            if(j>=wei[i]) chmax(dp[i+1][j],dp[i][j-wei[i]]+ val[i]);
            chmax(dp[i+1][j],dp[i][j]);
        }
    }
    cout<<dp[n][w]<<"\n";
    return 0;
}

Measured memory_bytes: 90140
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <deque>

using namespace std;


int main()
{
    ios_base::sync_with_stdio(0);
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (u == s)
        a--;
    else
        b--;
    cout << a << ' ' << b;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    ll k;cin>>k;

    ll x = 0;
    rep(i, 1, 1000001){
        x *= 10;
        x += 7;
        x %= k;
        if (x == 0){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3664
package main

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

func main() {
	N, K := ReadInt(), ReadInt()
	S := ReadString()

	nums := make([]int, 0)
	prev := byte('1')
	cnt := 0
	for i := 0; i < N; i++ {
		if S[i] != prev {
			nums = append(nums, cnt)
			prev = S[i]
			cnt = 1
		} else {
			cnt++
		}
	}
	nums = append(nums, cnt)
	if prev == '0' {
		nums = append(nums, 0)
	}

	ans := 0
	sum := 0
	size := 2*K + 1
	r := 0
	for l := 0; l < len(nums); {
		for r < len(nums) && r-l < size {
			sum += nums[r]
			r++
		}
		if sum > ans {
			ans = sum
		}

		l++
		if l < len(nums) {
			sum -= nums[l-1]
		}
		l++
		if l < len(nums) {
			sum -= nums[l-1]
		}
		if r < l {
			r = l
		}
	}

	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

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


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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

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

const ll INF = 2e18;
const int MOD = 1e9 + 7;
const int MAXN = 5e5 + 5;

int K;
string s;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> K >> s;
	for(int i=0; i<min((int)s.size(), K); i++) cout << s[i];
	if(K < s.size()) cout << "...";
}

Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
        	int N = sc.nextInt();
        	int M = sc.nextInt();
        	long[] result=new long[N];
        	for (int i=0;i<N;i++) result[i]=0;
        	
        	for (int i = 0;i < M;i++) {
        		int a = sc.nextInt();
        		int b = sc.nextInt();
        		result[a-1]++;
        		result[b-1]++;
        	}
        	
        	boolean errchk = false;
        	for ( int i =0; i < N; i++) {
        		if (result[i]%2!=0) {
        			errchk=true;
        			break;
        		}
        	}
        	if (errchk) System.out.println("NO");
        	else System.out.println("YES");
        	
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 49672
//Love and Freedom.
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set> 
#define pa pair<int,int>
#define mp make_pair
#define ll long long
#define inf 20021225
#define N 200010
using namespace std;
int read()
{
	int s=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return f*s;
}
int a[N],n;
set<pa> st; int gg; 
void add(int x,int v)
{
	if(x<1)	return void(gg=1); pa tmp=*st.lower_bound(mp(x,0));
	if(tmp.first!=x)	st.insert(tmp=mp(x,0));
	else
	{
		st.erase(tmp); tmp.second++;
		if(tmp.second>=v)	add(x-1,v);
		else	st.insert(tmp);
	}
	while(st.upper_bound(tmp)!=st.end())
		st.erase(*st.rbegin());
}
int check(int x)
{
	gg=0; st.clear();
	for(int i=1;i<=n;i++)	if(a[i]<=a[i-1])
		add(a[i],x-1);
	if(gg)	return 0;
	return 1;
}
int solve()
{
	int l=2,r=n,ans=0;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(check(mid))	ans=mid,r=mid-1;
		else	l=mid+1;
	}
	return ans;
}
int main()
{
	n=read(); int flag=1; for(int i=1;i<=n;i++)	a[i]=read(),flag&=(a[i]>a[i-1]);
	if(flag)	return puts("1"),0; printf("%d\n",solve());
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
typedef long long LL;


int main()
{	 
	int i;
	LL a, b, c, d, x[4], ans;
		
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	x[0] = a * c, x[1] = a * d;
	x[2] = b * c, x[3] = b * d;
	for(ans = x[0], i = 1; i < 4; i++){
		if(x[i] > ans) ans = x[i];
	}
	printf("%lld\n", ans);
		
	return 0;
}

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


vector<bool> seen;
vector<int> first_order;
vector<int> last_order;

void dfs(const vector<vector<int>> &G, int v, int& time){
	first_order[v] = time++;
	seen[v] = true;
	for(auto next_v:G[v]){
		if(seen[next_v]) continue;
		dfs(G, next_v, time);
	}
	last_order[v] = time++;
}

int main()
{
	int n;
	cin>>n;
	vector<vector<int>> G(n+1);
	for(int i=1;i<n+1;i++){
		int a, b, c;
		cin>>a>>b;
		for(int j=0;j<b;j++){
			cin>>c;
			G[a].push_back(c);
		}
	}
	seen.assign(n+1, false);
	first_order.resize(n+1);
	last_order.resize(n+1);
	int time = 1;
	for(int i=1;i<n+1;i++){
		if(seen[i]) continue;
		dfs(G, i, time);
	}
	
	for(int i=1;i<n+1;i++){
		cout<< i << " " << first_order[i] << " " << last_order[i] << endl;
	}
}



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

using namespace std;

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

  sort(D.begin(), D.end());

  int div = N/2;
  int low = D[div-1];
  int up = D[div];
  int ans = up-low;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
char = list(map(str, input().split()))
stack = []
for s in char:
    if s not in {'+', '-', '*'}:
        stack.append(int(s))
    else:
        if s == '+':
            ans = stack.pop() + stack.pop()
            stack.append(ans)
        if s == '*':
            ans = stack.pop() * stack.pop()
            stack.append(ans)
        if s == '-':
            ans = -stack.pop() + stack.pop()
            stack.append(ans)
print(stack[0])


Measured memory_bytes: 5600