akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			int K = in.nextInt();
			int Q = in.nextInt();
			int[] A = new int[N + 1];
			for(int i = 0; i < Q; i++) {
				A[in.nextInt()] +=  1;
			}
			for(int i = 1; i <= N; i++) {
//				System.out.println(A[i] + K - Q);
				if(A[i] + K - Q <= 0) {
					System.out.println("No");
				} else {
					System.out.println("Yes");
				}
			}
		}
	}

	static boolean permutation_2(String s, String t) {
		if (s.length() != t.length()) {
			return false;
		}

		int[] letters = new int[256]; // 文字コードの仮定;

		char[] s_array = s.toCharArray();
		for (char c : s_array) {
			letters[c]++;
		}

		for (int i = 0; i < t.length(); i++) {
			int c = (int) t.charAt(i);
			if (--letters[c] < 0) {
				return false;
			}
		}
		return true;
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 47084
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String line = br.readLine();
	    int n = Integer.parseInt(line);

	    int tarouScore = 0;
	    int hanakoScore = 0;
	    for (int i = 0; i < n; i++) {
	    	String[]s = br.readLine().split(" ");
			String tarou = s[0];
			String hanako = s[1];

			ArrayList<String> dic = new ArrayList<String>();
			dic.add(tarou);
			dic.add(hanako);

			Collections.sort(dic);

			if (tarou.equals(hanako)) {
				tarouScore += 1;
				hanakoScore += 1;
			} else if (tarou.equals(dic.get(0))) {
				hanakoScore += 3;
			} else {
				tarouScore += 3;
			}
	    }
	    System.out.println(tarouScore + " " + hanakoScore);
	}
}

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

using namespace std;


double x[10];
double y[10];

int main(){
	
	int n;
	double t = 0;
	cin>>n;
	int comb[n];
	double k = 0;
	for(int i = 0; i < n;i++){
		comb[i] = i;
		cin>>x[i]>>y[i];
	}
	do{
		for(int i = 0; i < n-1; i++){
			k += sqrt((x[comb[i]]-x[comb[i+1]])*(x[comb[i]]-x[comb[i+1]]) + (y[comb[i]]-y[comb[i+1]])*(y[comb[i]]-y[comb[i+1]]));
			
		}
		t++;
	}while(next_permutation(comb,comb+n));
	
	printf("%.10lf",k/t);
}


Measured memory_bytes: 384
while True:
    try:
        n = float(input())
    except:
        break

    if n <= 48:
        print("light fly")
    elif n > 48 and n <= 51:
        print("fly")
    elif n > 51 and n <= 54:
        print("bantam")
    elif n > 54 and n <= 57:
        print("feather")
    elif n > 57 and n <= 60:
        print("light")
    elif n > 60 and n <= 64:
        print("light welter")
    elif n > 64 and n <= 69:
        print("welter")
    elif n > 69 and n <= 75:
        print("light middle")
    elif n > 75 and n <= 81:
        print("middle")
    elif n > 81 and n <= 91:
        print("light heavy")
    else:
        print("heavy")

Measured memory_bytes: 6740
n = int(input())
ns = list(map(int, input().split()))
ns = sorted(ns)
ans = [0] * 24
ans[0] = 1
for i in range(n):
    if i % 2 == 0:
        ans[ns[i]] += 1
    else:
        ans[(24 - ns[i]) % 24] += 1
for i in ans:
    if i >= 2:
        print(0)
        exit()
ans = ans[1:]
print(1+min(len(i) for i in ''.join(map(str, ans)).split('1')))


Measured memory_bytes: 38464
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int_fast64_t A = read(), B = read(), C = read(), D = read();
    int_fast64_t ans = B-A+1;
    ans -= B/C-(A-1)/C;
    ans -= B/D-(A-1)/D;
    int_fast64_t cd = (C*D)/__gcd(C, D);
    ans += B/cd-(A-1)/cd;
    printf("%lld\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
 
int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
    int n;
    for (int i=0; i<=N; i++){
        n = i;
        int sum_dig = 0;
        while(true){
            if (n == 0) break;
            sum_dig  = sum_dig + (n%10);
            n/= 10;
        }
        if (A <= sum_dig && sum_dig <= B) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let k: usize = iterator.next().unwrap().parse().unwrap();

    let mut ans: usize = 0;
    for a in 1..=k {
        for b in 1..=k {
            for c in 1..=k {
                ans += gcd(gcd(a, b), c);
            }
        }
    }

    return ans.to_string();
}

fn gcd(mut x: usize, mut y: usize) -> usize {
    while y != 0 {
        let r = x % y;
        x = y;
        y = r;
    }
    return x;
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int cnt[26];

int main(){
  int N; cin>>N;
  string S; cin>>S;
  rep(i,N) cnt[S[i]-'a']++;
  ll ans=1;
  rep(i,26) (ans*=(cnt[i]+1))%=MOD;
  ans=(ans-1+MOD)%MOD;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    var (a, b, c, x, y) = readLine()!!.split(" ").map(String::toInt)

    // ABの個数を全列挙
    val sum = (0..Math.max(x, y)).fold(Integer.MAX_VALUE) { acc, i ->
        Math.min(i * 2 * c + Math.max(0, x - i) * a + Math.max(0, y - i) * b, acc)
    }.let(::println)
}


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

int main(){
  string n;
  cin >> n;
  
  long long c=0,cb=0;
  for(int i=0;i<n.size();i++){
    if(n[i]=='B') cb++;
    else{
      c+=cb;
    }
  }
  cout << c;
}

Measured memory_bytes: 640
ans = []
n = int(input())
for i in range(n):
    x = i+1
    y = n-i
    ans.append(x*y)
pos = sum(ans)
cnt = 0
for i in range(n-1):
    u,v = list(map(int,input().split()))
    x,y = min(u,v),max(u,v)
    cnt+=(x*(n-y+1))
print(pos-cnt)

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

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

using namespace std;
const long long MOD = 998244353;
const long long INF = 1LL << 61;

int main() {
	int N;
	cin >> N;
	cout << N * N * N;
}

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

using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int i = 1;
    while(a > 0 && c > 0) {
        if(i & 1){
            c -= b;
        }
        else {
            a -= d;
        }
        i++;
    }
    cout << ((a > 0) ? "Yes": "No");
    return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>

using namespace std;

int main() {
	long long k, a, b;
	cin >> k >> a >> b;

	// 選択肢１：コスト１消費して一枚増やす
	// 選択肢２：コスト２消費してb-a枚増やす

	long long res = 1;
	long long cnt;

	cnt = k;

	if (b - a >= 3) {
		if (res < a) {
			res += a - 1;
			cnt -= a - 1;
		}
		if (cnt % 2 == 1) {
			res += 1;
			cnt -= 1;
		}
		if (cnt % 2 == 0) {
			res += (b - a) * (cnt / 2);
		}
	}
	else {
		res += k;
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>           // printf(), scanf()
#include <cstdlib>          // abs()

class Point
{
public:
	double x, y;

	Point(double x = 0, double y = 0): x(x), y(y) {}
	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double a) { return Point(a * x, a * y); }
};

struct Segment
{
	Point p1, p2;
};

typedef Point Vector;

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

Point
getCrossPoint(Segment s1, Segment s2)
{
	Vector base = s2.p2 - s2.p1;
	double d1 = abs(cross(base, s1.p1 - s2.p1));
	double d2 = abs(cross(base, s1.p2 - s2.p1));
	double t = d1 / (d1 + d2);
	return s1.p1 + (s1.p2 - s1.p1) * t;
}

int
main(int argc, char** argv)
{
	Segment s1, s2;
	Point a;
	int xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3;
	int q;

	scanf("%d", &q);
	while (q--)
	{
		scanf("%d %d %d %d %d %d %d %d", &xp0, &yp0, &xp1, &yp1, &xp2, &yp2, &xp3, &yp3);
		s1.p1.x = xp0, s1.p1.y = yp0;
		s1.p2.x = xp1, s1.p2.y = yp1;
		s2.p1.x = xp2, s2.p1.y = yp2;
		s2.p2.x = xp3, s2.p2.y = yp3;
		a = getCrossPoint(s1, s2);
		printf("%.10f %.10f\n", a.x, a.y);
	}

	return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String n = br.readLine();
        int l = n.charAt(n.length()-1) - '0';
        if(l == 3) System.out.println("bon");
        else if(l == 0 || l == 1 || l == 6 || l== 8) System.out.println("pon");
        else System.out.println("hon");
    }
}


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

int main() {
  int N,M;
  cin >> N;
  vector<int> T(N);
  int sumT=0;
  for (int i=0; i<N; i++) {
    cin >> T[i];
    sumT += T[i];
  }
  cin >> M;
  int P,X;
  for (int i=0; i<M; i++) {
    cin >> P >> X;
    cout << sumT - T[P-1] + X << endl;
  }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [True] * (N + 1)
for i in range(M):
    a = int(input())
    A[a] = False

dp = [0] * (N + 1)
dp[0] = 1
mod = 10 ** 9 + 7

for i in range(N):
    for j in range(i + 1, min(N, i + 2) + 1):
        if A[j]:
            dp[j] += dp[i]
            dp[j] %= mod
            # print(dp)

print(dp[N])


Measured memory_bytes: 7700
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
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; }

int main(){
	int H, W;
	cin >> H >> W;
	vector<string>	s(H);
	for(int i = 0;i < H;i++)	cin >> s[i];
	vector<vector<LL>>	ver(H, vector<LL>(W, 0)), sid(H, vector<LL>(W, 0));
	for(int i = 0;i < H;i++){
		int l = 0;
		int sum = 0;
		for(int j = 0;j < W;j++){
			if(s[i][j] == '#'){for(int k = l;k < j;k++){sid[i][k] += sum;}l = j+1;sum = 0;continue;}
			else if(j == W-1){for(int k = l;k < W;k++){sid[i][k] += sum+1;}l = j+1;sum = 0;continue;}
			sum++;
		}
	}
	for(int i = 0;i < W;i++){
		int l = 0;
		int sum = 0;
		for(int j = 0;j < H;j++){
			if(s[j][i] == '#'){for(int k = l;k < j;k++){ver[k][i] += sum;}l = j+1;sum = 0;continue;}
			else if(j == H-1){for(int k = l;k < H;k++){ver[k][i] += sum+1;}l = j+1;sum = 0;continue;}
			sum++;
		}
	}
	LL ans = 0;
	for(int i = 0;i < H;i++){for(int j = 0;j < W;j++){ans = max(ans, ver[i][j]+sid[i][j]);}}
	cout << (ans-1) << endl;
}

Measured memory_bytes: 67072
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000007
using namespace std;

int main(){
  long n,m;
  cin >> n >> m;
  long a[n];
  vector<long> mod;
  mod.push_back(0);
  long rui = 0;
  long ans = 0;
  rep(i,n){
    cin >> a[i];
    rui += a[i];
    mod.push_back(rui%m);
  }
  sort(mod.begin(), mod.end());
  long tmp = 1;
  rep(i,int(mod.size())-1){
    if(mod[i] == mod[i+1])tmp++;
    else{
      ans += (tmp*(tmp-1))/2;
      tmp = 1;
    }
  }
  ans += (tmp*(tmp-1))/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5036
def abc097_c():
    S = str(input())
    K = int(input())
    subs = set()

    for l in range(1, K+1):
        for i in range(len(S)):
            subs.add(S[i: i+l])
            # スライスのストップ条件はインデックス外でもよい

    subs_asc = sorted(list(subs))
    ans = subs_asc[K-1]
    print(ans)

abc097_c()

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

int main(void) {
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x-a) < abs(x-b)) {
    cout << "A" << endl;
  }
  else {
    cout << "B" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> arr(N, 0);
    for(int i=0; i<N; i++)
    {
        cin >> arr[i];
    }
    vector<bool> visited(N, false);
    int ret = 0;
    for(int i=0; i<N; i++)
    {
        if(visited[i]) continue;
        int tmp = arr[i];
        if(arr[tmp-1] == i+1) {
            ret++;
            visited[tmp-1] = true;
        }
        visited[i] = true;
    }
    cout << ret << endl;

}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int a[100002];
int b[100002];
int main(){
	int n,k=0,m=0;
	memset(b,0,sizeof(b));
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
		if(a[i]>k)
			k=a[i];
		b[a[i]]++;
		b[a[i]-1]++;
		b[a[i]+1]++;
	}
	for(int i = -1;i <= k+1;i++){
		if(b[i]>m)
			m=b[i];
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;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 INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define PI 3.14159265359

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    double r;
    cin >> r;
    cout <<2* r * PI<< endl;


}
 

Measured memory_bytes: 3800
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dish_list = [a,b,c,d,e]
count = 0
modmin = [10, -1]
for i in range(5):
    if dish_list[i] % 10 != 0:
        count += 1
        if  dish_list[i] % 10 < modmin[0]:
            modmin[0] = dish_list[i] % 10
            modmin[1] = i

if modmin[1] == -1:
    ans = sum(dish_list)
else:
    ans = 0
    for i in range(5):
        if dish_list[i] % 10 != 0 and i != modmin[1]:
            b = dish_list[i] + (10- (dish_list[i] % 10))
        else:
            b = dish_list[i] 
        ans += b

print(ans)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  for(;;){
    int n,m,p,a,b;
    cin >> n >> m >> p >> a >> b;
    if(!n&&!m&&!p&&!a&&!b) return 0;
    vector<int> t;
    t.resize(n);
    REP(i,n) cin >> t[i];
    vector<vector<pair<int,double> > > adj;
    adj.assign(m+1,vector<pair<int,double> >());
    REP(i,p){
      int x,y,z;
      cin >> x >> y >> z;
      adj[x].push_back(make_pair(y,1.0*z));
      adj[y].push_back(make_pair(x,1.0*z));
    }      
    priority_queue<pair<double,pair<int,int> > > dijk;
    // negcost,(city,used)
    set<pair<int,int> > already;
    dijk.push(make_pair(0.0,make_pair(a,0)));
    double answer=1e+10;
    while(!dijk.empty()){
      double negc;
      int city,used;
      negc=dijk.top().first;
      city=dijk.top().second.first;
      used=dijk.top().second.second;
      dijk.pop();
      if(city==b){
	answer=min(answer,-negc);
	break;
      }
      if(!already.insert(make_pair(city,used)).second) continue;
      REP(i,n){
	if(used&(1<<i)) continue;
	int nextused=(used|(1<<i));
	REP(j,adj[city].size()){
	  int nextcity=adj[city][j].first;
	  double dist=adj[city][j].second;
	  dijk.push(make_pair(negc-dist/t[i],make_pair(nextcity,nextused)));
	}
      }
    }
    if(answer>1e+9) cout << "Impossible" << endl;
    else cout << answer << endl;
  }
}

Measured memory_bytes: 15316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FUP(i,x,y) for(int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(int i=(x);i>=(y);i--)
#define MAXN 100010
#define INF 0x7fffffff
#define MOD 1000000007
#define ll long long
#define db double
using namespace std;
int read(){
    int w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x<y?x:y;}
int abs(int x){return x<0?(-x):x;}
char c;
int main(){
	cin>>c;
	printf("%c",c+1);
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 201001;//ここを問題の制約を見ながらいじる．配列の確保に使う．
//ll P[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//ll dp[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
ll A[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．


ll MOD = 1000000007;
int digit_length(int num)
{
    int count = 0;
    while (num) {
        num = num / 10;
        ++count;
    }
    return count;
}


ll gcd(ll a, ll b) {
    ll v0 = a, v1 = b, v2 = a % b;
    while (v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}


// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//ll lcm(ll a, ll b) {
//    return a / (gcd(a, b) % MOD) * (b % MOD);
//}

ll lcm(ll a, ll b) {
    return( (a % MOD) *modinv(gcd(a, b), MOD) * (b % MOD)) % MOD;
}
       // Main program
void solve() {
    ll N;
    cin >> N;
    string tmp;
    std::map<std::string, int> ren;

    for(ll i=0;i<N;i++){
        cin >> tmp;
        ren[tmp]++;
        if(ren[tmp]!=1){
          cout << "NO";
          return;
        }
    }

    // for(ll i=0;i<sqrt(N);i++){
    //    for(ll j=i;j<N;j++){
    //        if(i==j){
    //            cout << "NO";
    //            return;
    //        }
    //     }
    // }
    cout << "YES";
    return;
}


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








Measured memory_bytes: 22144
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define scanInt(a) scanf("%d", &a)
using namespace std;

int main() {
    char a;
    scanf("%c", &a);
    if (a < 91) printf("A\n");
    else printf("a\n");
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main (void) {
    int n;
    scanf("%d", &n);
    double  x[n], ans = 0;
    char    u[n][4];
    int     i;

    for (i = 0; i < n; i++ ) {
        scanf("%lf%s", &x[i], &u[i][0]);
        if ( u[i][0] == 'B' ) {
            x[i] *= 380000;
        }
        ans += x[i];
    }

    printf("%lf\n", ans);
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static string Alp = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
      var n = ScanInt();
      var h = ScanIntArray();
      int prev = 0;
      int count = 0;
      for(int i=0; i<n; i++){
        if(h[i] > prev) 
          count += h[i] - prev;
        prev = h[i];
      }
      WriteLine(count);
    }
  }
    
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


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

int main(void) {
  ll a,v;
  ll b,w;
  ll t;
  cin >> a >> v;
  cin >> b >> w;
  cin >> t;
  int spd = v - w;
  int dist = (ll)abs(a - b);
  if(spd < 0){
    puts("NO");
  } else if(dist > spd * t) {
    puts("NO");
  } else {
    puts("YES");
  }
  return 0;
}


Measured memory_bytes: 3592
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  vector<ll> tmp(n+1);
  tmp[0]=0;
  rep(i,n) tmp[i+1]=tmp[i]+v[i];
  vector<ll> ans(n-k+1);
  rep(i,n-k+1) ans[i]=tmp[i+k]-tmp[i];
  ll ans2=0;
  rep(i,n-k+1) chmax(ans2,ans[i]);
  cout<<fixed<<setprecision(2)<<(double)(k+(ans2-k)*0.5)<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N;
  int K;
  int d;
  int A;
  int cnt;
  cin >> N >> K;
  vector<bool> hav(N);
  rep(i,K)
  {
    cin >> d;
    rep(j,d)
    {
      cin >> A;
      hav.at(A-1) = true;
    }
  }
  rep(i,N)
  {
    if(hav.at(i) == false)
    {
      cnt++;
    }
  }
  cout << cnt << endl;
  

}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int a[10] ;
int main()
{
    char a[5];
   cin>>a;
  if((a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3])||(a[0]==a[1]&&a[1]==a[2]&&a[3]!=a[1])||(a[1]==a[2]&&a[2]==a[3]&&a[0]!=a[2]))
  cout<<"Yes"<<'\n';
  else cout<<"No"<<'\n';
  return 0;
      }

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b, c, k, x;
    cin >> a >> b >> c >> k;
    if (k >= a) x = a;
    else x = k;
    k -= x;
    if (k) k -= b;
    if (k > 0) {
        if (k > c) x -= c;
        else x -= k;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 3616
n = int(input())
j = int(n / 1.08 )
#print(n/1.08,int(j*1.08))
if int(j*1.08) == n:
    print(j)
elif int((j+1)*1.08) == n:
    print(j+1)
elif int((j-1)*1.08) == n:
    print(j-1)
else:
    print(":(")

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  int count = 0;
  
  while (count < C && B > 0) {
    B = B - A;
    if (B < 0) {
      break;
    }
    count++;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    even_count = 0

    for a in a_list:
        if a % 2 == 0:
            even_count += 1

    print(3 ** n - 2 ** even_count)


if __name__ == "__main__":
    main()


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

int main() {

int N;
cin >> N;
vector<int> A(N-1);
vector<int> ans(N-1);

for (int i = 0;i < N-1;i++){
    cin >> A.at(i);
}

for (int i = 0;i < N-1 ;i++){
    int j = A.at(i)-1;
    ans.at(j) += 1;
}


ans.push_back(0);

for (int i = 0;i < N;i++){
    cout << ans.at(i) << endl;
}


}


Measured memory_bytes: 5572
#事前に階乗を計算しておく maximにnの最大値をいれる
maxim = 10**6+1

MOD = 10**9+7
kaijou = [1]*(maxim)
for i in range(1,maxim):
    kaijou[i]=(kaijou[i-1]*i)%MOD
#nCr
def nCr(n,r):
    if n < r:
        return 0
    return ((kaijou[n]*pow(kaijou[r],MOD-2,MOD))%MOD*pow(kaijou[n-r],MOD-2,MOD))%MOD

#nHr
def nHr(n,r):
    if r == 0:
        if n == 0:
            return 1
        return 0
    return ((kaijou[n+r-1]*pow(kaijou[n],MOD-2,MOD))%MOD*pow(kaijou[r-1],MOD-2,MOD))%MOD

N = int(input())
ans = 0
for i in range(1,(N//3)+1):
    tmp = nHr(N-3*i,i)
    ans = (ans+tmp)%MOD

print(ans)

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

int	main()
{
	const static int upper = 1e+9 + 1;
	int	n;
	cin >> n;
	vector<int>	tail_vec(n, upper);
	int	a;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		*lower_bound(tail_vec.begin(), tail_vec.end(), a) = a;
	}
	auto	end = lower_bound(tail_vec.begin(), tail_vec.end(), upper);
	int	max_len = end - tail_vec.begin();
	cout << max_len << endl;
}




Measured memory_bytes: 3128
N = int(input())
arr_t = [0]
arr_x = [0]
arr_y = [0]
flag = 0

for i in range(N):
  t, x, y = list(map(int, input().split()))
  arr_t.append(t)
  arr_x.append(x)
  arr_y.append(y)

for i in range(N):
  if arr_t[i+1]-arr_t[i] < abs(arr_x[i+1]-arr_x[i])+abs(arr_y[i+1]-arr_y[i]):
    flag = 1
  elif ((arr_t[i+1]-arr_t[i])-abs(arr_x[i+1]-arr_x[i])+abs(arr_y[i+1]-arr_y[i]))%2 == 0:
    flag = 0
  else:
    flag = 1

if flag == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 18096
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

void solve() {
    int d, n;
    scanf("%d%d", &d, &n);
    if(n == 100) n = 101;
    std::cout << n;
    rep(i, d) std::cout << "00";
    std::cout << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 256
N=int(input())
p=list(map(float,input().split()))

dp=[[0]*(N+1) for i in range(N+1)]
dp[0][0]=1
for i in range(N):
    for j in range(N+1):
        if j==0:
            dp[i+1][j]=dp[i][j]*(1-p[i])
        else:
            dp[i+1][j]=dp[i][j]*(1-p[i])+dp[i][j-1]*p[i]
print(sum(dp[N][N//2+1:]))

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

#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define PI				double PPPPPP = 3.14159265358979323846;

void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
struct M{
    int w,v;
};
vector<M> v;
int cap,n;
ll dp[100+3][int(1e5+5)];
ll sol(int i,int cap) {
    //// base
    if(i==n)
        return 0;
    /// node => (i,cap)
    ll &ret = dp[i][cap];
    if(ret != -1)
        return ret;
    ret = sol(i + 1, cap); /// leave
    if(cap>=v[i].w) {
        ret = max(ret, v[i].v + sol(i + 1, cap - v[i].w));
    }

    return ret;


}
int main() {
    run();
    cin>>n>>cap;
    v.resize(n);
    for(auto &i:v){
        cin>>i.w>>i.v;
    }
    memset(dp,-1, sizeof(dp));
    cout<<sol(0,cap);
    return 0;
}

Measured memory_bytes: 80768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  char c;
  cin >> c;
  if(c>=(int)'a' && c<=(int)'z') cout << 'a' << endl;
  else cout << 'A' << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 100;

int n;
double x[MAX_N], y[MAX_N], z[MAX_N], r[MAX_N];

struct edge { int u, v; double d; };

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        REP(i, N) par[i] = i;
    }

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

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

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

double dist(double x1, double y1, double z1, double x2, double y2, double z2) {
    double dist = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2) + pow(z1 - z2, 2));
    return dist;
}

bool comp_edge(const edge& e1, const edge& e2) {
    return e1.d < e2.d;
}

int main() {
    while (true) {
        cin >> n;
        if (n == 0) break;
        UnionFind cell(n);
        vector<edge> es;
        REP(i, n) {
            cin >> x[i] >> y[i] >> z[i] >> r[i];
        }
        REP(i, n) {
            REP(j, n) {
                if (cell.same(i, j)) continue;
                double l = dist(x[i], y[i], z[i], x[j], y[j], z[j]) - r[i] - r[j];
                if (l <= 0) cell.unite(i, j);
                else es.PB(edge{ .u = i, .v = j, .d = l});
            }
        }
        sort(es.begin(), es.end(), comp_edge);
        double sum_len = 0;
        REP(i, es.size()) {
            if (cell.same(es[i].u, es[i].v)) continue;
            cell.unite(es[i].u, es[i].v);
            sum_len += es[i].d;
        }
        printf("%.3f\n", sum_len);
    }
    return 0;
}


Measured memory_bytes: 3540
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

int f[200010];
int modpow(int a, int p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {

		int halfP = p / 2;
		int half = modpow(a, halfP);

		return half * half % mod;
	}
	else {

		return a * modpow(a, p - 1) % mod;
	}
}



int comb(int a, int b) {
	if (b > a - b) return comb(a, a - b);


	int ansMul = 1;
	int ansDiv = 1;
	for (int i = 0; i < b; i++)
	{
		ansMul *= (a - i);
		ansDiv *= (i + 1);
		ansMul %= mod;
		ansDiv %= mod;
	}

	int ans = ansMul * modpow(ansDiv, mod - 2) % mod;

	return ans;
}

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

	int N;
	cin >> N;
	vector<pii> V;
	REP(i, N) {
		int a;
		cin >> a;
		V.push_back(make_pair(a,0));
	}
	REP(i, N) {
		int a;
		cin >> a;
		V.push_back(make_pair(a, 1));
	}
	SORT(V);

	f[0] = 1;
	FOR(i, 1, 2 * N + 1) {
		f[i] = f[i - 1] * i;
		f[i] %= mod;
	}
	VI v2;
	int cnt = 1;
	FOR(i, 1, V.size()) {
		if (V[i].second == V[i - 1].second)cnt++;
		else {
			v2.push_back(cnt);
			cnt = 1;
		}
	}
	v2.push_back(cnt);

	bool turn = true;
	int ret = 1;
	cnt = 0;
	for (int i : v2) {
		if (turn)cnt += i;
		else {
			if (cnt >= i) {
				ret *= comb(cnt, i)*f[i] % mod;
				ret %= mod;
				cnt -= i;
			}
			else {
				ret *= f[cnt];
				ret %= mod;
				cnt = i - cnt;
				turn = !turn;
			}
		}
		turn = !turn;
	}

	cout << ret % mod << endl;
	
	return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void warshall_floyd(Graph &graph) {
    int V = graph.size();
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}

ll to_id(ll x, ll y) {
    return 25 * x + y;
}

void Main() {
    int H, W;
    cin >> H >> W;
    vector<string> grid(H);
    rep(i, H) cin >> grid[i];

    Graph graph(500, vector<ll>(500, MOD));
    rep(i, H) {
        rep(j, W) {
            if (grid[i][j] == '#') continue;
            rep(k, 4) {
                int x = dx[k];
                int y = dy[k];
                if (0 <= j + y && j + y < W && 0 <= i + x && i + x < H && grid[i + x][j + y] != '#') {
                    ll from = to_id(i, j);
                    ll to = to_id(i + x, j + y);
                    graph[from][to] = 1;
                }
            }
        }
    }
    warshall_floyd(graph);
    ll ans = 0;
    rep(i, H) {
        rep(j, W) {
            ll start = to_id(i, j);
            if (grid[i][j] == '#') continue;
            rep(i2, H) {
                rep(j2, W) {
                    ll goal = to_id(i2, j2);
                    if (start == goal)continue;
                    if (grid[i2][j2] == '#') continue;
                    ll tmp = graph[start][goal];
                    // ll tmp2 = graph[goal][start];
                    // print(tmp);
                    if (tmp < MOD / 2) {
                        ans = max(tmp, ans);
                    }
//                    if (tmp2 < MOD / 2) {
//                        ans = max(tmp2, ans);
//                    }
                }
            }
        }
    }
    if (ans <= 500) {
        cout << ans << '\n';
    } else {
        cout << 0 << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 2176
from collections import Counter
N = int(input())
T = [input() for i in range(N)]
S = [x[:1] for x in T]
CS = Counter(S)
A = [CS['M'],CS['A'],CS['R'],CS['C'],CS['H']]
ans = 0
for i in range(0,3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans += A[i]*A[j]*A[k]
print(ans)

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

using namespace std;

int main()
{
    int l, r, d;
    cin >> l >> r >> d;
    int tmp1, tmp2;
    tmp1 = l / d;
    tmp2 = r / d;
    int ans = tmp2 - tmp1;
    if(l % d == 0 && r % d == 0)
        ans++;
    
    cout << ans << endl;
    return 0;
}

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

int main(){
  long a, b, c;
  cin >> a >> b >> c;
  if(c-a-b<=0){
    cout << "No" << endl;
    return 0;
  }
  if(4*a*b < (c-a-b)*(c-a-b)){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <cctype>
//小文字を大文字 c-0x20;


#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define vvll(z,a,b) vector<vector<ll>>z(a,vector<ll>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) c.begin(),c.end()
#define fix(k) fixed<<setprecision(k)
#define PI 3.141592653589793
#define sizestr(i,x)  size_t i=x.length();
using namespace std;


int hantei(ll n){
    int h=sqrt(n);
    if(n==h*h)return h; 
    for(int j=h,gu=h;j<=n;j++,gu--){
        ll xk=0;
        if(n%j==0){
            //xk=n/j;
            //if(j>=xk)
            
            return j;
           
        }else if(n%gu==0) {
            j=n/gu;
            return j;

        }
    }
return -1;
   
}

int main(){
    ll n;cin>>n;
    string str=to_string(hantei(n));
    sizestr(st,str);
    cout<<st<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int p, q, r, min1, min2;
    scanf("%d %d %d", &p, &q, &r);
    if(p <= q && p <= r){
        min1 = p;
        if(q < r){
            min2 = q;
            printf("%d", min1+min2);
        }else{
            min2 = r;
            printf("%d", min1+min2);
        }
    }
    if(q < p && q < r){
        min1 = q;
        if(p < r){
            min2 = p;
            printf("%d", min1+min2);
        }else{
            min2 = r;
            printf("%d", min1+min2);
        }
    }
    if(r < p && r < q){
        min1 = r;
        if(p < q){
            min2 = p;
            printf("%d", min1+min2);
        }else{
            min2 = q;
            printf("%d", min1+min2);
        }
    }
    return 0;
}

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


class Main{
  public static void main(String[] args)throws IOException{
     
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
 
    String[] strAry = str.split(" ");
    int x = Integer.parseInt(strAry[0]);
    int y = Integer.parseInt(strAry[1]);
 
    System.out.println(x*y +" "+ 2*(x+y));
  }
}

Measured memory_bytes: 24132
import sys
from itertools import permutations
inputs = sys.stdin.readlines()

n = int(inputs[0])
P = list(map(int, inputs[1].split()))
Q = list(map(int, inputs[2].split()))

p, q = ''.join(map(str, P)), ''.join(map(str, Q))

p_index = q_index = -1
for i, x in enumerate(permutations(range(1, n+1))):
    x = ''.join(map(str, x))
    if x == p:
        p_index = i
    if x == q:
        q_index = i
    if p_index != -1 and q_index != -1:
        break
print(abs(p_index - q_index))

Measured memory_bytes: 3064
/**************************************************
  Solution to: ABC 174 C - Repsept
  Writer: InvisibleCyclist
  By/Based on:
**************************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll k;
int main(){
	cin>>k;
	ll k1=7;
	ll cnt=1;
	while(cnt<1000000){
		k1%=k;
		if(k1==0){
			cout<<cnt<<endl;
			return 0;
		}
		k1*=10;
		k1+=7;
		cnt++;
	}
	cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 3628
from collections import defaultdict
def main():
    N = int(input())
    A = [int(a) for a in input().split()]

    edge = defaultdict(int)

    for i in range(N):
        edge[A[i]] += 1

    edge = [ [k, v] for k, v in edge.items() if v >= 2 ]
    edge.sort(key = lambda x : x[0])

    if len(edge) >= 2 :
        if edge[-1][1] >= 4:
            print(max(edge[-1][0]**2, edge[-1][0]*edge[-2][0]))
        else:
            print(edge[-1][0]*edge[-2][0])
        
    elif len(edge) == 1:
        if edge[-1][1] >= 4:
            print(edge[-1][0]**2)
        else:
            print(0)
    else:
        print(0)

if __name__ == "__main__":
    main()

Measured memory_bytes: 18592
#include<bits/stdc++.h>
using namespace std ; 
int main(){
        string s , t ; 
        cin>>s>>t;
        int min= t.size();
        for(int i =0;i+t.size()-1<s.size();i++){
                int cnt=0 ; 
                for(int j=0;j<t.size();j++){
                        if(s[i+j]!=t[j]){cnt++;}
                }if(cnt<min)min=cnt;
                
                
                
        }cout<<min  ; }

Measured memory_bytes: 3620
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
int a[100005];
int main(void)
{
    int n;
    while(cin>>n)
    {
        int mac=0,x;
        memset(a,0,sizeof(a));
        for(int i=1;i<=n;i++)
        {
            cin>>x;
            if(x!=0)
            {
                a[x]++;
                a[x-1]++;
                a[x+1]++;
                mac=max(mac,max(a[x],max(a[x-1],a[x+1])));
            }
            else
            {
                a[x]++;
                a[x+1]++;
                mac=max(mac,max(a[x],a[x+1]));
            }
        }
        cout<<mac<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll k, t; cin >> k >> t;
	ll ma = 0, sum = 0;
	REP(i, t) {
		ll a; cin >> a;
		ma = max(ma, a);
		sum += a;
	}
	sum -= ma;
	cout << (ma > sum + 1 ? ma - sum - 1 : 0) << endl;

	return 0;
}

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

using namespace std;

const int N = 2005, P = 924844033;

int f[N][N][2], n, S, k, g[N], M[N], fac[N];


int main () {
	scanf("%d%d", &n, &k);
	S = (n + k - 1) / k;
	f[0][0][1] = 1;
	fac[0] = 1; for (int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % P;
	for (int i = 1; i <= S; ++i) {
		for (int j = 0; j <= n; ++j) {
			f[i][j][0] = (f[i - 1][j][0] + f[i - 1][j][1]) % P;
			if (j) f[i][j][1] = f[i - 1][j - 1][0];
		}
	}
	M[0] = 1;
	for (int i = min(k << 1, n), j, v, w, l; i; --i) {
		l = (n - i + k) / k + (i > k);
		memset(g, 0, sizeof g);
		for (v = l >> 1; ~v; --v) {
			w = f[l][v][0] + f[l][v][1];
			for (j = n; j >= v; --j) {
				g[j] = (1ll * M[j - v] * w + g[j]) % P;
			}
		}
		memcpy(M, g, sizeof g);
	}
	int ret = 0;
	for (int i = 0; i <= n; ++i) {
		if (i & 1) ret = (-1ll * fac[n - i] * M[i] + ret) % P;
		else ret = (1ll * fac[n - i] * M[i] + ret) % P;
	}
	printf("%d\n", (ret + P) % P);
	return 0;
}

Measured memory_bytes: 31616