akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int main(){
    long int n, a[5];
    cin >> n;
    for(int i = 0; i < 5; i++){
        cin >> a[i];
    }
    long int mn = 10000000000000000;
    for(int i = 0; i < 5; i++){
        if (mn > a[i]) {
            mn = a[i];
        }
    }
    long int ans = 0;
    if (n % mn == 0) {
        ans = n / mn + 4;
    }else{
        ans = n / mn + 1 + 4;
    }
    cout << ans << '\n';
    
}

Measured memory_bytes: 256
// SeeAlso: https://atcoder.jp/contests/abc143/tasks/abc143_b

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

const long double PI = acos(-1);

int main() {
    int n;
    cin >> n;
    int d[50];
    rep(i, n) {
        cin >> d[i]; 
    } 

    ll sum = 0;
    rep(i, n) {
        FOR(j, i+1, n) {
            sum += d[i] * d[j];
        }
    }
    print(sum);
    return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


char hiki(int ch,int diff){
   
    ch+=diff;
    while(ch>(int)'z'){
        ch-=26;
    }
   
   
    return ch;
}


string solve(string s,int a,int b){
    int diff=abs(b-a);
   
    int xx=s[a];
    s[a]=s[b];
    s[b]=xx;
   
    s[a]=hiki(s[a],diff);
    s[b]=hiki(s[b],diff);
   
    return s;
}

int main() {
    int n;
    while(cin>>n){
        if(n==0)break;
        string s;
        cin>>s;
       
       
        stack<pii> a;
        rep(i,n){
            int x,y;
            cin>>x>>y;
            x--;
            y--;
            a.push(pii(x,y));
        }
       
        while(a.size()){
            s=solve(s,a.top().first,a.top().second);
            a.pop();

        }
        cout<<s<<endl;
    }
   
   
    return 0;
}

Measured memory_bytes: 1212
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int T,X;
	cin>>T>>X;
	printf("%.10f\n",1.0*T/X);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long K,N,A1,A2,gap,champ;
cin>>K>>N;
cin>>A1;
gap=A1;
for(int i=1;i<N;++i){
    A2=A1;
    cin>>A1;
    if(champ<(A1-A2)){
        champ=A1-A2;
    }
}
gap+=K;
gap-=A1;
if(gap>champ){
    champ=gap;
}
cout<<K-champ<<"\n";
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
#define MAX_V 1000
struct edge{int to,cap,rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    edge &e=G[v][i];
    if(!used[e.to]&&e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
	e.cap-=d;
	G[e.to][e.rev].cap+=d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow=0;
  for(;;){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,INF);
    if(f==0)return flow;
    flow+=f;
  }
}

int main(){
  int n,a[100],b[100],c[100],d[100];
  bool can[100][100];
  int s=500,t=501;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i]>>b[i];
  for(int i=0;i<n;i++)cin>>c[i]>>d[i];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      if(a[i]<c[j]&&b[i]<d[j])can[i][j]=true;
      else can[i][j]=false;
  for(int i=0;i<n;i++){
    add_edge(s,i,1);
    add_edge(n+i,t,1);
  }
   for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      if(can[i][j])add_edge(i,j+n,1);
   cout<<max_flow(s,t)<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N;
    ll H,W;
    cin >> N >> H >> W;
    vel A(N), B(N);

    int ans = 0;
    rep(i,N) {
        cin >> A[i] >> B[i];
        if(A[i] >= H and B[i] >= W) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

ll dig(ll n) {
	if (n == 0) {
		return 0;
	}
	ll i = 1;
	ll j = 1;
	ll d = 0;
	if (n > 0) {
		i = 1;
		while (1) {
			if (n <= i) {
				return d;
			}
			j *= 4;
			i += j;
			d += 2;
		}
	}
	else {
		++d;
		i = -2;
		j = -2;
		while (1) {
			if (i <= n) {
				return d;
			}
			j *= 4;
			i += j;
			d += 2;
		}

	}
}

int main() {
	ll n;
	cin >> n;
	vi v(100, 0);
	ll md = 0;
	while (n != 0) {
		ll d = dig(n);
		md = max(md, d);
		v[d] = 1;
		ll a = 1;
		rep(i, 0, d) {
			a *= -2;
		}
		n -= a;
	}
	repr(i, md + 1, 0) {
		cout << v[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 1000010

string s;
ll dp[M][2];
ll f(ll pos,ll car){
	if(pos < 0) return car;
	if(dp[pos][car]!=-1) return dp[pos][car];
	ll num = s[pos] - '0';
	ll val = num + car, ans;
	if(val >= 10){
		ans = f(pos-1, 1) + val % 10;
	}
	else {
		ans = f(pos-1, 0) + val;
		ans = min(ans, f(pos-1,1) + (10 - val));
	}
	return dp[pos][car] = ans; 
}
int main(){
	IOS;
	tihs;
	memset(dp,-1,sizeof(dp));
	cin>>s;
	ll n=sz(s)-1;
	cout<<f(n,0);




	return 0;
}

Measured memory_bytes: 63900
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int ans = 1;
  int x = 0, y = 0, z = 0;
  REP(i, N){
    int cnt = 0;
    if(x == A[i]) cnt++;
    if(y == A[i]) cnt++;
    if(z == A[i]) cnt++;

    ans *= cnt;
    ans %= MOD;

    if(x == A[i]) x++;
    else if(y == A[i]) y++;
    else if(z == A[i]) z++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
import sys

while True:
    N = int(sys.stdin.readline().rstrip())
    if N == 0:
        break;
    max_value = 0
    prev_row = [0] * (N+1)
    for i in range(N):
        row = sys.stdin.readline().rstrip()
        curr_row = [0] * (N+1)
        for x,d in enumerate(row,1):
            if d == '.':
                curr_row[x] = min(prev_row[x-1], prev_row[x], curr_row[x-1]) + 1
        max_value = max(max(curr_row), max_value)
        prev_row = curr_row

    print(max_value)

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

using namespace std;

#define REP(i, a, b) for(ll i=a;i<b;i++)
#define REPR(i, a, b) for(ll i=b-1;i>=a;i--)
#define forr(i, n) for(ll i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define w(t) int t;cin>>t;while(t--)
#define W(t) ll t;cin>>t;while(t--)
#define endl '\n'
#define space ' '
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl

typedef long long ll;

// const int N = 2e5 + 5;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll N;
	cin >> N;
	string s;
	cin >> s;
	int w = count(s.begin(), s.end(), 'W'), r = count(s.begin(), s.end(), 'R');
	int cnt = 0;
	for (int i = 0; i < r; i++)
	{
		if (s[i] == 'W')
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3740
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
dst = [{} for i in range(n+1)]
for i in range(n-1):
    u,v,w = inm()
    dst[u][v] = dst[v][u] = w
q = [1]
d = [BIG]*(n+1)
d[1] = 0
while len(q)>0:
    x = q.pop()
    for y in dst[x]:
        if d[y]==BIG:
            d[y] = d[x]+dst[x][y]
            q.append(y)
for i in range(1,n+1):
    print(d[i]%2)


Measured memory_bytes: 86048
N = int(input())
a = list(map(int, input().split()))
x = 0
y = 0

for ai in a:
    if ai % 4 == 0:
        x += 1
    elif ai % 2 == 1:
        y += 1
if x >= y or (x == y - 1 and x + y == N):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
# frozen_string_literal: true

n, k = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
dp = Array.new(n, 100_000_000_000)

dp[0] = 0
(n - 1).times do |i|
  count = [k, n - i - 1].min
  1.upto(count) do |x|
    tmp = dp[i] + (h[i] - h[i + x]).abs
    dp[i + x] = tmp if dp[i + x] > tmp
  end
end

puts dp[n - 1]


Measured memory_bytes: 11396
line = input()
num = [int(n) for n in line.split()][0]
number_of_sums = num//2 + 1 + 1*num % 2
smallest_sum = 100000
for i in range(1, number_of_sums):
    first_number = i
    second_number = num-i
    summation = 0
    while first_number and summation < smallest_sum:
        summation += first_number % 10
        first_number //= 10
    while second_number and summation < smallest_sum:
        summation += second_number % 10
        second_number //= 10
    if smallest_sum > summation:
        smallest_sum = summation
print(smallest_sum)

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

int no(const void* to, const void* ma) {
	int mi = *(const int*)to, ko = *(const int*)ma;
	return mi < ko ? -1 : mi > ko;
}

int N;
int a[114514];

int kitaeri;
int asumisu[114514], mizuhasu[114514];

int emirin(int yukachi) {
	int aoi = 0, ayana = kitaeri - 1;
	while (aoi <= ayana) {
		int sumipe = aoi + (ayana - aoi) / 2;
		if (asumisu[sumipe] == yukachi) return sumipe;
		else if (asumisu[sumipe] < yukachi) aoi = sumipe + 1;
		else ayana = sumipe - 1;
	}
	return 114513;
}

int main(void) {
	int harukasu;
	int hocchann;
	if (scanf("%d", &N) != 1) return 1;
	for (harukasu = 0; harukasu < N; harukasu++) {
		if (scanf("%d", &a[harukasu]) != 1) return 1;
		asumisu[harukasu] = a[harukasu];
	}
	qsort(asumisu, N, sizeof(*asumisu), no);
	kitaeri = 1;
	for (harukasu = 1; harukasu < N; harukasu++) {
		if (asumisu[kitaeri - 1] != asumisu[harukasu]) {
			asumisu[kitaeri++] = asumisu[harukasu];
		}
	}
	for (harukasu = 0; harukasu < N; harukasu++) {
		mizuhasu[emirin(a[harukasu])]++;
	}
	hocchann = 0;
	for (harukasu = 0; harukasu < kitaeri; harukasu++) {
		int hayaminn = mizuhasu[harukasu];
		if (harukasu > 0 && asumisu[harukasu - 1] == asumisu[harukasu] - 1) {
			hayaminn += mizuhasu[harukasu - 1];
		}
		if (harukasu + 1 < kitaeri && asumisu[harukasu + 1] == asumisu[harukasu] + 1) {
			hayaminn += mizuhasu[harukasu + 1];
		}
		if (hayaminn > hocchann) hocchann = hayaminn;
	}
	printf("%d\n", hocchann);
	return 0;
}


Measured memory_bytes: 1276
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  bool operator< (const Point &p1) {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

Int N;

void input() {
  cin >> N;
}

void solve() {
  if (N <= 104) {
    cout << 0 << endl;
    return;
  }

  int count = 0;
  for (int i=105; i<=N; i += 2) {
    int c = 0;
    for (int j=1; j<=i; j++) {
      if (i%j==0) c++;
    }
    if (c == 8) count++;
  }
  cout << count << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
  cin>>s;
  cin>>s;
  cout<<"A"<<s[0]<<"C"<<endl;
    return 0;
}


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

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        System.out.println(solve(a, b));
    }

    static int solve(int a, int b) {

        if (a == 1) {
            return 1;
        }

        return a > b ? a - 1 : a;
    }

}

Measured memory_bytes: 21460
#include<stdio.h>
#include<utility>
#include<algorithm>

using namespace std;

struct Node{
    int parent;
    int left;
    int right;
};

Node nodes[25];
int depths[25];
int heights[25];

void setdepth(int current, int depth){
    depths[current] = depth;
    if(nodes[current].left != -1){
        setdepth(nodes[current].left, depth + 1);
    }
    if(nodes[current].right != -1){
        setdepth(nodes[current].right, depth + 1);
    }
}

int setheight(int current){
    heights[current] = 0;
    if(nodes[current].left != -1){
        heights[current] = setheight(nodes[current].left) + 1;
    }
    if(nodes[current].right != -1){
        int tmp = setheight(nodes[current].right) + 1;
        if(heights[current] < tmp){
            heights[current] = tmp;
        }
    }
    return heights[current];
}

int main(){
    int n;
    scanf("%d", &n);

    for(int i = 0; i < 25; i++){
        nodes[i].parent = nodes[i].left = nodes[i].right = -1;
    }

    for(int i = 0; i < n; i++){
        int id, left, right;
        scanf("%d%d%d", &id, &left, &right);

        nodes[id].left = left;
        nodes[id].right = right;

        if(left != -1){
            nodes[left].parent = id;
        }
        if(right != -1){
            nodes[right].parent = id;
        }
    }

    int root;
    for(int j = 0; j < 25; j++){
        if(nodes[j].parent == -1){
            root = j;
            break;
        }
    }

    setdepth(root, 0);

    setheight(root);

    for(int i = 0; i < n; i++){
        printf("node %d", i);

        printf(": parent = %d", nodes[i].parent);

        int sibling = -1;
        if(nodes[i].parent != -1){
            int parent = nodes[i].parent;
            if(nodes[parent].left != i){
                sibling = nodes[parent].left;
            }
            else{
                sibling = nodes[parent].right;
            }
        }
        printf(", sibling = %d", sibling);

        int degree = 0;
        if(nodes[i].left != -1){
            degree++;
        }
        if(nodes[i].right != -1){
            degree++;
        }
        printf(", degree = %d", degree);

        printf(", depth = %d", depths[i]);

        printf(", height = %d", heights[i]);

        if(nodes[i].parent == -1){
            printf(", root\n");
        }
        else if(nodes[i].left == -1 && nodes[i].right == -1){
            printf(", leaf\n");
        }
        else{
            printf(", internal node\n");
        }
    }
}


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

using namespace std;

#define int long long
#define endl "\n"
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 1000000007

void start(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	#ifndef ONLINE_JUDGE
		freopen("in.txt","r",stdin);
		freopen("out.txt","w",stdout);
	#endif

}


int dp[10002][102][2];
string k;
int d;

int solve(int pos,int sum,bool tight){

	if(pos == k.size()){
		return sum%d == 0;
	}
	if(dp[pos][sum][tight] != -1) return dp[pos][sum][tight];

	int end = (tight)?k[pos] - '0' : 9;
	int ans = 0;

	for(int i=0;i<=end;i++){
		ans = (ans + solve(pos+1,(sum+i)%d,tight&(i == end)))%mod;
	}

	return dp[pos][sum][tight] = ans;


}



int32_t main(){
	fastIO
	start();

	memset(dp,-1,sizeof(dp));
	cin>>k;
	cin>>d;

	cout<<(solve(0,0,1)-1 + mod)%mod<<endl;

	// it is said that we need more heads than tails so i 
	// opted for n+1/2 heads

}

Measured memory_bytes: 20408
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var XY = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i <= XY[0]; i++)
            {
                var twoLeg = i;
                var fourLeg = XY[0] - i;
                if (twoLeg * 2 + fourLeg * 4 == XY[1])
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");
        }
    }
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (2e18)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = -INF;
    ans = max({ans, a*c, a*d, b*c, b*d});
    cout << ans << endl;
    return 0;
}


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

int w,h;
char m[22][32];

int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
int dfs(int y,int x){
	if(m[y][x]=='#')return 0;
	int res=1;
	m[y][x]='#';
	for(int i=0;i<4;i++){
		res+=dfs(y+dy[i],x+dx[i]);
	}
	return res;
}
int main(){
	while(cin>>w>>h,w|h){
		memset(m,'#',sizeof(m));
		for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)cin>>m[i][j];
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				if(m[i][j]!='@')continue;
				cout<<dfs(i,j)<<endl;
				goto BREAK;
			}
		}
		BREAK:;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	int ans = 0;
	REP(i, N) {
		int a, b; cin >> a >> b;
		ans += b - a + 1;
	}
	cout << ans << endl;

	return 0;
}



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

int main(){
    int64_t K;
    cin >> K;

    int64_t count = 1;
    int64_t nom = 7;
    bool state_1 = false;
    bool state_2 = true;
    if(K%2==0) state_2 = false;
    if(state_2){
        for(int64_t i=0;i<K;i++){
            nom = nom%K;
            if(nom == 0){
                state_1 = true;
                break;
            }else{
                nom = 10*nom + 7;
                count++;
            }
        }
        if(!state_1){
            state_2 = false;
        }
    }

    if(state_2){
        cout << count << endl;
    }else{
        cout << -1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		String str = scanner.next();
		for (int i = 0; i < str.length(); i += 2) {
			sb.append(str.charAt(i));
		}
		System.out.println(sb.toString());
	}
}


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

def main():
    N,M = map(int, input().split())
    A = [0]*N
    for _ in range(M):
        a,b = map(int, input().split())
        A[a-1] += 1
        A[b-1] += 1
    for a in A:
        if a%2 == 1:
            print("NO")
            return
    print("YES")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
using namespace std;
typedef long long ll;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
 
int main(){
    int N;
    cin >> N;
    vector<ll> ans;
    while (N!=0)
    {
        vector<ll> a;
        a.resize(N);
        for (int i = 0; i < N; i++) cin >> a[i];
        ll thismin = 1e10;
        for (int i = 0; i < N;i++) {
            for (int n = 0; n < N; n++) {
                if (n == i) continue;
                thismin = min(thismin, abs(a[i] - a[n]));
            }
        }
        ans.push_back(thismin);
        cin >> N;
    }
    for (auto i : ans) {
        cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 3096
class UFTree:
    def __init__(self, N):
        self.nodes = [Node(i) for i in range(N)]
        self.N = N

    def find_max_child_num(self):
        result = 0
        for i in range(self.N):
            result = max(result, self.nodes[i].child_num)
        return result

class Node:
    def __init__(self, ID):
        self.ID = ID
        self.parent = None
        self.child_num = 0
        self.rank = 1

    def get_root(self):
        if self.parent is None:
            return self
        
        return self.parent.get_root()

    def is_in_same_tree(self, another):
        return self.get_root().ID == another.get_root().ID

    def concat(self, another):
        if self.is_in_same_tree(another):
            return

        sr = self.get_root()
        ar = another.get_root()

        if sr.rank > ar.rank:
            parent, child = sr, ar
        else:
            parent, child = ar, sr

        parent.child_num += child.child_num + 1
        parent.rank = max(parent.rank, child.rank + 1)
        child.parent = parent

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

AB = []
for i in range(M):
    l = list(map(int, input().split()))
    AB.append(l)

for i in range(M):
    a, b = AB[i][0], AB[i][1]
    a -= 1;
    b -= 1;

    tree.nodes[a].concat(tree.nodes[b])

# # for debug
# for i in range(N):
#     n = tree.nodes[i]
#     if n.parent is None:
#         print(i + 1, "is root")
#     else:
#         print("parent of", i + 1, "is", n.parent.ID + 1)

print(tree.find_max_child_num() + 1)


Measured memory_bytes: 85204
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define MAX_N 55
#define ll long long

ll N, K;

int compress(vector<ll>& x1, vector<ll>& x2,vector<ll>& xs) {
	for (int i = 0; i < N;i++) {
		xs.push_back(x1[i]);
		xs.push_back(x2[i]);
	}
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());

	for (int i = 0; i < N;i++) {
		x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
		x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
	}
	return xs.size();
}

int main() {
	cin.tie(0);ios::sync_with_stdio(false);
	cin >> N >> K;
	vector<ll> X1(N), X2(N), Y1(N), Y2(N), D1(N), D2(N);
	vector<ll> xs, ys, ds;
	for (int i = 0; i < N;i++) {
		cin >> X1[i] >> Y1[i] >> D1[i] >> X2[i] >> Y2[i] >> D2[i];
	}
	ll X = compress(X1, X2, xs);
	ll Y = compress(Y1, Y2, ys);
	ll D = compress(D1, D2, ds);

	ll ans = 0;

	vector<vector<vector<ll>>> m(X, vector<vector<ll>>(Y, vector<ll>(D, 0)));
	for (int i = 0; i < N;i++) {
		for (int x = X1[i] + 1; x <= X2[i]; x++) {
			for (int y = Y1[i] + 1; y <= Y2[i]; y++) {
				for (int d = D1[i] + 1; d <= D2[i]; d++) {
					m[x][y][d]++;
				}
			}
		}
	}

	for (int x = 1; x < X; x++) {
		for (int y = 1; y < Y;y++) {
			for (int d = 1; d < D;d++) {
				if (m[x][y][d] >= K) {
					ll a_x, a_y, a_d;
					a_x = xs[x] - xs[x - 1];
					a_y = ys[y] - ys[y - 1];
					a_d = ds[d] - ds[d - 1];

					ans += a_x * a_y * a_d;
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 10984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int h[n];
    rep(i, 0, n) cin >> h[i];

    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    rep(i, 2, n) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[n - 1] << endl;
    return 0;
}


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

#define MAX_N 2003

int n ,x ,y;
int a[MAX_N];

int main()
{
    scanf("%d%d%d",&n,&x,&y);
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
    if(n == 1)
        printf("%d\n",abs(a[0]-y));
    else
        printf("%d\n",max(abs(a[n-1]-y) ,abs(a[n-1]-a[n-2])));
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var buf = new string[h];
        var ha = new bool[h];
        var wa = new bool[w];
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            buf[i] = s;
            for (int j = 0; j < w; j++)
                if (s[j] == '#') { wa[j] = true; ha[i] = true; }
        }
        for (int i = 0; i < h; i++)
        {
            var ans = "";
            for (int j = 0; j < w; j++)
                if (ha[i] && wa[j]) ans += buf[i][j];
            if (ans.Length > 0) Console.WriteLine(ans);
        }
    }
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  string s = to_string(n);
  int sum = 0;
  for (int i = 0; i < s.size(); ++i) {
    sum += s[i] - '0';
  }

  cout << (n % sum == 0 ? "Yes" : "No") << '\n';
  return 0;
}

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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
int main(){
  int N;
  cin >> N;
  
  if(N%10*100 + N/10%10*10 + N/10/10%10 == N) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<bitset>
using namespace std;
const int MAX=5005;
int a[MAX];
int dp[MAX];
int need,n,k,number;
bool check(int m)
{
	for(int i=1;i<=k;++i) dp[i]=0;
	for(int i=1;i<=number;++i){
		if(i==m) continue;
		for(int j=k;j>=1;--j){
			if(j-a[i]>=0&&dp[j-a[i]]==1){
				dp[j]=1;
			}
		}
	}
	for(int j=k-a[m];j<k;j++){
		if(dp[j]){
			return true;	
		}
	}
	return false;
}
int solve()
{
	int ans=number+1;
	int lo=1,hi=number;
	while(lo<=hi)
	{
		int mi=(lo+hi)/2;
		if(check(mi))
		{
			ans=mi;
			hi=mi-1;
		}
		else lo=mi+1;
	}
	return ans;
}
int main()
{
	int maximum=1;
	int b;
	cin>>n>>k;
	for(int i=1;i<=n;++i){
		cin>>b;
		if(b>=k) need++;
		else{
			number++;
			maximum=max(maximum,b);
			a[number]=b;
		}
	}
	sort(a+1,a+number+1);
	dp[0]=1;
	int ans=solve();
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
count = 0
check = -1

for i in range(N):
    eat = A[i] - 1
    count += B[eat]
    if 1 <= i <= (N-1):
        if check == eat - 1:
            count += C[check]
    check = eat

print(count)

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

using namespace std;

typedef long long ll;

int x[200100];
int main() {
    int N, K;
    cin >> N >> K;
    fill(x, x+N, 0);

    for(int i = 0; i < N; i++){
        int a;  cin >> a;
        x[--a] += 1;
    }

    sort(x, x+N);
    int s = 0;
    for(int i = N - K - 1; i >= 0; i--){
        s += x[i];
    }
    cout << s << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 2005
#define INF 1000000005
#define INFLL (long long)1e18
#define PI 3.1415926535897
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int n=5;
    vector<int>a(n);
    REP(i,n)cin>>a[i];
    REP(i,n){
        if(a[i]==0){
            OUT(i+1);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b;
    int k;
    int i;
    while(scanf("%d%d%d",&a,&b,&k)!=EOF)
    {
        if(k<1||k>100)
            break;
    if(2*k>b-a+1)
    {
        for(i=a;i<=b;i++)
        {
            printf("%d\n",i);
        }
    }
    else
    {
        for(i=a;i<=a+k-1;i++)
        {
            printf("%d\n",i);
        }
        for(i=b-k+1;i<=b;i++)
        {
            printf("%d\n",i);
        }
    }
    }
    return 0;
}


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

using namespace std;

int main()
{
    int n,m,v;
    string s;
    unordered_map<string, int> a, b;
    cin>>n;
    for(int i = 0; i < n; i++){
        cin>>s;
        if(a.find(s) == a.end()){
            a[s] = 1;
        }else{
            a[s]++;
        }
    }
    cin>>m;
    for(int i = 0; i < m; i++){
        cin>>s;
        if(b.find(s) == b.end()){
            b[s] = 1;
        }else{
            b[s]++;
        }
    }
    int ans = 0;
    for(auto& x:a){
        if(b.find(x.first) != b.end()){
            auto mid = b.find(x.first);
            ans = max(ans, x.second-mid->second);
        }else{
            ans = max(ans, x.second);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>


using namespace std;

bool check(vector<int> &dp){
  for(int i = 0; i < dp.size(); i++){
    if(dp[i] == 0){
      return false;
  	}
  }
  return true;
}

void dfs(int p, vector<vector<int>> &mp, vector<int> &dp){
  dp[p] = 1;
  for(int i = 0; i < mp.size(); i++){
    if(mp[p][i] == 1){
      mp[p][i] = 2;
      dfs(i, mp, dp);
    }
  }
}

int main(int argc, const char * argv[]) {
  int n, m;
  cin >> n >> m;
  int a, b;
  vector<vector<int>> mpbk(n,vector<int>(n,0));
  vector<vector<int>> mp(n,vector<int>(n,0));
  for(int i = 0; i < m; i++){
    cin >> a >> b;
    mp[a-1][b-1] = 1;
    mp[b-1][a-1] = 1;
  }
//  for(int i = 0; i < n; i++){
//    for(int j = 0;j < n; j++){
//      cout << mp[i][j] << " ";
//    }
//    cout << endl;
//  }
  
  mpbk = mp;
  int ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= i; j++){
      if(mpbk[i][j] == 1){
        vector<int> dp(n,0);
        mp = mpbk;
        mp[i][j] = 3;
        mp[j][i] = 3;
        dfs(0, mp, dp);
//        cout << i << "," << j;
//        if(check(dp) == false){
//          cout << "o" << endl;
//        }else{
//          cout << "x" << endl;;
//        }
        ans += (check(dp) ? 0 : 1);
//          for(int l = 0; l < n; l++){
//            for(int o = 0;o < n; o++){
//              cout << mp[l][o] << " ";
//            }
//            cout << endl;
//          }
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
#define ls (rt << 1)
#define rs (rt << 1 | 1) 
typedef pair<int, int> pii; 
const ll mod = 1e9 + 7;
template <class T> T lowbit(T x){return ((x)&(-(x)));}
const int maxn = 2e5 + 10;
int n, k;
ll ans, f[maxn];
ll powMod(ll a, ll k) { ll ret = 1; while(k) { if(k & 1) ret = ret * a % mod; a = a * a % mod; k >>= 1;} return ret;}
ll inv(ll a) { return powMod(a, mod - 2);}
ll norm(ll a) { while(a < 0) a += mod; while(a >= mod) a -= mod; return a;}
int main()
{
	cin >> n >> k;
	for(int i = k; i; --i)
	{
		f[i] = powMod(k / i, n);
		for(int j = i + i; j <= k; j += i)
			f[i] = norm(f[i] - f[j]);
		ans = norm(ans + i * f[i] % mod);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long n;cin>>n;
    std::vector<long long>A(n),B(n+1);
    for(long long i=0;i<n;i++){
        cin>>A[i];
    }
    for(long long i=0;i<n;i++){
        if(i%2==0){
            if(n%2==1){
                B[(n+i)/2+1]=A[i];
            }
            else{
                B[(n+i)/2]=A[i];
            }
        }
        else{
            B[(n-i)/2]=A[i];
        }
    }
    if(n%2==1){
        reverse(B.begin(),B.end());
    }
    for(long long i=0;i<n;i++){
        cout<<B[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 6324
#include<stdio.h>
#include<math.h>
int main(){
  int sum = 0;
  int i,num,taste,tmp;
  scanf("%d %d",&num ,&taste);
  for(i = 1,tmp = taste; i <= num;i++){
    sum += taste;
    if(abs(tmp) > abs(taste)){
      tmp = taste;
    }
    taste++;
  }
  
  printf("%d\n",sum - tmp);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
using namespace std;
string s;
int sum;
int main()
{
    getline(cin,s);
    for(int i=0;i<s.size();i++)
        if(i!=0&&i!=s.size()-1) sum++;
    cout<<s[0]<<sum<<s[s.size()-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

int main() {
  
  int N;
  while(cin >> N && N) {
    vector<int> in(N), v(N);
    rep(i, N) cin >> in[i];
    int ans = -1<<29;
    rep(i, N) {      
      if(i-1 >= 0 && v[i-1] >= 0) {
	v[i] += v[i-1] + in[i];
      }
      else {
	v[i] = in[i];
      }
      ans = max(ans, v[i]);
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
int main(void)
{
	int a,s,d[1000],f[1000],g[1000],i,j,z;
	z=1;
	scanf("%d %d",&a,&s);
	for(i=1;i<=a;i++){
		scanf("%d",&d[i]);
	}
	for(i=1;i<=s;i++){
		scanf("%d",&f[i]);
	}
	for(i=1;i<=a;i++){
		g[i]=0;
		for(j=1;j<=s;j++){
			if(d[i]<=f[j]){
				g[i]++;
				f[j]=0;
			}
		}
//		printf("%d\n",g[i]);
	}
	for(i=1;i<=a;i++){
		if(g[1]<g[i]){
			g[1]=g[i];
			z=i;
		}
	}
	printf("%d\n",z);
	return 0;
}

Measured memory_bytes: 1036
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

struct SCC{
    int n;
    VVI G, rG;
    VI vs, cmp;
    vector<bool> used;

    SCC(){}
    SCC(int x){
        n = x;
        G.resize(n);
        rG.resize(n);
        cmp.resize(n);
        used.resize(n);
    }

    void add_edge(int from, int to){
        G[from].push_back(to);
        rG[to].push_back(from);
    }

    void dfs(int v){
        used[v] = true;
        for (int next : G[v]){
            if (!used[next]) dfs(next);
        }
        vs.push_back(v);
    }

    void rdfs(int v, int k){
        used[v] = true;
        cmp[v] = k;
        for (int next : rG[v]){
            if (!used[next]) rdfs(next, k);
        }
    }

    VI scc(){
        fill(ALL(used), false);
        vs.clear();
        REP(i,n) if (!used[i]) dfs(i);
        fill(ALL(used), false);
        int k = 0;
        FORR(i,n-1,0) if (!used[vs[i]]) rdfs(vs[i], k++);
        return cmp;
    }
};

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

    SCC sc(n);
    while (m--){
        int u, v;
        scanf("%d %d", &u, &v);
        sc.add_edge(u, v);
    }
    VI cmp = sc.scc();

    // REP(i,n) cout << cmp[i] << endl;

    int q;
    cin >> q;
    while (q--){
        int u, v;
        scanf("%d %d", &u, &v);
        printf("%d\n", (cmp[u] == cmp[v]));
    }

    return 0;
}

Measured memory_bytes: 4620
#include <iostream>

using namespace std;

int main() {
    int n,i,j,k,l,ans;

    while(cin >> n){

        ans = 0;
        for(i = 0;i <= 9;i++){
            for(j = 0;j <= 9;j++){
                for(k = 0;k <= 9;k++){
                    for(l = 0;l <= 9;l++){
                        if(n == i + j + k + l){
                            ans++;
                        }
                    }
                }
            }
        }
        
        cout << ans << endl;
    }
    
    return 0;
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    long long ans = 0L;
    for(int A = 1; A < n; A++){
    	ans += ((n - 1) / A);
    }
    cout << ans;
    
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
using namespace std;
 
#define int long long
 

int gcd(int a, int b){
	
	if(b==0){
		return a;
	}
	
	gcd(b,a%b);
	
}

int LCM(int a, int b){
	
	
return (a*b)/gcd(a, b);  
	
	
}

 
int f(int x){
	
	
	int res = 0;
	
	while( x%2 == 0){
		
		x/=2;
		res++;
	}
	
	return res;
	
}


 
int32_t main() {
 
 
 	int n,k;
 	
 	cin >> n >> k;
 	
 	int r,s,p;
 	
 	cin >> r >> s >>p;
  
  	string t;
  	
  	cin >> t;
  	
  	int point = 0;
  	int sz = t.length();
  	vector<int> v(sz);
  	
  	
  	for(int i=0; i<sz; i++){
  	 
  	 	if(i-k >=0 && v[i-k] && t[i] == t[i-k])
  	 	continue;
  	 
  	 
  	 	if(t[i] == 'r') point+= p;
  	 	if(t[i] == 's') point+= r;
  	 	if(t[i] == 'p') point+= s;
  	 	
  	 	v[i] = 1;
	}
 
 	cout << point << endl;
}








Measured memory_bytes: 3976