akhauriyash/Code-Regression huggingface dataset:
N = int(input())
x = []
y = []
h = []
for i in range(N):
    _x, _y, _h = map(int, input().split())
    x.append(_x)
    y.append(_y)
    h.append(_h)

def solve():
    for cx in range(101):
        for cy in range(101):
            H = -1
            Hmax = 1<<30
            flg = True
            for i in range(N):
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                if h[i] > 0:
                    HH = h[i] + dist
                    if H < 0:
                        H = HH
                    if H != HH or H > Hmax:
                        flg = False
                        break
                else:
                    Hmax = min(Hmax, dist)
                    if H > Hmax:
                        flg = False
                        break
            if flg:
                #if Hmax == 1:
                #    H = 1
                print(cx, cy, H)
                return

solve()

Measured memory_bytes: 41200
import sys
s=list(input())
ct=0
l=0;r=len(s)-1
while l<r:
  if s[l]==s[r]:
    l+=1
    r-=1
  elif s[l]!='x' and s[r]!='x':
    print(-1)
    sys.exit()
  elif s[l]=='x':
    ct+=1
    l+=1
  else:
    ct+=1
    r-=1
print(ct)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<ll> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi;

    ll solve(ll a[][2],vvi &dp,int n,int w,int i){
        if(i==n || w==0) return 0;
        if(dp[i][w]!=-1) return dp[i][w];
        if(a[i][0]>w) return dp[i][w]=solve(a,dp,n,w,i+1);
        return dp[i][w]=max(solve(a,dp,n,w,i+1),a[i][1]+solve(a,dp,n,w-a[i][0],i+1));

    }

    int main(){
                        
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin); 
    freopen("output.txt","w",stdout);   
    #endif */
 
        fast;   
        int t=1;
        // cin>>t; 
        while(t--){
            int n,w;
            cin>>n>>w;
            ll a[n][2];
            vvi dp(n+1,vi(w+1,-1));
            rep(i,0,n) cin>>a[i][0]>>a[i][1];
            cout<<solve(a,dp,n,w,0);
        } 
        return 0;   
    }       


    // First, solve the problem. Then, write the code. 


Measured memory_bytes: 80256
#include<stdio.h>

void q_sort(int numbers[], int left, int right){
    int pivot, l_hold, r_hold;

    l_hold = left;
    r_hold = right;
    pivot = numbers[left];
    while (left < right)
    {
        while ((numbers[right] >= pivot) && (left < right))
            right--;
        if (left != right)
        {
            numbers[left] = numbers[right];
            left++;
        }
        while ((numbers[left] <= pivot) && (left < right))
            left++;
        if (left != right)
        {
            numbers[right] = numbers[left];
            right--;
        }
    }
    numbers[left] = pivot;
    pivot = left;
    left = l_hold;
    right = r_hold;
    if (left < pivot)
        q_sort(numbers, left, pivot-1);
    if (right > pivot)
        q_sort(numbers, pivot+1, right);
}

int main(){
    int n[100],p[100],s[100],k[31]={0},i=1,x,cnt=1,len;
    while(scanf("%d,",&n[i])){
        //if(!n[i])break;
        scanf("%d",&p[n[i]]);
        if(n[i]==0&&p[n[i]]==0)break;
        s[n[i]]=p[n[i++]];
    }
    len=i;
    //for(i=1;i<=len;i++)printf("%d %d %d\n",n[i],p[i],s[i]);
    q_sort(s,1,len);
    //for(i=1;i<=len;i++)printf("%d %d %d\n",n[i],p[i],s[i]);
    for(i=len-1;i>0;i--){
    //puts("#");
        if(k[s[i]]==0)k[s[i]]=cnt++;
    }
    //for(i=0;i<=30;i++)printf("%d %d\n",i,k[i]);
    while(scanf("%d",&x)!=EOF){
        printf("%d\n",k[p[x]]);
    }
    return 0;
}

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

using namespace std;

const int64_t INF = 1e18;

int64_t dp[5050][5050][2];

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int N; cin >> N;
   vector<int64_t> L(N), R(N);
   for (int i = 0; i < N; ++i) cin >> L[i] >> R[i];
   {
      vector<int> ord(N);
      iota(ord.begin(), ord.end(), 0);
      sort(ord.begin(), ord.end(), [&](int i, int j) {
         return L[i] + R[i] < L[j] + R[j];
      });
      vector<int64_t> newL(N);
      vector<int64_t> newR(N);
      for (int i = 0; i < N; ++i) {
         newL[i] = L[ord[i]];
         newR[i] = R[ord[i]];
      }
      L.swap(newL);
      R.swap(newR);
   }
   for (int i = 0; i <= N; ++i) {
      for (int j = 0; j <= i; ++j) {
         for (int z = 0; z < 2; ++z) dp[i][j][z] = INF;
      }
   }
   int NL = (N-1)/2;
   int NR = N/2;
   dp[0][0][0] = 0;
   for (int i = 0; i < N; ++i) {
      for (int nl = 0; nl <= i; ++nl) {
         for (int z = 0; z < 2; ++z) {
            if (dp[i][nl][z] == INF) continue;
            int nr = i-nl-z;
            if (nl < NL) dp[i+1][nl+1][z] = min(dp[i+1][nl+1][z], dp[i][nl][z] + R[i] + (L[i]+R[i]) * (NL-nl-1));
            if (nr < NR) dp[i+1][nl][z] = min(dp[i+1][nl][z], dp[i][nl][z] + L[i] + (L[i]+R[i])*(NR - nr - 1));
            if (z == 0) dp[i+1][nl][1] = min(dp[i+1][nl][1], dp[i][nl][z] + L[i] * NL + R[i] * NR);
         }
      }
   }
   cout << dp[N][NL][1] << '\n';
   return 0;
}


Measured memory_bytes: 218756
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 87;
typedef long long ll;
int n;
ll MOD, dp[N], ans[N];
vector<int> g[N];
void dfs1(int u,int p)
{
    auto it = find(begin(g[u]), end(g[u]), p);
    if (it != end(g[u]))
        g[u].erase(it);
    dp[u] = 1;
    for (int v : g[u]) {
        dfs1(v, u);
        dp[u] = dp[u] * (1 + dp[v]) % MOD;
    }
}
void dfs2(int u, ll above)
{
    ans[u] = dp[u] * (1 + above) % MOD;
    vector<ll> a, po;
    int w = g[u].size();
    for (int v : g[u])
        a.push_back(dp[v] + 1);
    a.push_back(above + 1);
    po = a;
    for (int i = w - 1; i >= 0; --i)
        po[i] = po[i] * po[i + 1] % MOD;
    ll pr = 1;
    for (int i = 0; i < w; ++i) {
        dfs2(g[u][i], pr * po[i + 1] % MOD);
        pr = pr * a[i] % MOD;
    }
}
int main()
{
    cin >> n >> MOD;
    for (int i = 0; i < n - 1; ++i) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs1(1, 1);
    dfs2(1, 0);
    for (int i = 1; i <= n; ++i)
        cout << ans[i] << '\n';
}


Measured memory_bytes: 21888
import fileinput

chr_master = [
    ' ', '\',.!?', 'abcABC', 'defDEF', 'ghiGHI',
    'jklJKL', 'mnoMNO', 'pqrsPQRS', 'tuvTUV', 'wxyzWXYZ'
]

for s in (line.strip() for line in fileinput.input()):
    s += '!'
    prev_c = None
    cnt = 0
    chr_list = []
    for c in s:
        if c == prev_c:
            cnt += 1
            continue
        if prev_c == '0':
            if cnt > 1:
                chr_list.extend([(0, 0)] * (cnt - 1))
        else:
            if prev_c is not None:
                chr_list.append((int(prev_c), cnt - 1))

        prev_c = c
        cnt = 1
    print(''.join(chr_master[i][j] for i, j in chr_list))

Measured memory_bytes: 7552
#include <stdio.h>
#include <stdlib.h>

int min(int a, int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

int mins(int **s, int j, int n){
	int i, ans = 100;
	for(i = 0; i < n; i++){
		ans = min(ans, s[i][j]);
	}
	return ans;
}

int main(){
	int n, i, j;
	char c = 'a';
	scanf("%d\n", &n);
	int **s = (int **)malloc(sizeof(int *) * n);
	for(i = 0; i < n; i++){
		s[i] = (int *)malloc(sizeof(int) * 26);
		for(j = 0; j < 26; j++){
			s[i][j] = 0;
		}
		for(;;){
			scanf("%c", &c);
			if(c == '\n'){
				break;
			}
			s[i][(int)c - (int)('a')]++;
		}
	}
	for(j = 0; j < 26; j++){
		for(i = 0; i < mins(s, j, n); i++){
			printf("%c", (char)((int)('a') + j));
		}
	}
	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

s = input().split()[0]
t = input().split()[0]

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]
for i in range(len(s)):
    for j in range((len(t))):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i][j]+1, dp[i+1][j], dp[i][j+1])
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

i = len(s)
j = len(t)
ans = ''
while i>0 and j>0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        i -= 1
        j -= 1
        ans = s[i] + ans
print(ans)

Measured memory_bytes: 112476
#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 ALL(v) v.begin(), v.end()
typedef long long int ll;
using namespace std;

int main()
{
  int n;
  scanf("%d",&n);
  int a,b;
  vector<pair<int, int>> task;
  REP(i,n){
    scanf("%d%d",&a,&b);
    task.push_back(make_pair(b,a));
  }
  sort(ALL(task));
  int time=0;
  for(auto t: task){
    time += t.second;
    if(time>t.first){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC088D - Grid Repainting
  int H, W; cin >> H >> W;
  vector<string> s(H);
  REP(i, H){
    cin >> s[i];
  }
  
  queue<pair<int, int> > q;
  vector<int> x = {1, 0, -1, 0};
  vector<int> y = {0, 1, 0, -1};
  vector<vector<int> > d(H, vector<int>(W, -1));
  
  q.push({0, 0});
  d[0][0] = 0;
  while(!q.empty()){
    auto cur = q.front(); q.pop();
    REP(i, 4){
      if(cur.first+x[i] < 0 || cur.first+x[i] > H-1) continue;
      if(cur.second+y[i] < 0 || cur.second+y[i] > W-1) continue;
      if(s[cur.first+x[i]][cur.second+y[i]] == '#') continue;
      if(d[cur.first+x[i]][cur.second+y[i]] == -1){
        q.push({cur.first+x[i], cur.second+y[i]});
        d[cur.first+x[i]][cur.second+y[i]] = d[cur.first][cur.second] + 1;
      }
    }
  }
  
  int cnt = 0;
  REP(i, H){
    REP(j, W){
      if(s[i][j] == '#') cnt++;
    }
  }
  
  if(d[H-1][W-1] == -1){
    cout << -1 << endl;
  }else{
    cout << H * W - cnt - (d[H-1][W-1]+1) << endl;
  }
}

Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let mut h=::std::collections::HashSet::new();
    let n=read::<i32>();
    for _ in 0..n{h.insert(read::<i32>());}
    println!("{}",h.len());
}


Measured memory_bytes: 4352
import fractions

n, X = map(int, input().split())

x = list(map(int, input().split()))

x.append(X)

x.sort()

dis = []

for i in range(1, n+1):
    dis.append(x[i] - x[i-1])

for i in range(n):
    if i == 0:
        now = dis[i]
    else:
        now = fractions.gcd(dis[i], now)

print(now)


Measured memory_bytes: 16244
#include<bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int>
#define pqueue priority_queue
#define rep(a,n) for(int i=(a);i<(n);i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int n,vin &a){
    rep(0,n){
        cin>>a.at(i);
    }
}

signed main(){
    typedef pair<int,int> P;
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b && b!=c) || (b==c && c!=a) || (a==c && c!=b)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
  string s;
  string t;
  
  cin>>s>>t;
  
  int size_1=s.length();
  int size_2=t.length();
  int ans=2000;
  int sen=0;
  
  for(int i=0;i<=size_1-size_2;i++)
  {
    sen=0;
    for(int j=0;j<size_2;j++)
    {
      if(s[i+j]!=t[j])
      {
        sen++;
      }
    }
    ans=min(ans,sen);
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3608
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
dp=[[0]*3 for i in range(n+1)]
for i in range(n):
    dp[i+1][0]=l[i][0]+max(dp[i][1],dp[i][2])
    dp[i + 1][1] = l[i][1] + max(dp[i][0], dp[i][2])
    dp[i + 1][2] = l[i][2] + max(dp[i][1], dp[i][0])
print(max(dp[n]))

Measured memory_bytes: 47388
// Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

// Macro
#define rep(i, N) for(int i=0; i<(int)N; i++)
#define rrep(i, N) for(int i=(int)N-1; i>=0; i--)

// Type
template <typename T> using P = pair<T, T>;
using ll = long long;
using ull = unsigned long long;

// Constants
const ll INF = 1e18;
const ll MOD = 1000000007;

int main() {
  char c;
  cin >> c;

  switch(c) {
    case 'A':
      cout << "T" << endl;
      break;
    case 'C':
      cout << "G" << endl;
      break;
    case 'G':
      cout << "C" << endl;
      break;
    case 'T':
      cout << "A" << endl;
      break;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define DEBUG (0)

int getmin(int *array, int length);

int main(void)
{
  int a_num,b_num,m_num = 0;
  
  scanf("%d %d %d",&a_num, &b_num, &m_num);
  
  int price_a[a_num]= {0};
  int price_b[b_num]= {0};
  int x[m_num] = {0};
  int y[m_num] = {0};
  int c[m_num] = {0};
  int z[m_num] = {0};	/* z = x + y - c */
  
  int a_min,b_min,z_min = 0;
  int total_min = 0;
  
  /* aの価格 */
  for(int i = 0; i < a_num; i++){
    scanf("%d",&price_a[i]);
  }
  
  /* bの価格 */
  for(int i = 0; i < b_num; i++){
    scanf("%d",&price_b[i]);
  }
  
  /* x,y,c */
  for(int i = 0; i < m_num; i++){
    scanf("%d %d %d",&x[i],&y[i],&c[i]);
  }
  
  /* z計算*/
  for(int i = 0; i < m_num; i++){
    z[i] = price_a[x[i] -1 ] + price_b[y[i] - 1] - c[i];
  }
    
  a_min = getmin(price_a, a_num);
  b_min = getmin(price_b, b_num);
  z_min = getmin(z,m_num);
  
  if(a_min + b_min <= z_min){
    total_min = a_min + b_min;
  }else{
    total_min = z_min;
  }
  
  
#if DEBUG
  /* aの価格 */
  for(int i = 0; i < a_num; i++){
    printf("price_a[%d]:%d\n",i, price_a[i]);
  }
  printf("\n");
  
  /* bの価格 */
  for(int i = 0; i < b_num; i++){
    printf("price_b[%d]:%d\n",i, price_b[i]);
  }
  printf("\n");
  
  /* x,y,c */
  for(int i = 0; i < m_num; i++){
    printf("x[%d]:%d ,y[%d]:%d c[%d]:%d\n",i,x[i],i,y[i],i,c[i]);
  }
  printf("\n");

  /* zの値 */
  for(int i = 0; i < m_num; i++){
    printf("z[%d]:%d\n",i, z[i]);
  }
  printf("\n");

  printf("%d %d %d %d\n",a_min, b_min, z_min, total_min);
#endif
  
  printf("%d\n", total_min);
  
}


int getmin(int *array, int length){
  int ret = array[0];	/* 10^5 で初期化 */

  /* 配列arrayの最小値を取得 */
  for(int i = 0; i < length; i++){
    if(array[i] < ret){
      ret = array[i];
    }
  }
 
  return ret;
}

Measured memory_bytes: 2560
H,N=list(map(int,input().split()))
A=[tuple(map(int,input().split())) for _ in range(N)]

INF=10**9+7
dp=[INF]*(H+1)
dp[0]=0
for i in range(H):
    if dp[i]==INF:
        continue
    for j in range(N):
        a=A[j][0]
        b=A[j][1]
        k=min(H,i+a)
        dp[k]=min(dp[k], dp[i]+b)
print(dp[-1])

Measured memory_bytes: 74332
#include<bits/stdc++.h>
using namespace std;
int N;
char a[202020];
int main()
{
  scanf("%d", &N);
  scanf("%s", a);
  int ans = 0;
  int cnt = 0;
  for(int i=0; i<N; ++i)
  {
    if(a[i] == '.') ++cnt;
  }
  ans = cnt;
  for(int i=0; i<N; ++i)
  {
    if(a[i] == '.') --cnt;
    else ++cnt;
    ans = min(ans, cnt);
  }
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define ld long double

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const ll mod = 1e9 + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1);

bool equal(ld a, ld b) {return abs(a - b) < EPS;}

struct Vector{
    ld x, y;
    Vector(){}
    Vector(ld x, ld y) : x(x), y(y) {}
    Vector operator + (const Vector &v) const {return Vector(x + v.x, y + v.y);}
    Vector operator - (const Vector &v) const {return Vector(x - v.x, y - v.y);}
    Vector operator * (ld a) const {return Vector(x * a, y * a);}
    ld len() {
        return sqrt(x * x + y * y);
    }
    Vector rotate(ld a) const {return Vector(cos(a) * x - sin(a) * y, sin(a) * x + cos(a) * y);}
};

struct Disk{
    Vector center;
    ld radius;
};

vector<Vector> inter(const Disk &c1, const Disk &c2) {
    Vector ab = c2.center - c1.center;
    ld d = ab.len();
    ld r1 = c1.radius, r2 = c2.radius;
    if (equal(d, 0)) return {};

    if(equal(r1 + r2, d) == true) return {c1.center + ab * (r1 / d)};
    if(equal(r1 + d, r2) == true) return {c1.center - ab * (r1 / d)};
    if(equal(r2 + d, r1) == true) return {c1.center + ab * (r1 / d)};

    if(r1 + r2 < d)  return {};
    if(r1 + d  < r2) return {};
    if(r2 + d  < r1) return {};

    double a = (d * d + r1 * r1 - r2 * r2) / (2 * d);
    return {c1.center + ab * (a / d) + ab.rotate(PI/2.0)  * (sqrt(r1*r1 - a*a) / d),
            c1.center + ab * (a / d) + ab.rotate(-PI/2.0) * (sqrt(r1*r1 - a*a) / d)};
}

bool is_inside(Disk c, Vector v) {
    return (c.center - v).len() < c.radius + EPS;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<Vector> a(n);
    vector<ld> c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].x >> a[i].y >> c[i];
    }

    ld left = 0, right = 1e6;
    for (int it = 0; it < 100; it++) {
        ld mid = (left + right) / 2;
        vector<Disk> l(n);
        for (int i = 0; i < n; i++) {
            l[i].center = a[i];
            l[i].radius = mid / c[i];
        }
        vector<Vector> check;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                for (auto &p : inter(l[i], l[j])) check.pb(p);
            }
        }
        for (int i = 0; i < n; i++) {
            check.pb(a[i]);
        }
        int mx = 0;
        for (auto &p : check) {
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                if (is_inside(l[i], p)) cnt++;
            }
            mx = max(mx, cnt);
        }
        if (mx >= k) right = mid;
        else left = mid;
    }
    cout << fixed << setprecision(15) << right;
    return 0;
}


Measured memory_bytes: 3908
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
s=array(n,1)
n.times do|i|
  s[i]=gets.to_i
end
ans=s.inject(:+)
if (ans%10).zero?
  s.sort!
  val=s[0]
  i=1
  while (val%10).zero?
    if i>=n
      val=ans
      break
    end
    val=s[i]
    i+=1
  end
  ans-=val
end
puts ans

Measured memory_bytes: 1788
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class Hello
{
    public static void Main()
    {
        var A_B_H_M = Console.ReadLine().Trim().Split();
        var A = int.Parse(A_B_H_M[0]);
        var B = int.Parse(A_B_H_M[1]);        
        var H = int.Parse(A_B_H_M[2]);        
        var M = int.Parse(A_B_H_M[3]);        

        var th = (double)(60 * H + M) / 720 * 2 * Math.PI;
        var tm = (double)(M) / 60 * 2 * Math.PI;

        var xh = A * Math.Cos(th);
        var yh = A * Math.Sin(th);
        var xm = B * Math.Cos(tm);
        var ym = B * Math.Sin(tm);
        
        var dx = xh - xm;
        var dy = yh - ym;

        var ans = Math.Sqrt(dx*dx + dy*dy);
        Console.WriteLine(ans);
   }
}

Measured memory_bytes: 27752
#include <iostream>
using namespace std;
int a[51];
int main()
{
    int n, m, br=0;
    cin >> n >> m;
    for(int i = 0; i<m ; i++){
        int x, y;
        cin >> x >> y;
        a[x]++;
        a[y]++;
    }
    for(int i = 1; i<=n ; i++){
        cout << a[i] << "\n";
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int m1 = sc.nextInt();
        sc.nextLine();
        int m2 = sc.nextInt();
        sc.nextLine();
        
        System.out.println(m1 != m2 ? '1': '0');
    }
}


Measured memory_bytes: 21844
N=int(input())
s=input()

sa=s[:N]
sb=s[N:]

import itertools
ALLIST=list(itertools.product((0,1),repeat=N))

from collections import defaultdict
STRA = defaultdict(int)
STRB = defaultdict(int)

for i in ALLIST:
    red_a=""
    blue_a=""
    red_b=""
    blue_b=""
    for j in range(N):
        if i[j]==0:
            red_a+=sa[j]
            red_b+=sb[j]
        else:
            blue_a+=sa[j]
            blue_b+=sb[j]

    STRA[(red_a[::-1],blue_a[::-1])]+=1
    STRB[(red_b,blue_b)]+=1

ANS=0
for key in STRA:
    ANS+=STRA[key]*STRB[key]

print(ANS)

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

int main(void){
    int n, m, k;
    cin >> n >> m >> k;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            int cnt = i * m - i * j + (n - i) * j;
            if(cnt == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F(i,a,b) for(ll i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-7
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 1e5+10;
const int E = 1e6+10; 

int n;

int main(){
	int d,t,s;
	cin>>d>>t>>s;
	if(s*t>=d){
		printf("Yes\n");
	} 
	else printf("No\n");
}

Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.InteropServices;
using System.Text;
using static System.Console;
using static System.Math;
class Simple {
    private int N, M, X;
    private int[] A;
    void Solve() {
        //in
        N = io.Int;
        M = io.Int;
        X = io.Int;
        A = new int[M];
        for(int i = 0; i < M; ++i) {
            A[i] = io.Int;
        }
        //cal
        var underCost = A.Count(x => x < X);
        var overCost = M - underCost;
        //out
        WriteLine(Min(underCost,overCost));
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO {
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if(_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while(st == "")
            st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int N, M;
vector<VI> graph;
bool visited[20];

int dfs(int v, int depth) {
    if (depth == N) return 1;
    int ans = 0;
    for (int u: graph[v]) {
        if (visited[u]) continue;
        visited[u] = 1;
        ans += dfs(u, depth + 1);
        visited[u] = 0;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> N >> M;
    graph.assign(N+2, VI());
    REP(i, M) {
        int x, y;
        cin >> x >> y;
        graph[x].pb(y);
        graph[y].pb(x);
    }
    visited[1] = 1;
    cout << dfs(1, 1) << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow

}


//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor_ver2(int n, map<int, int> res) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n]++;
	return res;
}

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

	int N;
	cin >> N;
	int ans = 1;

	map<int, int> mp;

	for (int i = 2; i <= N; i++)
	{
		mp = prime_factor_ver2(i, mp);
	}

	for (int i = 0; i <= N; i++)
	{
		//cout <<"i:"<<i<<"   "<< mp[i] << endl;
		if (mp[i] > 0) {
			ans *= ((mp[i] + 1)% 1000000007);
			ans %= 1000000007;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	int n;
	scanf("%d", &n);
	double sum = 0;
	rep(i, n) {
		int a;
		scanf("%d", &a);
		sum += 1.0 / a; //int型とdouble型との演算はdoubleに暗黙変換されるので、1.0で割ることでdoubleに変換してる。
	}
	double ans = 1 / sum;
	printf("%.10f\n", ans); //ドットの後に10やると小数点10桁まで
	return 0;
}

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

int p_count;
vector<tuple<int, int, int>> pyramid;
vector<tuple<int, int, int>> measure;

void init_pyramid()
{
  p_count = 101 * 101;
  for (auto y = 0; y <= 100; y++) {
    for (auto x = 0; x <= 100; x++) {
      pyramid.emplace_back(make_tuple(x, y, 0));
    }
  }
}

void read_measure_data()
{
  int n;
  cin >> n;
  for (auto i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    measure.emplace_back(make_tuple(a, b, c));
  }
}

void check1()
{
  for (auto&& m : measure) {
    for (auto&& p : pyramid) {
      if (get<2>(p) < 0) continue;
      if (get<2>(m) == 0) continue;
      int guess = get<2>(m) + abs(get<0>(p) - get<0>(m)) + abs(get<1>(p) - get<1>(m));
      if (get<2>(p) == 0) {
	get<2>(p) = guess;
      } else if (get<2>(p) != guess) {
	get<2>(p) = -1;
	p_count--;
	if (p_count <= 1) return;
      }
    }
  }
}

void check2()
{
  if (p_count <= 1) return;
  for (auto&& m : measure) {
    for (auto&& p : pyramid) {
      if (get<2>(p) < 0) continue;
      if (get<2>(m) != 0) continue;
      int guess = abs(get<0>(p) - get<0>(m)) + abs(get<1>(p) - get<1>(m));
      if (guess - get<2>(p) < 0) {
	get<2>(p) = -1;
	if (p_count <= 1) return;
      }
    }
  }
}

void print_ans()
{
  for (auto&& p : pyramid) {
    if (get<2>(p) > 0) {
      cout << get<0>(p) << " " << get<1>(p) << " " << get<2>(p) << endl;
    }
  }
}

int main()
{
  init_pyramid();
  read_measure_data();
  check1();
  check2();
  print_ans();
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string s; cin >> s;
  int n = (int)s.size() + 1;
  vector<int> v(n,-1); 
  for(int i = 0; i < n-1; ++i){
    if(s[i] == '<'){
      if(i == 0 || s[i-1] == '>'){
	v[i] = 0;
      }
    } else {
      if(i == n - 2){
	v[i+1] = 0;
      }
    }
  }
  for(int i = 1; i < n; ++i){
    if(s[i-1] == '<')v[i] = v[i-1] + 1;
  }
  for(int i = n-2; i >= 0; --i){
    if(s[i] == '>')v[i] = max(v[i],v[i+1] + 1);
  }
  ll sum = 0;
  for(int i = 0; i < n; ++i){
    cerr << i << ' ' << v[i] << ' ' << s[i] <<  endl;
    sum += v[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2820
N = int(input())
S = input()

E, W = [], []
e, w = 0, 0
for s in S:
    if s == 'E':
        e += 1
    else:
        w += 1
    E.append(e)
    W.append(w)

ans = e - E[0]
for i in range(1, N):
    ans = min(W[i-1] + e - E[i], ans)
print(ans)

Measured memory_bytes: 17880
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;

bool compare_by_b(pair<int,string> a, pair<int,string> b) {
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second < b.second;
	}
}

int main()
{
	int N;
	map<string,int>mp;
	vector<pair<int,string>>vec;
	cin >> N;
	fore(i,0,N){
		string s;
		cin >> s;
		map<string,int>::iterator itr = mp.begin();
		itr = mp.find(s);
		if(itr==end(mp)){
			mp[s]=1;
		}
		else{
			mp[s]++;
		}
	}
	for(auto i = mp.begin(); i != mp.end() ; ++i){
		pair<int,string>pa=make_pair(i->second,i->first);
		vec.push_back(pa);
	}
	sort(vec.begin(),vec.end(),compare_by_b);
	for(int i=0;i<vec.size();i++){
		if(vec[i].first==vec[0].first){
			cout << vec[i].second << endl;
		}
		else{
			break;
		}
	}

}

Measured memory_bytes: 29556
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val segs = mutableListOf<Pair<Int, Int>>()
    for (i in 0 until n) {
        val a = sc.nextInt()
        val b = sc.nextInt()
        segs.add(a to b)
    }
    if (n % 2 == 1) {
        segs.sortBy { it.first }
        val l = segs[n / 2].first
        segs.sortByDescending { it.second }
        val r = segs[n / 2].second
        println(r - l + 1)
    } else {
        segs.sortBy { it.first }
        val l1 = segs[(n - 1) / 2].first
        val l2 = segs[n / 2].first
        segs.sortByDescending { it.second }
        val r1 = segs[(n - 1) / 2].second
        val r2 = segs[n / 2].second
        println(r1 - l1 + r2 - l2 + 1)
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 74508
#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[]) {
    int i=0,n=0,x[100],y[100];
    double a1=0.0,a2=0.0,a3=0.0,a4=0.0,a;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<n;i++){
        scanf("%d",&y[i]);
    }
    for(i=0;i<n;i++){
        a=abs(y[i]-x[i]);
        a1+=a;
        a2+=(a*a);
        a3+=(a*a*a);
        if(a4<a){
            a4=a;
        }
    }
    printf("%f\n%f\n%f\n%f\n",a1,sqrt(a2),pow(a3,1.0/3.0),a4);
    return 0;
}

Measured memory_bytes: 672
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int K;
        public int[] A;
        public void Run()
        {
            K = Input.ReadInt();
            A = Input.ReadIntArray();
            A = A.Reverse().ToArray();

            long mn = 2;
            long mx = 2;
            for (int i = 0; i < A.Length; i++)
            {
                long a = A[i];
                mn = mn % a == 0 ? mn : (mn / a + 1) * a;
                mx = (mx / a) * a;
                mx += (a - 1);
            }

            if (mx < mn)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine("{0} {1}", mn, mx);
            }
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 27612
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abcPpc_d();
	}
  
  	public static void solve_abcPpc_d(){

		Scanner sc = new Scanner(System.in);
		
		
		int N = sc.nextInt();
		
		solve_abcPpc_d_dfs("",N,'a');
		
		sc.close();
	}

	public static void solve_abcPpc_d_dfs(String s, int N, char mx){
		
		
		//if length == N
		if(s.length() == N){
			//print string
			System.out.println(s);
		}
		else{
			//for c = a , c <= mx, c++
			for(char c = 'a';c <= mx; c++){
				
				solve_abcPpc_d_dfs(s + c, N, (c == mx ? (char)(mx + 1): mx));
			}
		
		}
	}
}

Measured memory_bytes: 42872
NumberOfSheet = int(input())
OwnedCards = [[str(i) for i in input().split()] for loop in range(NumberOfSheet)]
S = [int(0) for i in range(13)]
H = [int(0) for i in range(13)]
C = [int(0) for i in range(13)]
D = [int(0) for i in range(13)]
for i in OwnedCards:
  if i[0] == 'S' or i[0] == 'H' or i[0] == 'C' or i[0] == 'D':
    if i[0] == 'S': S[int(i[1]) - 1] = 1
    if i[0] == 'H': H[int(i[1]) - 1] = 1
    if i[0] == 'C': C[int(i[1]) - 1] = 1
    if i[0] == 'D': D[int(i[1]) - 1] = 1

for i in range(13):
  if S[i] == 0: print('S',i + 1)
for i in range(13):
  if H[i] == 0: print('H',i + 1)
for i in range(13):
  if C[i] == 0: print('C',i + 1)
for i in range(13):
  if D[i] == 0: print('D',i + 1)

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

int a, b;
bool isPossible()
{
    return a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    cin >> a >> b;

    cout << (isPossible() ? "Possible" : "Impossible") << endl;

	return 0;
}

Measured memory_bytes: 256
n, k = [int(i) for i in input().split(" ")]
h = [int(input()) for i in range(n)]

h.sort()
ans = 1e9 + 1
s = 0
while s + k - 1 <= n - 1:
  mm = h[s+k-1] - h[s]
  if mm < ans:
    ans = mm
  s += 1
print(int(ans))



Measured memory_bytes: 7384
N = int(input())
dp = [float('inf')]*(N+1)
dp[0] = 0
for i in range(N+1):
    if i >= 1:
        dp[i] = min(dp[i-1]+1,dp[i])
    for j in range(1,N+1):
        if i < 6**j:
            break
        dp[i] = min(dp[i-6**j]+1,dp[i])
    for k in range(1,N+1):
        if i < 9**k:
            break
        dp[i] = min(dp[i-9**k]+1,dp[i])
print(dp[N])

Measured memory_bytes: 74992
an = []
for i in range(5):
    temp = input()
    an.append(int(temp))

f = False
k  = int(input())
for a1 in an:
    for a2 in an:
        if abs(a1-a2) > k:
            f  =True
if f:
    print(":(")
else:
    print("Yay!")



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> lp;
typedef pair<ll,pair<ll,ll>> lpp;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
まっすぐk個まで進める：曲がったタイミングで精算

6 7 3
6 2 6 7
.@.@...
.@...@.
...@.@.
..@....
.@..@@@
..@....
*/

ll h,w,k,x3,x2,y3,y2,ans=1e18;
priority_queue<lp, vector<lp>, greater<lp> > qu;
ll dx[]={0,0,1,-1},dy[]={1,-1,0,0};


int main(void){
	cin>>h>>w>>k;
	cin>>x3>>y3>>x2>>y2;
	x3--;
	y3--;
	x2--;
	y2--;
	vector<string> s(h);
	vector<vector<vector<ll>>> d(h, vector<vector<ll>>(w, vector<ll>(4, 1e18)));
	rep(i,h)cin>>s[i];
	d[x3][y3][0]=0;
	qu.push({0, (w*x3 + y3)*4 + 0});
	while(!qu.empty()){
		auto a = qu.top();qu.pop();
		ll cur=a.second;
		ll x=a.second/4/w, y=(a.second/4)%w, v=a.second%4;
		if(x==x2 && y==y2){
			cout<<(a.first+k-1)/k<<endl;
			return 0;
		}
		rep(i,4){  // 向きを変える
			if(d[x][y][i] > (d[x][y][v] + k - 1) / k * k){  // 切り上げ
				d[x][y][i] = (d[x][y][v] + k - 1) / k * k;
				qu.push({d[x][y][i], (x*w+y)*4+i});
			}
		}
		ll xx=x+dx[v], yy=y+dy[v];
		if(0<=xx && xx<h && 0<=yy && yy<w &&
		d[xx][yy][v] > d[x][y][v] + 1 && s[xx][yy]!='@'){
			d[xx][yy][v] = d[x][y][v] + 1;
			qu.push({d[xx][yy][v], (xx*w+yy)*4+v});
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 143972
#include <bits/stdc++.h>
#define int long long
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int n;
int arr[100001], dp[100001];
signed main(){
    cin >> n;
    for(int i=0; n>i; i++){
        cin >> arr[i];
    }
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    for(int i=2; n>i; i++){
        dp[i] = min(abs(arr[i] - arr[i-2]) + dp[i-2], abs(arr[i] - arr[i-1]) + dp[i-1]);
    }
    cout << dp[n-1] << endl;
}










Measured memory_bytes: 1792
N, M = list(map(int, input().split()))
A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
  A[i], B[i] = list(map(int, input().split()))
k = list(range(N))
k.sort(key=lambda x: A[x])
r = 0
c = 0
for i in k:
  if B[i]<M-c:
    r += B[i]*A[i]
    c += B[i]
  else:
    r += (M-c)*A[i]
    c += M-c
    break
print(r)

Measured memory_bytes: 16476
#include <stdio.h>

int cnt = 0;

void search(int A[], int n, int key)
{	int j = 0;
	A[n] = key;
	while(A[j] != key)
	{
		j++;
	}
	
	if(j != n){
		cnt++;
	}
}

int main()
{
	int n, q, A[10000+1], key;
	scanf("%d", &n);

	for(int i = 0; i < n; i++) scanf("%d", &A[i]);

	scanf("%d", &q);
	for(int i = 0; i < q; i++)
	{
		scanf("%d", &key);
		search(A, n, key);
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 2760
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
#define ld long double
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
ll mod2=998244353;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 300005
// Comment this out for interactive problem
#define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
ll n,m;
vector<ll> adj[100005];
ll vis[100005];

void dfs(ll u){
    for (auto i = adj[u].begin(); i != adj[u].end(); ++i)
    {
        if(!vis[*i]){
            vis[*i]=true;
            dfs(*i);
        }
    }
}

int main(){ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    cin>>n>>m;
    for (int i = 0; i < m; ++i)
    {
        ll a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    for (int i = 1; i < n+1; ++i)
    {
        vis[i]=false;
    }

    ll tot=0;
    for (int i = 1; i < n+1; ++i)
    {
        if(!vis[i]){
            vis[i]=true;
            dfs(i);
            tot++;
        }
    }
    cout<<tot-1;

    return 0;
}


Measured memory_bytes: 11096
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  auto f = [](const int64_t x, const int64_t y, const int64_t z, const int64_t n) -> int64_t {
    return (z * z + (x + y) * z + (x * x + y * y + x * y - n));
  };
  for (int64_t n = 1; n <= N; ++n) {
    int64_t result = 0;
    const int64_t sq = static_cast<int64_t>(sqrt(static_cast<double>(n)));
    for (int64_t x = 1; x <= sq; ++x) {
      for (int64_t y = 1; y <= sq; ++y) {
        const int64_t b = x + y;
        const int64_t c = x * x + y * y + x * y - n;
        const int64_t temp = b * b - c * 4;
        if (temp >= 0) {
          const int64_t temp2 = static_cast<int64_t>(sqrt(static_cast<double>(temp)));
          const int64_t z1 = (-b + temp2) / 2;
          const int64_t z2 = (-b - temp2) / 2;
          if (f(x, y, z1, n) == 0 && f(x, y, z2, n) == 0) {
            if (temp == 0 && z1 >= 1) {
              ++result;
            } else {
              if (z1 >= 1) {
                ++result;
              }
              if (z2 >= 1) {
                ++result;
              }
            }
          }
        }
      }
    }
    cout << result << endl;
  }
  return 0;
}


Measured memory_bytes: 3668