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

// macros
#define overload_rep(_1, _2 ,_3 ,name, ...) name
#define re_p(i, n) for(int i = 0; i < (n); ++i)
#define r_ep(i, x, y) for(int i = (x); i < (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, r_ep, re_p,)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do{ cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << setprecision(20);
    }
} iosetup;

// Let's get AC!
int main(){

    string s;
    cin >> s;

    int l, r;
    rep(i, (int)s.size()){
        if(s[i] == 'Z')r = i;
    }
    for(int i = (int)s.size() - 1; i >= 0; i--){
        if(s[i] == 'A')l = i;
    }

    cout << r - l + 1 << endl;
    return 0;

}

Measured memory_bytes: 720
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

double len(double xa, double ya, double xb, double yb) {
	double ans = 0;
	ans = sqrt(pow((xa - xb), 2) + pow((ya - yb), 2));
	return ans;
}

int main() {
	lint N;
	cin >> N;
	double xa, ya, ra, xb, yb, rb;
	rep(i, N) {
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		if (len(xa, ya, xb, yb) + ra < rb) {
			cout << -2 << endl;
		}
		else if (len(xa, ya, xb, yb) + rb < ra) {
			cout << 2 << endl;
		}
		else if (len(xa, ya, xb, yb) > ra + rb) {
			cout << 0 << enld;
		}
		else {
			cout << 1 << endl;
		}
	}
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B){
    cout<<C<<endl;
  }
  else if(B==C){
    cout<<A<<endl;
  }
  else{
    cout<<B<<endl;
  }
}

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

using namespace std;
#define ll long long
const int N=2e5+5,mod=1e9+7;
const ll INF=1e15;
bool vis[N][5];
ll dp[N][5];
int a[N];
int n;
ll solve(int idx,int f)
{
    if(idx>=n)
    {
        if(f==2) return -INF;
        return 0;
    }
    ll &ret=dp[idx][f];
    if(vis[idx][f]==1) return ret;
    vis[idx][f]=1;
    ret=solve(idx+2,f)+a[idx];
    if(f) ret=max(ret,solve(idx+1,f-1));
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    cout<<solve(0,n%2+1)<<endl;
    return 0;
}


Measured memory_bytes: 17840
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define FORE(e,v) for(auto&& e : v)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
template<class T>inline void OUT(T t){cout<<t<<endl;}
template<class T,class... Ts>inline void OUT(T t,Ts... ts){cout<<t<<" ";OUT(ts...);}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type FILL(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type FILL(T&t,const V&v){for(auto &e:t)FILL(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int H,W;
	cin>>H>>W;
	int N;
	cin>>N;
	auto a = mv<vector<pair<int,int>>>(4);
	auto f = [&](int x,int y,int i){
		if(y==0&&x>=0)a[0].push_back({x,i});
		else if(x==H&&y>=0)a[1].push_back({y,i});
		else if(y==W&&y>=0)a[2].push_back({-x,i});
		else a[3].push_back({-y,i});
	};
	REP(i,N){
		int x,y,xx,yy;
		cin>>x>>y>>xx>>yy;
		if((x==0||x==H||y==0||y==W)&&(xx==0||xx==H||yy==0||yy==W)){
			f(x,y,i);f(xx,yy,i);
		}
	}
	REP(i,4)sort(ALL(a[i]));
	vector<int>b;
	REP(i,4){
		REP(j,a[i].size()){
			b.push_back(a[i][j].second);
		}
	}
	map<int,int>mp;
	int now = 0;
	REP(i,b.size()){
		if(mp.count(b[i])){
			if(now!=mp[b[i]]){
				OUT("NO");
				return 0;
			}
			now^=b[i];
		}else{
			now^=b[i];
			mp[b[i]]=now;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 11176
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    string S, T;
    cin >> S >> T;
    cout << T << S;
    return 0;
}

Measured memory_bytes: 256
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define ra read_alpha()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline char read_alpha() { char c = ge; while(!isalpha(c) && c != EOF) c = ge; return c; }
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

const int mod = 1e9 + 7;
const ll MOD = 1ll * mod * mod;

inline int Mod(int x) { return x >= mod ? x - mod : x; }
inline void Add(ll&a, ll b) { a += b, a -= a >= MOD ? MOD : 0; }

vector<int>to[5010];

int G[5010];
ll g[5010];
int si[5010];
int mul[5010];
int f[5010][5010];

inline void dfs(int x, int la) {
	f[x][1] = si[x] = 1;
	for(auto u : to[x]) {
		if(u == la) continue;
		dfs(u, x);
		for(int i = 1; i <= si[x]; i++) {
			int F = f[x][i];
			Add(g[i], 1LL * F * (mod - G[u]));
			for(int j = 1; j <= si[u]; j++)
				Add(g[i + j], 1LL * F * f[u][j]);
		} si[x] += si[u];
		for(int i = si[x]; i; i--) f[x][i] = g[i] % mod, g[i] = 0;
	} int &F = G[x];
	for(int i = 2; i <= si[x]; i += 2) 
		F = (F + 1LL * mul[i] * f[x][i]) % mod;
}

int main() {
#ifdef LOCAL
	FILE("");
#endif
	int n = ri; mul[0] = 1;
	for(int i = 2; i <= n; i += 2) mul[i] = 1LL * mul[i - 2] * (i - 1) % mod;
	for(int i = 1; i < n; i++) {		
		int u = ri, v = ri;
		to[u].push_back(v);
		to[v].push_back(u);
	} dfs(1, 0), printf("%d\n", G[1]);
	return 0;
}

Measured memory_bytes: 98176
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int l;
    cin>>s;
    l=s.size();
    for(int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
#n=int(input())
n = int(input())
h=list(map(int,input().split()))
isStarted = False
fin = False
flowers = [0] * len(h)
all = 0
for i in h:
    all += i
done = False
ans=0
while (not done):
    tmp = 0
    isStarted=False
    for i in range(len(flowers)):
        if (flowers[i] == h[i] and isStarted):
            ans+=1
            isStarted = False
            break
        if (flowers[i] < h[i] and not isStarted):
            isStarted = True
        if (isStarted):
            flowers[i] += 1
        tmp += flowers[i]
        if (all == tmp):
            done = True
        if (isStarted and i == len(flowers) - 1):
            ans+=1
            isStarted = False
            break
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){
	int number[31],a,b,i,n,counter,tmp;
	while(scanf("%d",&counter) != EOF){
		for(i=1;i<31;i++){
			number[i] =i;
		}
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d,%d",&a,&b);
			tmp = number[a];
			number[a] = number[b];
			number[b] = tmp;
		}
		for(i=1;i<=counter;i++){
			printf("%d\n",number[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using _TYPE = int;
typedef tree< _TYPE, null_type, less< _TYPE >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main() {
    IO;
    ll n;
    cin >> n;
    vector<ll> v(n + 1, 1);
    unsigned long long ans = 0;
    for(int i = 2; i <= n; i++) {
        for(int j = i; j <= n; j += i)
            v[j]++;
    }
    for(int i = 1; i <= n; i++)
        ans += i * v[i];
    cout << ans;
    return 0;
}


Measured memory_bytes: 81324
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD (100000009)
#define INF (100000009)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n;
string s;

int L[MAXN];
int R[MAXN];
int ans[MAXN];

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> s;
	n = s.size();

	int first_R = 0;
	int first_L = n-1;

	for (int i = 1; i < n; ++i)
	{
		if (s[i] == 'R') first_R = i;
		else R[i] = first_R;//index of first R from i to the left
	}

	for (int i = n-2; i >= 0; --i)
	{
		if (s[i] == 'L') first_L = i;
		else L[i] = first_L;//index of first L from i to the right
	}

	for (int i = 0; i < n; ++i)
	{
		if (s[i] == 'R')
			ans[L[i] - ( (L[i] - i) % 2 )]++;
		else
			ans[R[i] + (i - R[i])%2]++;
	}

	for (int i = 0; i < n; ++i)
		cout << ans[i] << " ";
}

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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if (L > R)
    cout << "Left" << endl;
  if (L == R)
    cout << "Balanced" << endl;
  if (L < R)
    cout << "Right" << endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from collections import deque
 
H, W, K = map(int,readline().split())
x1, y1, x2, y2 = map(int,readline().split())
x1 -= 1; y1 -= 1; x2 -= 1; y2 -= 1
C = read().split()

dist = [[-1]*W for i in range(H)]
dist[x1][y1] = 0
d = deque([[x1, y1]])
dxy= [[1, 0], [0, 1], [-1, 0], [0, -1]]
while d:
  x, y = d.popleft()
  if (x, y) == (x2, y2):
    print(dist[x][y])
    quit()
  for dx, dy in dxy:
    xx = x; yy = y
    for i in range(K):
      xx += dx; yy += dy
      if 0<=xx<H and 0<=yy<W and C[xx][yy]!='@':
        if 0 <= dist[xx][yy] <= dist[x][y]:
          break
        if dist[xx][yy] == -1:
           d.append([xx, yy])
        dist[xx][yy] = dist[x][y] + 1
      else:
        break

print(-1)

Measured memory_bytes: 36596
S = input()
N = len(S)
flag = False

for i, charS in enumerate(S):
    if charS == "C" and (1 < i and i < N-1):
        flag = True
        numC = i
        break

if S[0] != "A":
    flag = False

if flag:
    text = [S[j] for j in range(N) if j != 0 and j != numC]
    text = ''.join(text)
    if not(text.islower()):
        flag = False

print("AC" if flag else "WA")

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
#define input freopen("/Users/peteryuanpan/data.txt","r",stdin)

const double eps = 1e-9, pi = acos(-1.0);
int sgn(double x){
    if(abs(x) < eps) return 0;
    else return x > 0 ? 1 : -1;
}

#define N 10010
int n;
struct Maze{
    int x1, y1;
    int x2, y2;
}ma[N];

struct Seg{
    double l, r;
}seg[N << 1], seg1[N << 1];
bool cmp1(const Seg a, const Seg b){
    if(sgn(a.r - b.r) != 0) return sgn(a.r - b.r) < 0;
    else return sgn(a.l - b.l) < 0;
}

double getangle(int x1, int y1){
    double a = atan2(y1, x1);
    if(sgn(a) < 0) a += 2 * pi;
    return a;
}

int solve(Seg *seg, int fr, int to){
    int ans = 0;
    for(int i = fr, j = fr; i <= to;){
        for(; j <= to && sgn(seg[j].l - seg[i].r) <= 0; j++);
        ans++;
        i = j;
    }
    return ans;
}

int main(){
    //input;
    while(scanf("%d",&n) == 1){
        for(int i = 1; i <= n; i++){
            scanf("%d%d%d%d",&ma[i].x1, &ma[i].y1, &ma[i].x2, &ma[i].y2);
        }
        for(int i = 1; i <= n; i++){
            double rad[10];
            rad[1] = getangle(ma[i].x1, ma[i].y1);
            rad[2] = getangle(ma[i].x1, ma[i].y2);
            rad[3] = getangle(ma[i].x2, ma[i].y1);
            rad[4] = getangle(ma[i].x2, ma[i].y2);
            sort(rad + 1, rad + 1 + 4);
            double d = 0.0;
            int w1 = 1, w2 = 2;
            for(int i1 = 1; i1 <= 4; i1++){
                for(int i2 = i1 + 1; i2 <= 4; i2++){
                    double d1 = abs(rad[i1] - rad[i2]);
                    d1 = min(d1, 2 * pi - d1);
                    if(sgn(d1 - d) > 0){
                        d = d1;
                        w1 = i1, w2 = i2;
                    }
                }
            }
            double a1 = rad[w1], a2 = rad[w2];
            if(sgn(a1 - a2) > 0) swap(a1, a2);
            if(sgn((a2 - a1) - d) != 0) swap(a1, a2);
            if(sgn(a1 - a2) > 0) a2 += 2 * pi;
            seg[i].l = a1, seg[i].r = a2;
        }
        
        sort(seg + 1, seg + 1 + n, cmp1);
        for(int i = n + 1; i <= 2 * n; i++){
            seg[i].l = seg[i - n].l + 2 * pi;
            seg[i].r = seg[i - n].r + 2 * pi;
        }
        int ans = n;
        for(int i = 1; i <= n; i++){
            for(int j = i; j <= i + n - 1; j++) seg1[j] = seg[j];
            sort(seg1 + i, seg1 + i + n, cmp1);
            int ans1 = solve(seg1, i, i + n - 1);
            ans = min(ans, ans1);
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1460
fn gcd(x: u64, y: u64) -> u64 {
    if x == 0 {
        y
    } else {
        gcd(y % x, x)
    }
}

fn lcm(x: u64, y: u64) -> u64 {
    x * y / gcd(x, y)
}

fn main() {
    let _ = read::<usize>();
    let a = read_vec::<u64>();
    //let m = a.iter().fold(1, |acc, &x| lcm(acc, x)) - 1;
    //let ans = a.into_iter().map(|x| m % x).sum::<u64>();
    let ans = a.into_iter().map(|x| x-1).sum::<u64>();
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=1000+10;
const int mod=1e9+7;

int n,c[N];
void calc(int x) {
	for (int i=2;i*i<=x;++i)
		while (x%i==0) x/=i,++c[i];
	if (x>1) ++c[x];
}

int main() {
	n=read();
	for (int i=1;i<=n;++i) calc(i);
	int ans=1;
	for (int i=1;i<=n;++i) ans=1ll*ans*(c[i]+1)%mod;
	printf("%d\n",ans);
	return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}
int N;

char judge(string &T) {
	char c;
#ifdef DEBUG
	if (stoi(T) <= N && T <= to_string(N) ||
			stoi(T) > N && T > to_string(N) ) {
		c = 'Y';
	} else {
		c = 'N';
	}
#else
	cin >> c;
#endif
	return (c);
}

int main() {
#ifdef DEBUG
	cin >> N;
#endif
	string S;
	while (true) {
		int ok, ng;
		char c;

		//sakini 9 situmon suru
		{
			string T = S + '9';
			cout << "? " << T << el;
			fflush(stdout);
			c = judge(T);
		}

		if (c == 'N') {
			ok = 0, ng = 9;
			while (abs(ok-ng) > 1) {
				int m = (ok+ng)/2;
				string T = S + (char)(m + '0');
				cout << "? " << T << el;
				fflush(stdout);
				c = judge(T);
				if (c == 'Y') ok = m;
				else ng = m;
			}
			S += (ok + '0');	
			continue;
		}

		ok = 10, ng = -1;
		while (abs(ok-ng) > 1) {
			int m = (ok+ng)/2;
			string T = S + (char)(m + '0');
			if (count(begin(T), end(T), '0') == T.size()) {
				ng = m;
				continue;
			}
			while (T.size() < 15) T += '0';
			cout << "? " << T << el;
			fflush(stdout);
			c = judge(T);
			if (c == 'Y') ok = m;
			else ng = m;
		}
		if (ok == 10) {
			S += '9';
			continue;
		} else {
			S += (ok + '0');
			cout << "! " << S << el;
			fflush(stdout);
			break;
		}
	}
	return (0);
}


Measured memory_bytes: 692
#include <map>
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
    int h, w, n; cin >> h >> w >> n;
    map<pair<int, int>, int> m;
    while (n--) {
        int x, y; cin >> x >> y; x--; y--;
        for (int i = max(0, x-2); i <= min(x, h-3); i++)
            for (int j = max(0, y-2); j <= min(y, w-3); j++)
                m[make_pair(i, j)]++;
    }
    int ans[10] = {};
    for (auto e : m) {
        ans[e.second]++;
    }
    long long ans0 = (long long)(h-2) * (w-2);
    for (int i = 1; i < 10; i++) ans0 -= ans[i];
    cout << ans0 << endl;
    for (int i = 1; i < 10; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 56448
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll N;
  cin >> N;
  vector<ll> P(N);
  REP(i,N){ cin >> P[i];}

  vector<ll> pow_ten(7);
  REP(i,7){ pow_ten[i] = pow((ll)10,i); }

  vector<vector<ll>> cnt(9,vector<ll>(9)); // cnt[begin][end] 1~9
  REP(i,9){
    REP(j,9){
      ll st = i+1;
      ll en = j+1;
      ll d = (st!=en) ? 1 : 0;
      ll num = (st!=en) ? st*10+en : st;
      while (num <= N){
        //if (num>=80 || num==9) cout << " num:" << num;
        if (num+pow_ten[d] <= N){
          cnt[i][j] += (d<2) ? 1 : pow_ten[d]/10;
          //if (num>=80 || num==9) cout << " cnt:" << ((d==0) ? 1 : pow_ten[d]/10) << "\n";
        } else {
          cnt[i][j] += (d<2) ? 1 : (N-num)/10+1;
          //if (num>=80 || num==9) cout << " cnt:" << max((ll)1, (N-num)/10+1) << "\n";
        }
        d++;
        num = st*pow_ten[d]+en;
      }
    }
  }

  ll ans = 0;
  REP(i,9){
    REP(j,9){
      ans += cnt[i][j] * cnt[j][i];
    }
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 1792
//by rko27
//One more....
//---------------------------------------------------------------------------------------------------------------------------------------------------

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int  long long 
#define ll  long long 
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define nl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)(x.size())
#define god ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

//----------------------------------------------------------------------------------------------------------------------------------------------------

const long double pi = 3.14159265358979323;
int mod=1000000000+7;
int modu=998244353;

//----------------------------------------------------------------------------------------------------------------------------------------------------

ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
ll powe(ll x, ll y){ x = x%mod, y=y%(mod-1);ll ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;}
void fun()
{
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif
	//786
}
bool isPrime(int n){for(int i=2;i*i<=n;i++)if(n%i==0) return false;return true;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}

//-------------------------------------------------------------------------------------------------------------------------------------------------------

const int N=1e6+7;
std::vector<int> v[N];

//--------------------------------------------------------------------------------------------------------------------------------------------------------



//--------------------------------------------------------------------------------------------------------------------------------------------------------
signed main() 
{
	god;
	//rko;
	fun();
	int ttt=1; //cin>>ttt;
	while(ttt--)
	{
		int n,k; cin>>n>>k; int ans=0;
		for(int i=k;i<=n+1;i++)
		{
			int l=(i*(i-1))/2;
			int r=n*i - l;
			ans+=(r- l+1);
		}
		cout<<ans%mod;
	}
	return 0;
}

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

using int64 = long long;

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

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

        s += a[i];
    }

    for (int64 K = max(0LL, s - N * (N - 1)); K <= s; K++) {
        bool ok = true;
        int64 sum = 0;
        for (int i = 0; i < N; i++) {
            if ((a[i] + K) % (N + 1) == N) {
                ok = false;
                break;
            }
            sum += (a[i] + K) % (N + 1);
        }
        ok = ok && (sum == s - K);

        if (ok) {
            cout << K << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;


int main() {

	int N, R;

	cin >> N >> R;

	if (N >= 10) {
		cout << R << endl;
	}
	else {
		cout << R+100*(10-N) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int N,cnt=0,ans,A[201];
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&A[i]);
		while(A[i]%2==0){A[i]/=2;cnt++;}
		if(i==0||cnt<ans){ans=cnt;}
		cnt=0;
	}
	printf("%d",ans);
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

const int INF = (int)1e7;

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int V, E; cin >> V >> E;
  vector<vector<int>> dp(1 << V, vector<int>(V, INF)), D(V, vector<int>(V, INF));

  REP(i, E) {
    int s, t, d; cin >> s >> t >> d;
    D[s][t] = d;
  }

  dp[0][0] = 0;
  for (int state = 0; state < (1 << V); state++) {
    REP(i, V) REP(j, V) if (not (state >> j & 1) and dp[state | (1 << j)][j] > dp[state][i] + D[i][j]) {
      dp[state | (1 << j)][j] = dp[state][i] + D[i][j];
    }
  }

  cout << (dp[(1 << V) - 1][0] == INF ? -1 : dp[(1 << V) - 1][0]) << endl;
  return 0;
}

Measured memory_bytes: 6316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            //ここから

            int N = IO.ReadLineToInt();
            var v = IO.ReadLineToDoubleList();

            while (v.Count != 1)
            {
                v = v.OrderBy(o => o).ToList();
                var newv = (v[0] + v[1]) / 2.0;
                v.RemoveRange(0, 2);
                v.Add(newv);
            }

            //ここまで
            Console.WriteLine(v[0]);
            Console.ReadKey();
        }
    }

    static class Func
    {
        static long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }


        public static double ToAngle(this double radian)
        {
            return (double)(radian * 180 / Math.PI);
        }

        public static double ToRadian(this double angle)
        {
            return (double)(angle * Math.PI / 180);
        }

        static public long Conbination(int n,int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * Conbination(n - 1, m - 1) / m;
        }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }

        static public List<double> ReadLineToDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }

        static public void WriteStrings(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 13524
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
        int n;
        cin >> n;

        int a[n+2]={0},all=0;
        for(int i=1;i<n+1;i++){
                cin >> a[i];
                all+=abs(a[i]-a[i-1]);
        }
        all+=abs(a[n+1]-a[n]);

        for(int i=1;i<n+1;i++){
                int ans,bef,aft;
                if(i==n){
                        bef=n-1; aft=n+1;
                }else{
                        bef=i-1; aft=i+1;
                }
                if((a[i]-a[bef])*(a[aft]-a[i])>0) ans=all;
                else ans=all-abs(a[i]-a[bef])-abs(a[aft]-a[i])+abs(a[aft]-a[bef]);
                cout << ans << endl;
        }

        return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt();
		String str = null;
		int count = 0;
		for(;a <= b; a++) {
			str = String.valueOf(a);
			if(str.equals(new StringBuilder(str).reverse().toString())) count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 38228
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, M = map(int, input().split())

AS = list(map(int, input().split()))
BS = list(map(int, input().split()))

xyc = [[int(x) for x in input().split()] for _ in range(M)]

ans = min(AS) + min(BS)

for x, y, c in xyc:
    r = AS[x - 1] + BS[y - 1] - c
    ans = min(ans, r)

print(ans)


Measured memory_bytes: 32552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e5+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}


vector < ll > v, prime;
map < ll , int > M2 , M ;
int A[N];

int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	REPP(i,2,N){
		if(!A[i]){
			prime.pb(i);
			M2[(1ll)*i*i] = i;
			for(int j = 2*i;j<N;j+=i) A[j] = 1;
		}
	}


	int n;scanf("%d",&n);
	REP(i,n){
		ll s;scanf("%lld",&s);
		REP(j,prime.size()){
			ll p = prime[j]*prime[j]*prime[j]; 
			if(p>s) break;
			while(s%p==0) s/=p;
		}
		v.pb(s);
		M[s]++;
	}
	sort(all(v));
	v.resize(unique(all(v))-v.begin());
	int ans = 0;
	REP(i,v.size()){
		if(M[v[i]]==0) continue;
		ll s = v[i];
		if(s==1){ ans++;continue;}
		ll ort = 1;
		REP(j,prime.size()){
			ll p = prime[j]*prime[j]*prime[j];
			if(p>s) break;
			if(s%(prime[j]*prime[j])==0) ort *= prime[j],s/=prime[j]*prime[j];
			else if(s%prime[j]==0) ort*= prime[j]*prime[j],s/=prime[j]; 
		}
		if(M2.count(s)){
			ort *= M2[s];
		}else ort *= s*s;
		ans += max(M[v[i]],M[ort]);
		M[v[i]] = M[ort] = 0;
	}
	printf("%d\n",ans);
	return 0;
}




Measured memory_bytes: 14580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll a,b;
cin>>a>>b;
if((a+b)==15)
{
cout<<"+";
}
else if((a*b)==15)
{
cout<<"*";
}
else
{
cout<<"x";
}
return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb the vegetable chicken
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define pb              push_back
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
#define read            ZXBs_fast_input
#define write           ZXBs_fast_output
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool write(int x){
	if(x >= 10) write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

int n, m;
vector<int> graph[100100];
int dp[100100];
int inDeg[100100];
int ans = 0;

int dfs(int now){
	if(dp[now]) return dp[now];
	if(graph[now].size() == 0) return 0;
	rep(i, graph[now].size()){
		dp[now] = max(dp[now], dfs(graph[now][i]) + 1);
	}
	return dp[now];
}

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n >> m;
	rep(i, m){
		int x, y;
		cin >> x >> y;
		x--, y--;
		graph[x].pb(y);
		inDeg[y]++;
	}
	rep(i, n){
		if(inDeg[i] == 0){
			ans = max(ans, dfs(i));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11264
#include<stdio.h>
int d[7][7]={{0,6,10,12,14,27,33},{6,0,7,9,12,23,30},{10,7,0,5,8,20,27},{12,9,5,0,5,17,26},{14,12,8,5,0,12,23},{27,23,20,17,12,0,10},{33,30,27,26,23,10,0}};
int c[]={0,6,13,18,23,43,58};
int ABS(int a){return a<0?-a:a;}
int main(){
	int a;
	while(scanf("%d",&a),a){
		a--;
		int p,q,r,s,t;
		scanf("%d%d%d%d%d",&p,&q,&r,&s,&t);
		r--;
		int ret=d[a][r];
		if(ABS(c[a]-c[r])<=40){
			if(1050<=p*60+q&&p*60+q<=1170)ret=(ret+1)/2;
			else if(1050<=s*60+t&&s*60+t<=1170)ret=(ret+1)/2;
		}printf("%d\n",ret*50);
	}
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0 ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
 
}

const int MAXN = 200100;

int32_t main(){
  fastio;
  string s;
  cin>>s;
  int ok=0;
  for(int i=0;i<3;i++){
    if(s[i]=='7')ok=1;
  }
  cout<<(ok?"Yes":"No")<<endl;
  // Math -> gcd it all // chack MAXN // check ll
  //did you check N=1? Did you mix up N,M?
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(int i = (a); i<(b); ++i)
#define rep(i, n) for (int i=0; i<(n); ++i)
#define out(x) cout << x << endl

int main() {
    int A, B;
    cin >> A >> B;
    if ((A < 10) && (B < 10)){
        out(A*B);
    }
    else out(-1);
}

Measured memory_bytes: 256
// Problem : C - Repsept
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}
vi vis;
void solve()
{
	int k;cin>>k;
	queue<pii> q;
	inc(vis,k,0);
	q.push({1,7%k});
	vis[7%k]=1;
	while(!q.empty())
	{
		pii x=q.front();
		//cerr<<x.se<<"\n";
		q.pop();
		if(x.se==0)
		{
			cout<<x.f;
			return;
		}
		int ne=(x.se*10+7)%k;
		if(vis[ne]==0)
		{
			vis[ne]=1;
			q.push({x.f+1,ne});
		}
	}
	cout<<-1;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 11048
#include <stdio.h>

int main(void) {
  
  int s[10000] = {0}, t[500] = {0}, n, q, i, j, cnt = 0;
  
  scanf("%d", &n);
  
  for (i = 0; i < n; i++) {
    scanf("%d", &s[i]);
  }
  
  scanf("%d", &q);
  
  for (i = 0; i < q; i++) {
    scanf("%d", &t[i]);
  }
  
  for (i = 0; i < q; i++) {
    for (j = 0; j < n; j++) {
      if (t[i] == s[j]) {
        cnt++;
        break;
      }
    }
  }
  
  printf("%d\n", cnt);
  
  return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1000000007;
ll dp[51][51][2501];
main(){
    int N,A,X[50];
    cin >> N >> A;
    for(int i = 0;i < N;i++){
        cin >> X[i];
    }
    dp[0][0][0] = 1;
    for(int i = 0;i < N;i++){
        for(int j = 0;j < N;j++){
            for(int k = 0;k <= 2500;k++){
                dp[i+1][j][k] += dp[i][j][k];
                if(k-X[i] >= 0)dp[i+1][j+1][k] += dp[i][j][k-X[i]];
            }
        }
    }
    ll ans = 0;
    for(int i = 1;i <= N && i*A <= 2500;i++){
        ans += dp[N][i][i*A];
    }
    cout << ans << endl;
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<string> A(N);
	vector<string> B(M);
	for (int n = 0; n < N; ++n) {
		cin >> A[n];
	}
	for (int n = 0; n < M; ++n) {
		cin >> B[n];
	}
	int ans = 0;
	for (int n = 0; n <= N - M; ++n) {
		for (int m = 0; m <= N - M; ++m) {
			bool b = true;
			for (int i = 0; i < M; ++i) {
				for (int j = 0; j < M; ++j) {
					if (A[i + n][j + m] != B[i][j]) {
						b = false;
					}
				}
			}
			if (b) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

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

	int q;
	cin >> q;

	for(int i = 0; i < q; ++i){
		int c, a, n;
		cin >> c >> a >> n;

		int team = 0;
		int m1 = min({c, a, n});
		team += m1;
		c -= m1;
		a -= m1;
		int m2 = min(c / 2, a);
		team += m2;
		c -= m2 * 2;
		a -= m2;
		team += c / 3;
		cout << team << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
/*
      author : nishi5451
      created: 11.08.2020 23:17:00
*/

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


int main(){
    int n;
    cin >> n;
    n%=10;
    switch(n){
        case 3: cout << "bon" << endl; break;
        case 0:
        case 1:
        case 6:
        case 8: cout << "pon" << endl; break;
        default : cout << "hon" << endl; break;
    }
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int n, q, s, t, x, u, a[1 << 18];
bool b;

int get(int x) {
	int y = 0;
	x += u;
	while (x) {
		y += a[x];
		x /= 2;
	}
	return y;
}
void add(int s, int t, int x, int k, int l, int r) {
	if (!(r < s || t < l)) {
		if (s <= l&&r <= t)
			a[k] += x;
		else {
			add(s, t, x, k * 2, l, (l + r) / 2);
			add(s, t, x, k * 2 + 1, (l + r) / 2 + 1, r);
		}
	}
}

int main(){
	cin >> n >> q;
	for (int i = 1;; ++i) {
		if ((1 << i) / n >= 2) {
			u = 1 << i - 1;
			break;
		}
	}
	for (int i = 0; i != q; ++i) {
		cin >> b >> s;
		if (b) {
			cout << get(s - 1) << endl;
		}
		else {
			cin >> t >> x;
			add(s - 1, t - 1, x, 1, 0, u - 1);
		}
	}
	return 0;
}



Measured memory_bytes: 3848
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 100;

long long x, k, d;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> x >> k >> d;
    
    x = abs(x);

    if (ceil(x / d) <= k)
    {
        if (x / d % 2 == k % 2)
            cout << x % d;
        else
            cout << d - x % d;
    }
    else
        cout << x - k * d;
    
    return 0;
}


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

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> v(h, vector<char>(w));

    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin >> v[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < (1 << h); i++){
        for (int j = 0; j < (1 << w); j++){
            bitset<6> bh(i);
            bitset<6> bw(j);
            int count = 0;
            for (int k = 0; k < h; k++){
                for (int l = 0; l < w; l++){
                    if (bh.test(k) && bw.test(l)) {
                        if (v[k][l] == '#') count++;
                    }
                }
            }

            if (count == k) ans++;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3600
#include <stdio.h>
#define MAX 10000000
#define noParent -1

struct  Node {int  parent,right,left; } ;
struct Node box[MAX];
int D[MAX];
int n;

void prints(int u) {
	int i,c;
	printf("node %d: ",u);
	printf("parent = %d, ",box[u].parent);
	printf("depth = %d, ",D[u]);
	if (box[u].parent == noParent) {
		printf("root, ");
	} else if (box[u].left == noParent) {
		printf("leaf, ");
	}else printf("internal node, ");
	
	printf("[");
	for( i = 0, c = box[u].left ; c != noParent ; i++, c = box[c].right){
		if(i) printf(", ");
	printf("%d",c);
	}
	printf("]\n");
}

int serchDepth(int u) {
	int d;
	d = 0;
	for(; box[u].parent != noParent ;d++){
		u = box[u].parent;
	}
		return d;
}

int main(){
  int i,j,a,b,c,l,r;

	scanf("%d", &n);
	for(i=0;i < n;i++){
		box[i].parent = box[i].left = box[i].right = noParent; 
	}
	
	for(i=0;i < n;i++){
		scanf("%d %d",&a,&b);
		for(j=0;j < b;j++){	
			scanf("%d",&c);
			if (j == 0) box[a].left = c;
			else box[l].right = c;
			l = c;
			box[c].parent = a;
		}
	}	
	r = 0;
	for (i = 0; i < n; i ++){
		D[i] = serchDepth(i);
		if(D[i] > r ) r = D[i];
		}
	
	for(i=0;i<n;i++) prints(i);
	
	return 0;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<ll,ll> pi;

bool isPalin(string &re){
    for(int i = 0, j = re.size()-1;i < j;++i,--j){
        if(re[i] != re[j]) return 0;
    }
    return 1;
}

int main(){
    string re;
    cin >> re;
    string fi = re.substr(0,(int)re.size()>>1);
    string se = re.substr(((int)re.size()>>1)+1,re.size());
   // cout << fi << " " << se << "\n";
    if(isPalin(re) && isPalin(fi) && isPalin(se))
        puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
N,C=map(int,input().split())
xv=[list(map(int,input().split())) for _ in range(N)]

l=[0]*N
l[0]=xv[0][1]
for i in range(1,N):
  l[i]=l[i-1]+xv[i][1]
for i in range(N):
  l[i]-=xv[i][0]

r=[0]*N
r[0]=xv[N-1][1]
for i in reversed(range(N-1)):
  r[N-1-i]=r[N-1-i-1]+xv[i][1]
for i in reversed(range(N)):
  r[N-1-i]-=C-xv[i][0]
  
ans=max(max(l),max(r))

lm=[0]*N
lm[0]=l[0]
for i in range(1,N):
  lm[i]=max(lm[i-1],l[i])
  
rm=[0]*N
rm[0]=r[0]
for i in range(1,N):
  rm[i]=max(rm[i-1],r[i])

for i in range(N-1):
  ans=max(ans,l[i]-xv[i][0]+rm[N-1-i-1])
for i in range(N-1):
  ans=max(ans,r[i]-C+xv[N-1-i][0]+lm[N-1-i-1])
  
print(max(ans,0))


Measured memory_bytes: 39668
#include<bits/stdc++.h>
using namespace std;
int n,A[100];
char s[201000];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	long long ans=1ll*n*(n-1)/2;
	for(int i=1;i<=n;++i)A[s[i]-97]++;
	for(int i=0;i<26;++i)ans-=1ll*A[i]*(A[i]-1)/2;
	printf("%lld",ans+1);
}

Measured memory_bytes: 384