akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  ll n,a[100010],b,c=0;
  cin>>n;
  fr(i,n) cin>>a[i];
  fr(i,n-1){
    c+=a[i]/2;
    b=min(a[i]%2,a[i+1]);
    c+=b;
    a[i+1]-=b;
  }
  c+=a[n-1]/2;
  cout<<c<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const double INF = 1000000;
const double EPS = 0.000000001;
struct point{
  double x, y;
  point(){
  }
  point(double x, double y): x(x), y(y){
  }
  point operator +(point P){
    return point(x + P.x, y + P.y);
  }
  point operator -(point P){
    return point(x - P.x, y - P.y);
  }
  point operator *(double k){
    return point(x * k, y * k);
  }
  point operator /(double k){
    return point(x / k, y / k);
  }
};
double abs(point P){
  return sqrt(pow(P.x, 2) + pow(P.y, 2));
}
double dist(point P, point Q){
  return abs(Q - P);
}
point rotate90(point P){
  return point(P.y, - P.x);
}
struct circle{
  point C;
  double r;
  circle(){
  }
  circle(point C, double r): C(C), r(r){
  }
};
bool in_circle(point P, circle C){
  return dist(P, C.C) <= C.r + EPS;
}
pair<point, point> circle_intersection(circle C1, circle C2){
  double d = dist(C1.C, C2.C);
  double x = (C1.r * C1.r - C2.r * C2.r + d * d) / (2 * d);
  point A = C1.C + (C2.C - C1.C) / d * x;
  double y = sqrt(C1.r * C1.r - x * x);
  point B = rotate90(C2.C - C1.C) / d * y;
  return make_pair(A + B, A - B);
}
int main(){
  cout << fixed << setprecision(10);
  int N, K;
  cin >> N >> K;
  vector<point> P(N);
  vector<double> c(N);
  for (int i = 0; i < N; i++){
    cin >> P[i].x >> P[i].y >> c[i];
  }
  double t = INF;
  double f = 0;
  for (int i = 0; i < 100; i++){
    double mid = (t + f) / 2;
    vector<circle> C(N);
    for (int j = 0; j < N; j++){
      C[j] = circle(P[j], mid / c[j]);
    }
    vector<point> Q;
    for (int j = 0; j < N; j++){
      Q.push_back(P[j]);
    }
    for (int j = 0; j < N; j++){
      for (int k = j + 1; k < N; k++){
        double d = dist(C[j].C, C[k].C);
        if (abs(C[j].r - C[k].r) <= d && d <= C[j].r + C[k].r){
          pair<point, point> tmp = circle_intersection(C[j], C[k]);
          Q.push_back(tmp.first);
          Q.push_back(tmp.second);
        }
      }
    }
    int cnt = Q.size();
    bool ok = false;
    for (int j = 0; j < cnt; j++){
      int cnt2 = 0;
      for (int k = 0; k < N; k++){
        if (in_circle(Q[j], C[k])){
          cnt2++;
        }
      }
      if (cnt2 >= K){
        ok = true;
      }
    }
    if (ok){
      t = mid;
    } else {
      f = mid;
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 3912
// https://atcoder.jp/contests/abc127/tasks/abc127_b

#include <bits/stdc++.h>
using namespace std;
int main() {
    int r, d, prev;
    cin >> r >> d >> prev;

    
    for(int i = 1; i <= 10; i++) {
        cout << r*prev-d << endl;
        prev = r*prev-d;
    }

    
}


Measured memory_bytes: 256
#include <stdio.h>
 #include <string.h>
char s[101];
 int main(void) {
 scanf("%s", s);
 int res = 0;
 int n = strlen(s);
 for (int i = 0; i < n; i++) {
 if (s[i] != s[n - 1 - i]) res++;
 }
 printf("%d\n", res / 2);
 }

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

public class Main {

    public static void main(String[] args) {
        //System.setIn(Main.class.getClassLoader().getResourceAsStream("input"));
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = sc.nextInt();
        sc.nextLine();
        String slim  = sc.nextLine();
        int res = 1;
        for (int i = 1; i < n; i++) {
            if(slim.charAt(i) != slim.charAt(i-1)) res++;
        }
        System.out.println(res);
    }
}


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

int main(){
	int x,y;
	while(1){
		cin >> x;
		cin >> y;
		if(x==0 && y==0){break;}
		else if(x < y){	cout << x << " " << y << endl;	}
		else{cout << y << " " << x << endl;}
	}
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;

LL inf = 1000000000000;
LL mod = 1000000007;



int main()
{
	LL n;
	cin >> n;
	
	vector<LL> x(n);

	LL s = 0;
	for (auto &e : x) {
		cin >> e;
		s += e;
	}

	LL ans = 100000000000000;
	for (LL j = s/n-1; j <= s/n+1; ++j) {
		LL ans1 = 0;
		for (LL i = 0; i < n; ++i) {
			ans1 += (j - x[i])*(j- x[i]);
		}
		ans = min(ans1, ans);
	}
	cout << ans << "\n";
	
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  // or pb_ds;

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#ifndef DEBUG
#define endl "\n"
#endif
#define fff ff
#define sss ss.ff
#define ttt ss.ss
#define INF (1 << 30)
#define LLF (1ll << 60)
#define PRIME (1000000007)
#define FASTIO std::ios::sync_with_stdio(false)
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << x << endl
#else
#define debug(x)
#endif
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define FILE_INPUT                  \
  freopen("input.txt", "r", stdin); \
  freopen("output.txt", "w", stdout)

#define all(x) x.begin(), x.end()

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<string> vs;

template <typename T, typename B = null_type>
using oset =
    tree<T, B, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order / order_of_key

const ld eps = 1e-12;

/*-----------------END TEMPLATE-----------------*/

vi vals;
vi valsR;

int(((((((((((((((main)))))))))))))))() {
  FASTIO;
  ll a, b, x;
  cin >> a >> b >> x;
  if (x >= a && x <= a + b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

/*

0 1 2 3 4
      x

*/

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#define INF INT_MAX
using namespace std;

string S;
int N;
int ans = 999;

int main(){
	cin >> S;
	N = S.size();
	for (int i = 0; i <= N - 3; i++){
		int num = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + (S[i + 2] - '0');
		ans = min(ans, abs(num - 753));
	}
	
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
			var n = firstLine[0];
			var m = firstLine[1];

			var edges = new List<int[]>();

			for(var i = 0; i < m; i++)
			{
				edges.Add(Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray());
				edges[i][0]--;
				edges[i][1]--;
				edges[i][2] *= -1;
			}

			var distances = new long[n];
			var isNegative = new bool[n];

			for(var i = 0; i < n; i++)
			{
				distances[i] = long.MaxValue - 1000000001;
			}
			distances[0] = 0;

			for(var i = 0; i < n; i++)
			{
				foreach(var edge in edges)
				{
					if(distances[edge[1]] > distances[edge[0]] + edge[2])
					{
						distances[edge[1]] = distances[edge[0]] + edge[2];

						if (i == n - 1)
						{
							isNegative[edge[1]] = true;
						}
					}
				}
			}

			foreach(var edge in edges)
			{
				if(isNegative[edge[0]])
				{
					isNegative[edge[1]] = true;
				}
			}

			Console.WriteLine(isNegative[n - 1] ? "inf" : $"{-distances[n - 1]}");
		}
	}
}


Measured memory_bytes: 13496
# -*- coding: utf-8 -*-
n = int(input())
d = list(map(int, input().split()))

d.sort()

half = n // 2
max_abc = d[half - 1]
min_agc = d[half]

if max_abc == min_agc:
    print(0)
else:
    print(min_agc - max_abc)

Measured memory_bytes: 52776
# -*- coding: utf-8 -*-
from collections import deque
import itertools

def roundrobin(iterables,ite2,act):
    aaa = deque(iterables)
    bbb = deque(ite2)

    endtime = 0
    while aaa:
        if(aaa[0] > act):        
            aaa[0] -= act
            endtime += act
            #yield next(aaa[0])
            
            aaa.rotate(-1)
            bbb.rotate(-1)
        else:
            endtime += aaa[0]
            print(bbb[0],endtime)
            aaa.popleft()
            bbb.popleft()


task,act = (int(x) for x in input().split())

queue = []
time = []
for i in range(task):
    q,t = input().split()
    queue.append(q)
    time.append(int(t))

roundrobin(time,queue,act)


Measured memory_bytes: 10672
//header{{{
//#define _GLIBCXX_DEBUG
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost::multiprecision;  
//using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

//prime_table{{{
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//}}}

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    auto prime = prime_table(55555);
    vector<int> primes;

    for(int i = 3; i <= 55555; ++i){
        if(prime[i]){
            primes.emplace_back(i);
        }
    }

    int cnt = 0;
    vector<int> res;

    for(auto&& e : primes){
        if(e % 10 == 3){
            res.emplace_back(e);
        }
    }

    rep(i,n){
        cout << res[i] << ' ';
    }
    cout << '\n';

    return 0;
}


Measured memory_bytes: 3768
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
 
class Point {
public:
    int x, y;
    Point(int a = 0, int b = 0)
    {
        int x = a;
        int y = b;
    };
    bool operator <(const Point& p) const {
        return y < p.y || (y == p.y && x < p.x);
    }
};
 
inline bool direct(Point& base, Point& a, Point& b) {
    return (a.x - base.x)*(b.y - base.y) - (a.y - base.y)*(b.x - base.x) < 0;
}
 
 
int main() {
    int n, i;
    int k = 2;
    scanf("%d", &n);
    vector <Point> P(n), H(2 * n);
    for (i = 0; i < n; ++i) {
        scanf("%d%d",&P[i].x, &P[i].y);
    }
    sort(P.begin(), P.end());
    H[0] = P[0];
    H[1] = P[1];
    for (i = 0; i < n - 2; ++i) {
        while (k >= 2 && direct(H[k - 2],H[k - 1],P[i + 2])) k--;
        H[k++] = P[i + 2];
    }
    H[k++] = P[n - 2];
    for (i = n; i > 2; i--) {
        while (k >= 2 && direct(H[k - 2],H[k - 1],P[i - 3])) k--;
        H[k++] = P[i - 3];
    }
    printf("%d\n", k - 1);
    for (i = 0; i < k - 1; ++i) {
        printf("%d %d\n", H[i].x, H[i].y);
    }
    return 0;
}

Measured memory_bytes: 4672
n, a, b = map(int, input().split())
S = input()

asum = 0
bsum = 0
for s in S:
    if s == 'a' and asum+bsum < a+b:
        asum += 1
        print('Yes')
    elif s == 'b' and (asum+bsum < a+b and bsum < b):
        bsum += 1
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 4016
/********** BiSmIlLaHiR rAhMaNiR rAhIm ***********\
*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*
*$*                                             *$*
*$*    ||||||||  ||||||||  ||||||||  ||||||||   *$*
*$*    ||    ||  ||           ||     ||         *$*
*$*    ||||||||  ||||||||     ||     ||||||     *$*
*$*    ||    ||        ||     ||     ||         *$*
*$*    ||    ||  ||||||||  ||||||||  ||         *$*
*$*                                             *$*
*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*
\*************** DIIT(17th batch) ****************/

#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define pf printf
#define sf scanf
#define endl "\n"
#define pb push_back
#define makep make_pair
#define MOD 1000000007
#define PI acos(-1.0)
#define PII pair<string , ll> 
#define SIZE 1000005
#define fio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
ll fx[]={1,0,-1,0,-1,-1,1,1};
ll fy[]={0,1,0,-1,-1,1,-1,1};

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    fio();
    ll i;
    string s;
    map<char,ll>mp;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        mp[s[i]]++;
    }
    if(mp.size()==2)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}
// ! () &

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   int a,b,c,d,i,j,t=0,u=0;
   string x,y,z;

cin>>x;
for(i=0;i<x.length();i++){
    x[i]='x';
}
cout<<x<<endl;
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)

#define FOREACH(x,a) for(auto&& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_ll.hpp>
// using namespace boost::multiprecision; // cpp_ll

#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>

#define pb(a) push_back(a)
#define mp make_pair

signed main(){
    CIN(n,m);VC2(m,a,b);
    map<int, vector<P>> v;
    REP(i,m)v[a[i]].emplace_back(b[i], i);
    V ans(m);
    FOREACH(xx,v){
        sort(ALL(xx.second));
        REP(i,xx.second.size())ans[xx.second[i].second] = i + 1;
    }
    REP(i,m){
       std::cout << std::setfill('0') << std::setw(6) << a[i];
       std::cout << std::setfill('0') << std::setw(6) << ans[i];
       ENDL;
    }

}


Measured memory_bytes: 14720
#include <bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define rep(i , a , n) for (int i=a; i<(int)(n); i++)
#define re(i , n)     for (int i=0; i<(int)(n); i++)
#define pb push_back
#define em emplace_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define trace(a) cerr << #a << " = " << a << endl

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
typedef long double ld;

const int mod=7+1e9;
const int inf=1e9+5;
const ll  INF=1e18+5;
const int N=2e5+5;

int main()
{
    IOS;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    int i=0;
    while(i<n)
    {
    	ans++;
    	while(i<n &&s[i]==s[i+1] )i++;
    	i++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    long long n,sum=0;
    cin >>n;

    for(long long i=1;i<=n;i++){
        if((i%3 != 0) && (i%5 !=0) ){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cctype>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=505;
int n,m;
bool a[N][N],b[N][N];
char s[N][N];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

int main()
{
	n=getint(),m=getint();
	rep(i,1,n) scanf("%s",s[i]+1);
	rep(i,1,n) rep(j,1,m) if(s[i][j]=='#') a[i][j]=b[i][j]=1;
	rep(i,1,n) a[i][1]=b[i][m]=1;
	rep(i,1,n)
		if(i&1) rep(j,1,m-1) a[i][j]=1;
		else rep(j,2,m) b[i][j]=1;
	rep(i,1,n)
	{
		rep(j,1,m) if(a[i][j]) putchar('#'); else putchar('.');
		puts("");
	}
	puts("");
	rep(i,1,n)
	{
		rep(j,1,m) if(b[i][j]) putchar('#'); else putchar('.');
		puts("");
	}
	return 0;
}		

Measured memory_bytes: 1408
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n, a, b; scan(n, a, b);
    int ans = min(a * n, b);
    writeln(ans);
}


Measured memory_bytes: 256
n = gets.to_i
nums = gets.chomp.split.map(&:to_i)
nums.each.with_index do |num, i|
  while 0 < i && num < nums[i-1]
    nums[i] = nums[i-1]
    i -= 1
  end
  nums[i] = num
  puts nums * ' '
end

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int n; cin >> n;
        vector<map<char, int>> freq(n);
        for (int i = 0; i < n; i++) {
                string s; cin >> s;
                for (auto c: s) freq[i][c]++;
        }

        string s;
        for (auto it: freq[0]) {
                while (freq[0][it.first]) {
                        bool ok = 1;
                        for (int i = 0; i < n; i++) {
                                if (!freq[i][it.first]) {
                                        ok = 0;
                                        break;
                                }
                        }

                        if (ok) {
                                for (int i = 0; i < n; i++) {
                                        freq[i][it.first]--;
                                }
                                s += it.first;
                        } else {
                                break;
                        }
                }
        }

        cout << s;
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3684
i,o,t,j,l,s,z = map(int,input().split())
a = 2*(i//2+j//2+l//2)
if i>0 and j>0 and l>0:
    i,j,l = i-1,j-1,l-1
    b = 2*(i//2+j//2+l//2)
    print(o+max(a,b+3))
else:
    print(o+a)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
    int K,X;
    cin >> K >> X;
    bool ans = true;
    if(K*500 < X)
        ans = false;
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N,M = LI()
A = LI()
A = list(itertools.accumulate(A))

d = {0:1}
for x in A:
    m = x % M
    if m in d:
        d[m] += 1
    else:
        d[m] = 1

ans = 0
for x in d.values():
    ans += x * (x-1) // 2
print (ans)

Measured memory_bytes: 64796
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

vector<vector<ll>> c;
vector<ll> d;
vector<ll> pa;
ll dfs(ll pos,ll par) {
	pa[pos]=par;
	ll ret=1;
	REP(i,c[pos].size()) {
		if(c[pos][i]==par) continue;
		ret+=dfs(c[pos][i],pos);
	}
	return d[pos]=ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	c.resize(n);
	d.resize(n);
	pa.resize(n);
	REP(i,n-1) {
		ll a,b;
		cin>>a>>b;
		--a;
		--b;
		c[a].pb(b);
		c[b].pb(a);
	}
	dfs(0,-1);
	ll c=0;
	ll pos=n-1;
	while(pos!=0) {
		pos=pa[pos];
		c++;
	}
	c--;
	ll hoge=c/2;
	pos=n-1;
	REP(i,hoge) pos=pa[pos];
	if(n<=2*d[pos]) {
		cout<<"Snuke"<<endl;
	} else cout<<"Fennec"<<endl;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    int N; cin >> N;
    vec a(N); readv(a);
    int s = 0;
    REP(i, N) s += a[i];
    int m = INF;
    int ans = -1;
    REP(i, N){
        if(llabs(N * a[i] - s) < m){
            m = llabs(N * a[i] - s);
            ans = i;
        }
    }
    cout << ans;
    
    return 0;
}

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

using namespace std;

int main()
{
    int cri = 0;
    for(int j=1;j<1000;j++){
        if(j%3){
            cri += 195;
        }else{
            cri += 200;
        }
    }
    cri++;
    int n;
    cin >> n;
    rep(i,n){
        int y,m,d;
        cin >> y >> m >> d;
        int res = 0;
        for(int j=1;j<y;j++){
            if(j%3){
                res += 195;
            }else{
                res += 200;
            }
        }
        for(int j=1;j<m;j++){
            if(y%3){
                if(j%2){
                    res += 20;
                }else{
                    res += 19;
                }
            }else{
                res += 20;
            }
        }
        res += d;
        cout << cri-res << "\n";
    }
}



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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> S(N+1, 0), T(M+1, 0);
    REP(i,1,N+1) cin >> S[i];
    REP(j,1,M+1) cin >> T[j];

    vector<vector<ll>> dp(N+1, vector<ll>(M+1, 0));

    dp[0][0] = 1;
    REP(i,1,N+1) dp[i][0] = 1;
    REP(j,1,M+1) dp[0][j] = 1;
    REP(i,1,N+1) {
        REP(j,1,M+1) {
            if(S[i] == T[j]) dp[i][j] = (dp[i][j] + dp[i-1][j-1]) % MOD;
            dp[i][j] = (dp[i][j] + dp[i-1][j] + dp[i][j-1]) % MOD;
            dp[i][j] = dp[i][j] - dp[i-1][j-1] >= 0 ? (dp[i][j] - dp[i-1][j-1]) % MOD : (dp[i][j] - dp[i-1][j-1] + MOD) % MOD;
        }
    }
    _PR(dp[N][M] % MOD);

    return 0;
}

/*



*/

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
    cin>>n;
    vector<long long>a(n);
    vector<long long>b(n);
    for(int i=0;i<n;i++)
    {
      cin>>a[i]>>b[i];
    }
    long long d=0;
    for(int i=n-1;i>=0;i--)
    {
      a[i]+=d;
      if(a[i]%b[i]!=0)
      {
        d+=(((a[i]/b[i])+1)*b[i])-a[i];
      }
    }
    cout<<d<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
typedef long long ll;

int main()
{
    int n; cin >> n;
    //firstはその数字がでてきた個数,secondはその数字
    vector<pair<int, int> > odd_count(100005), even_count(100005);
    int odd1, odd2, even1, even2; //mode

    for(int i = 0; i < 100005; i++){
        odd_count[i].second = i;
        even_count[i].second = i;
    }
    for (int i = 0; i < n; i++)
    {
        int v; cin >> v;
        if(i % 2 == 0){
            odd_count[v].first++;
        }
        else{
            even_count[v].first++;
        }
    }

    //個数が大きい順にソート
    sort(odd_count.begin(), odd_count.end(), greater<pair<int, int>>());
    sort(even_count.begin(), even_count.end(), greater<pair<int, int>>());

    odd1 = odd_count[0].second;
    odd2 = odd_count[1].second;
    even1 = even_count[0].second;
    even2 = even_count[1].second;

    if(odd1 != even1){
        cout << n - (odd_count[0].first + even_count[0].first) << endl;
    }
    else{
        cout << n - max(odd_count[1].first + even_count[0].first, odd_count[0].first + even_count[1].first) << endl;
    }
    return 0;

}


Measured memory_bytes: 1792
#coding:utf-8

n = int(input())
string = list(map(int,input().split()))

cnt = 0
Q = [string[0]]
for i in range(1,n):
    if Q[0] == string[i]:
        Q.append(string[i])
    else:
        cnt += len(Q) //2
        Q = [string[i]]

cnt += len(Q) // 2

print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n;
  	cin >> n;
  	vector<ll> a(n), b;
  	for(auto& i : a) cin >> i;
  	b = a;
  	sort(b.rbegin(), b.rend());
    for(auto& i : a) cout << (i != b[0] ? b[0] : b[1]) << endl;
}

Measured memory_bytes: 4864
#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++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
double calc_distance(int x1, int y1, int x2, int y2)
{
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

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

    int n;
    cin >> n;

    vvi xy(n, vi(2));

    vi r(n);

    REP(i, n)
    {
        int x, y;
        cin >> x >> y;
        xy[i][0] = x;
        xy[i][1] = y;

        r[i] = i;
    }

    double ans = 0;
    int times = 0;
    do
    {
        REP(i, n - 1)
        {
            ans += calc_distance(xy[r[i]][0], xy[r[i]][1], xy[r[i + 1]][0], xy[r[i + 1]][1]);
        }
        times++;

    }while( next_permutation(r.begin(), r.end()) );

    cout << ans / times << endl;
}

Measured memory_bytes: 256
#
# abc074 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1 2 10 20 15 200"""
        output = """110 10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 2 1 2 100 1000"""
        output = """200 100"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """17 19 22 26 55 2802"""
        output = """2634 934"""
        self.assertIO(input, output)


def resolve():
    A, B, C, D, E, F = map(int, input().split())
    N = 0
    W = 100*A
    S = 0
    for i in range(31):
        for j in range(31):
            for k in range(101):
                for l in range(101):
                    w = A*i+B*j
                    s = C*k+D*l
                    if w == 0 or 100*w+s > F or s > w*E:
                        break
                    n = 100*s / (100*w+s)
                    if n > N:
                        N = n
                        W = 100*w+s
                        S = s
    print(f"{W} {S}")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16232
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
   int N;
   std::cin >> N;
   std::vector<int> a(N);
   for(int i=0; i<N; ++i) std::cin >> a[i];

   std::sort(a.begin(),a.end());
   std::cout << a[N-1] - a[0] << std::endl;
   return 0;

}


Measured memory_bytes: 256
def readlines
  ncase = ARGF.gets.to_i
  ARGF.each_line.take(ncase).map(&:chomp)
end

KEYMAP = {
  "1" => ".,!? ",
  "2" => "abc",
  "3" => "def",
  "4" => "ghi",
  "5" => "jkl",
  "6" => "mno",
  "7" => "pqrs",
  "8" => "tuv",
  "9" => "wxyz"
}

def convert(line)
  line.scan(/(([1-9])\2*0)/).map { |s, _|
    set = KEYMAP[s[0]]
    set[(s.size-2) % set.size]
  }.join
end

readlines.each do |line|
  puts convert(line)
end

Measured memory_bytes: 6232
#include<iostream>
#include<math.h>

using namespace std;

static const int MAX_N = 100;
int A[MAX_N + 1];

int main() {
    int N, D, X, C, S;

    S = 0;

    cin >> N;
    cin >> D >> X;

    for (int i = 1; i < N + 1; i++) {
        cin >> A[i];
    }

    for (int i = 1; i < N + 1; i++) {
        S += int((D - 1) / A[i]) + 1;
    }

    cout << S + X << endl;

    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

const ll MOD = 998244353;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	
	vl dp(d+1);
	dp[b] = 1;
	FOR(j,b+1,d+1) dp[j] = dp[j-1]*a % MOD;
	
	FOR(i,a+1,c+1) {
		vl ndp(d+1);
		ll sum = 0;

		FOR(j,b,d+1) {
			ndp[j] = (j*dp[j] + sum) % MOD;
			sum = (i*sum + j*dp[j]) % MOD;
		}

		dp = ndp;
	}
	cout << dp[d] << endl;
}


Measured memory_bytes: 3628
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
    a=list(map(int,input().split()))
    k=0
    for i in range(m):
        k+=a[i]*b[i]
    ans+=(k+c>0)
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
bool lf[30009][19],rf[30009][19];
bool f[19][19];

int main(){
  int n;
  string s;
  cin>>n>>s;
  s='a'+s;
  for(int i=1;i<=n;i++){
    for(int j=0;j<10;j++){
      lf[i][j]=lf[i-1][j];
    }
    lf[i][s[i]-'0']=true;
  }
  for(int i=n;i>0;i--){
    for(int j=0;j<10;j++){
      rf[i][j]=rf[i+1][j];
    }
    rf[i][s[i]-'0']=true;
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    int a=0,b=0;
    for(int j=0;j<10;j++){
      if(lf[i-1][j]&&!f[j][s[i]-'0']){
	f[j][s[i]-'0']=true;
	a++;
      }
      if(rf[i+1][j])b++;
    }
    ans+=a*b;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 1408
/*
        Author  : Malisetti Samrat
*/

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#include   <bits/stdc++.h>
#include   <algorithm>
#include   <queue>
#include   <list>
#include   <map>
#include   <math.h>
#include   <numeric>
#include   <iomanip>
using      namespace        std;
#define    endl             '\n'
#define    FAST             ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define    ipfile           ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define    pb(x)            push_back(x)
#define    int              long long int
#define    ull              unsigned long long int
#define    db               long double
#define    mod              1000000007
#define    vll              vector<int>
#define    all(v)           v.begin(),v.end()
#define    GCD(m,n)         __gcd(m,n)
#define    LCM(m,n)         m*(n/GCD(m,n))
#define    REVVEC(v)        reverse(v.begin(),v.end())
#define    REVARR(a)        reverse(a,a+n)
#define    maxc(v)          max_element(all(v))
#define    minc(v)          min_element(all(v))
#define    inputarr(a,n)    for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define    outputarr(a,n)   for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define    rep(i,m, n)      for(int i = m; i < (n); ++i)
#define    sp               setprecison(10)
#define    sz(v)            v.size()
#define    len(s)           s.length()

clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}


void TestCase3()
{
    
    int n,f=0;
    cin>>n;
    vector<int>v(n);
    inputarr(v,n);
    rep(i,0,n)
    if(v[i]%2==0)
    {
        if(v[i]%3==0 or v[i]%5==0);
        else{
            f=1;}
    }
    if(f==1) cout<<"DENIED\n";
    else cout<<"APPROVED\n";
    
}

signed main() {
	    
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

  // int T; cin>>T; while( T -- > 0){

    TestCase3();
  	
    //}
    time();
	return 0;
}

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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int K = cin.nextInt();
        long[] h = new long[N];
        for (int i = 0; i < N; i++)
        {
            h[i] = cin.nextLong();
        }

        Array.Sort(h);

        long ans = 10000000001;
        for (int i = 0; i < N - K + 1; i++)
        {
            ans = Math.Min(h[i + K - 1] - h[i], ans);
        }
        Console.WriteLine(ans);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 15952
M = int(input())
d = [0] * M
c = [0] * M
for i in range(M):
	d[i], c[i] = map(int, input().split())
D = 0
S = 0
for i in range(M):
	D += c[i]
	S += d[i] * c[i]
print((D - 1) + (S - 1) // 9)

Measured memory_bytes: 12532
#include <iostream>

using namespace std;

int main()
{
    int h, w;
    
    while (cin >> h >> w) {
        if (h == 0 && w == 0) {
            break;
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

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

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

    char symbol;

    cin >> symbol;

    if (symbol == 'A')
        cout << 'T' << endl;
    else if (symbol == 'T')
        cout << 'A' << endl;
    else if (symbol == 'G')
        cout << 'C' << endl;
    else
        cout << 'G' << endl;


    return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

ll ans[10];

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	ll h, w, n;
	cin >> h >> w >> n;

	map<pair<ll, ll>, ll> dat;
	vector<pair<ll, ll>> v;
	for(int i=0; i<n; i++){
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		dat[make_pair(a, b)] = 1;
		v.pb(make_pair(a, b));
	}

	map<pair<ll, ll>, ll> tgt;
	for(int i=0; i<n; i++){
		ll y = v[i].first - 2;
		ll x = v[i].second - 2;
		for(int j=0; j<3; j++){
			for(int k=0; k<3; k++){
				ll ny = y + j;
				ll nx = x + k;

				if(ny >= 0 && ny < h-2 && nx >= 0 && nx < w-2){
					tgt[make_pair(ny, nx)] = 1;
				}
			}
		}
	}

	for(auto it = tgt.begin(); it != tgt.end(); it++){
		ll cnt = 0;
		auto cord = it->first;
		//printf("%d %d\n", cord.first, cord.second);
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				if(dat.find(make_pair(cord.first + i, cord.second + j)) != dat.end()){
					cnt++;
				}
			}
		}
		ans[cnt]++;
	}

	ll sum = 0;
	for(int i=1; i<10; i++){
		sum += ans[i];
	}
	ans[0] = (h-2) * (w-2) - sum;

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

	
	return 0;
}


Measured memory_bytes: 64368
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int sum = 0;
      for(int A = 1 ; A < a + 1 ; A++){
        for(int B = 1 ; B < a + 1 ; B++){
          for(int C = 1 ; C < a + 1 ; C++){
            sum += gcd3(A,B,C);
          }
        }
      }
      System.out.println(sum);
    }
  static int gcd3(int a , int b , int c){
    return gcd2(gcd2(a,b),c);
  }
      
  static int gcd2(int a, int b){
    if(a % b == 0)
      return b;
    return gcd2(b , a % b);
  }
}


Measured memory_bytes: 35508
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力
		int N = sc.nextInt();
		
		int[] h = new int[N];
		for (int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}
		
		// 入力チェック
		/*
		if (error) {
			System.out.println("無効な入力値です");
			return;
		}
		*/
		// 答えを出力
		int ans = 0;
		ans += h[0];
		for (int i = 1; i < N; i++) {
			if(h[i] > h[i-1]) {
				ans += h[i] - h[i-1];
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] alpher ={'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
        String ans ="None";
        for(int i=0;i<26;i++){
            if(!s.contains(String.valueOf(alpher[i]))){
                ans = String.valueOf(alpher[i]);
                break;
            }
        }
        System.out.println(ans);
    }
}

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

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

int am[5], pm[5];

void solve() {
  rep(i,4) cin>>am[i+1]>>pm[i+1];
  
  int res = 0, max = am[0]+pm[0];
  rep(i,4) {
    int t = am[i+1]+pm[i+1];
    if (t > max) {
      max = t;
      res = i+1;
    }
  }
  
  char c = 'A'+res;
  cout<<c<<" "<<max<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>am[0]>>pm[0], am[0]||pm[0]) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;




int main() {
	int n, k;
	cin >> n >> k;

	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		p[i]--;
	}

	vector<ll> c(n);
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}

	ll ans = -INF;

	for (int i = 0; i < n; i++) {

		int pos = i;
		ll cycle_cnt = 0;
		ll cycle_sum = 0;
		
		while (true) {
			
			cycle_cnt++;
			cycle_sum += c[pos];
			pos = p[pos];
			if (pos == i) {
				break;
			}
			
		}

		ll sum = 0;
		ll cnt = 0;

		while (true) {
			
			cnt++;
			sum += c[pos];
			if (cnt > k) {
				break;
			}
			
			ll num = (k - cnt) / cycle_cnt;
			ll score = sum + max(0ll, cycle_sum) * num;
			ans = max(ans, score);
			pos = p[pos];
			if (pos == i) {
				break;
			}
		}

	}

	std::cout << ans << endl;
}


Measured memory_bytes: 3704
n, k = map(int,input().split())
h = []

for i in range(n):
    x = int(input())
    h.append(x)

h = sorted(h)
ans = 10**9
tmp = 0

for i in range(k-1, n):
    tmp = h[i] - h[i-(k-1)]
    if tmp < ans:
        ans = tmp

print(ans)


Measured memory_bytes: 14020
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int N,K;
    cin >> N >> K;

    cout << (N%K==0 ? 0 : 1 )<< endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 300010
ll n,x;
struct ver{
	ll b,l,r;
	ll allsum(){
		return b*l+(x-b)*r;
	}
	ll opp(){
		return b*l;
	}
	
	ver(ll b,ll l,ll r){
		this->b=b,this->l=l,this->r=r;
	}
};
bool operator<(const ver&a,const ver&b){
	ll vl=a.b*a.l+(x-a.b)*a.r;
	ll vr=b.b*b.l+(x-b.b)*b.r;
	return vl>vr;
};
vector<ver> v;
ll cs[N],oppsum;
bool judge(ll k,ll t){
	ll cost=k/x; if(cost>=n)return 1;
	ll res=min(k%x,v[t].b)*v[t].l+max(0LL,k%x-v[t].b)*v[t].r;
	res+=cs[min(t,cost)]-cs[0];
	res+=max(0LL,cs[cost+1]-cs[t+1]);
	return oppsum<=res;
}
bool solve(ll k){
	for(int i=0;i<n;i++){
		if(judge(k,i))return 1;
	}
	return 0;
}
int main(){
	cin>>n>>x;
	for(int i=0;i<n;i++){
		ll b,l,r; cin>>b>>l>>r;
		v.push_back(ver(b,l,r));
	}
	sort(v.begin(),v.end());
	oppsum=0;
	for(auto t:v)oppsum+=t.opp();
	cs[0]=0;
	for(int i=0;i<v.size();i++){
		cs[i+1]=cs[i]+v[i].allsum();
	}
	ll l=-1,r=1e17,m;
	while(l<r-1){
		m=(l+r)>>1;
		if(solve(m))r=m;
		else l=m;
	}
	cout<<r<<endl;
	return 0;	
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  string S;
  cin>>S;
  int X[4]={0};
  string T="NEWS";
  rep(i,S.size()) rep(j,4) if(S[i]==T[j]) X[j]=1;
  if((X[0]+X[3]==0||X[0]+X[3]==2)&&(X[1]+X[2]==0||X[1]+X[2]==2)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
            int[] arrayS;
            arrayS = new int[N];
            int i = 0;
            for(i=0;i<N;i++){
                arrayS[i] = sc.nextInt();
            }

            int Q = sc.nextInt();
            int[] arrayT;
            arrayT = new int[Q];
            int j = 0;
            for(j=0;j<Q;j++){
                arrayT[j] = sc.nextInt();
            }

            int testdata;
            int sum;
            int counter;

            int position;
            int start;
            int end;

            sum = 0;
            for(j=0 ; j<Q ; j++ ){
            testdata = arrayT[j];
            counter=N;
            start = 0;
            end = N-1;
            position = (start+end)/2;
                    while(counter>0){
                        if(arrayS[position] == testdata){
                                sum += 1;
                                break;
                        }else{
                    if( arrayS[position] > testdata){
                        end = position-1;
                    }else{
                        start = position+1;
                    }
                    position = (start+end)/2;
                    counter /=2;
                }
            }

        }
        System.out.println(sum);
        sc.close();

    }
}


Measured memory_bytes: 67284