akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static int[][][] makeadj(int n, int[] from, int[] to, int[] w) {
        int[][][] e = new int[n][][];
        int[] d = new int[n];
        for (int f : from)
            d[f]++;
        for (int t : to)
            d[t]++;
        for (int i = 0; i < n; i++)
            e[i] = new int[d[i]][2];
        for (int i = 0; i < from.length; i++) {
            --d[from[i]];
            e[from[i]][d[from[i]]][0] = to[i];
            e[from[i]][d[from[i]]][1] = w[i];
            --d[to[i]];
            e[to[i]][d[to[i]]][0] = from[i];
            e[to[i]][d[to[i]]][1] = w[i];
        }
        return e;
    }

    public static int prim(int[][][] adj) {
        int[] c = new int[adj.length];
        Arrays.fill(c, Integer.MAX_VALUE);
        c[0] = 0;
        boolean[] vis = new boolean[adj.length];
        int w = 0;
        while (true) {
            int v = -1;
            for (int u = 0; u < adj.length; u++) {
                if (!vis[u] && (v == -1 || c[v] > c[u])) {
                    v = u;
                }
            }
            if (v == -1)
                break;
            w += c[v];
            vis[v] = true;
            for (int[] e : adj[v]) {
                if (!vis[e[0]] && c[e[0]] > e[1]) {
                    c[e[0]] = e[1];
                }
            }
        }
        return w;
    }

    public static void main(String... args) {
        Scanner sc = new Scanner(System.in).useDelimiter("[^0-9]+");
        while (true) {
            int n = sc.nextInt();
            if (n == 0)
                break;
            int m = sc.nextInt();
            int[] f = new int[m];
            int[] t = new int[m];
            int[] w = new int[m];
            for (int i = 0; i < m; i++) {
                f[i] = sc.nextInt();
                t[i] = sc.nextInt();
                w[i] = (sc.nextInt() / 100) - 1;// / 100;
            }
            int[][][] g = makeadj(n, f, t, w);
            System.out.println(prim(g));
        }
    }
}

Measured memory_bytes: 38328
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>

using namespace std;
set<vector<int> > s;

void Play(vector<int> input){
  vector<int> nums = input;
  int count = 0;

  while(1){
	for(int i=0; i<3; i++){
	  if(nums[i] % 2 == 1){
		cout << count << endl;
		return;
	  }
	}

	vector<int> v(3);
	v[0] = (nums[1] + nums[2]) / 2;
	v[1] = (nums[0] + nums[2]) / 2;
	v[2] = (nums[0] + nums[1]) / 2;
	if(s.find(v) != s.end()){
	  cout << "-1" << endl;
	  return;
	}
	count++;
	nums = v;
	s.insert(v);
  }
  
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> input(3);
  for(int i=0; i<3; i++)
	cin >> input[i];
  Play(input);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100000][3];
int main()
{
	int f=1,i,j,n;
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		if ((a[i][2]+a[i][1]>a[i][0]) || a[i][0]%2!=(a[i][1]+a[i][2])%2)
		  f=0;
	}
	if (f==1) 
	  cout<<"Yes"<<endl;
	else
	  cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1408
const main = stdin => {
  const [N, R] = stdin.trim().split(' ').map(x => parseInt(x))
  if (N >= 10) {
    console.log(R)
  } else {
    console.log(R + 100 * (10 - N))
  }
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29600
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string ss,tt;
    cin>>ss>>tt;
    vector<char> s,t;
    for(int i=0;i<ss.size();i++){
        s.push_back(ss[i]);
    }
    for(int i=0;i<tt.size();i++){
        t.push_back(tt[i]);
    }
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<>());
    if(s.size()>=t.size()){
        for(int i=0;i<s.size();i++){
            //cout<<s[i]<<t[i]<<endl;
            if(s[i]-'a'<t[i]-'a'){
                cout<<"Yes"<<endl;
                return 0;
            }
            else if(s[i]-'a'>t[i]-'a'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"No"<<endl;
    }
    else {
        for(int i=0;i<t.size();i++){
            //cout<<s[i]<<t[i]<<endl;
            if(s[i]-'a'<t[i]-'a'){
                cout<<"Yes"<<endl;
                return 0;
            }
            else if(s[i]-'a'>t[i]-'a'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }
        
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  vector<int> dp(n, 0); 
  dp[0] = 0;
  dp[1] = abs(a[0] - a[1]);
  for (int i = 2; i < n; i++){
    dp[i] = min( (dp[i-1] + abs(a[i] - a[i-1])), (dp[i-2] + abs(a[i] - a[i-2])));
  }
  cout << dp[n-1] << '\n';

  return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
ll modpow(ll a, ll b, ll M) {
	ll res = 1;
	for (; b > 0; b >>= 1) {
		if (b & 1) res = (res * a) % M;
		a = a * a % M;
	}
	return res;
}
int main() {
	int n;
	cin >> n;
	VL a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll ans = 0;
	rep(bit, 61) {
		ll zero = 0;
		ll one = 0;
		rep(i, n) {
			(1 & (a[i] >> bit)) ? one++ : zero++;
		}
		ll bits = modpow(2, bit, MOD);
		ans += bits * (zero * one % MOD);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> v; int b; int M;
  for(int i=0; i<n; i++){
    cin >> b;
    v.push_back(b);
  }
  
  decltype(v)::iterator p = max_element(v.begin(), v.end());
  M = *p;
  v.erase(p);
  
  int s=0; for(int i=0; i<v.size(); i++){s=s+v[i];}
  if(s>M){cout << "Yes";}
  else{cout << "No";}
  
  return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz(x) ((int)(x).size())

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int inf = 1e9 + 5;
const int mod = 1e9 + 7;
const ll INF = 4e18 + 5;

int n, a, b;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);

	cin >> n;
	for(int i = 1; i <= n; ++i) {
		int x;
		cin >> x;
		if(x & 1) a++;
		else b++;
	}
	b += a / 2, a %= 2;
	if(b > 0) b = 1;
	if(a + b < 2) 
		cout << "YES";
	else
		cout << "NO";
	return 0;
}

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

int R0;
int W;
int C;
int R;

int main() {
  while (1) {
    scanf("%d%d%d%d", &R0, &W, &C, &R);
    if ((R0|W|C|R) == 0) return 0;

    int ans = 0;
    int sum = R0;
    while (sum < W*C) {
      sum += R;
      ans++;
    }

    printf("%d\n", ans);
  }
}

Measured memory_bytes: 3096
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <deque>
using namespace std;

int main(){
	int n, x;
	while(scanf("%d", &n), n){
		vector<int> a(n);
		deque<int> b;
		for(int i = 0; i < n; ++i){
			scanf("%d", &a[i]);
		}
		for(int i = 0; i < n; ++i){
			scanf("%d", &x);
			b.push_back(x);
		}
		sort(a.begin(), a.end(), greater<int>());
		sort(b.begin(), b.end(), greater<int>());

		int c = 0;
		int k;
		for(k = 0; c * 2 <= k && !b.empty(); ++k){
			if(a[k] > b.front()){
				++c;
				b.pop_back();
			}
			else{
				b.pop_front();
			}
		}

		if(c * 2 > k && !b.empty()){
			printf("%d\n", k);
		}
		else{
			puts("NA");
		}
	}
}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define has_bit(bit_mask, x) ((bit_mask) & (1Uint << (x)))
#define turn_on_bit(bit_mask, x) (bit_mask |= (1Uint << (x)))
#define turn_off_bit(bit_mask, x) (bit_mask &= (~(1Uint << (x))))
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    unordered_map<char, int> score;
    cin >> score['r'] >> score['s'] >> score['p'];
    unordered_map<char, char> winC;
    winC['r'] = 'p'; winC['p'] = 's'; winC['s'] = 'r';
    string str;
    cin >> str;
    vector<ll> dp(n, 0);
    vector<char> prev(n, ' ');
    for (int i = 0; i < str.size(); ++i)
    {
        if (i < k)
        {
            prev[i] = winC[str[i]];
            dp[i] = score[prev[i]];
        }
        else
        {
            char ch = winC[str[i]];
            if (prev[i-k] != ch)
            {
                prev[i] = ch;
                dp[i] = score[prev[i]];
            }
        }
    }
    cout << accumulate(dp.begin(), dp.end(), 0) << '\n';
    return 0;
}

Measured memory_bytes: 1280
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  const std::string march("MARCH");

  int N;

  std::cin >> N;
  
  std::string s;

  std::map<char, int> map;

  for (int i = 0; i < N; i ++) {
    std::cin >> s;

    if (march.find(s[0]) != std::string::npos)
      map[s[0]] ++;
  }

  long long C = 0;

  for (int i = 0; i < (1 << 5); i ++)
    if (__builtin_popcount(i) == 3) {
      long long c = 1;
      
      for (int k = 0, b = 1; k < 5; k ++, b <<= 1)
        if (i & b)
          c *= map[march[k]];

      C += c;
    }

  std::cout << C << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;

const int mn = 100000;
vector<int> G[100000];
int w[100000];

int c[100000];
bool non[100000];

int sum, ma;
bool exi0 = false;
int dfs(int id, int fr) {
	if (id == 0)exi0 = true;
	int ret = 0;
	rep(j, G[id].size()) {
		int to = G[id][j];
		if (fr == to)continue;
		if (!non[to]) {
			ret = max(ret, sum + ma);
		}
		else {
			ret = max(ret, dfs(to, id));
		}
	}
	return ret + w[id];
}
int csum;
bool dfs2(int id, int fr) {
	rep(j, G[id].size()) {
		int to = G[id][j];
		if (fr == to)continue;
		if (!non[to]) {
			csum += w[id];
			w[id] = 0;
			return true;
		}
		if (dfs2(to, id)) {
			csum += w[id];
			w[id] = 0;
			return true;
		}
	}
	return false;
}

void solve() {
	int n, m; cin >> n >> m;
	rep(i, n)cin >> w[i];
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
		c[a]++; c[b]++;
	}
	queue<int> q;
	rep(i, n) {
		if (c[i] == 1) {
			q.push(i);
			non[i] = true;
		}
	}
	while (!q.empty()) {
		int id = q.front(); q.pop();
		rep(j, G[id].size()) {
			int to = G[id][j];
			c[to]--;
			if (c[to] == 1) {
				q.push(to);
				non[to] = true;
			}
		}
	}
	rep(i, n) {
		if (!non[i])sum += w[i];
	}
	rep(i, n)if (!non[i]) {
		rep(j, G[i].size()) {
			int to = G[i][j];
			if (!non[to])continue;
			exi0 = false;
			int z = dfs(to, i);
			if (!exi0) {
				ma = max(ma, z);
			}
		}
	}
	if (!non[0]) {
		cout << sum + ma << endl;
	}
	else {
		int ans = dfs(0, -1);
		dfs2(0,-1);
		rep(i, n)if (!non[i]) {
			rep(j, G[i].size()) {
				int to = G[i][j];
				if (!non[to])continue;
				ma = max(ma, dfs(to, i));
			}
		}
		ans = max(ans, csum + sum + ma);
		cout << ans << endl;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//while (cin >> n,n)solve();
	solve();
	//stop
	return 0;
}



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

def calc(A):
    s = sum(A)
    ma = max(A)
    if 2*ma > s:
        return s - ma
    return s//2

def check():
    candi = [[] for _ in range(N)]
    for l in L[:0:-1]:
        p = P[l]
        if candi[l]:
            x = sum(candi[l]) - A[l]
            y = A[l] - x
            if not 0 <= x <= calc(candi[l]):
                return 'NO'
        else:
            x = 0
            y = A[l]
        candi[p].append(y)
    x = sum(candi[root]) - A[root]
    y = A[root] - x
    if candi[root]:
        if not 0 <= x <= calc(candi[root]):
            return 'NO'
    if y:
        return 'NO'         
    return 'YES'

def parorder(Edge, p):
    N = len(Edge)
    par = [0]*N
    par[p] = -1
    stack = [p]
    order = []
    visited = set([p])
    ast = stack.append
    apo = order.append
    while stack:
        vn = stack.pop()
        apo(vn)
        for vf in Edge[vn]:
            if vf in visited:
                continue
            visited.add(vf)
            par[vf] = vn
            ast(vf)
    return par, order

def getcld(p):
    res = [[] for _ in range(len(p))]
    for i, v in enumerate(p[1:], 1):
        res[v].append(i)
    return res


N = int(readline())
A = list(map(int, readline().split()))
Edge = [[] for _ in range(N)]
Dim = [0]*N
for _ in range(N-1):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)
    Dim[a] += 1
    Dim[b] += 1

if N == 2:
    ans = 'YES' if A[0] == A[1] else 'NO'
else:
    root = Dim.index(max(Dim))
    P, L = parorder(Edge, root)
    C = getcld(P)
    ans = check()

print(ans)


Measured memory_bytes: 99820
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku
long long modpow(long long x,long long n) {
    long long result = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            result = (result * x) % mod;
        }
        x = (x * x) % mod;
        n >>= 1;
    }
 
    return result;
}

#define N 1000

long long x[N+1],y[N+1];

void make_fact_table(int n){
	int i;
	x[0]=y[0]=1;
	for(i=1;i<=n;i++){
		x[i]=(long long)(x[i-1]*i)%mod;
		y[i]=modpow(x[i],mod-2);
	}
}

long long mod_nCr(int n, int r){
	return x[n]*y[n-r]%mod*y[r]%mod;
}

int main(void){
	int n=in(),d=in(),x=in(),i,j,a,s=0;
	rep(i,n){
		a=in();
		for(j=1;j<=d;j+=a)s++;
	}
	print(s+x);
	return 0;
}

Measured memory_bytes: 128
w = input()

d = {}

for i in list(w):
    if i not in d.keys():
        d[i] = 1
    else:
        d[i] += 1

ans = 'Yes'
for _, v in d.items():
    if v%2 != 0:
        ans = 'No'
        break
print(ans)


Measured memory_bytes: 9076
//Author: Abitnav
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){

ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//string s;
	int n,m,c=0,t=1,i=0,j,k,sum=0,ans,f=0,x,y;
	cin>>n>>k;
	for(int i=k;i<=n+1;i++){
		sum=(sum+mm(i,n-i+1)+1)%M;
	}
	cout<<sum;	
		
	return 0;
}













Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


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

    sort(A.begin(), A.end(), greater<int>());

    long long ans = 0;
    ans += A[0];

    int cnt = 2;
    for (int i = 1; i < N; i++) {
        if (N == 2) break;

        ans += A[i];
        cnt++;
        if (cnt == N) break;

        //cout << cnt << " " <<  ans << endl;

        ans += A[i];
        cnt++;
        if (cnt == N) break;

        //cout << cnt << " " <<  ans << endl;
    }

    cout << ans << endl;
}


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

Measured memory_bytes: 4044
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

map<vi,int> m;

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n; cin>>n;
    string s;
    FOR(i, 0, n) {
    	cin>>s;
    	vi cnt(26, 0);
    	for(auto c : s) {
    		cnt[c - 'a']++;
    	}
    	m[cnt]++;
    }
    ll ans = 0;
    for(auto itr : m) {
    	int val = itr.second;
    	ans += 1LL * val * (val -1) / 2;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 19072
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <cassert>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=(a%10/5)+(a%5), a/=10; return res;}

int main() {
  int n; cin>>n;
  ll a[n],b[n],c[n];
  for(int i=0;i<n;i++) {
    cin>>a[i]>>b[i]>>c[i];
  }
  ll dp[n][3];fill(dp[0],dp[n],0);
  dp[0][0]=a[0]; dp[0][1]=b[0]; dp[0][2]=c[0];

  for(int i=1;i<n;i++) {
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
  }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest

Measured memory_bytes: 8304
if __name__ == '__main__':
	n,m,l=map(int,raw_input().split())
	a=[map(int,raw_input().split()) for _ in [0]*n]
	b=zip(*[map(int,raw_input().split()) for _ in [0]*m])
	sums=[i[k]*j[k] for i in a for j in b for k in xrange(m)]
	c=[sum(sums[i:i+m]) for i in [j for j in xrange(len(sums)) if j%m==0]]
	for i in xrange(len(c)):
		if (i+1)%l==0: print c[i]
		else: print c[i],

Measured memory_bytes: 39512
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <vector>
#include <stdlib.h>
 
#define FOR(i, l, r) for (i = (l); i < r; i++ )
 
using namespace std;
typedef long long ll;
 
#define MAX_N (500010)
 
struct Node{
    int key;
    Node *p_p;
    Node *p_l;
    Node *p_r;
};
 
int m;
 
Node *T = NULL;
 
 
void insert(int k) {
    Node *p_y = NULL;       // parent of x
    Node *p_x = T;
    Node *p_z = (Node *)malloc(sizeof(Node));
     
    p_z->key = k;
    p_z->p_p = p_z->p_l = p_z->p_r = NULL;
 
    while ( p_x != NULL ) {
    p_y = p_x;
    if ( k < p_x->key ) {
        p_x = p_x->p_l;
    }
    else {
        p_x = p_x->p_r;
    }
    }
 
    if ( p_y == NULL ) {        // T is NULL.
    T = p_z;
    }
    else if ( k < p_y->key ) {    // z is left child of y.
    p_y->p_l = p_z;
    }
    else {          // z is right child of y.
    p_y->p_r = p_z;
    }
 
    return;
}
 
void preorder( vector<int> *p_v, Node *p_x ) {
    if ( p_x == NULL ) return;
    else {
    p_v[0].push_back(p_x->key);
    preorder(p_v, p_x->p_l);
    preorder(p_v, p_x->p_r); 
    }
     
    return;
}
 
void inorder( vector<int> *p_v, Node *p_x ) {
    if ( p_x == NULL ) return;
    else {
    inorder(p_v, p_x->p_l);
    p_v[0].push_back(p_x->key);  
    inorder(p_v, p_x->p_r);  
    }
     
    return;
}
 
int main()
{
    scanf("%d", &m);
    for ( int i = 0; i < m; i++ ) {
    char str[100];
    scanf("%s", str);
    if ( str[0] == 'i' ) {  // insert
        int k;
        scanf("%d", &k);
        insert(k);
    }
    else {          // print
        vector<int> pre;
        vector<int> in;
        preorder( &pre, T );
        inorder( &in, T );
 
        for ( int i = 0; i < in.size(); i++ ) {
        printf(" %d", in[i]);
        }
        printf("\n");
        for ( int i = 0; i < pre.size(); i++ ) {
        printf(" %d", pre[i]);
        }
        printf("\n");       
    }
    }
     
    return 0;
}


Measured memory_bytes: 31244
import math
N= int(input())

def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

l = sorted(divisor(N))
kazu = math.ceil(len(l)/2)

now=0
for i in l[:kazu]:
    tmp = N/i
    tmp2 = i + tmp
    if now==0:
        now=tmp2
    if tmp2 < now:
        now=tmp2

print(int(now-2))

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

ll a[5] = {0};

ll dfs(int i, int n){
  if(i == 5){
    if(n == 3) return 1;
    else return 0;
  }
  return a[i]*dfs(i+1, n+1) + dfs(i+1, n);
}

int main(){
  int N;
  cin >> N;
  string S[N];
  rep(i, N) {
    cin >> S[i];
    if(S[i][0] == 'M') a[0]++;
    else if(S[i][0] == 'A') a[1]++;
    else if(S[i][0] == 'R') a[2]++;
    else if(S[i][0] == 'C') a[3]++;
    else if(S[i][0] == 'H') a[4]++;
  }
  cout << dfs(0, 0) << endl;
  return 0;
}


Measured memory_bytes: 6144
n, m = map(int, input().split())

x = []
for i in range(2**n):
    temp = []
    for j in range(n):
        if i>>j & 1:
            temp.append(j+1)
    x.append(temp)

l = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

z = 0
for a in range(2**n):
    for b in range(m):
        y = 0
        for c in range(l[b][0]):
            if l[b][c+1] in x[a]:
                y += 1
        if y % 2 != p[b]:
            break
    else:
        z += 1

print(z)

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n; cin >> n;
    int b; cin >> b;
    REP(i, n - 1) {
        int a; cin >> a;
        b ^= a;
    }
    if(!b) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, Q;
    while(cin >> N >> Q, N|Q){
        vector<int> dates(100);
        for(int i=0; i<N; i++){
            int M; cin >> M;
            int D;
            while(M--){
                cin >> D;
                dates[D]++;
            }
        }
        int m = 0; int ans = 0;
        for(int i=0; i<100; i++){
            if(m < dates[i]){
                m = dates[i];
                ans = i;
            }
        }
        cout << (m < Q ? 0 : ans) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1200
/*3.4 hightierra*/
#include <stdio.h>

int main(void){
  //変数Nを定義、値を入力
  int N;
  scanf("%d",&N);
  
  int i,j; //for文のカウンタ
  int judge = 0; //九九で表せるかの判定

  /*二重ループで九九にあるかを判定*/
  for(i=1; i<10; i++){
    for(j=1; j<10; j++){
      if(N == i*j){
        judge = 1; //表せたらjudgeを１に
        break; //内側for文を抜ける
      }
    }
    if(judge){
        break; //外側for文を抜ける
    }
  }
  // 判定
  if(judge){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}

    

Measured memory_bytes: 128
#X = int(input())
#S = str(input())
N, K= map(int, input().split())
A = list(map(int, input().split()))
  
for i in range(N - K):
  #print(start, now)
  if A[K + i] > A[i]:
    print("Yes")
  else:
    print("No")
  
  


Measured memory_bytes: 31560
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971

#define MAX 100005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	char ch;
	db aa,bb,cc;
	string s1,s2,s3;
    lli i,j,k,a,b,c,n,m,sum=0,ans=0,temp;
    cin >> n >> k;
    lli h[n];
    rep(i,0,n)	cin >> h[i];
    vector<lli>dp(n,M);
    dp[0]=0;dp[1]=abs(h[0]-h[1]);
    for(i=2;i<n;i++){
    	m=M;
    	for(j=1;j<=k && j<=i;j++){
    		m=min(m,dp[i-j]+abs(h[i]-h[i-j]));
		}
		dp[i]=m;
	}
    cout << dp[n-1] << endl;
	
    
    
    
    return 0;
}

















/* UJJWAL KESHRI */

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int N,M;cin>>N>>M;
    pair<bool,int> dp[N];
    for(int i=0;i<N;i++){
        dp[i]=make_pair(0,1);
    }
    dp[0].first=1;
    
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        if(dp[a].first==0){
            dp[a].second--;
            dp[b].second++;
        }else{
            if(dp[a].second==1){
                dp[a].first=0;
                dp[a].second=0;
                dp[b].first=1;
                dp[b].second++;
            }else{
                dp[a].second--;
                dp[b].first=1;
                dp[b].second++;
            }
        }
    }
    int cnt=0;
    for(int i=0;i<N;i++){
        if(dp[i].first) cnt++;
    }
    cout<<cnt<<endl;
}


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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);

#define endl "\n";

#define loop(i,s,n)  for(ll i=s;i<n;i++)
#define test  ll t; cin>>t; while(t--)
#define p push_back
typedef long long ll;
int main()
{IOS
ll n;
cin>>n;
for(auto i=1;i<1000;i++)
{if(1000*i>=n)
{cout<<(1000*i)-n;
break;}
}
return 0;





}


Measured memory_bytes: 3656
#include <bits/stdc++.h>  // ver2.2.2
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

VVi gr;
VVi gr2;
Vi dist;
int n,m,l;

void shortest(int s){
  int n = dist.size();
  rep(i,0,n) dist[i]=INF;
  dist[s] = 0;
  
  priority_queue<Tiii,vector<Tiii>,greater<Tiii>> q;
  q.push(make_tuple(0,s,-1));
  
  while(!q.empty()){
    int nowdist,now,past;
    tie(nowdist,now,past) = q.top();
    q.pop();
    
    if(nowdist>dist[now]) continue;
    
    dist[now]=nowdist;
    
    rep(i,0,n){
      if(gr[now][i]==-1) continue;
      int next = i,cost = gr[now][i];
      if(next!=past && nowdist+cost<dist[next]){
        q.push(make_tuple(nowdist+cost,next,now));
        dist[next]=nowdist+cost;
      }
    }
  }
  return;
}


signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  cin >> n >> m >> l;
  int qw,er,ty;
  
  gr = VVi(n,Vi(n,-1));
  gr2= VVi(n,Vi(n,-1));
  
  rep(i,0,m){
    cin >> qw >> er >> ty;
    qw--,er--;
    gr[qw][er] = ty;
    gr[er][qw] = ty;
  }
  
  dist = Vi(n,0);
  
  rep(i,0,n){
    shortest(i);
    rep(j,0,n){
      if(dist[j] <= l) {
        gr2[i][j] = 1;
        gr2[j][i] = 1;
      }
    }
  }
  
  //VVout(gr2);
  gr = gr2;
  VVi ans(n);
  
  rep(i,0,n){
    shortest(i);
    ans[i] = dist;
  }
  //VVout(ans);
  int q;
  cin >> q;
  rep(i,0,q){
    cin >> qw >> er;
    qw--,er--;
    ty = ans[qw][er];
    if(ty >= INF/3) cout << -1 << endl;
    else cout << ty-1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3228
N = int(input())
A = list(map(int, input().split()))
A.sort()

if A[0] < 0 and A[-1] > 0:
    ans = 0
    for a in A:
        ans += abs(a)
    print(ans)
    now = A[0]
    for a in A[1:N - 1]:
        if a >= 0:
            print(now, a)
            now -= a
    print(A[-1], now)
    now = A[-1] - now
    for a in A[1: -1]:
        if a < 0:
            print(now, a)
            now -= a
elif A[0] >= 0:
    ans = sum(A) - A[0] * 2
    print(ans)
    now = A[0]
    for a in A[1: -1]:
        print(now, a)
        now -= a
    print(A[-1], now)
else:
    ans = -sum(A) + A[-1] * 2
    print(ans)
    now = A[-1]
    for a in A[: -1]:
        print(now, a)
        now -= a

Measured memory_bytes: 14324
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

//改良版 俺天才

long long mypow(long long x, int n) {
    long long ans=1;
    for(int i=0; i<n; i++) {
        ans *= x;
    }
    return ans;
}
int main() {
    char s[11];
    scanf("%s",s);
    int len = (int)strlen(s);
    long long result=0, sum=0;
    for (int cut1=0; cut1 < len; cut1++) {
        sum = 0;
        for (int cut2=cut1+1; cut2 <= len; cut2++) {
            sum = 10*sum + (s[cut2-1]-'0');
            result += sum * mypow(2,max(len-1-cut2,0)+max(cut1-1,0));
        }
    }
    printf("%lld\n",result);
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll n,x;
	bool b=true;
	map<ll,ll> mp;
	cin >> n;
	rep(i,n){
		cin >> x;
		mp[x]++;
		if(mp[x]>1) b=false;
	}
	cout << (b?"YES\n":"NO\n");
	return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vvchar vector<vector<char>>
#define vchar vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,d; cin >> n >> d;
    int res=0;
    rep(i,n){
        int x,y;cin>>x>>y;
        if(x*x+y*y<=d*d) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main()
{
	int a[100];
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	scanf("%d",&a[i]);
	for (int i = 0;i<n-1;i++)	printf("%d ",a[i]);
		printf("%d",a[n-1]);
		printf("\n");
	for	(int i =1;i<n;++i)
	{
		
	for(int j = i - 1; j >=0;j--)
	{
		if(a[j+1]<a[j])
		{
			int tem = a[j+1];
			a[j+1] = a[j];
			a[j] = tem;
		}
	}
	for (int i = 0;i<n-1;i++)	printf("%d ",a[i]);
		printf("%d",a[n-1]);
		printf("\n");
}

 } 


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main(){

    //input from txt （提出時にこの箇所は削除すること）
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    int N, K;
    cin >> N >> K;
    vector<int> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end());
    int ans = 0;
    for(int i=0; i<K; i++){
        ans += vec[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<cstdio>

int main(void){
int n,m,i,k,j;
scanf("%d",&n);
int a[n],b[n],c[n],d[n],r[120]={0};

for(i=0;i<n;i++){
scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
k=30*(a[i]-1)+10*(b[i]-1)+c[i]-1;
r[k]=r[k]+d[i];
};
for(i=1;i<=3;i++){
for(j=1;j<=3;j++){
for(k=1;k<=10;k++){
printf(" %d" ,r[30*(i-1)+10*(j-1)+k-1]);
};
printf("\n");
};
for(m=1;m<=20;m++)
{printf("#");};
printf("\n");
};
for(j=1;j<=3;j++){
for(k=1;k<=10;k++){
printf(" %d" ,r[30*(3)+10*(j-1)+k-1]);
};
printf("\n");
};

return 0;
}

Measured memory_bytes: 2716
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

for z in range(X+1, Y+1):
    flg_x, flg_y = False, False

    for xi in x:
        if xi >= z:
            break
    else:
        flg_x = True

    for yi in y:
        if yi < z:
            break
    else:
        flg_y = True

    if flg_x & flg_y:
        print("No War")
        exit()

print("War")


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9

using namespace std;
int coin[4] = {10, 50, 100, 500};

int main(){
  int n;
  while(cin >> n and n) {
    set<int> know[n];
    vector<int> known;
    REP(i, n){
      int x; cin >> x;
      REP(j, x) { int tmp; cin >> tmp; know[i].insert(tmp); }
    }
    int k; cin >> k;
    REP(i, k){
      int tmp; cin >> tmp;
      known.push_back(tmp);
    }
    int res = -1;
    REP(i, n){
      bool target = true;
      REP(j, known.size()){
        if(know[i].find(known[j]) == know[i].end()) target = false;
        if(target == false) break;
      }
      if(target and res != -1) { res = -1; break; }
      if(target) res = i+1;
    }
    cout << res << endl;
  }
}

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

int main()
{
    int p, n, d;
    scanf("%d%d", &n, &d);
    p=d*2+1;
    if(n%p==0) printf("%d", n/p);
    else printf("%d", n/p+1);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
 
using namespace std;
int N;
string S;
int main()
{
  int i;
  cin >> N >> S;
  for (i=0; i<S.length(); i++) {
    printf("%c", (S[i]-'A'+N)%26+'A');
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()
    for i in s:
        if i == '1':
            print(9, end = '')
        if i == '9':
            print(1, end= '')
    
    print()
    

solve()


Measured memory_bytes: 2940
from math import ceil
D,G = map(int,input().split())
list = [list(map(int,input().split())) for _ in range(D)]

def dfs(G,i):
    if i <= 0:
        return float('inf')
    n = min(ceil(G/(100*i)),list[i-1][0])
    s = 100*i*n
    if n == list[i-1][0]:
        s += list[i-1][1]
    if G > s:
        n += dfs(G-s,i-1)
    return min(n,dfs(G,i-1))

print(dfs(G,D))

Measured memory_bytes: 3064
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int w, h, n; cin >> w >> h >> n;
    int m[101][101];
    REP(i, 100) {
        REP(j, 100) {
            m[i][j] = 0;
        }
    }
    REP(k, n) {
        int x, y, a; cin >> x >> y >> a;
        REP(i, h) {
            REP(j, w) {
                if ((a == 1) && (j < x)) {
                    m[i][j] = 1;
                } else if ((a == 2) && (j >= x)) {
                    m[i][j] = 1;
                } else if ((a == 3) && (i < y)) {
                    m[i][j] = 1;
                } else if ((a == 4) && (i >= y)) {
                    m[i][j] = 1;
                }
            }
        }
    }
    int res = 0;
    REP(i, h) {
        REP(j, w) {
            // cout << m[i][j];
            if (m[i][j] == 0) {
                res++;
            }
        }
        // cout << endl;
    }
    cout << res << endl;
    return 0;
}

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

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

/** Application main entry point. */
int main (
  int argc,
  char *argv[ ]
  )
{
  int d[ 5 ];

  scanf ( "%d %d %d %d %d", d, d + 1, d + 2, d + 3, d + 4 );

  qsort ( d, 5, sizeof ( int ), cmpr );

  printf ( "%d %d %d %d %d\n", *d, d[ 1 ], d[ 2 ], d[ 3 ], d[ 4 ] );

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll mygcd(ll x,ll y){
	if(y==0)return x;
	else return mygcd(y,x%y);
}
int N;
ll T[105];
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> T[i];
	}
	ll ans = 1ll;
	for(int i=0;i<N;i++){
		ans = ans/mygcd(ans,T[i])*T[i];
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(201);
    for (int i = 1; i <= N; i++) {
        if(i % 2 != 0) {
            for (int j = 1; j <= i; j++) {
                if(i % j == 0){
                    ++A.at(i);
                    
                }
            }
        }
    }
    
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if(A.at(i) == 8){
        ++ans;
    }
   }
   
    
    cout << ans << endl;
}


Measured memory_bytes: 256