akhauriyash/Code-Regression huggingface dataset:
import random
import copy
import time
def evaluateSatisfaction(d, c, s, ans):
    score = 0
    last = [-1 for i in range(26)]
        
    for i in range(d):
        
        score += s[i][ans[i]]
        last[ans[i]] = i
        for j in range(26):
            if j != ans[i] or True:
                score -= c[j]*(i - last[j])
    return score
    
def valuationFunction(d,c,s,contestType,day,last):
    las = copy.copy(last)
    las[contestType] = day
    gain = s[day][contestType]
    lost = 0
    for i in range(8):
        for j in range(26):
            lost += c[j]*(day + i - las[j])
    return gain - lost

def Input():
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for i in range(d)]
    #s[3][25] =   contest(25+1) of day(3+1)
    return d, c, s

def evolution(d, c, s, ans):
    score_before = evaluateSatisfaction(d, c, s, ans)
    ans_after = copy.copy(ans)
    x = random.randint(0,(d-1)-10)
    idx1 = x
    idx2 = x+random.randint(1,5)
    
    tmp = ans_after[idx1]
    ans_after[idx1] = ans_after[idx2]
    ans_after[idx2] = tmp

    score_after = evaluateSatisfaction(d,c,s,ans_after)

    if score_after > score_before:
        return ans_after
    else:
        return ans

if __name__ == "__main__":
    
    d, c, s = Input()
    
    #print("val =", evaluateSatisfaction(d, c, s, [1, 17, 13, 14, 13]))

    #calc start
    t1 = time.time()
    ans = [0 for i in range(d)]
    last = [-1 for i in range(26)]
    for i in range(d):
        evalValueList = [0 for j in range(26)]
        for j in range(26):
            evalValueList[j] = valuationFunction(d, c, s, j,i,last)

        max_idx = 0
        max = evalValueList[0]

        for j in range(26):
            if (max < evalValueList[j]):
                max_idx = j
                max = evalValueList[j]
        
        ans[i] = max_idx
        last[ans[i]] = i


    
    #ans = [1, 2, 3, 4, 5]
    t2 = time.time()
    while(float(t2-t1) < 1.8):
        ans = evolution(d, c, s, ans)
        #print("ans = ",evaluateSatisfaction(d,c,s,ans))
        t2 = time.time()
    for x in ans:
        print(x + 1)
    #print(evaluateSatisfaction(d,c,s,ans))

Measured memory_bytes: 10068
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int d,t,s; cin >> d >> t >> s;
    cout << (t*s >= d ? "Yes" : "No");
}

Measured memory_bytes: 3608
from collections import Counter

N=int(input())
D=list(map(int,input().split()))
CD=Counter(D)
# print(CD) #DB
M=int(input())
T=list(map(int,input().split()))
CT=Counter(T)
# print(CT) #DB

f=True
for Ti in CT.keys():
    if CD[Ti]<CT[Ti]:
        f=False
        break

print('YES' if f else 'NO')

Measured memory_bytes: 122832
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, pair<int, int>> P; 
struct edge{
	int to; int cost; long long time; 
};
int N, M, S;
int C[55]; 
long long D[55]; 
vector<edge> E[55]; 
long long ans[55]; 
long long dp[55][2510]; // dp[頂点i][銀貨をちょうどj枚持っている（50N枚以上は10N）]
long long INF = 1145141919810364364; 
priority_queue<P, vector<P>, greater<P>> que; 
int main(){
	cin >> N >> M >> S; 
	for(int i = 0; i < M; i++){
		int u, v, a; long long b; 
		cin >> u >> v >> a >> b; 
		u--; v--; 
		E[u].push_back((edge){v, a, b}); 
		E[v].push_back((edge){u, a, b}); 
	}
	for(int i = 0; i < N; i++) cin >> C[i] >> D[i]; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= N * 50; j++){
			dp[i][j] = INF; 
		}
	}
	que.push(make_pair(0, make_pair(0, min(S, 50 * N)))); 
	dp[0][min(S, 50 * N)] = 0; 
	while(que.size()){
		P p = que.top(); que.pop(); 
		long long t = p.first; 
		int v = p.second.first; int m = p.second.second;
		if(t > dp[v][m]) continue;
		if(m == 50 * N){
			for(auto e : E[v]){
				if(t + e.time >= dp[e.to][50 * N]) continue; 
				dp[e.to][50 * N] = t + e.time; 
				que.push(make_pair(t + e.time, make_pair(e.to, 50 * N)));
			}
		}else{
			for(auto e : E[v]){
				if(m < e.cost) continue; 
				if(t + e.time >= dp[e.to][m - e.cost]) continue; 
				dp[e.to][m - e.cost] = t + e.time; 
				que.push(make_pair(t + e.time, make_pair(e.to, m - e.cost)));
			}
			if(dp[v][min(m + C[v], 50 * N)] <= t + D[v]) continue;
			dp[v][min(m + C[v], 50 * N)] = t + D[v];
			que.push(make_pair(t + D[v], make_pair(v, min(m + C[v], 50 * N))));
		}
	}
	fill(ans, ans + N, INF);
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= 50 * N; j++){
			ans[i] = min(ans[i], dp[i][j]); 
		}
	}
	for(int i = 1; i < N; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 6340
//0558 ?????????
//bfs

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#include<queue>
#define INF 2100000000
using namespace std;
typedef pair<int,int> P;
int glid[1001][1001];
char put[1001][1001];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
char su[9]={'1','2','3','4','5','6','7','8','9'};
int main(void)
{
	int i,j,k,h,w,n,sum,x,y;
	int sx,sy;
	P pop_xy;
	queue<P> push_xy;
	cin>>h>>w>>n;
	for(i=0;i<h;i++) cin>>put[i];
	for(i=0;i<h;i++) {
		for(j=0;j<w;j++) {
			glid[i][j]=INF;
		}
	}		
	for(i=0;i<h;i++) {
		for(j=0;j<w;j++) {
			if(put[i][j]=='S') {
				push_xy.push(P(i,j));
				glid[i][j]=0;
				break;
			}
		}
	}
	sum=0;
	for(i=0;i<n;i++) {
		if(i>0) {
			for(j=0;j<h;j++) {
				for(k=0;k<w;k++) glid[j][k]=INF;
			}		
			while(push_xy.size()!=0) push_xy.pop();
			push_xy.push(P(sy,sx));
			glid[sy][sx]=0;
		}
		while(push_xy.size()!=0) {
			pop_xy=push_xy.front();push_xy.pop();
			if(put[pop_xy.first][pop_xy.second]==su[i]) {
				sum+=glid[pop_xy.first][pop_xy.second];
				sy=pop_xy.first;sx=pop_xy.second;
				break;
			}
			for(j=0;j<4;j++) {
				y=dy[j]+pop_xy.first;
				x=dx[j]+pop_xy.second;
				if(y>=0 && y<h && x>=0 && x<w &&
				put[y][x]!='X' && glid[y][x]==INF) {
					push_xy.push(P(y,x));
					glid[y][x]=glid[pop_xy.first][pop_xy.second]+1;
				}
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}
	

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N;
    i64 Z,W;
    cin >> N >> Z >> W;

    vector<i64> a(N+2);
    a[0]=Z;
    a[1]=W;
    rep(i,2,N+2) cin >> a[i];

    static i64 memo[2002][2]={};
    static bool done[2002][2]={};
    function<i64(int,int)> rec=[&](int i,int turn){
        i64& res=memo[i][turn];
        if(done[i][turn]) return res;
        done[i][turn]=true;

        int next=i+1;
        if(turn==0){
            res=max(res,abs(a[N+1]-a[i]));
            rep(j,next,N+1) res=max(res,rec(j,1-turn));
            return res;
        }else{
            res=inf64;
            res=min(res,abs(a[N+1]-a[i]));
            rep(j,next,N+1) res=min(res,rec(j,1-turn));
            return res;
        }
    };

    cout << rec(1,0) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <ctime>
#include <cstring>
#define ll long long
#define INF 1000000000
#define For(i,a,b) for(int i=a;i<=b;++i)
#define Rev(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define pq priority_queue
#define PI acos(-1)

namespace IO
{
#define p(x) ('0'<=x&&x<='9')
	char cc; int C;
	template <class T>
	void read( T &x )
	{
		x=0; cc=getchar(); C=1;
		while(!p(cc)) { if(cc=='-') C=-1; cc=getchar(); }
		while(p(cc)) { x=x*10+cc-48; cc=getchar(); }
		x*=C;
	}
#undef p
}

using namespace IO;
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	srand(time(0));
#ifdef LOCAL
	freopen("./tmp/input.txt", "r", stdin);
#endif

	char s[10];

	scanf("%s",s);
	For(i,0,2) s[i]='0'+'0'+10-s[i];
	printf("%s\n",s);

	return 0;
}


Measured memory_bytes: 256
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(arr[int(input())-1])

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	int n, x;
	cin >> n >> x;
	vector<int> l(n);
	for (int i = 0; i < n; i++) cin >> l[i];
	int sum,  ans;
	sum = 0;
	ans = 0;
	for (int i = 0; i < n; i++)
	{
		ans++;
		sum += l[i];
		if (x < sum)
		{
			break;
		}
	}
	if (sum <= x) ans++;

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, end) for (long long int i=0; i<end; i++)
#define repp(i, begin, end) for (long long int i=begin; i<end; i++)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vs = vector<string>;
ll sm(vll x) {ll sum=0; rep(i, x.size()) sum+=x[i]; return sum;}
void vdeb(string s, vector<int> x) {cout<<s<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<endl;}
//=======================================================================================================

double dis(vector<int> a, vector<int> b)
{
    double sum = 0;
    rep(i, a.size()) {
        sum += (a[i] - b[i]) * (a[i] - b[i]);
    }
    return sqrt(sum);
}

int main()
{
    int n, d;
    cin >> n >> d;
    vector<vector<int> > x(n, vector<int>(d));
    rep(i, n) rep(j, d) cin >> x[i][j];

    int ans = 0;
    rep(i, n) {
        repp(j, i+1, n) {
            double tmp;
            tmp = dis(x[i], x[j]);
            if(ceil(tmp) == floor(tmp))
                ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(void)
{
	int n, p;
	while (cin >> n >> p, n && p){
		int stone[n];
		int now = 0, all = p, ret = 0;
		for (int i = 0; i < n; i++){
			stone[i] = 0;
		}
		while (1){
			if (all == 0){
				all += stone[now];
				stone[now] = 0;
			}
			else {
				all--;
				stone[now]++;
				if (all == 0 && stone[now] == p){
					ret = now;
					break;
				}
			}
			now++;
			now %= n;
		}
		cout << ret << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  vector<int> ans(n + 1, 0);
  for(int x = 1; x <= 100; x++){
    for(int y = 1; y <= 100; y++){
      for(int z = 1; z <= 100; z++){
        int temp = x * x + y * y + z * z + x * y + y * z + z * x;
        if(temp > n) continue;
        ans[temp]++;
      }
    }
  }
  for(int i = 1; i <= n; i++){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3660
my $s= <STDIN>;
my @dat = split(/ /,$s);
my $k = $dat[0];
my $N = $dat[1];
my $mod = 10**9+7;
my $sum =0;
my @del;
for(my $i=0;$i<$N;$i++){
 $del[$i] = 0;
}


for(my $i=$N;$i>0;$i--){
 my $count = int($N /$i);
 $del[$i] = &powmod($count,$k,$mod);
 for(my $j=2;$j<=$count;$j++){
    $del[$i]= $del[$i] - $del[$i*$j];
 }
 $sum = ($sum + $i*$del[$i])%$mod;
 #print "i$i del$del[$i] $sum\n";
}
print "$sum";
exit;

sub powmod{
   my ($a,$b,$m) = @_;
   if($b==1){return $a;}
   my $c = powmod(($a*$a)%$m,int($b/2),$m);
   if($b%2){
     $c = ($c*$a)%$m;
   }
   return $c;
}


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

int main(){
  int t[100001]={0},n,l,r,sum=0,T,max;
  cin>>n>>T;
  //change by below contents
  for(int i=0;i<n;i++){
    cin>>l>>r;
    t[l]++;
    t[r]--;
  }
  max=0;
  for(int i=0;i<=T;i++){
    sum+=t[i];
    if(sum>max)max=sum;
  }
  cout<<max<<endl;

  return 0;
}

Measured memory_bytes: 3472
import math
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
if max(a)==0:
  print(0)
  exit()
m=math.floor(math.log(max(a),2))+1
ans=0
for i in range(m):
  cnt0=0
  cnt1=0
  for j in range(n):
    if a[j]>>i&1:
      cnt1+=1
    else:
      cnt0+=1
  ans+=(2**i)*(cnt1*cnt0)
  ans%=mod
print(ans)

Measured memory_bytes: 122936
import java.util.*;


public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int hight = sc.nextInt();
		int width = sc.nextInt();
		int ans = 0;
		
		char[][] meiz = new char[hight][width];
		int[][] map = new int[hight][width];
		
		
			for(int j=0;j<hight;j++){
				String line = sc.next();
				for(int i=0;i<width;i++){
				
				meiz[j][i] = line.charAt(i);
				ans += (meiz[j][i]== '.' ? 1 : 0);
				map[j][i] = (meiz[j][i]== '.' ? 0 : -1);
				}
			}
		
			map[0][0] = 1;
			int cost=0;
			boolean check;
			
			for(cost=1;map[hight-1][width-1]==0;cost++){
				check = true;
				for(int j=0;j<hight;j++)
					for(int i=0;i<width;i++){
						
						
				
						if(map[j][i]==cost){
							work(meiz,map,j,i,cost);
							check = false;
						}
				
					}
				if(check) break;
			}
			
			if(map[hight-1][width-1]==0)
				System.out.println("-1");
			else
				System.out.println(ans-cost);
//			for(int j=0;j<hight;j++){
//				for(int i=0;i<width;i++){
//				
//				System.out.print(map[j][i]);
//				}
//				System.out.println();
//			}
	}

	private static void work(char[][] meiz,int[][] map, int j, int i ,int cost) {
		// TODO 自動生成されたメソッド・スタブ
		
		if(j>0) check(meiz,map,j-1,i,cost);
		if(i>0) check(meiz,map,j,i-1,cost);
		if(j<meiz.length-1) check(meiz,map,j+1,i,cost);
		if(i<meiz[0].length-1) check(meiz,map,j,i+1,cost);
		
	}

	private static void check(char[][] meiz,int[][] map, int j, int i, int cost) {
		
		if(meiz[j][i]== '.')
			if(map[j][i]==0)
				map[j][i] = cost+1;
	}

	
}

Measured memory_bytes: 21972
#include <stdio.h>
int main () {
    int n, m, l, data;
    int a[100+1][100+1];
    int b[100+1][100+1];
    long int c[100+1][100+1];
    scanf("%d %d %d", &n, &m, &l);
     
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &data);
            a[i][j] = data;
        }
    }
     
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            scanf("%d", &data);
            b[i][j] = data;
        }
    }
     
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            c[i][j] = 0;
        }
    }
     
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            for (int k = 0; k < m; k++) {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
     
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l-1; j++) {
            printf("%ld ", c[i][j]);
        }
        printf("%ld\n", c[i][l-1]);
    }
    return 0;
}






Measured memory_bytes: 2848
#include <bits/stdc++.h>
	
using namespace std;
	
#define endl "\n"
#define ll long long
#define vi vector <int >
#define vii vectir < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define a first
#define b second

int mark[25][25], ans, n, m;
char arr[25][25];

pii f(int t){
	if(t == 0) return {0, 1};
	if(t == 1) return {1, 0};
	if(t == 2) return {-1, 0};
	return {0, -1};
}



void bfs(int x, int y){
	queue <pii > q;
	q.push({x, y});
	mark[x][y] = 0;
	while(!q.empty()){
		int i = q.front().a;
		int j = q.front().b;
		q.pop();
		forn(e, 4){
			pii aux = f(e);
			int x1 = i + aux.a;
			int y1 = j + aux.b;
			if(x1 >= 0 && x1 <n && y1 < m && y1 >= 0){
				if(mark[x1][y1] == -1 && arr[x1][y1] != '#'){
					q.push({x1, y1});
					mark[x1][y1] = mark[i][j] + 1;
					ans = max(ans,mark[x1][y1]);
				}
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	ans = 0;
	cin >> n >> m;
	forn(i, n){
		forn(j, m){
			cin >> arr[i][j];
		}
	}
	forn(i, n){
		forn(j, m){
			memset(mark, -1, sizeof mark);
			if(arr[i][j] != '#'){
				bfs(i, j); 
			}
		}
	}

	cout << ans << endl;



	

	return 0;
}

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

int main() {
  string a, b;
  cin >> a >> b;
  string c = a + b;
  int n = stoi(c);
  for (int i = 1; i*i <= n; i++) {
    if (n == i*i) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int A[100000],n;

int binarySearch(int key){
  int left = 0;
  int right = n;
  int i = 0;
  int mid;
  while(left < right){
    mid = (left + right) / 2;
    if(key == A[mid]){
      return 1;
    }
    if(key > A[mid]) left = mid + 1;
    else if( key < A[mid]) right = mid;
  }
  return 0;
}
        

int main(){
  int q,i,k,ans = 0;
  cin >> n;
  for(i = 0; i < n; i++)
    cin >> A[i];

  cin >> q;
  for(i = 0; i < q; i++){
    cin >> k;
    if(binarySearch(k)) ans++;
  }

  cout << ans << endl;
  
  return 0;
}




Measured memory_bytes: 3476
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll INF =1e9+7;
    typedef pair<ll,ll> ii;
    #define f(i,a,b) for(long long i = a;i < b;i++)
    #define rf(i,a,b) for(long long i=a;i>=b;i--)
    #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define w(t) while(t--)
    #define c(n); cin>>n;
    #define p(n) cout<<n;
    #define pl(n) cout<<n<<endl;
    #define ps(n); cout<<n<<" ";
    double dist(ll x1,ll y1,ll x2, ll y2){
        ll a = (x1 - x2) * (x1 - x2);
        ll b = (y1 - y2) * (y1 - y2);
        return sqrt(a+b);
    }
    int main(void){
        fastio;
        ll n;
        c(n);
        string s="";
        ll x[n];
        ll y[n];
        f(i,0,n){
            c(x[i]);
            c(y[i]);
            s += '0' + i;
        }
        vector<double>ans;
        do{
            double num = 0;
            f(i,0,n-1){
                ll pos1 = s[i] - '0';
                ll pos2 = s[i+1] - '0';
                num += dist(x[pos1],y[pos1],x[pos2],y[pos2]);
            }
            ans.push_back(num);
        }
        while(next_permutation(s.begin(),s.end()));
        double sum = 0;
        for(auto x:ans){
            sum += x;
        }
        sum /= ans.size();
        cout<<setprecision(10)<<fixed<<sum<<endl;
   }


Measured memory_bytes: 892
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <list>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
using namespace std;

#define mp make_pair
#define pb push_back

typedef long long int64;
typedef unsigned long long uint64;

template<typename T>
void printVector(string &txt, vector<T> &a){
    cout << txt;
    for (int i = 0; i < a.size(); ++i)
        cout << a[i] << ' ';
    cout << endl;
}


int main(){

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

    int64 a, b;
    cin >> a >> b;
    if ((max(a, b) - min(a, b)) % 2 == 0)
        cout << (a + b) / 2 << endl;
    else
        cout << "IMPOSSIBLE" << endl;


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <set>
#include <map>
using namespace std;

int main() {
    long long N, M;
    cin >> N >> M;

    set<pair<long long, long long>> st;
    for(int i=0;i<M;i++){
        int a, b;
        cin >> a >> b;
        st.emplace(a, b);
    }
    for(int i=2;i<N;i++){
        if(st.count({1, i}) && st.count({i,N})){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "YES" : "NO";
}

int main(){
    string s; cin >> s;
    
    int ans = 0;
    rep(i,4){
        if(s[i] == '+') ans++;
        else ans--;
    }
    
    cout << ans << endl;
}







Measured memory_bytes: 256
#include <iostream>

int gcd(int x, int y)
{
    if (x < y) {
        int tmp = x;
        x = y;
        y = tmp;
    }
    while (y > 0) {
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main()
{
    int x, y;
    std::cin >> x >> y;
    int ans = gcd(x, y);
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES  

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>

int main(){
    int a, b;
    char symbol;

    while(1){
        std::cin >> a >> symbol >> b;
        if('?' == symbol){
            break;
        }else{
            switch(symbol){
                case '+':
                    std::cout << a + b << std::endl;
                    break;
                case '-':
                    std::cout << a - b << std::endl;
                    break;
                case '*':
                    std::cout << a * b << std::endl;
                    break;
                case '/':
                    std::cout << a / b << std::endl;
                    break;
            }
        }
    }
    
    return 0;
}


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

#define MAX 100
const int INF = INT_MAX;
int V, E;
long long A[MAX][MAX];

void marshallfroyd() {
	for (int k = 0; k < V; k++) {
		for (int i = 0; i < V; i++) {
			if (A[i][k] == INF)
				continue;
			for (int j = 0; j < V; j++) {
				if (A[k][j] == INF)
					continue;
				A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
			}
		}
	}
}

int main() {
	cin >> V >> E;
	for (int i = 0; i < V; i++) {
		for (int j = 0; j < V; j++) {
			A[i][j] = ((i == j) ? 0 : INF);
		}
	}
	for (int i = 0; i < E; i++) {
		int s, t, d;
		cin >> s >> t >> d;
		A[s][t] = d;
	}
	marshallfroyd();
	for (int i = 0; i < V; i++) {
		if (A[i][i] < 0) {
			cout << "NEGATIVE CYCLE" << endl;
			return 0;
		}
	}
	for (int i = 0; i < V; i++) {
		for (int j = 0; j < V - 1; j++) {
			if (A[i][j] == INF)
				cout << "INF" << " ";
			else
				cout << A[i][j] << " ";
		}
		if (A[i][V - 1] == INF)
			cout << "INF" << endl;
		else
			cout << A[i][V - 1] << endl;
	}
	return 0;
}



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

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

using namespace std;

using ll = long long;

template <class Pred>
ll partition_point_ll(ll first, ll last, Pred p) {
    ll count = last - first;
    while (count > 0) {
        ll step = count / 2;
        ll mid = first + step;
        if (p(mid)) {
            first = mid + 1;
            count -= step + 1;
        } else {
            count = step;
        }
    }
    return first;
}

ll ceil_sqrt(ll x) {
    return partition_point_ll(0, 1000000001, [=](ll a) { return a * a <= x; }) - 1;
}

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int Q;
    cin >> Q;
    REP(_, Q) {
        ll A, B;
        cin >> A >> B;
        if (A > B) swap(A, B);
        ll C = A * B - 1;
        ll sqrt_C = ceil_sqrt(C);
        ll result = 2 * sqrt_C;
        if (sqrt_C && C / sqrt_C == sqrt_C) --result;
        if (A <= sqrt_C) --result;
        cout << result << endl;
    }
    return 0;
}


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

int main() {
    ll n;
    cin >> n;
    map<string, ll> mp;
    mp.clear();
    for (ll i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }

    ll cnt = 0;
    for(auto i:mp){
        cnt = max(cnt, i.second);
    }
    for(auto i:mp){
        if (i.second == cnt) cout << i.first << endl;
    }
}


Measured memory_bytes: 25216
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>


using namespace std;


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

	long long ans = K;
	for (int i = 1; i < N; i++) {
		ans *= (K - 1);
	}

	cout << ans << endl;
}



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

using namespace std;

int main()
{
    int n,x,m[101],sum=0;
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>m[i];
        sum+=m[i];
    }
    sort(m,m+n);
    cout<<n+((x-sum)/m[0]);
    return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N) {
  string s = to_string(N);
  string t = s;
  reverse(ALL(t));
  cout << (s == t) << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	solve(N);
	return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for p in range(a + 1):
    for q in range(b + 1):
        #print("p:{}, q:{}, (x - p*500 - q*100) // 50:{}".format(p, q, (x - p*500 - q*100) // 50))
        if (x - p*500 - q*100) // 50 <= c and (x - p*500 - q*100) // 50 >= 0:
            ans += 1
            #print("hit")
print(ans)


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

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

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

ll gcd(ll x, ll y) {
    if (x % y == 0) {
        return y;
    }

    else {
        return gcd(y, x % y);
    }
}

int main() {
    ll N;
    cin>>N;
    vector<ll> v(N);
    rep(i,N) cin>>v[i];
    vector<bool> prime(1000005,true);
    prime[0] = prime[1] = false;
    vector<ll> m(1000005,0);
    vector<ll> cnt(1000005,0);
    rep(i,N) cnt[v[i]]++;
    rep(i,1000005){
        if(prime[i]) {
            m[i] += cnt[i];
            for(ll j = 2LL; i*j < 1000005; j++) {
                prime[i*j] = false;
                m[i] += cnt[i*j];
            }
        }
    }
    bool ok1 = true;
  rep(i,1000005){
        if(m[i]>=2) ok1 = false;
    }
    ll g = v[0];
    rep(i,N-1){
        g = gcd(g,v[i+1]);
        if(g==1) break;
    }
    if(ok1) cout<<"pairwise coprime"<<endl;
    else if(g==1) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
}

Measured memory_bytes: 26648
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        int count = 0;
        int numCount = 1;

        for (int i = 0; i < N; i++) {
            int num = scanner.nextInt();
            if (num != numCount) {
                count++;
            } else {
                numCount++;
            }
        }
        scanner.close();

        if (count != N) {
            System.out.println(count);
        } else {
            System.out.println(-1);
        }

    }
}


Measured memory_bytes: 65156
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define REP(i,j,n) for(int i = j;i < (n);i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int p1 = a*n;
  int p2 = b;
  cout << min(p1,p2) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
using pii=pair<int,int>;
using vs=vector<string>;
using vvi=vector<vi>;
using vpii=vector<pii>;
using si=set<int>;

#define REP(i,a) for(int i=0;i<a;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rREP(i,a) for(int i=(a)-1;i>=0;i--)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define out(S) cout<<(S)<<endl;
#define beginend(v) (v).begin(),(v).end()
#define IfOut(condition,text) if(condition){out(text);return 0;}
#define IfOutElse(condition,if_text,else_text) if(condition){out(if_text);return 0;}else{out(else_text);return 0;}
#define mod(s) ((s)%(ll)(1e9+7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a*modpow((ll)b,(ll)(1e9+5))))
#define pb(i) push_back(i)
#define fst first
#define snd second
#define Foreach(item,collection) for(auto item:collection)
#define INF (int)1e10
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}
ll sum(vi v) {ll sum=0;Foreach(i,v){sum+=i;}return sum;}
#define ShowAll(v) Foreach(i,v) out(i);
bool isInnerIndex(int kx,int ky,int mx,int my){ return (kx>=0&&kx<mx&&ky>=0&&ky<my); }

int x,y;
vvi box;
int dx[]{0,1,0,-1,1,1,-1,-1};
int dy[]{1,0,-1,0,-1,1,-1,1};
ll s=0;
void dfs(int px,int py){
    box[py][px]=2;
    REP(i,8){
        int nx=px+dx[i];
        int ny=py+dy[i];
        if(isInnerIndex(nx,ny,x,y)){
            if(box[ny][nx]==1)dfs(nx,ny);
        }
    }
    return;
}

int main(){
    vi ans;
    while (cin>>x>>y,(x||y))
    {
        box.clear();
        box.resize(y);
        REP(i,y) REP(n,x) {
            int c;
            cin>>c;
            box[i].pb(c);
        }
        ll s=0;
        REP(i,y)REP(n,x){
            if(box[i][n]==1) {dfs(n,i);s++;}
        }
        ans.pb(s);
    }
    
    ShowAll(ans);
    return 0;
}

Measured memory_bytes: 3124
#include <stdio.h>
int main()
{
int k,a,b;
int t=0;
scanf("%d",&k);
scanf("%d %d",&a,&b);
for(int i=a;i<=b;i++)
if(i%k==0) {printf("OK\n");t++;break;}
if(t==0) printf("NG\n");
return 0;
}

Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
#define alrep(i,j,n) for(int i=0;i<(n);++i)for(int j=i+1;j<(n);++j
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
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; }
const int MOD=1e9+7;
const long long INF = 1LL << 60;
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()



signed main(){
  int N;
  cin >> N;
  pair<double,double> xy[N];
  rep(i,N) cin >> xy[i].first >> xy[i].second;
  sort(xy,xy+N);
  double ans=0;
  do {
    rep(i,N-1){
      ans+=sqrt((xy[i].first-xy[i+1].first)*(xy[i].first-xy[i+1].first) + (xy[i].second-xy[i+1].second)*(xy[i].second-xy[i+1].second));
    }
  } while (next_permutation(xy,xy+N));
  int Nk=1;
  for(int i=1;i<=N;i++) Nk*=i;
  cout << fixed << setprecision(6) << ans/(double)Nk << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <complex>
using namespace std;

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

	cout<<N-M+1<<endl;
	return 0;
}

Measured memory_bytes: 256
import fractions
import functools
N, M = map(int, input().split())
A = [int(i) for i in input().split()]


def multiple(a, b):
    return a*b // fractions.gcd(a, b)


def lcm(nums):
    return functools.reduce(multiple, nums)


lcm = lcm(A)
hlcm = lcm//2
# print(lcm, hlcm)

for a in A:
    if a % 2 == 1:
        print(0)
        exit()
    if lcm//a % 2 == 0:
        print(0)
        exit()

if hlcm > M:
    print(0)
else:
    print((M+hlcm)//hlcm//2)


Measured memory_bytes: 89772
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
int era(int x,int *prime);
int main(){
    long int x;
    scanf("%ld",&x);
    int *a=(int*)malloc(sizeof(int)*(x-2));
    int c=0;
    int l=era(x-1,a);
    for(int i=x;;i++){
        c=0;
        for(int j=0;j<l;j++){
            if(i%a[j]==0){
                c=1;
                break;
            }
        }
        if(c==0){
            printf("%d\n",i);
            break;
        }
    }
    free(a);
    return 0;
}

int era(int x,int *prime){
    int i, j= 0;
    int count = 0;
    int *flags = (int*)calloc(x+1,sizeof(int));
    for (i = 2; i <= x; i++) {
        if (flags[i] == 0) {
            ++count;
            prime[count-1]=i;
            for (j = i * 2; j <= x; j += i) {
                flags[j] = 1;
            }
        }
    }
    return count;
}

Measured memory_bytes: 640
A,B=map(x->parse(Int,x),split(readline()))
s=chomp(readline())
flag=true
for i=1:A
	if s[i]=='-'
		flag=false
	end
end
if s[A+1]!='-'
	flag=false
end
for i=A+2:A+B+1
	if s[i]=='-'
		flag=false
	end
end
println(flag ? "Yes" : "No")


Measured memory_bytes: 110340
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,k,sum,vis[100005];
vector<int>v[100005];
const int Mod=1000000007;
void dfs(int x){
	vis[x]=1;
	ll y;
	if(x==0)y=k-1;
	else y=k-2;
	for(int i=0;i<v[x].size();i++){
		int u=v[x][i];
		if(vis[u])continue;
		if(y==0)sum=0;
		else sum=(sum*y)%Mod;
		y--;
		dfs(u);
	}
}
int main(){
	in(n);in(k);
	sum=k;
	for(int i=1;i<n;i++){
		int x,y;
		in(x);in(y);
		v[x-1].push_back(y-1);
		v[y-1].push_back(x-1);
	}
	dfs(0);
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 9600
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        
        System.out.println(Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2)));
    }
}


Measured memory_bytes: 28016
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <stack>
using namespace std;

#define INF 1e18
#define int long long



signed main() {
    int x, y; cin >> x >> y;

    if(x % y == 0) {
        cout << -1 << endl;
        return 0;
    }

    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
S = str(input())
T = str(input())
slist = list(S)
tlist = list(T)
Slen = len(slist)
Tlen = len(tlist)
ANSlist = []
Flag = 0
if Slen < Tlen:
    Flag = 0
else:
    for i in range(Slen-Tlen+1):
        flag = 0
        for j in range(Tlen):
            if slist[i+j] == "?" or slist[i+j] == tlist[j]:
                pass
            else:
                flag = 1
                break
        if flag == 0:
            Skari = ""
            k = 0
            for k in range(i):
                if slist[k] == "?":
                    Skari+="a"
                else:
                    Skari+=slist[k]
            l = 0
            for l in range(Tlen):
                Skari+=tlist[l]
            m = 0
            Skarilen = len(Skari)
            for m in range(Slen-Skarilen):
                M = m+Skarilen
                if slist[M] == "?":
                    Skari+="a"
                else:
                    Skari+=slist[M]
            ANSlist.append(Skari)
            Flag+=1
        else:
            pass
if Flag >= 1:
    print(min(ANSlist))
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
S = input()
T = ['dream', 'dreamer', 'erase', 'eraser']


def reverse(t):
    return t[::-1]


RT = [reverse(t) for t in T]
RS = reverse(S)
can = True
i = 0
while i < len(RS):
    can2 = False
    for j in range(4):
        sizeT = len(RT[j])
        if RT[j] == RS[i:i + sizeT]:
            i += sizeT
            can2 = True
            break

    if not can2:
        can = False
        break

if can:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>

using namespace std;
using ll=long long int;
const int INF = 1e9;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }

    vector<array<int, 2>> t(n);
    t[0][0] = 1;
    t[0][1] = -INF;
    t[1][0] = s[0] == s[1] ? -INF : 2;
    t[1][1] = 1;
    for (int i = 2; i < n; ++i) {
        t[i][0] = t[i-1][1]+1;
        t[i][1] = t[i-2][0]+1;
        if (s[i-1] != s[i]) t[i][0] = max(t[i][0], t[i-1][0]+1);
        if (i > 2 && s.substr(i-3, 2) != s.substr(i-1, 2)) t[i][1] = max(t[i][1], t[i-2][1]+1);
    }

    cout << max(t[n-1][0], t[n-1][1]) << endl;
    return 0;
}


Measured memory_bytes: 2180
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

int main(){
	ll n;
	scanf("%lld",&n);
	rep(i,0,100)rep(j,0,100){
		if(i*4+j*7==n){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}

Measured memory_bytes: 128
n, d = map(int, input().split())
XN = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
    for j in range(i+1, n):
        Y = XN[i]
        Z = XN[j]
        dis = 0
        for y, z in zip(Y, Z):
            dis += (y-z)**2
        if int(dis**.5) == dis**.5:
            ans += 1
print(ans)


Measured memory_bytes: 3188
N, A, B = map(int, input().split())
ans = 0

for i in range(1, N+1):
    num_str = str(i)
    nums_list = list(num_str)
    nums_list_int = list(map(int, nums_list))
    num_sum = sum(nums_list_int)
    if A <= num_sum <= B:
        ans += i
print(ans)

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, K) = Slice2<long>();
            var S = ReadLine().ToCharArray();
            S[K - 1] = (char)(S[K - 1] + 'a' - 'A');
            WriteLine(string.Join("", S));
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 27512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
        int[] o=new int[n];
      	for (int i=1;i<=n;i++){
          int a=sc.nextInt();
          o[a-1]=i;
        }
        for (int i=0;i<n;i++){
			System.out.print(o[i]+" ");
        }
	}
}

Measured memory_bytes: 60996
h1, m1, h2, m2, k = list(map(int, input().split()))
ans = 0
delta = 60 * (h2 - h1)
if m2 > m1:
    delta += (m2 - m1)
else:
    delta -= (m1 - m2)
print(max(0, delta - k))

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

void shuffle(vector<int> &deck,int c) {
    const int n = deck.size();
    queue<int> a,b;
    for(int i=0; i<(n/2); ++i) b.push(deck[i]);
    for(int i=(n/2); i<n; ++i) a.push(deck[i]);

    int idx=0;
    while(true) {
        for(int i=0; i<c; ++i) {
            if(a.empty()) break;
            deck[idx++] = a.front();
            a.pop();
        }

        for(int i=0; i<c; ++i) {
            if(b.empty()) break;
            deck[idx++] = b.front();
            b.pop();
        }

        if(a.empty() && b.empty()) break;
    }
}

int main() {
    int n,k,r;
    while(cin>>n>>r) {
        vector<int> deck(n);
        for(int i=0; i<n; ++i) deck[i] = i;

        for(int i=0; i<r; ++i) {
            cin>>k;
            shuffle(deck, k);
        }
        cout<<deck[n-1]<<endl;
    }
}

Measured memory_bytes: 0
x, y, z = map(int, input().split())

all = x * y * z

ans1 = int(x/2) * y * z
ans2 = x * int(y/2) * z
ans3 = x * y * int(z/2)

if ans1 == max(ans1, ans2, ans3):
    print(all - ans1 * 2)
elif ans2 == max(ans1, ans2, ans3):
    print(all - ans2 * 2)
else:
    print(all - ans3 * 2)

Measured memory_bytes: 3060
import java.util.*;

 public class Main {

  
    public static void main(String[] args) {
      Scanner x= new Scanner(System.in);
      int n = x.nextInt();
      int d = x.nextInt();
      double[]nums = new double[n];
      for(int i = 0 ; i < n;i++){
      double a = x.nextDouble();
      double b = x.nextDouble();
      a = Math.pow(a,2);
      b= Math.pow(b,2);
      double c = Math.sqrt(a+b);
      nums[i] = c;
      }
      int count = 0;
          for(int i = 0 ; i<n;i++){
          if(nums[i] <=d){
          count++;
          }
          }
          System.out.println(count);
          
    }
    
}


Measured memory_bytes: 66212
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n;
	cin>>n;
	cout<<"ABC"<<n<<endl;
}

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

int main(void)
{
    int a[5];
    int k;
    for (int i = 0; i < 5; i++)
    {
        cin >> a[i];
    }
    cin >> k;
    // 今回はa<b<c<・・・<e
    // 最大値であるaとeの距離がk以下ならok
    if (a[0] - a[4] <= k and a[0] - a[4] >= -k)
    {
        cout << "Yay!";
    }
    else
    {
        cout << ":(";
    }
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  val s = StdIn.readLine.split(" ")
  val d = s(0).toInt
  val n = s(1).toInt

  if (n == 100) {
    d match {
      case 0 => println(101)
      case 1 => println(10100)
      case 2 => println(1010000)
    }
  } else {
    d match {
      case 0 => println(n)
      case 1 => println(n * 100)
      case 2 => println(n * 10000)
    }
  }
}

Measured memory_bytes: 25532