akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
typedef long long lint;
const int N=1e5+5;
const int mod=1e9+7;
int n;

namespace utils{
	template <class T> inline void apx(T &x,const T y){
		x<y?x=y:0;
	}
	template <class T> inline void apn(T &x,const T y){
		x>y?x=y:0;
	}
	inline char get_c(){
		static char buf[20000],*h,*t;
		if(h==t){
			t=(h=buf)+fread(buf,1,20000,stdin);
			if(h==t) return EOF;
		}
		return *h++;
	}
	inline int nxi(FILE *fd=stdin){
		int x=0;
		char c;
		while((c=get_c())>'9'||c<'0');
		while(x=x*10-48+c,(c=get_c())>='0'&&c<='9');
		return x;
	}
}
using namespace utils;

template <class T>
inline int fpow(int x,T t){
	int ans=1;
	for(; t; x=(lint)x*x%mod,t>>=1){
		if(t&1) ans=(lint)ans*x%mod;
	}
	return ans;
}

namespace G{
	int rt,ans,cnt,fir[N<<1];
	int cir_dep,dep[N<<1];
	int eg_cnt,nd_cnt;
	bool vis[N<<1];
	std::vector <int> cir_l;
	struct edge{
		int to,nx;
	}eg[N<<2];

	inline void add(const int a,const int b){
		eg[++cnt]=(edge){b,fir[a]};
		fir[a]=cnt;
	}

	bool dfs_cir(const int x,const int fa){
		++nd_cnt;
		vis[x]=1;
		bool on_cir=0;
		for(int i=fir[x]; i; i=eg[i].nx){
			const int y=eg[i].to;
			++eg_cnt;
			if(y==fa) continue;
			if(vis[y]){
				if(~cir_dep) continue;
				cir_dep=dep[y];
				on_cir=1;
			}
			else{
				dep[y]=dep[x]+1;
				on_cir|=dfs_cir(y,x);
			}
		}
		on_cir&=dep[x]>=cir_dep;
		if(on_cir) cir_l.push_back(x);
		return on_cir;
	}

	int dfs_tot(const int x,const int fa){
		int sz=1;
		for(int i=fir[x]; i; i=eg[i].nx){
			const int y=eg[i].to;
			if(y==rt&&y!=fa) assert(y>fa);
			if(y==fa||y==rt) continue;
			if(y<fa) sz+=dfs_tot(y,x);
			else dfs_tot(y,x);
		}
		ans=(lint)ans*sz%mod;
		return sz;
	}

	int solve(const int x){
		cir_l.clear();
		eg_cnt=nd_cnt=0;
		cir_dep=-1;
		dfs_cir(x,0);
		if(eg_cnt!=nd_cnt<<1) return 0;
		const int sz=cir_l.size();
		assert(sz);
		int r=0,res=0;
		for(int i=1; i<(int)cir_l.size(); ++i){
			if(cir_l[i]<cir_l[r]) r=i;
		}
		{
			int f,x;
			if((f=r-1)<0) f=sz-1;
			if((x=f-1)<0) x=sz-1;
			ans=1;
			G::rt=cir_l[x];
			dfs_tot(cir_l[x],cir_l[f]);
			res=(res+fpow(ans,mod-2))%mod;
		}
		{
			int f,x;
			if((f=r+1)==sz) f=0;
			if((x=f+1)==sz) x=0;
			ans=1;
			G::rt=cir_l[x];
			dfs_tot(cir_l[x],cir_l[f]);
			res=(res+fpow(ans,mod-2))%mod;
		}
		return res;
	}
}

int main(){
	n=nxi();
	for(int i=1; i<=n<<1; ++i){
		int x=nxi(),y=nxi();
		G::add(x,y+n);
		G::add(y+n,x);
	}
	int res=1;
	for(int i=1; res&&i<=n; ++i){
		if(!G::vis[i]) res=(lint)res*G::solve(i)%mod;
	}
	for(int i=1; i<=n<<1; ++i){
		res=(lint)res*i%mod;
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<string> vs;
#define ifr(i,n) for((i)=0;(i)<(n);i++)
#define dfr(i,n) for((i)=(n);(i)>=0;i--)
int main(){
  int a,b,C;
  cin >> a >> b >> C;
  double S=0.5*a*b*sin(2*M_PI*C/360);
  double L;
  double l=sqrt(-2*a*b*cos(2*M_PI*C/360)+a*a+b*b);
  L=a+b+l;
  double h=2*S/a;
  printf("%.8lf\n%.8lf\n%.8lf\n",S,L,h);
  return 0;
}

Measured memory_bytes: 3476
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
  int R,G,B,N;
  cin>>R>>G>>B>>N;
  ll ans = 0;
  for (int i = 0; i <= N/R; i++) {
    for (int j = 0; j <= N/G; j++) {
      if ((N - i * R - j * G) >= 0 && (N - i * R - j * G) % B == 0) {
        ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long sum = 0;
		long max = 0;
		long min = 0;
		int i = Integer.parseInt(scan.next());
		long[] ary = new long[i];
		for(int a=0;a<i;a++){
			ary[a]=Long.parseLong(scan.next());
			if(a==0){ 
				min=ary[a];
				max=ary[a];
			}
			sum+=ary[a];
			if(ary[a]>max) max = ary[a];
			if(min>ary[a]) min = ary[a];
		}
		System.out.println(min+" "+max+" "+sum);
		scan.close();
	}
}

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

ll N,W;
vector<ll>w,v;
vector<vector<ll>> dp;

ll solve(ll i,ll j){
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    ll res=0;
    if(i==N){
        res = 0;
    }else if(j<w[i]){
        res= solve(i+1,j);
    }else{
        res=max(solve(i+1,j),solve(i+1,j-w[i])+v[i]);
    }
    //cout<<"i:"<<i<<" res:"<<res<<endl;
    return dp[i][j]=res;
}

int main(){
    cin>>N>>W;
    w.resize(N);
    v.resize(N);
    for(ll i=0;i<N;i++){
        cin>>w[i]>>v[i];
    }
    dp=vector<vector<ll>>(N+1,vector<ll>(100001));
    for(int i=0;i<N;i++){
        for(int j=0;j<100001;j++){
            dp[i][j]=-1;
            //cout<<dp[i][j]<<endl;
        }
    }
    cout<<solve(0,W)<<endl;
}

Measured memory_bytes: 80256
import math
n, d = list(map(int, input().split()))
x = [list(map(int, input().split())) for i in range(n)]

flag = 0
for y in range(len(x)):
    for z in range(y+1, len(x)):
        distance2 = 0
        for i in range(d):
            distance2 += (x[y][i] - x[z][i]) ** 2
        distance = math.sqrt(distance2)
        distance = float(distance)
        if distance.is_integer():
            flag += 1
print(flag)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int N, M;
int a[100], b[100];

bool exists(vector<int> v) {
  for (int i = 0; i < v.size() - 1; i++) {
    int s = v[i], e = v[i+1];
    bool flag = false;
    for (int j = 0; !flag && j < M; j++) {
      if ((a[j] == s && b[j] == e) || (b[j] == s && a[j] == e)) { flag = true; }
    }
    if (!flag) { return false; }
  }
  return true;
}

void solve() {
  vector<int> v;
  for (int i = 1; i <= N; i++) { v.push_back(i); }

  int ans = 0;
  do {
    if (v[0] != 1) { continue; }
    if (exists(v)) { ans++; }
  } while (next_permutation(v.begin(), v.end()));
  cout << ans << endl;
}

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

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        int countx = 0;
        int county = 0;
        while(sc.hasNext()){
            int a = sc.nextInt();
            if(a % 4 == 0){
            	countx++;
            }else if(a % 2 == 0){
            	county++;
                if(county == 2){
                	countx++;
                    county = 0;
                }
            }
        }
        if(n / 2 <= countx){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
	}
}

Measured memory_bytes: 57348
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
S = [input().strip('\n') for _ in range(N)]
c = Counter(S)
mx = 0

for k, v in c.items():
  mx = max(mx, v)

ans = []
for k, v in c.items():
  if mx == v:
    ans += [k]

ans = sorted(ans)
for k in ans:
  print(k)


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

int f(int A, int B, int C) {
  if(A%2==1 || B%2==1 || C%2==1) return 0;
  if(A==B && A == C) return -1;
  return f((B+C)/2, (C+A)/2, (A+B)/2)+1;
}

int main() {
  int A, B, C; cin >> A >> B >> C;
  int ans = f(A, B, C);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n, k;
	cin >> n >> k;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll px = a[0];
	rep(i, n - k) {
		if (px < a[k + i]) cout << "Yes" << endl;
		else cout << "No" << endl;
		px = a[i + 1];
	}
	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	double t,a;
	cin>>t>>a;

	double maxx=999999999;
	int maxn;
	for(int i=1;i<=n;i++)
	{
		double x;
		cin>>x;
		if(maxx>fabs(a-t+x*0.006)) maxx=fabs(a-t+x*0.006),maxn=i;
	}
	cout<<maxn<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    vector<int>v(N + 2);
    for(int i = 1; i <= N; i++)cin >> v[i];
    int ans = 0;
    for(int l = 0; l <= N; l++){
        for(int r = l + 1; r <= N + 1; r++){
            int cost = 0;
            priority_queue<int, vector<int>, greater<int> >Q;
            for(int i = 1; i <= N; i++){
                if(i <= l || r <= i){
                    cost++;
                    Q.push(v[i]);
                }
            }
            if(cost > K)continue;
            while(cost + 1 <= K && !Q.empty() && Q.top() < 0){
                Q.pop();
                cost++;
            }
            int score = 0;
            while(!Q.empty()){
                score += Q.top();
                Q.pop();
            }
            ans = max(ans, score);
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s; cin >> s;
  int ans = 0;
  rep(i, s.size()) {
    ans += s[i] == s[i+1];
    s[i + 1] = s[i] == '1' ? '0' : '1';
  } cout << ans;
}


Measured memory_bytes: 512
//AOJ 0524 chain
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = 100000000;
int n, x[10001][2], list[4], save[10001], l1 = 0, l2 = 0, ans = INF;
vector<int> v1, v2, v3;
int solve(int a){
	l1 = 0; l2 = 0;
	for (int i = 1; i < v2.size(); i++){
		if (v2[a + i] == v2[a]){
			l1++;
		}
		else
			break;
	}
	for (int i = 1; i < v2.size(); i++){
		if (v2[a - i] == v2[a]){
			l2++;
		}
		else
			break;
	}
	if (l1 + l2 >= 3){
		v2.erase(v2.begin() + a - l2, v2.begin() + a + l1 + 1);
		solve(a - l2 - 1);
	}
	else{
		return v2.size();
	}
}
int main(){
	while (true){
		cin >> n;
		if (n == 0){
			break;
		}
		for (int i = 1; i <= n; i++){
			cin >> x[i][0];
			v1.push_back(x[i][0]);
			if (i - list[x[i][0]] == 2){
				save[i - 1] = 2;
			}
			list[x[i][0]] = i;
			if (x[i][0] == x[i - 1][0] && x[i][0] == x[i - 2][0]){
				save[i + 1] = 1;
				save[i - 3] = 1;
			}
		}
		for (int i = 1; i <= n; i++){
			if (save[i] == 1){
				v2 = v1;
				v2.erase(v2.begin() + i - 1);
				if (x[i + 1][0] == x[i + 2][0] && x[i + 1][0] == x[i + 3][0]){
					v2.insert(v2.begin() + i - 1, x[i + 1][0]);
				}
				else if (x[i - 1][0] == x[i - 2][0] && x[i - 1][0] == x[i - 3][0]){
					v2.insert(v2.begin() + i - 1, x[i - 1][0]);
				}
				ans = min(solve(i - 1), ans);
			}
			else if (save[i] == 2 && x[i + 1][0] == x[i + 2][0]){
				v2 = v1;
				v2.erase(v2.begin() + i - 1);
				v2.insert(v2.begin() + i - 1, x[i + 1][0]);
				ans = min(solve(i - 1), ans);
			}
			else if (save[i] == 2 && x[i - 1][0] == x[i - 2][0]){
				v2 = v1;
				v2.erase(v2.begin() + i - 1);
				v2.insert(v2.begin() + i - 1, x[i - 1][0]);
				ans = min(solve(i - 1), ans);
			}
			else save[i] = 0;
		}
		cout << ans << endl;
		ans=INF;
		v1=v3;
	}
	return 0;
}

Measured memory_bytes: 1440
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int H, W;
  	for(int i=0;; i++){
      	cin >>H >>W;
      	if(H==0 && W==0) break;
      	for(int j=0; j<H; j++){
          	for(int k=0; k<W; k++){
              	cout << "#";
            }
          	cout << endl;
        }
      	cout << endl;
    }
}


Measured memory_bytes: 3096
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>
#include<numeric>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

int main() {
	long long N, K, cnt = 0, tmp, ans = 0;

	cin >> N;
	vector<long long> p(N);
	for (auto &x : p) {
		cin >> x;
	}

	for (int i = 1; i < N - 1; i++) {
		if ((p[i-1] < p[i] && p[i] < p[i+1] )||(p[i - 1] > p[i] && p[i] > p[i + 1]) ) {
			ans++;
		}
	}

	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 105

struct Point{
	Point(double arg_x,double arg_y,double arg_z){
		x = arg_x;
		y = arg_y;
		z = arg_z;
	}

	Point(){
		x = y = z = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y,z+p.z); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y,z-p.z);}
	Point operator * (double a){ return Point(a*x,a*y,a*z); }
	Point operator / (double a){ return Point(x/a,y/a,z/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y + z*z; }

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS && fabs(z-p.z) < EPS;
	}
	double x,y,z;
};

typedef Point Vector;

struct LINE{
	LINE(Point arg_p1,Point arg_p2){
		p1 = arg_p1;
		p2 = arg_p2;
	}
	LINE(){

	}
	Point p1,p2;
};

struct Sphere{
	Point center;
	double r;
};

int N;
Sphere info[NUM];

double norm(Vector a){
	return a.x*a.x+a.y*a.y+a.z*a.z;
}

double abs(Vector a){
	return sqrt(norm(a));
}

double abs(LINE a){
	return abs(a.p1-a.p2);
}

double dot(Vector a,Vector b){
    return a.x*b.x + a.y*b.y+a.z*b.z;
}

Point cross(Vector a,Vector b){
	return Point(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);
}

Point projection(LINE &line,Point &point) {
    double t = dot(point-line.p1, line.p1-line.p2)/norm(line.p1-line.p2);
    return line.p1+(line.p1-line.p2)*t;
}

Point reflection(LINE &line,Point &point){
	return point+(projection(line,point)-point)*2.0;
}

bool intersect(Sphere &sphere, LINE &line){
    if(abs(line.p2-sphere.center) < sphere.r-EPS){
    	return true;
    }
    Point point = projection(line, sphere.center);
    return abs(point-line.p1)+abs(point-line.p2)-abs(line) < EPS and abs(point-sphere.center)< sphere.r-EPS;
}

Point cross_point(Sphere &sphere,LINE &line){
    Point point = projection(line, sphere.center);
    double d = sqrt(sphere.r * sphere.r-norm(point-sphere.center));
    return point+(line.p1-line.p2)/abs(line)*d;
}

void func(){

	Point current,tmp,calc;

	current.x = 0;
	current.y = 0;
	current.z = 0;

	Vector V;
	scanf("%lf %lf %lf",&V.x,&V.y,&V.z);

	for(int i = 0; i < N; i++){

		scanf("%lf %lf %lf %lf",&info[i].center.x,&info[i].center.y,&info[i].center.z,&info[i].r);
	}

	LINE line,tmp_line;

	int index = -1,next_index;

	line.p1 = current;
	line.p2 = current+(V/abs(V))*1000;

	while(true){

		next_index = -1;

		for(int i = 0; i < N; i++){
			if(i == index)continue;

			if(!intersect(info[i],line))continue;

			tmp = cross_point(info[i],line);
			line.p2 = tmp;
			next_index = i;
		}
		if(next_index == -1){
			break;
		}
		tmp_line.p1 = info[next_index].center;
		tmp_line.p2 = tmp;
		calc = reflection(tmp_line,current);
		current = tmp;
		V = calc-tmp;
		line.p1 = current;
		line.p2 = current+(V/abs(V))*1000;
		index = next_index;
	}

	printf("%.10lf %.10lf %.10lf\n",current.x,current.y,current.z);
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3124
N = int(input())

def ask(i):
    print(i, flush=True)
    s = input()
    if s == "Vacant":
        exit()
    return s

s = ask(0)

L = 0
R = N
s_L = s
s_R = s
for _ in range(19):
    M = (L+R)//2
    s_M = ask(M)
    if ((M-L)%2) ^ (s_L == s_M):
        L = M
        s_L = s_M
    else:
        R = M
        s_R = s_M


Measured memory_bytes: 3660
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int p[N];
    int su=0;
    int ma=0;
    int ans=0;
    
    for(int i=0;i<N;i++)
    {
        cin >> p[i];
    }
    
    for(int i=0;i<N;i++)
    {
        su=su+p[i];
        
        if(p[i] > ma)
        {
            ma = p[i];
        }
    }
    
    ans=su-ma*0.5;
    
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <random>
#include <map>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)
#define YN(f) f?cout<<"YES"<<endl:cout<<"NO"<<endl;
#define yn(f) f?cout<<"Yes"<<endl:cout<<"No"<<endl;

string s;
int a,b;
string key="keyence";
bool f=false;

signed main(){
	cin>>s;
	for(int i=0;i<7;i++){
		if(s[i]==key[i])a++;
		else break;
	}
	for(int i=0;i<7;i++){
		if(s[s.length()-1-i]==key[6-i])b++;
		else break;
	}
	if(a+b>=7)f=true;
	YN(f);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    int n;
    cin >> n;
    vector<int>red;
    vector<int>white;
    for(int i=0;i<n;i++){
        char c;
        cin >> c;
        if(c=='R'){
            red.push_back(i);
        }
        if(c=='W'){
            white.push_back(i);
        }
    }
    reverse(red.begin(),red.end());
    int ans=0;
    for(int i=0;i<n;i++){
        if(red.size()==0||white.size()==0){
            break;
        }
        if(red[0]>white[0]){
            ans++;
            red.erase(red.begin());
            white.erase(white.begin());
        }
        else {
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4536
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;

int main()
{
	char x, y;
	scanf("%c %c", &x, &y);
	if(x > y)
		printf(">\n");
		else if(x < y)
			printf("<\n");
			else
				printf("=\n");
	return 0;
}

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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int x, y;
    cin >> x >> y;
    int ans = 0;
    ans += max(4 - x, 0) * 100000;
    ans += max(4 - y, 0) * 100000;
    if (x == 1 && y == 1)
    {
        ans += 100000 * 4;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  double sum = 0;
  for(int i = 0;i<a;i++){
    double b;
    string c;
    cin >> b >> c;
    if(c == "JPY")
      sum += b;
    else
      sum += 380000*b;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int m = n, s = 0;
    for (;m;) {
        s += m % 10;
        m /= 10;
    }

    cout << (n % s == 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

MOD = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, 11**5):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % MOD

def solve():
    N, M = map(int, input().split())
    l = factorize(M)
    
    ans = 1
    for _, c in l:
        ans = ans * cmb(c+N-1, c) % MOD
        
    return ans

print(solve())

Measured memory_bytes: 22484
from fractions import Fraction
N = int(input())
A = [int(x) for x in input().split()]

def solve():
    B = [None] * N
    B[0] = sum(A[i] * (-1 if i%2==1 else 1) for i in range(N))
    for i in range(N-1, 0, -1):
        B[i] = 2 * A[i] - B[(i+1) % N]
    return B

print(*solve())

Measured memory_bytes: 16136
import numpy as np

q = int(input())

# 素数列挙
n = 10**5 + 1
primes = set(range(3, n+1, 2))
for i in range(3, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes.add(2)

arr = np.array(list(primes))
arr = np.bincount(arr)

# 素数かつ2017に似た数を列挙
like_2017 = np.zeros(n, bool)
for i in np.where(arr == 1)[0]:
    if (i + 1) // 2 in primes:
        like_2017[i] = True

like_2017 = like_2017.cumsum()


def cnt_primes(l, r):
    return like_2017[r] - like_2017[l - 1]


ans = []
for _ in range(q):
    tmp = 0
    l, r = map(int, input().split())
    tmp += cnt_primes(l, r)
    ans.append(tmp)

print(*ans, sep="\n")

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

using namespace std;

int main(){
    int vals[5];
    for(int i=0; i<5; i++){
        cin >> vals[i];
    }

    for(int j=0; j<5; j++){
        if (vals[j] == 0){
            cout << j + 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3580
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    to[a].push_back(b);
  }
  int mn = 1e9;
  vector<int> ans;
  rep(i, n) {
    vector<int> dist(n, -1), prev(n, -1);
    dist[i] = 0;
    queue<int> que;
    que.push(i);
    while (!que.empty()) {
      int cur = que.front();
      que.pop();
      for(auto next : to[cur]) {
        if (dist[next] != -1)
          continue;
        dist[next] = dist[cur]+1;
        prev[next] = cur;
        que.push(next);
      }
    }
    rep(j, n) {
      for (auto k : to[j]) {
        if (k == j || k != i || dist[j] == -1)
          continue;
        vector<int> tmp{j};
        int cur = j;
        while (cur != k) {
          cur = prev[cur];
          tmp.push_back(cur);
        }
        if (chmin(mn, (int)tmp.size()))
          ans = tmp;
      }
    }
  }
  if (mn == 1e9)
    cout << -1 << endl;
  else {
    cout << ans.size() << endl;
    for (auto e : ans)
      cout << e+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
	   {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}

  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
	{
	  if(i>1&&i<a&&j<b&&j>1)printf(".");
	  else printf("#");
	}
      printf("\n");
    }
  printf("\n");
    
	   }
  return 0;
}

Measured memory_bytes: 572
loop do
  n = gets.chomp.to_i
  break if n == 0

  graph = []
  total = Array.new(n+1, 0)
  n.times do
    line = gets.chomp.split(' ').map(&:to_i)

    line_sum = 0
    line.each{|cell| line_sum += cell}

    line << line_sum
    graph << line

    total = total.zip(line).map{|x, y| x + y}
  end

  graph << total
  graph.each do |line|
    puts line.map{|cell|"%5d" % cell}.join
  end
end

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

using ll = long long;
#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, n, m) for(int (i)=(n); (i)<(m); ++i)
//#define INF 1e9
constexpr ll INF = 1LL << 62;
constexpr int mod = 1e9+7;

vector<ll> ans;
void solve(ll N){
  if(N >= 1e10) return;
  int c = N % 10;
  ans.push_back(N*10+c);
  solve(N*10+c);
  if(c != 0){
    ans.push_back(N*10+c-1);
    solve(N*10+c-1);
  }
  if(c != 9){
    ans.push_back(N*10+c+1);
    solve(N*10+c+1);
  }
}
int main(){
  int K;
  cin >> K;
  FOR(i, 1, 10){
    ans.push_back(i);
    solve(i);
  }
  sort(ans.begin(), ans.end());
  cout << ans[K-1] << endl;
  return 0;
}


Measured memory_bytes: 10476
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        int[] input = Console.ReadLine().Split().Select(i =>int.Parse(i)).ToArray();
 
        Console.WriteLine((input[0]+input[1])%24);
 
        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();
        
    }
}

Measured memory_bytes: 11348
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll x[N], y[N];
  vector<pair<ll, int> > arr1(N), arr2(N);
  for(int i=0;i<N;++i) {
    cin>>x[i]>>y[i];
    arr1[i] = mp(x[i], i);
    arr2[i] = mp(y[i], i);
  }
  sort(arr1.begin(), arr1.end());
  sort(arr2.begin(), arr2.end());
  vector<vector<pair<ll, ll> > > edge(N);
  for(int i=0;i<N-1;++i) {
    edge[arr1[i].se].push_back(mp(min(abs(x[arr1[i].se]-x[arr1[i+1].se]), abs(y[arr1[i].se]-y[arr1[i+1].se])), arr1[i+1].se));
    edge[arr1[i+1].se].push_back(mp(min(abs(x[arr1[i].se]-x[arr1[i+1].se]), abs(y[arr1[i].se]-y[arr1[i+1].se])), arr1[i].se));
    edge[arr2[i].se].push_back(mp(min(abs(x[arr2[i].se]-x[arr2[i+1].se]), abs(y[arr2[i].se]-y[arr2[i+1].se])), arr2[i+1].se));
    edge[arr2[i+1].se].push_back(mp(min(abs(x[arr2[i].se]-x[arr2[i+1].se]), abs(y[arr2[i].se]-y[arr2[i+1].se])), arr2[i].se));
  }
  for(int i=0;i<N;++i) {
    sort(edge[i].begin(), edge[i].end());
  }
  priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > > que;
  que.push(mp(0, 0));
  pair<ll, ll> state; //(dist, ind)
  map<ll, ll> amap;
  for(int i=0;i<N;++i) amap[i] = -1;
  ll node, dist;
  while(!que.empty()) {
    state = que.top();que.pop();
    node = state.se;
    dist = state.fi;
    if(amap[node]>-1) continue;
    amap[node] = dist;
    for(int i=0;i<edge[node].size();++i) {
      if(amap[edge[node][i].se]>-1) continue;
      que.push(mp(edge[node][i].fi, edge[node][i].se));
    }
  }
  ll ans = 0;
  for(int i=0;i<N;++i) ans += amap[i];
  cout<<ans<<endl;
}



Measured memory_bytes: 27036
// ------------------------------------
// Date:2018/ 2/26
// Problem:ABC 051 CandidatesOfNoShortestPaths re_d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

using ll = long long;

#define MOD 1000000007

int main()
{
  int N,M,cnt = 0;
  cin >> N >> M;
  vector< vector<int> > line(N, vector<int> (N,1e4));
  vector<int> a(M);
  vector<int> b(M);
  vector<int> c(M);
  REP(i,M) {
    cin >> a[i] >> b[i] >> c[i];
    line[--a[i]][--b[i]] = c[i];
    line[b[i]][a[i]] = c[i];
  }
  
  // Warshall-Floyd
  REP(h,N) {
    REP(i,N) {
      REP(j,N) {
        line[i][j] = min(line[i][j], line[i][h] + line[h][j]);
      }
    }
  }
  
  REP(i,M) {
    if (line[a[i]][b[i]] < c[i]) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}


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

struct Character
{
	int health;
	int attack;
	int defence;
	int speed;
};

struct Enemy : public Character
{
	bool defeatable;
	unsigned long long dameges_per_turn;
	unsigned long long turns_for_beat;

	Enemy() :
		defeatable(true)
	{

	}
};

std::istream& operator>>(std::istream& stream, Character& character)
{
	return ( stream >> character.health >> character.attack >> character.defence >> character.speed );
}

int main()
{
	// read length of enemies
	int enemy_length;
	std::cin >> enemy_length;

	// read player data
	Character player;
	std::cin >> player;

	// read enemies data
	std::vector<Enemy> enemies(enemy_length);
	for(auto& enemy : enemies)
		std::cin >> enemy;

	// calculate enemies extra data
	for(auto& enemy : enemies)
	{
		// calculate dameges
		int damage_for_enemy  = player.attack - enemy .defence;
		int damage_for_player = enemy .attack - player.defence;

		// turns_for_beat
		if(damage_for_enemy <= 0)
			enemy.defeatable = false;
		else
			enemy.turns_for_beat = enemy.health / damage_for_enemy + (enemy.health % damage_for_enemy ? 1 : 0);

		// damages_per_turn
		enemy.dameges_per_turn = damage_for_player > 0 ? damage_for_player : 0;

		// cannot defeat this enemy no matter how
		if(!enemy.defeatable && enemy.dameges_per_turn > 0)
		{
			std::cout << -1 << std::endl;
			return 0;
		}
	}

	// erase immortal but harmless enemies
	enemies.erase(
		std::remove_if(
			enemies.begin(),
			enemies.end(),
			[](const Enemy& enemy)
			{
				return !(enemy.defeatable);
			}
		),
		enemies.end()
	);

	// sort enemies by order to defeat
	std::sort(
		enemies.begin(),
		enemies.end(),
		[](const Enemy& lhs, const Enemy& rhs)
		{
			return (rhs.dameges_per_turn * lhs.turns_for_beat) < (lhs.dameges_per_turn * rhs.turns_for_beat);
		}
	);

	// surprise attack by enemy
	unsigned long long total_damages = 0;
	for(auto& enemy : enemies)
		if(player.speed < enemy.speed)
			total_damages += enemy.dameges_per_turn;
	
	// fight simulation
	unsigned long long total_turns   = 0;
	for(auto& enemy : enemies)
	{
		total_turns   += enemy.turns_for_beat;
		total_damages += enemy.dameges_per_turn * (total_turns - 1);

		// player lose test
		if(player.health <= total_damages)
		{
			std::cout << -1 << std::endl;
			return 0;
		}
	}
	
	// result
	std::cout << total_damages << std::endl;
	return 0;
}

Measured memory_bytes: 2580
//{
#include<bits/stdc++.h>
using namespace std;
 
// #define DEBUG

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif
//}

bool cmp(string a, string b) {
    if(a.size() != b.size())
        return a.size() < b.size();
    else
        return a > b;
}

string solve(string s, ll k) {
    set<string> st;
    for(int i = 0; i < s.size(); i++) {
        for(int j = i; j < s.size() and j < i + 7; j++) {
            string sts = s.substr(i, (j - i + 1));
            st.insert(sts);
        }
    }
    
    vector<string> sbstr;
    for(auto x: st){
        sbstr.pb(x);
    }
    
    db1(sbstr);
    
    sort(sbstr.begin(), sbstr.end());
    
    return sbstr[k - 1];
    
}

void Input() {
    rd1(string, s);
    rd1(ll, k);
    cout << solve(s, k);
}

int main() {
	
	fastio;

    // rd1(ll, t);
	ll t = 1;

    while(t--) {
        Input();
    }
    
	return 0;
}

Measured memory_bytes: 6164
# coding: utf-8
# Your code here!

N, T = map(int, input().split())
a = list(map(int, input().split()))
total_t, a_len = 0, len(a)

for i in range(a_len - 1):
    if a[i] + T > a[i + 1]: 
        total_t += a[i + 1] - a[i]
    else: 
        total_t += T

print(total_t + T)

Measured memory_bytes: 26836
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define INF 900000000

using namespace std;

int main()
{
	int S;
	
	cin>>S;
	cout<<S/3600<<":"<<(S%3600)/60<<":"<<(S%3600)%60<<endl;  
    return 0;
}



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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

const int MAX_N = 200002;
ll fact[MAX_N];
ll factinv[MAX_N];
long long mod_pow(long long x, long long n, long long mod){
	long long res = 1;
	while(n > 0){
		if(n & 1) res = res * x % mod;
		x = x*x % mod;
		n >>= 1;
	}
	return res;
}

//階乗のリストを作る
void make_fact_tbl(long long n, long long mod){
	fact[0] = 1;
	for(long long i=1; i<=n; i++){
		fact[i] = fact[i-1] * i;
		fact[i] %= mod;
	}
}

//階乗の逆元のリストを作る
void make_factinv_tbl(long long n, long long mod){
	factinv[0] = 1; //0の逆元は存在しない
	for(long long i=1; i<=n; i++){
		factinv[i] = mod_pow(fact[i], mod-2, mod);
	}
}

//組み合わせの計算に必要な情報の作成
void comb_init(long long n, long long mod){
	make_fact_tbl(n, mod);
	make_factinv_tbl(n, mod);
}

//組み合わせの計算
long long comb(long long n, long long k, long long mod){
	if(n < k) return 0;
	if(k == 0 || n-k == 0) return 1;
	//printf("n:%lld k:%lld n-k:%lld\n", fact[n], factinv[k], factinv[n-k]);
	return ((fact[n] * factinv[k]) % mod) * factinv[n-k] % mod;
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	comb_init(200002, MOD);
	
	int h, w, a, b;
	cin >> h >> w >> a >> b;


	ll ans = 0;
	for(int i=b+1; i<=w; i++){
		int ww = i-1;
		int hh = h - a - 1;
		ll tmp = (fact[ww + hh] * factinv[ww] % MOD) * factinv[hh] % MOD;
		//cout << tmp << endl;

		ww = w-i;
		hh = a-1;
		ll tmp2 = (fact[ww + hh] * factinv[ww] % MOD) * factinv[hh] % MOD;
		//cout << tmp2 << endl;

		ans += (tmp * tmp2) % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3328
/*
 * atcoder/abc095_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int A, B, AB, X, Y;
void solve() {
  cin >> A >> B >> AB >> X >> Y;
  int d = abs(X-Y);
  int cost = 0;
  if (X > Y) {
    cost += d * min(A, 2 * AB);
    X = Y;
  } else {
    cost += d * min(B, 2 * AB);
    Y = X;
  }
  cost += X * min(A + B, 2 * AB);
  cout << cost << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int fibonacci(int n);
int F[44];

int main(){

  int n;
  scanf("%d", &n);

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

  return 0;
}

int fibonacci(int n){
  F[0] = 1; 
  F[1] = 1;
  int i;
  for(i=2;i<=n;i++){
    F[i] = F[i-2] + F[i-1];
  }

  return F[n];
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	int x, y;
	cin >> x >> y;
	map<int,int>mp;
	mp[1] = mp[3] = mp[5] = mp[7] = mp[8] = mp[10] = mp[12]=1;
	mp[4] = mp[6] = mp[9] = mp[11] = 2;
	mp[2] = 3;
	if (mp[x] == mp[y])cout << "Yes" << endl;
	else { cout << "No" << endl; }

	return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val num = scala.io.StdIn.readInt
    var check_num = Array.fill( num )( false )

    if( num%2 == 0 || num%5 == 0 ) println( -1 )
    else {
      var check = 7%num
      var count = 1
      while( check != 0 && !check_num( check ) ) {
        count += 1
        check_num( check ) = true
        check = ( check*10 + 7 )%num 
      }

      if( check%num != 0 ) println( -1 )
      else                 println( count )
    }
  }
}

Measured memory_bytes: 54748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    string s, t;
    cin >> s >> t;
    reverse(t.begin(), t.end());
    if(s == t) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

const string FES = "FESTIVA";
string S;
ll K;

int main() {
	cin >> K;
	for (int i = 0; i < 60; ++i) {
		if (i == 0) {
			S = FES;
		}
		else if (i <= 7) {
			S += FES.substr(7 - i);
		}
		else if (i <= 15) {
			for (int j = 0; j < (1 << i - 7); ++j) {
				S.push_back('F');
			}
			S += FES.substr(1);
		}
		else if (i <= 23) {
			for (int j = 0; j < (1 << i - 15); ++j) {
				S.push_back('E');
			}
			S += FES.substr(2);
		}
		else if (i <= 31) {
			for (int j = 0; j < (1 << i - 23); ++j) {
				S.push_back('S');
			}
			S += FES.substr(3);
		}
		else if (i <= 39) {
			for (int j = 0; j < (1 << i - 31); ++j) {
				S.push_back('T');
			}
			S += FES.substr(4);
		}
		else if (i <= 47) {
			for (int j = 0; j < (1 << i - 39); ++j) {
				S.push_back('I');
			}
			S += FES.substr(5);
		}
		else if (i <= 55) {
			for (int j = 0; j < (1 << i - 47); ++j) {
				S.push_back('V');
			}
			S += FES.substr(6);
		}
		else {
			for (int j = 0; j < (1 << i - 55); ++j) {
				S.push_back('A');
			}
		}
		if ((1ll << i)&K) {
			S.push_back('L');
		}
	}
	cout << S << endl;
}

Measured memory_bytes: 256
#n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
n=list(input())
if len(set(n[0:3])) == 1 or len(set(n[1:])) == 1 :
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9004
#include <stdio.h>

#define f(i, q) for(int i = 0; i < q; i++)  

typedef long long ll;

int main() {
    ll i, j, k = 0;
    char ans[20];

    scanf("%lld", &i);

    while(i > 0) {
        if (i % 26 == 0) {
            j = 26;
        } else {
            j = i % 26;
        }
        ans[k] = 'a' + j - 1;
        if (i % 26 == 0) {
            i = i / 26 - 1;
        } else {
            i /= 26;
        }
        k++;
    }

    for(int i = k - 1; i >= 0; i--) {
        printf("%c", ans[i]);
    }

    printf("\n");

    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

struct UnionFindTree{
    vector<int> v;
    vector<int> rank;
    UnionFindTree(int n){
        v = vector<int>(n);
        rank = vector<int>(n, 0);
        for(int i=0; i<n; i++) v[i]=i;
    }
    int Find(int x){
        if(v[x] != x){
            v[x] = Find(v[x]);
        }
        return v[x];
    }
    void Union(int a, int b){
        a = Find(a);
        b = Find(b);
        if(rank[a] < rank[b]){
            v[a] = b;
        }else{
            v[b] = a;
            if(rank[a] == rank[b]){
                rank[a]++;
            }
        }
    }
};

struct edge{
	int x,y,c;
	edge(int x, int y, int c):x(x),y(y),c(c){}
	edge(){}
	bool operator < (const edge &a) const{
		return c < a.c;
	}
};

int main(){
	while(1){
		int n,m;
		cin >> n >> m;
		if(n==0) break;
		
		vector<pair<int,int> > time(n);
		for(int i=0; i<n; i++){
			int h;
			cin >> h;
			time[i] = make_pair(h, i);
		}
		sort(time.begin(), time.end());
		reverse(time.begin(), time.end());
		
		vector<edge> bridge(m);
		for(int i=0; i<m; i++){
			int a,b,c;
			cin >> a >> b >> c;
			a--; b--;
			bridge[i] = edge(a,b,c);
		}
		sort(bridge.begin(), bridge.end());
		
		UnionFindTree uft(n);
		vector<bool> usable(n, false);
		int ans=0;
		for(int i=0; i<n; i++){
			usable[time[i].second] = true;
			while(i+1<n && time[i].first==time[i+1].first){
				i++;
				usable[time[i].second] = true;
			}
			for(int j=0; j<m; j++){
				edge e = bridge[j];
				if(usable[e.x] && usable[e.y] && uft.Find(e.x)!=uft.Find(e.y)){
					ans += e.c;
					uft.Union(e.x, e.y);
				}
			}
			int root = -1;
			for(int j=0; j<n; j++){
				if(usable[j]){
					if(root!=-1 && root!=uft.Find(j)){
						ans=0;
						uft = UnionFindTree(n);
					}
					if(root==-1) root = uft.Find(j);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


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

int main(){
    char c,table[5]={'a','i','u','e','o'};
    cin >> c;
    for(int i=0;i<5;i++){
        if(table[i]==c){
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
typedef pair<long double , ll> Ps;
 
const ll INF = 2e18;
const ll fact_table = 3200008;
long double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
#define rep(i, n) for (ll i = 0; i < (n); i ++)

// const ll mod = 998244353ll;
const ll mod = 1000000007ll;

ll mypow(ll a, ll b, ll mod){ll x=1;while(b){while(!(b&1)){(a*=a)%=mod;b>>=1;}(x*=a)%=mod;b--;}return x;}
void YES(bool cond){ if(cond){ p("YES");}else{ p("NO");} return;}
void Yes(bool cond){ if(cond){ p("Yes");}else{ p("No");} return;}


ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}


bool multicase = false;

ll n,m,num,a,b,c,d,e,h,q;
ll w, k, ans;

ll x[500005], y[500005], z[500005];
ll dp[5005][5005];
string s;

ll mul(ll a, ll b){
    if(b == 0)return 0;
    if(a > INF / b){
        return INF;
    }else{
        return a * b;
    }
}

void solve(){
    ll a;
    long double b;
    cin >> a >> b;
    b *= 100;
    ll bb = (b + 0.1);
    ll c = a * bb;
    c /= 100;
    p(c);
    return;
}


int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
class bipartite_matching {
public:
    int n;
    std::vector<std::vector<int>> g;
    std::vector<int> match;

    bipartite_matching(int n_) : n(n_), g(n_), match(n_), used(n_) {}

    void add_edge(int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int maximum_matching(void) {
        int res = 0;
        fill(begin(match), end(match), -1);
        for (int v = 0; v < n; ++v) {
            if (match[v] == -1) {
                fill(begin(used), end(used), false);
                if (dfs(v)) res++;
            }
        }
        return res;
    }

private:
    std::vector<int> used;
    bool dfs(int v) {
        used[v] = true;
        for (int u : g[v]) {
            int w = match[u];
            if (w == -1 || (!used[w] && dfs(w))) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }
};
bool judge(P r, P b) {
    return ((r.first < b.first) && (r.second < b.second));
}
int main() {
    int n; cin >> n;
    bipartite_matching bm(2*n);
    vector<P> red(n);
    rep(i, n) {
        cin >> red[i].first >> red[i].second;
    }
    vector<P> blu(n);
    rep(i, n) {
        cin >> blu[i].first >> blu[i].second;
    }
    rep(i, n) {
        rep(j, n) {
            if(judge(red[i], blu[j])) {
                bm.add_edge(i, n+j);
            }
        }
    }
    cout << bm.maximum_matching() << endl;
}


Measured memory_bytes: 256