akhauriyash/Code-Regression huggingface dataset:
import heapq as hq

N, M = map(int,input().split())

costs = dict()
adj = [list() for _ in range(N)]

e = lambda a,b: (a,b) if a<=b else (b,a)

for i in range(M):
  a,b,c = map(int, input().split())
  a -= 1
  b -= 1
  adj[a].append(b)
  adj[b].append(a)
  costs[e(a,b)] = c

max_dist = sum(costs.values())+1
used_edge = set()

for s in range(N):
  q = [(0,s)]
  dist = [max_dist]*N
  dist[s] = 0

  while q:
    c, u = hq.heappop(q)
    if c > dist[u]:
      continue

    for v in adj[u]:
      ee = e(u,v)
      if dist[v] > dist[u] + costs[ee]:
        dist[v] = dist[u] + costs[ee]
        hq.heappush(q, (dist[v], v))

  for t in adj[s]:
    if costs[e(s,t)] == dist[t]:
      used_edge.add(e(s,t))

print(len(costs.keys()-used_edge))


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

char N;
int s;

int main()
{
	cin>>s;
	while(cin>>N)
	{
		N+=s;
		if(N>'Z')
		{
			N-=26;
		}
		cout<<N;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

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

	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (x % 10 == 1) ans++;
		x /= 10;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int  n=nxt(),k=nxt();
    vector <int> v(n+1);
    ll sum=0;
    for(int i=1;i<=n;i++){
        cin>>v[i];
        sum+=v[i];
    }
    v[0]=INT_MIN;
    sort(all(v));
    if(sum<k)
    {
        cout<<n<<endl;
        return 0;
    }
    int index=0;
    int l=1,r=n;
    while(l<=r)
    {
        int mid=(l+r)/2;
        vector <vector <bool> > dp;
        vector <bool> row;
        row.resize(k,0);
        dp.resize(n+1,row);
        dp[0][0]=1;
        for(int i=1;i<=n;i++)
        {
            dp[i]=dp[i-1];
            if(i==mid)
                continue;
            for(int j=k-1;j>=0;j--)
            {
                if(j-v[i]<0)
                    break;
                if(dp[i][j-v[i]]==1)
                    dp[i][j]=1;
            }
        }
        int left=k-v[mid];
        int right=k-1;
        bool f=0;
        for(int i=0;i<k;i++)
            if(i>=left&&i<=right&&dp[n][i])
            {
                f=1;
                break;
            }
        //cout<<mid<<" "<<f<<endl;
        if(!f)
        {
            index=mid;
            l=mid+1;
        }
        else
            r=mid-1;
    }
    cout<<index<<endl;


    
    
    
    return 0;   
}




 
 


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
#define pii pair<int,int> 
int MOD = 1e9 + 7;

int main () {
	int n;
	cin >> n;
	lli tmp;
	int a[60];
	fop (i,0,60) a[i] = 0;
	fop (i,0,n) {
		cin >> tmp;
		fop (i,0,60) {
			if (tmp & (1ll << i)) {
				a[i]++;
			}
		}
	}
	lli sum = 0;
	fop (i,0,60) {
		lli aa = (1ll << i) % MOD;
		sum += (((aa * a[i]) % MOD) * (n - a[i]));
		sum %= MOD;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define mod 1000000007
using namespace std;
int n;
int arr[30][30];
int dp[22][(1LL<<22)];
int val;
int solve(int pos , int mask)
{
    if(pos == n)
    {
       if(mask == val)
        return 1;
       else
        return 0;
    }

    if(dp[pos][mask]!= -1)
      return dp[pos][mask];

    int wm;bool chk = false;int res = 0;
    for(int  i = 0;i<n;i++)
    {
       wm = arr[pos][i];
       if(wm && (mask&(1LL<<i))==0)
       {
           chk = true;
           res = (res + solve(pos+1 ,(mask|(1LL<<i))))%mod;
       }
    }

    if(!chk)
    {
      res = 0;
    }

    return dp[pos][mask] = res;
}
signed main(void)
{
   cin>>n;
   memset(dp , -1 ,sizeof dp);
   for(int  i = 0;i<n;i++){
    for(int  j = 0;j<n;j++)
      cin>>arr[i][j];
  }
    val = (1LL<<n)-1;
    cout<<solve(0,0)<<endl;
}

Measured memory_bytes: 721280
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair
ll dp[110][114514],w[110],v[110];

int main() {
	ll n, wa,a = 0;
	cin >> n >> wa;
	REP(i, n) cin >> w[i] >> v[i];
	REP(i, n) {
		REP(j, wa + 1) {
			if (j >= w[i]) dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
			else dp[i + 1][j] = dp[i][j];
		}
	}
	cout << dp[n][wa] << endl;
}

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

typedef long long ll;

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}


Measured memory_bytes: 3620
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

string s, t;
int dp[1001][1001];

int main() {
	cin >> s >> t;
	fill(dp[0], dp[0] + 1001, 1);
	for (int i = 0; i < t.size(); ++i) {
		for (int j = 0; j < s.size(); ++j) {
			dp[i + 1][j + 1] = dp[i + 1][j];
			if (j >= i && t[i] == s[j]) {
				dp[i + 1][j + 1] = dp[i][j] + dp[i + 1][j];
			}
			dp[i + 1][j + 1] %= MOD7;
		}
	}

	cout << dp[t.size()][s.size()] << endl;

	return 0;
}

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

int main()
{
	char c;
	int i = 1;
	int ans=0;
	int a[12] = {0};
	while (cin >> c) {
		if (c == 'A' || c == 'C' || c == 'G' || c == 'T')a[i]++;
		if (a[i] == 1 && a[i - 1] > 0)a[i] = a[i - 1] + 1;
		if (ans < a[i])ans = a[i];
		i++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

L = []
v = 0
for _ in range(M):
    a, b = map(int, input().split())
    l = sum([1 << (int(v) - 1) for v in input().split()])
    L.append([a, b, l])
    v = v | l
if v != (1 << N) - 1:
     print(-1)
     exit()

dp = [[10 ** 18 for _ in range(1 << N)] for _ in range(M + 1)]
dp[0][0] = 0

for i in range(M):
     for j in range(1 << N):
          dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

          dp[i + 1][j | L[i][2]] =  min(dp[i + 1][j | L[i][2]], dp[i][j] + L[i][0])

print(dp[M][(1 << N) - 1])

Measured memory_bytes: 76124
#include <stdio.h>

int main(){
  int input[10];
  int i;
  for(i =0; i < 3; i++){
    scanf("%d", &input[i]);
  }

  for(int i=0;i<2;i++){
    for(int j = 2;j>i;j--){
      if(input[j]<input[j-1]){
        int temp = input[j];
        input[j]=input[j-1];
        input[j-1] = temp;
      }
    }
  }

  for (i = 0; i < 3; i++) {
    printf("%d", input[i]);
    if (i < 2) {
      printf(" ");
    }else{
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i = 0;i<n;i++)
using ll = long long;
using P = pair<ll,ll>;
using Graph = vector<vector<char>>;

int main() {
  string s;cin>>s;
  int n = s.size();
  ll t = stol(s);
  vector<int> v(n);
  rep(i,n){
    v.at(i)=t%10;
    t/=10;
  }
  reverse(v.begin(),v.end());
  int ans = 1e4,num = 0;
  rep(i,n-2){
    num = v.at(i)*100 + v.at(i+1)*10 + v.at(i+2);
    ans = min(ans,abs(num-753));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [0] * N
d = [0] * N
c[N-1]=a[N-1]+b[N-1]
d[N-1]=b[N-1]
for i in range(N-2,-1,-1):
    d[i] = d[i+1] + b[i]
    c[i] = max(a[i]+c[i+1],a[i]+d[i])
print(c[0])

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;


void sieve(vector<int> &primes){
    const int M = 100010;
    bool isPrime[M];
    for(int i=2;i<M;i++) isPrime[i] = true;
    for(int i=2;i*i<M;i++){
        if(not isPrime[i]) continue;
        for(int j=i*i;j<M;j+=i){
            isPrime[j] = false;
        }
    }
    for(int i=2;i<M;i++){
        if(isPrime[i]) primes.push_back(i);
    }
}

int main(){
    vector<int> primes;
    sieve(primes);
    while(true){
        ll m,a,b;
        cin >> m >> a >> b;
        if(m == 0) break;
        ll maxpq = -1;
        ll retp,retq;
        for(int i=0;i<primes.size();i++){
            int lower = 0,upper = primes.size()-1;
            for(int j=0;j<100;j++){
                int mid = (lower+upper)/2;
                ll p=primes[i],q=primes[mid];
                if(p*q <= m and a*q <= p*b){
                    lower = mid;
                }else{
                    upper = mid;
                }
            }
            ll p = primes[i],q=primes[lower];
            if(p <= q and p*q >= maxpq){
                maxpq = p*q;
                retp = p,retq = q;
            }
        }
        cout << retp << " " << retq << endl;
    }
    return 0;
}

Measured memory_bytes: 1416
#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 MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}


int main()
{
  ll N, X;
  cin >> N >> X;

  vector<ll> A(N);
  REP(i, N){
    cin >> A[i];
  }
  if(N>=2){
    ll x = abs(X-A.at(0));
    ll MIN = gcd(x,abs(A.at(1)-A.at(0)));
    FOR(i,1,N-1){
      MIN = gcd(MIN,abs(A.at(i+1)-A.at(0)));
    }
    cout << MIN << endl;
  }else{
    cout << abs(A.at(0)-X) << endl;
  }
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

        String s = sc.nextLine();
        String[] str = new String[3];
        str = s.split("");
        if (str[0].equals(str[1]))
            System.out.println("No");
        else if (str[0].equals(str[2]))
            System.out.println("No");
        else if (str[1].equals(str[2]))
            System.out.println("No");
        else
            System.out.println("Yes");
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

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

void intSort(int d[],int s){int i=-1,j=s,k,t;if(s<=1)return;k=(d[0]+d[s-1])/2;while(1){while(d[++i]<k);while(d[--j]>k);if(i>=j)break;t=d[i];d[i]=d[j];d[j]=t;}intSort(d,i);intSort(d+j+1,s-j-1);}

int main(){
  int i;
  int data[100];

  rep(i,10) scanf("%d", &data[i]);
  intSort(data,10);
  rep(i,3) printf("%d\n", data[10-1-i]);

  return 0;
}

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

using namespace std;
const int nax = 2e5 + 5;
vector<int> g[nax];
bool visited[nax];

void dfs(int u, int& tmp) {
  if(visited[u]) {
    return;
  }
  visited[u]=1;
  tmp++;
  for(int v : g[u]) {
    dfs(v, tmp);
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, e;
  cin >> n >> e;
  while(e--) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    if(!visited[i]) {
      int tmp = 0;
      dfs(i, tmp);
      ans = max(ans, tmp);
    }
  }
  cout<<ans<<'\n';
  return 0;
}
  


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

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


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

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] num1=new int[n];
		int[] num2=new int[n];
		
		for(int t=0;t<n;t++) {
			num1[t]=sc.nextInt();
			num2[n-t-1]=num1[t];
		}
		
		for(int a=0;a<n-1;a++) {
			System.out.print(num2[a]+" ");
		}
		System.out.println(num2[n-1]);
	}
	
}





Measured memory_bytes: 26320
import sys
import math

a = []
for l in sys.stdin:
    a.append(l)

_input = a[0]

n = int(_input.split()[0])
k = int(_input.split()[1])

each_result = max(n-k+1, 0) * (1/n)

for each_n in range(1, min(n+1, k)):
    each_time = math.ceil(math.log2(k/each_n))
    each_result += 1/n * (1/2) ** each_time

print(each_result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
}
int r,c;
int arr[1000][1000];
vector<vector<char> > ve;
bool valid(int i, int j)
{
    return (i!=r&&j!=c&&ve[i][j]!='#');
}
int Pathnum(int rr , int cc)
{ if(!valid(rr,cc)) return 0;
  if(rr==r-1&&cc==c-1)return 1;
  int &mem =arr[rr][cc];
  if(mem!=-1)return mem;
  return arr[rr][cc]=(Pathnum(rr+1,cc)%1000000007+Pathnum(rr,cc+1)%1000000007)%1000000007;
}
int main()
{
    init();
    cin>>r>>c;
    ve.resize(r,vector<char>(c));
    for (int i=0; i<r; i++)
    {
        for (int j=0; j<c; j++)
            {cin>>ve[i][j];}
    }
    memset(arr,-1,sizeof(arr));
    cout<<Pathnum(0,0);
    return 0;
}


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

class DisjointSet {
	public:
		vector<int> rank,p;
		
	DisjointSet() {}
	DisjointSet(int size) {
		rank.resize(size,0);
		p.resize(size,0);
		for(int i=0;i<size;i++) {
			makeSet(i);
		}
	}
	
	void makeSet(int x) {
		p[x]=x;
		rank[x]=0;
	}
	
	bool same(int x, int y) {
		return findSet(x)==findSet(y);
	}
	
	void unite (int x, int y) {
		link(findSet(x), findSet(y));
	}
	
	void link(int x, int y) {
		if(rank[x] > rank[y]) {
			p[y]=x;
		}
		else {
			p[x]=y;
			if(rank[x]==rank[y]) rank[y]++;
		}
	}
	
	int findSet(int x) {
		if(x!=p[x]) {
			p[x]=findSet(p[x]);
		}
		return p[x];
	}
};

int main() {
	int n,q,x,y,t;
	cin>>n>>q;
	DisjointSet ds=DisjointSet(n);
	
	for(int i=0;i<q;i++) {
		cin>>t>>x>>y;
		
		if(t==0) {
			ds.unite(x,y);
		}
		else {
			if(ds.same(x,y)) cout<<1<<endl;
			else cout<<0<<endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;



int main(){

	int n,tmp,row_sum,col_sum[11];

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

		for(int i=0; i < 11; i++)col_sum[i] = 0;

		for(int i=0; i < n; i++){
			row_sum = 0;
			for(int k=0; k < n; k++){
				scanf("%d",&tmp);
				printf("%5d",tmp);
				row_sum += tmp;
				col_sum[k] += tmp;
			}
			printf("%5d\n",row_sum);
			col_sum[n] += row_sum;
		}
		for(int i=0; i <= n; i++)printf("%5d",col_sum[i]);
		printf("\n");
	}

    return 0;
}



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

using namespace std;

int main() {
    int n;
    cin >> n;
    if(n % 2)
    {
        cout << "No";
        return 0;
    }
    string s;
    cin >> s;
    bool all = true;
    for(int i = 0; i < n / 2; i++)
        all &= s[i] == s[n / 2 + i];
    if(all)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, p[11], res = 0;

    cin >> n;
    REP(i, n)
    cin >> p[i], res += p[i];

    sort(p, p + n);

    res -= p[n - 1] / 2;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

const int N = 2005, M = N * N, P = 1e9 + 7;

int n, k, fac[M], fac_rev[M], li, f[N][N];

int qp (int a, int b) { int c = 1; for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) c = 1ll * c * a % P; return c; }
int C (int n, int m) { if (m > n) return 0; return 1ll * fac[n] * fac_rev[m] % P * fac_rev[n - m] % P; }

int main () {
	scanf("%d%d", &n, &k);
	if (k == 1) return puts("1"), 0;
	li = n * k;
	fac[0] = 1; for (int i = 1; i <= li; ++i) fac[i] = 1ll * fac[i - 1] * i % P;
	fac_rev[li] = qp(fac[li], P - 2);
	for (int i = li - 1; ~i; --i) fac_rev[i] = 1ll * fac_rev[i + 1] * (i + 1) % P;
	f[0][0] = 1;
	for (int i = 0; i <= n; ++i) {
		for (int j = i; ~j; --j) if (f[i][j]) {
			if (j > 0) f[i][j - 1] = (f[i][j - 1] + f[i][j]) % P;
			if (i < n) f[i + 1][j + 1] = (1ll * C(k - 2 + i * k - j, k - 2) * (n - i) % P * f[i][j] + f[i + 1][j + 1]) % P;
		}
	}
	printf("%d\n", f[n][0]);
	return 0;
}

Measured memory_bytes: 46336
import java.util.*;
import java.io.*;

class FishingData implements Comparable<FishingData> {

    final int id;
    int no;

    FishingData( final int id ) {
	this.id = id;
    }

    FishingData( final int id, final int no ) {
	this.id = id;
	this.no = no;
    }

    public int compareTo( FishingData fd ) {
	if ( no != fd.no ) {
	    return no - fd.no;
	} else {
	    return fd.id - id;
	}
    }	
}

class MaxContainer {

    final TreeSet<FishingData> set;
    final HashMap<Integer, FishingData> map;
    
    public MaxContainer() {
	set = new TreeSet<FishingData>();
	map = new HashMap<Integer, FishingData>();
    }

    public FishingData getMaxData() {
	return set.last();
    }

    public void catchEvent( final int id, final int diff ) {
	if ( map.containsKey( id ) ) {
	    final FishingData fd = map.get( id );
	    set.remove( fd );
	    fd.no += diff;
	    set.add( fd );
	} else {
	    final FishingData fd = new FishingData( id, diff );
	    map.put( id, fd );
	    set.add( fd );
	}
    }
}

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	final int n = stdin.nextInt();
	final int q = stdin.nextInt();
	MaxContainer mc = new MaxContainer();

	for ( int i = 0; i < q; i++ ) {
	    final int id = stdin.nextInt();
	    final int vol = stdin.nextInt();
	    
	    mc.catchEvent( id, vol );
	    final FishingData maxFd = mc.getMaxData();
	    System.out.printf( "%d %d\n", maxFd.id, maxFd.no );
	}	
    }    
}

Measured memory_bytes: 119320
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20); 
    #endif
    int n;
    cin >> n;
    vector <int> a(n);
    int l = 0, ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] <= l + 1) {

        }
        else {
            ans += (a[i] - 1) / (l + 1);
            a[i] = 1;                           
        }   
        l = max(l, a[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3964
#include<stdio.h>
int main(){

	char op;
	int a,b;
	do{
		scanf("%d %c %d",&a,&op,&b);
		if(0<=a && b<=20000){
				switch(op){
					case '+' : 
						printf("%d\n",a+b);	break;
					case '-' : 
						printf("%d\n",a-b);	break;
					case '*' : 
						printf("%d\n",a*b);	break;
					case '/' : 
						printf("%d\n",a/b);	break;
				}
		}
	}while(op != '?');
	return 0;
}

Measured memory_bytes: 1812
#include <iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
int main(void){
set<long long> s;
int n,k;
cin>>n>>k;

int ar[n];
for(int i=0;i<n;i++){
    cin>>ar[i];
}
long long sum=0;
sort(ar, ar+n);
for(int i=0;i<(n-k);i++){
    sum+=ar[i];
}

cout<<sum;
}



Measured memory_bytes: 3976
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
const int N = 1e5 + 5;
typedef long long ll;
const ll INF = 0x3f3f3f3f3f3f3f3f; 
using namespace std;

int n, m, a[N], b[N], id[N], pa[N], vis[N];
ll f[N], sum[N]; 
vector<int> g[N], son; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int getf(int x) { return pa[x] == x ? x : pa[x] = getf(pa[x]); }

bool cmp(int x, int y) { return a[x] < a[y]; }

int main()
{
	n = read <int> (), m = read <int> ();
	for(int i = 1; i <= n; i++)
	{
		a[i] = read <int> (), b[i] = read <int> ();
		a[i] = max(a[i] - b[i], 0), id[i] = pa[i] = i; 
	}
	sort(id + 1, id + n + 1, cmp);
	for(int u, v, i = 1; i <= m; i++)
		u = read <int> (), v = read <int> (), g[u].push_back(v), g[v].push_back(u);
	for(int u, i = 1; i <= n; i++)
	{
		son.clear(), u = id[i];
		vis[u] = 1, sum[u] = b[u];
		for(int v, j = 0; j < g[u].size(); j++)
		{
			v = g[u][j]; if(!vis[v] || getf(v) == getf(u)) continue;
			sum[u] += sum[getf(v)], son.push_back(getf(v)), pa[getf(v)] = getf(u); 
		}
		if(!son.size()) { f[u] = a[u] + b[u]; continue; }
		f[u] = INF; 
		for(int v, j = 0; j < son.size(); j++)
			v = son[j], f[u] = min(f[u], sum[u] - sum[v] + max(1ll * a[u], f[v])); 
	}
	printf("%lld\n", f[id[n]]); 
	return 0; 
}

Measured memory_bytes: 12232
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pb push_back
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0)
const ll INF=4e18;
const ll MAX=1e5+5;
const ll MOD=1e9+7;
//}}}
ll cnt[300];
int main(){
	IOS;
	string s;
	cin>>s;
	for(int i:s)
		cnt[i]++;
	ll ans=SZ(s)*(SZ(s)-1)/2+1;
	for(int i='a';i<='z';i++){
		ans-=cnt[i]*(cnt[i]-1)/2;
	}
	cout<<ans<< '\n';
	return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


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

  vector <int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  int M = -1e6, m = 1e6;
  int Mnum = 0, mnum = 0;
  for (int i = 0; i < N; i++){
    if (M < A[i]){
      M = A[i]; Mnum = i;
    }
    if (m > A[i]){
      m = A[i]; mnum = i;
    }
  }

  vector < pair<int, int> > ans;
  if (m > 0){
    ans.push_back(make_pair(Mnum, 0));
    for (int i = 0; i < N - 1; i++){
      ans.push_back(make_pair(i, i + 1));
    }
  }else if(M < 0){
    ans.push_back(make_pair(mnum, N - 1));
    for (int i = N - 1; i >= 1; i--){
      ans.push_back(make_pair(i, i - 1));
    }
  }else{
    if (M >= abs(m)){
      ans.push_back(make_pair(Mnum, 0));
      ans.push_back(make_pair(Mnum, 0));
      for (int i = 0; i < N - 1; i++){
        ans.push_back(make_pair(i, i + 1));
        ans.push_back(make_pair(i, i + 1));
      }
    }else{
      ans.push_back(make_pair(mnum, N - 1));
      ans.push_back(make_pair(mnum, N - 1));
      for (int i = N - 1; i >= 1; i--){
        ans.push_back(make_pair(i, i - 1));
        ans.push_back(make_pair(i, i - 1));
      }
    }    
  }
    
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++){
    cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define EX 16016
#define MX 32032
using namespace std;
bitset<MX> dpx[MX], dpy[MX];
bitset<MX> visx[MX], visy[MX];
vector<int> xx, yy;
 
bool recx(int idx, int val) {
	if (idx==xx.size() && val==EX) return true;
	else if (idx==xx.size()) return false;
	else if (visx[idx][val]) return dpx[idx][val];
	visx[idx][val]=true;
	return dpx[idx][val]=recx(idx+1,val-xx[idx])|recx(idx+1,val+xx[idx]);
}
 
bool recy(int idx, int val) {
	if (idx==yy.size() && val==EX) return true;
	else if (idx==yy.size()) return false;
	else if (visy[idx][val]) return dpy[idx][val];
	visy[idx][val]=true;
	return dpy[idx][val]=recy(idx+1,val-yy[idx])|recy(idx+1,val+yy[idx]);
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	int x,y;
	cin>>x>>y;
	int c=0; bool dir=true;
	for (int i=0; i<s.length(); i++) {
		if (s[i]=='T') {
			if (dir) xx.push_back(c);
			else yy.push_back(c);
			c=0;
			dir=!dir;
		}
		else c++;
	}
	if (dir) xx.push_back(c);
	else yy.push_back(c);
	printf("%s\n", recx(1,x+EX-xx[0])&&recy(0,y+EX)?"Yes":"No");
}


Measured memory_bytes: 68224
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void){
    char s[200000+5];
    scanf("%s", s);
    int n=strlen(s);
    long cnt=0, wcnt=0;
    for(int i=0; i<n; i++){
        if(s[i]=='W'){
            cnt+=(i-wcnt);
            wcnt++;
        }
    }
    printf("%ld\n", cnt);
    return 0;
}


Measured memory_bytes: 1872
#include <stdio.h>

int sort(const void* a, const void* b) {
  return *( int * )a - *( int * )b;
}

int main(void) {
    	int i,j,k,n,q,t;
	int S[100000];
	int T[50000];
	int R[500];
	
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%d", &S[i]);
	}

	scanf("%d\n", &q);
	for(i=0;i<q;i++) {
		scanf("%d", &T[i]);
	}
	
	qsort((void*)S, n, sizeof(S[0]), sort);
	qsort((void*)T, q, sizeof(T[0]), sort);
	
	i=j=k=0;
	while(i<n && j<q) {
		if(S[i] == T[j]) {
			R[k] = S[i];
			i++;j++;k++;
		} else if(S[i] > T[j]) {
			j++;
		} else if(S[i] < T[j]) {
			i++;
		}
	}
	printf("%d\n", k);

	return 0;
}


Measured memory_bytes: 2524
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: k
    character(100):: s

    read*, k
    read*, s

    if (len_trim(s) <= k) then
        print'(a)', s
    else
        print'(a)', s(1:k) // '...'
    end if
end program main

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

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

using namespace std;

int main(){
  int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
  int dx=x2-x1;
  int dy=y2-y1;

  cout<<x2-dy<<' '<<y2+dx<<' '<<x1-dy<<' '<<y1+dx;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,cnt1[100010],cnt2[100010];
int main(){
	n=read();int i,t1;
	for(i=1;i<=n;i++){
		t1=read();
		if(i&1) cnt1[t1]++;
		else cnt2[t1]++;
	}
	int maxn=0,pos;
	for(i=1;i<=100000;i++){
		if(maxn<=cnt1[i]) maxn=cnt1[i],pos=i;
	}
	int ans=n/2-maxn,ppos=pos,mm=maxn;
	maxn=0;pos=0;
	for(i=1;i<=100000;i++){
		if(maxn<=cnt2[i]) maxn=cnt2[i],pos=i;
	}
	if(pos==ppos){
//			cout<<"c\n";
		int ans1=0,ans2=0,mmm=maxn;
//		if(mm>maxn){
			//change 2
//			cout<<"c2\n";
			maxn=0;pos=0;
			for(i=1;i<=100000;i++){
				if(i!=ppos&&maxn<cnt2[i]) maxn=cnt2[i];
			}
			ans+=n/2-maxn;
			ans1=ans;
//		}
//		else{
			// change 1
			ans=n/2-mmm;
			maxn=0;pos=0;
			for(i=1;i<=100000;i++){
				if(i!=ppos&&maxn<cnt1[i]) maxn=cnt1[i];
			}
//			cout<<"c1 "<<maxn<<'\n';
			ans+=n/2-maxn; 
			ans2=ans;
//		}
		ans=min(ans1,ans2);
	}
	else ans+=n/2-maxn;
	cout<<ans<<'\n';
} 

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  ll A, B, N; cin >> A >> B >> N; ll X;
  if(N<B) X = N;
  else X = B-1;
  cout << ((A*X)/B) - A*(X/B) << endl;
}

Measured memory_bytes: 3636
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Text.RegularExpressions;
using System.Security.Policy;

namespace Yuzuki
{
    class Yukari
    {
        static int n, x;
        static string s, t;
        static int[] ps;

        public static void Main(string[] args)
        {
            input();

            HashSet<int> hs = new HashSet<int>(ps);
            
            for (int i = 0; i < 200; i++)
            {
                if (!hs.Contains(x - i))
                {
                    Console.WriteLine(x - i);
                    return;
                }
                if (!hs.Contains(x + i))
                {
                    Console.WriteLine(x + i);
                    return;
                }
            }

        }

        public static void input()
        {
            string[] buf = Console.ReadLine().Split();
            x = int.Parse(buf[0]);
            n = int.Parse(buf[1]);
            //s = buf[0];
            //t = buf[1];

            buf = Console.ReadLine().Split();
            ps = new int[n];
            for (int i = 0; i < n; i++)
            {
                ps[i] = int.Parse(buf[i]); 
            }
            Array.Sort(ps);
        }

    }
}

Measured memory_bytes: 27672
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();
		long[] arr = r.rla();
		if(arr[0] > 1 && arr[1] == 1) {
			print(0);
			return;
		}
		print (arr[1] * (int)Math.pow(arr[1] - 1, arr[0]-1)); // K * (K - 1)^N-1
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}

Measured memory_bytes: 23252
import string

count = {x: 0 for x in string.ascii_lowercase}
lines = ""

while True:
    try:
        lines += input().lower()
    except EOFError:
        break

for c in lines:
    if 'a' <= c <= 'z':
        count[c] += 1

for key in string.ascii_lowercase:
    print("{0} : {1}".format(key, count[key]))

Measured memory_bytes: 8096
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
  	map<int,int >count;
  for(int i=0,a;i<n;i++){cin>>a;count[a]+=1;}
  int m;cin>>m;
  int pos=1;
  for(int i=0,a;i<m;i++){cin>>a;
                      if(pos==0)continue;
     if(count.find(a)==count.end()){pos=0;continue;} 
     if(count[a]==0){pos=0;continue;}
                         else count[a]-=1;
                        }
 if(pos==1)cout<<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 12984
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <string.h>

using namespace std;

int k[10];
int coins[6] = {500,100,50,10,5,1};
int cnt[5];
int amt;

int main(){
  	cin >> k[0];
    for(int i = 1; k[i-1]; i++){
        cin >> k[i];
      	k[i-1] = 1000 -k[i-1];
      	amt++;
    }

    for(int i = 0; k[i]; i++){
        for(int j = 0; j < 6; j++){
            while(k[i] - coins[j] >= 0){
                k[i] -= coins[j];
                cnt[i]++;
            }
        }
    } 

    for(int i = 0; i < amt; i++){
        cout << cnt[i] <<  endl;
    }
}



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

int main()
{
  int64_t A, B, K;
  cin >> A >> B >> K;
  if(A >= K){A -= K;}
  else if(A + B >= K)
  {
    B -= K - A;
    A = 0;
  }
  else{A = 0; B = 0;}
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n,k,freq[105];
int main()
{
    cin>>n>>k;
    for(int i=1;i<=k;i++)
    {
        int x;
        cin>>x;
        for(int j=1;j<=x;j++)
        {
            int d;
            cin>>d;
            freq[d]++;
        }
    }
    int sol=0;
    for(int i=1;i<=n;i++)
    {
        if(freq[i]==0)
            sol++;
    }
    cout<<sol;

}


Measured memory_bytes: 3644
for i in range(4) :
    t, n = map(int, input().split())
    if t == 1 :
        print(6000 * n)
    elif t == 2 :
        print(4000 * n)
    elif t == 3 :
        print(3000 * n)
    elif t == 4 :
        print(2000 * n)



Measured memory_bytes: 5596
N, K = map(int, input().split())
P = [int(i) for i in input().split()]
ex_list = []
ex = 0
sum = 0
for j in range(K):
  sum += P[j]
ex_list.append((sum + K) / 2)
for i in range(N - K):
  sum = sum - P[i] + P[i + K]
  ex_list.append((sum + K) / 2)
print(max(ex_list))

Measured memory_bytes: 25188
N = gets.chomp.to_i
# A, B = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

ans = false
1.upto(9).each do |i|
  if ((N % i) == 0) && [*1..9].include?(N/i)
    ans = true
  end
end

if ans
  print "Yes\n"
else
  print "No\n"
end



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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String str = in.readLine();
    char[] c = str.toCharArray();
    System.out.println(c[0]==c[1]||c[1]==c[2]||c[2]==c[3]?"Bad":"Good");
  }
}

Measured memory_bytes: 22996
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(3*n);
    for(int i=0; i<3*n; ++i)
        cin >> a[i];

    sort(a.rbegin(), a.rend());
    long long ans = 0;
    for(int i=0; i<n; ++i)
        ans += a[2*i+1];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
MOD = 10**9 + 7
N, M = map(int, input().split())
S = [[N+1]*(N+1) for i in [0,1,2]]
T = [[0]*(N+1) for i in [0,1,2]]

C = [0]*(N+1)
for i in range(M):
    l, r, x = map(int, input().split())
    if r-l < x-1:
        print(0)
        exit(0)
    S[x-1][r] = min(S[x-1][r], l)
    T[x-1][r] = max(T[x-1][r], l)
    C[r] = 1

S0, S1, S2 = S
T0, T1, T2 = T

ok = 1
for i in range(N+1):
    if not T2[i] < S1[i] or not T1[i] < S0[i]:
        ok = 0
        break

if not ok:
    print(0)
    exit(0)

RM = [N+1]*(N+1); GM = [N+1]*(N+1)
for i in range(N-1, -1, -1):
    RM[i] = min(RM[i+1], S1[i+1])
    GM[i] = min(GM[i+1], S0[i+1])


X = {(0, 0): 3}
D = [0]*(N+1); D[0] = 6
B = [{} for i in range(N+1)]
B[0][0] = 3
bb = 0
for b in range(1, N):
    t2 = T2[b+1]; s1 = S1[b+1]; t1 = T1[b+1]; s0 = S0[b+1]

    rm = RM[b]
    gm = GM[b]
    if t1 <= b < gm:
        F = B[b]
        for z in range(t2, min(rm, b)):
            v = D[z] % MOD
            if v:
                F[z] = v; D[z] += v; D[b] += v
    if C[b+1]:
        for g in range(bb, min(t1, b)):
            for r, v in B[g].items():
                D[r] -= v; D[g] -= v
            B[g] = None
        bb = max(t1, bb)
        for g in range(bb, b):
            for r, v in B[g].items():
                if not t2 <= r < s1:
                    D[r] -= v; D[g] -= v
            B[g] = {r: v for r, v in B[g].items() if t2 <= r < s1}
ans = 0
for b in range(bb, N+1):
    if B[b]:
        ans += sum(B[b].values())
print(ans % MOD)

Measured memory_bytes: 6772
MOD = 10**9 + 7


def main():
    def Eratosthenes(x: int) -> set:
        """x以下の素数の集合を返す"""
        primes = {i for i in range(2, x+1)}
        for i in range(2, N+1):
            if i*i > N:
                break
            if i in primes:
                mul = 2
                while i*mul <= x:
                    primes.discard(i*mul)
                    mul += 1
        return primes

    N = int(input())
    ans = 1
    pf = Eratosthenes(N)
    for p in pf:
        i = 1
        cnt = 0
        while N//pow(p, i) > 0:
            cnt += N//pow(p, i)
            i += 1
        ans *= cnt + 1
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63540
MOD = 10**9 + 7
n = int(input())
chk = [0 for i in range(n+1)]
for i in range(2, n+1):
    y = 2
    while y*y <= i:
        while i % y == 0:
            chk[y] += 1
            i //= y
        y += 1
    if i > 1:
        chk[i] += 1

ans = 1
for i in chk:
    if i:
        ans = ans*(i + 1)%MOD
print(ans)

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


int n, a, b;
const int MOD = 1e9 + 7;
const int MAX = 1e6;
ll fac[MAX], finv[MAX], inv[MAX];


void input() {
    cin >> n >> a >> b;
}


ll modpow(ll x, ll y) {
    ll res = 1;
    while (y > 0) {
        if (y & 1) res = res * x % MOD;
        x = x * x % MOD;
        y >>= 1;
    }
    return res;
}


void comb_init() {
    fac[0] = 1;
    fac[1] = n;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * (n - i + 1) % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


ll nC(int k){
    return fac[k] * finv[k] % MOD;
}


int main() {
    input();
    comb_init();
    ll ans = modpow(2, n);
    ans -= 1;
    ans -= nC(a);
    ans -= nC(b);
    ans %= MOD;
    if (ans < 0) ans += MOD;
    cout << ans << endl;
}


Measured memory_bytes: 23680
/**
  *  Worg
  */
#include <vector>
#include <iostream>

int main() {
	int n; std::cin >> n;
	std::vector<std::vector<int>> add(n, std::vector<int>(3));
	for (int i = 0; i < n; i++) {
		std::cin >> add[i][0] >> add[i][1] >> add[i][2];
	}

	std::vector<std::vector<int>> dp(n, std::vector<int>(3, 0));
	dp[0][0] = add[0][0]; dp[0][1] = add[0][1]; dp[0][2] = add[0][2];
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j != k) {
					dp[i][j] = std::max(dp[i][j], dp[i - 1][k] + add[i][j]);
				}
			}
		}
	}

	std::cout << std::max(dp[n - 1][0], std::max(dp[n - 1][1], dp[n - 1][2])) << '\n';
	return 0;
}


Measured memory_bytes: 11264
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
using namespace std;
int main(){

  int n;
  cin>>n;
  vector<int>a(n);
  priority_queue<int> que;
  for(int i=0;i<n;i++){
    cin>>a[i];
    que.push(a[i]);
  }

  int flag=0,f;
  for(int i=0;i<n;i++){
    int m=que.top();
    if(m==a[i]){
      flag++;
      f=i;
    }
  }

int top=que.top();

  for(int i=0;i<n;i++){
    if(flag==1){
      if(i!=f) cout<<top<<endl;
      else{
        que.pop();
        cout<<que.top()<<endl;
      }
    }
    else cout<<top<<endl;
  }

}


Measured memory_bytes: 3316
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<int> A(n);
  vector<int> B(n+1,0);
  for(int i = 0; i < n; i++){
    cin >> A.at(i);
  }
  for(int i = 0; i < n; i++){
    B.at(i+1)=A.at(B.at(i))-1;
  }
  int terminate=B.at(n);
  int loop_start,loop;
  for(int i = 1; i < n+1; i++){
      if(B.at(n-i)==terminate){
        loop_start=n-i;
        loop=i;
        break;
      }
    }
  if(k<=n){
    cout << B.at(k)+1 << "\n";
  }else{
    cout << B.at((k-loop_start)%loop+loop_start)+1 << "\n";
  }
  return 0; 
}

Measured memory_bytes: 4836
'use strict';
console.log(function(args){
  const _tmp = args.trim().split(' ');
  const A = _tmp[0]|0, B = _tmp[1]|0;
  let K = _tmp[2]|0;
  const divisor = [];
  for ( let i = A; i >= 1; i-- ) {
    if ( A%i === 0 ) divisor.push(i);
  }
  for ( let j of divisor ) {
    if ( B%j === 0 && --K === 0 ) return j.toString();
  }
  return '1';
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7372
#include<iostream>
#include<algorithm>
using namespace std;
int d[100005];
int main()
{	//ios::sync_with_stdio(false);
	int i,j,n;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>d[i];
	sort(d+1,d+n+1);
	for(i=1,j=n;;i++,j--)
	{
		if(i==n/2&&j==n/2+1)
		{
			cout<<d[j]-d[i];
			return 0;
		}
}

}

Measured memory_bytes: 640
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String ans = "No";
		if(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)){
			ans = "Yes";
		}
		System.out.println(ans);
	}	
}

Measured memory_bytes: 23764