akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}
int lcm(const vi& a)
{
	int res=1;
	for(int x:a) res=lcm(res,x);
	return res;
}

int main()
{
	for(int n;cin>>n && n;){
		vvi q(n);
		rep(i,n){
			int d,t; cin>>d>>t;
			q[i].resize(d);
			rep(j,d) cin>>q[i][(t-j+d)%d];
		}
		
		vi ds={13,17,19,23};
		vvi qq[2];
		rep(i,n)
			qq[count(all(ds),q[i].size())].push_back(q[i]);
		
		vi sum[2]={vi(1),vi(1)};
		rep(i,2){
			rep(j,qq[i].size())
				sum[i].resize(lcm(sum[i].size(),qq[i][j].size()));
			rep(j,qq[i].size()) rep(k,sum[i].size())
				sum[i][k]+=qq[i][j][k%qq[i][j].size()];
		}
		
		int res=0;
		rep(i,2) res+=*max_element(all(sum[i]));
		cout<<res<<endl;
	}
}

Measured memory_bytes: 1884
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a==1||b==1||c==1||d==1){
        if(a==9||b==9||c==9||d==9){
            if(a==7||b==7||c==7||d==7){
                if(a==4||b==4||c==4||d==4){
                    cout << "YES" << endl;
					return 0;
                }
            }
        }
    }
	cout << "NO" << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,r; cin>>n>>r;
    if (n>=10){
        cout<<r<<endl;
    }else{
        cout<<r+100*(10-n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


signed main() {

    int n;

    cin >> n;
    vector<int> x(n), y(n);    
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }

    vector<int> a;
    for(int i = 0; i < n; i++)
        a.bash(i);

    double ans = 0.0;
    int cnt = 0;
    do {
        cnt++;
        for(int i = 0; i < n-1; i++) {
            
            ans += pow(pow(x[a[i]]-x[a[i+1]],2)+pow(y[a[i]]-y[a[i+1]],2),0.5);
        }
    }while(next_permutation(ALL(a)));

    cout << ans/cnt << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k,s;
    cin >> k >> s;

    ll ret = 0;
    rep(i,k+1) rep(j,k+1)
    {
        int tmpx = s-i-j;
        if (tmpx>=0 && tmpx <= k) ret++;
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, K, S;
  cin >> N >> K >> S;

  ll b = S == 1e9 ? 1 : 1e9;
  REP(i, 0, N) {
    cout << (i < K ? S : b) << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define int long
#define mod (1000000007)
using pi=pair<int,int>;
#define mp make_pair
main(){
  int n,r;
  cin>>n;
  vector<int> v(n);
  for(auto& i:v)cin>>i;
  if(n==2)cout<<(v[0]==v[1]),exit(0);
  map<int,int> ev,od;
  for(int i=0;i<n;++i)(i%2?od:ev)[v[i]]++;
  vector<pi> evp,odp;
  for(auto p:ev)evp.push_back(p);
  for(auto p:od)odp.push_back(p);
  evp.push_back(mp(-1,0));
  odp.push_back(mp(-1,0));
  auto f=[](pi a,pi b){return a.second>b.second;};
  sort(evp.begin(),evp.end(),f);
  sort(odp.begin(),odp.end(),f);
  if(evp[0].first!=odp[0].first)r=n-evp[0].second-odp[0].second;
  else r=n-max(evp[0].second+odp[1].second,evp[1].second+odp[0].second);
  cout<<r;
}

Measured memory_bytes: 9592
#include <stdio.h>
int main(void){
    int i,n,x,max=-1000000,min=1000000;
    long long sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++) {
        scanf("%d",&x);
        if(x<min) min=x;
        if(x>max) max=x;
        sum=sum+x;
    }
    printf("%d %d %lld\n",min,max,sum);
   
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector <string> s(n);
  rep(i,n)cin >> s[i];
  map <string,int> mp;
  rep(i,n)if(mp[s[i]]==0)mp[s[i]]+=1;
  cout << mp.size() << endl;
}


Measured memory_bytes: 25124
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define S second
using namespace std;
map<int, int> m;
signed main() {
	string s;
	cin >> s;
	f(i, s.size())cout << "x";
	cout << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
int main()
{
    int n,a,min=1000,max=0;
    cin>>n;
    rep(i,n){
        cin>>a;
        if(min>a) min=a;
        if(max<a) max=a;
    }
    cout<<max-min<<endl;
    return 0;
}

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

using namespace std;

int main()
{
	int n, m;
	int match[10] = { 0,2,5,5,4,5,6,3,7,6 };
	cin >> n >> m;
	//vector<int> num(m, 0); //使える文字列
	//vector<int> dp(n + 1, numeric_limits<int>::lowest());//使える桁についての
	vector<int> b_list;
	string ans = "";

	//入力
	vector<int> num(8, 0);
	for (int i = 0; i < m;i++)
	{
		int a;
		cin >> a;
		num[match[a]] = max(num[match[a]], a);
	}

	vector<string> dp(n + 1, "0");
	dp[0] = "";
	for (int i = 0; i < n;i++)
	{
		for (int j = 0;j < 8;j++)
		{
			if (i + j > n || num[j] == 0 || dp[i] == "0")
			{
				continue;
			}
			string s = dp[i];
			s.push_back(num[j] + '0');

			if (dp[i + j] == "" || dp[i + j] < s || (int)(dp[i + j]).size() < (int)(s).size())
			{
				dp[i + j] = s;
			}
		}
	}
	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 45056
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const ll M=998244353;
char c[100005];
int ans[100005],i,j,s[2];
int main(){
	scanf("%s",c+1);
	for(i=1;c[i];i++)
		if(c[i]=='R'&&c[i+1]=='L')
		{
			memset(s,0,sizeof(s));
			for(j=i;c[j]=='R';j--)
				s[(i-j)%2]++;
			for(j=i+1;c[j]=='L';j++)
				s[(j-i)%2]++;
			ans[i]=s[0];
			ans[i+1]=s[1];
		}
	for(i=1;c[i];i++)
		printf("%d ",ans[i]);
}


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

#define pb push_back
#define mp make_pair

#define f first
#define s second

typedef long long int ll;
typedef long double ld;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f;
const int MOD = 1000000007;

const int MAXN = int(1e5)+99;

ll arr[MAXN];

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	cout.tie(NULL);
	
	ll N, K;
	cin >> N >> K;
	
	set<int> v;
	
	for (int i = 0; i < N; i++)
	{
		ll A, B;
		cin >> A >> B;
		arr[A] += ll(B);
		v.insert(A);
	}
	
	ll pos = 0;
	for(int l : v){
		pos += arr[l];
		if(pos >= K){
			cout << l << endl;
			break;
		}
	}
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> H(N), A(M), B(M);
    for (int i = 0; i < N; i++) cin >> H[i];
    vector<bool> tmp(N);
    for (int i = 0; i < N; i++) tmp[i] = true;
    for (int i = 0; i < M; i++) cin >> A[i] >> B[i];
    for (int i = 0; i < M; i++){
        if(H[A[i]-1]>H[B[i]-1]){
          tmp[B[i] - 1] = false;
        } else if (H[B[i] - 1] > H[A[i] - 1]) {
          tmp[A[i] - 1]=false;
        }else if(H[B[i]-1]==H[A[i]-1]){
          tmp[A[i] - 1] = false;
          tmp[B[i] - 1] = false;
        }
    }
    ll cnt = 0;
    for (int i = 0; i < N; i++) {
      if (tmp[i] == true) cnt++;
    }
    cout << cnt<< endl;
    return 0;
}

Measured memory_bytes: 5528
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
#include <cmath>
#define _USE_MATH_DEFINES
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
int main(){
  ll R;
  cin>>R;
  printf("%.5lf\n", R*2*M_PI);
  return 0;
}

Measured memory_bytes: 3256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class TaskC {
		long gcd(long a, long b) {
			if (b == 0)
				return a;
			return gcd(b, a % b);
		}

		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			long[] T = new long[n];
			for (int i = 0; i < n; i++) {
				T[i] = in.nextLong();
			}
			long sum = 1;
			for (long l : T) {
				long gcd1 = gcd(sum, l);
				l /= gcd1;
				sum *= l;
			}
			out.println(sum);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextFloat() {
			return Double.parseDouble(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}

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

r, c, n = map(int, input().split())
L = []
def trans(x, y):
  z = None
  if x == 0:
    z = y
  if y == c:
    z = c + x
  if x == r:
    z = c + r + c - y
  if y == 0:
    z = 2*r + 2*c - x
  return z

for _ in range(n):
  x1, y1, x2, y2 = map(int, input().split())
  z1 = trans(x1, y1)
  z2 = trans(x2, y2)
  if z1 is not None and z2 is not None:
    if z1 > z2:
      z1, z2 = z2, z1
    L.append((z1, z2))
    L.append((z2, z1))
L.sort()
cnt = 0
D = dict()
for z1, z2 in L:
  if z1 < z2:
    cnt += 1
    D[z1] = cnt
  else:
    if D[z2] != cnt:
      print("NO")
      exit()
    cnt -= 1
print("YES")

Measured memory_bytes: 80600
N,K = map(int,input().split())
P_List=list(map(int,input().split()))
#print(N,K)
#print(P_List)

def Kitaichi(p):
    result = 0
    for i in range(p):
        result += (i+1)*1/p
    #print(p,result)
    return result

def Kitaichi2(p):
    return (p+1)*0.5

kitaichi_list=[]
ruisekiwa_list=[]
ruisekiwa=0
for a in range(N):
    kitaichi_list.append(Kitaichi2(P_List[a]))
    ruisekiwa += Kitaichi2(P_List[a])
    ruisekiwa_list.append(ruisekiwa)

#print(kitaichi_list)
#print(ruisekiwa_list)
pre_max=0
temp_max=0
max_num=0
for j in range(N-(K-1)):
    if j == 0:
        temp_max = ruisekiwa_list[j+K-1] - 0
    else:
        temp_max = ruisekiwa_list[j+K-1] - ruisekiwa_list[j-1]
    

    if pre_max < temp_max:
        pre_max = temp_max
    temp_max=0

print(pre_max)

Measured memory_bytes: 27592
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define FOR(i, N) for (long i = 0; i < (N); i++)

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

    bool humiyasui = true;
    for (int i = 0; i < S.size(); i++) {
        if ((i % 2 == 0) && (S[i] == 'L')) {
            humiyasui = false;
        }
        if ((i % 2 == 1) && (S[i] == 'R')) {
            humiyasui = false;
        }
    }

    if (humiyasui) {
        cout << "Yes"
             << "\n";
    } else {
        cout << "No"
             << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
//
//AtCoder Beginner Contest 168
//D - .. (Double Dots) 
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

using Graph = vector<vector<int>>;
vector<bool> seen;

int main()
{
    int n, m;

    cin >> n >> m;

    Graph G(n);
    REP(i, m){
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    // BFS のためのデータ構造
    vector<int> dist(n, -1);    // 全頂点を「未訪問」に初期化
    vector<int> guide(n, -1);   // 道標(前の頂点)
    vector<vector <int>> mem(n); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    guide[0] = 0;
    que.push(0);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue;

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            if (guide[nv] == -1) guide[nv]=v;

            que.push(nv);
        }
    }

    //for (int v = 0; v < n; ++v) cout << v << ": " << dist[v] << ":" << guide[v] << endl;

    string f = "Yes";
    FOR(i, 1, n-1){
        if (dist[i] == 0) f="No";
    }

    cout << f << endl;
    if (f=="Yes"){
        FOR(i, 1, n-1) cout << guide[i]+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 13036
#include <iostream>

using namespace std;

int main ()
{
	int n,x,c = 0;
	//[012345....abc...n ]   a & b & c & .... <= n

	while (1)
	{
		c=0;
		cin >> n >> x;
	for (int q = 1; q <= n; q++)
	{
		for (int e = q + 1; e <= n; e++)
		{
			for (int y = e + 1; y <= n; y++)
			{
				if (q + e + y == x)
				{
					c++;
				}
			}
		}
	}

	if (n == 0 && x == 0)
				{
					break;
				}

	cout << c << endl;

	}
	return 0;
}

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

int main()
{
  int N;
  cin>>N;
  
  int a[N],b[N],c[N];
  int i;
  for(i=0;i<N;i++)
  {
    cin>>a[i]>>b[i]>>c[i];
  }
  
  int dp[N][3]={0};
  
  dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];
  for(i=1;i<N;i++)
  {
    dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
  }
  
  
  
 /* for(i=K;i<N;i++)
  {
    for(j=0;j<K;i++)
    {
      dp[i][j]=
    }
    dp[i][0]=min(dp[i-1][0],dp[i-1][1])+abs(h[i]-h[i-1]);
    dp[i][1]=min(dp[i-2][0],dp[i-2][1])+abs(h[i]-h[i-2]);
  }*/
  cout<<max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2]))<<endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define tam 100010
#define inf 1000000000

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vii> graph;

bool comp(int a, int b) {
	return a > b;
}

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

	int n, k;
	cin >> n >> k;
	int arr[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
	}
	vi dp(n, inf);
	dp[0] = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 1; i + j < n && j <= k; ++j)
		{
			dp[i + j] = min(dp[i + j], dp[i] + abs(arr[i] - arr[i + j]));
		}
	}
	cout << dp[n - 1] << "\n";
	return 0;
}


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

long long a[100005][5] , n;

int main()

{
	
	
	cin>>n;
	
	for(int i=0;i<n;i++)
	{
		
		for(int j=0;j<3;j++)
		cin>>a[i][j];
		
	}
	
	if(n == 1)
	{
		cout<<max(a[0][0] , max(a[0][1] , a[0][2]));
		return 0;
	}
	
	else
	{
		for(int i=n-1;i>=0;i--)
		{
			for(int j=0;j<3;j++)
			{
				if(j==0)
				a[i][j] = a[i][j] + max(a[i+1][1] , a[i+1][2]);
				else if(j==1)
				a[i][j] = a[i][j] + max(a[i+1][2] , a[i+1][0]);
				else
				a[i][j] = a[i][j] + max(a[i+1][1] , a[i+1][0]);
			}
			
		}
		
		cout<<max(a[0][0] , max(a[0][1] , a[0][2]));
	}
	
	
	
}

Measured memory_bytes: 4096
#include<iostream>
using namespace std;
int main()
{
	int n, c = 0;
	cin>>n;
	for(int x = 1; x <= n; x++){
		int z;
		cin>>z;
		c+=((x % 2) && (z % 2));
	}
	cout<<c<<endl;
	return 0;
}








Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine().Split(' ');
			int n = int.Parse(input[0]);    // スイッチの数
			int m = int.Parse(input[1]);    // 電球の数

			var lights = new List<Light>(m);
			for (int i = 0; i < m; i++)
			{
				var arg = Console.ReadLine();
				lights.Add(new Light(n, arg));
			}
			var rems = Console.ReadLine().Split(' ');
			for (int i = 0; i < m; i++)
			{
				lights[i].SetRemainder(int.Parse(rems[i]));
			}

			int maxSwitchPattern = (int)Math.Pow(2, n) - 1;
			int countAllLightOn = 0;
			for (int i = 0; i <= maxSwitchPattern; i++)
			{
				bool isLightOn = true;
				// 各電球について確認
				for (int j = 0; j < m; j++)
				{
					if (!lights[j].IsLightOn(i))
					{
						isLightOn = false;
						break;
					}
				}
				if (isLightOn)
				{
					countAllLightOn++;
				}
			}

			Console.WriteLine(countAllLightOn);
		}

		public class Light
		{
			int mTotalSw = 0;
			int mRemainder = 0;
			int mSwitch = 0;

			public Light(int totalSw, string input)
			{
				mTotalSw = totalSw;
				var args = input.Split(' ');
				int switchCount = int.Parse(args[0]);
				var switchIndex = new List<int>(switchCount);
				for (int i = 0; i < switchCount; i++)
				{
					switchIndex.Add(int.Parse(args[i + 1]) - 1);
				}
				for (int i = 0; i < mTotalSw; i++)
				{
					mSwitch <<= 1;
					if (switchIndex.Contains(i))
					{
						mSwitch |= 1;
					}
				}
			}

			public void SetRemainder(int remainder)
			{
				mRemainder = remainder;
			}

			public bool IsLightOn(int switchState)  // switchState : N(<=10)ビットの整数. S1, S2, .... SN の状態を表すもの。ON ならビットを立てる
			{
				var state = switchState & mSwitch;   // 関連づいていてONになっているビットが立つ
				int onSwitchCount = 0;
				for (int i = 0; i < mTotalSw; i++)
				{
					if ((state & 1) == 1)
					{
						onSwitchCount++;
					}
					state >>= 1;
				}

				return (onSwitchCount % 2 == mRemainder);
			}
		}
	}
}



Measured memory_bytes: 13152
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */

int main() {
  vector<ll> a(3);
  REP(i, 3) cin >> a[i];

  sort(ALL(a));

  ll ans = 0;
  if(a[2]%2 == 0){
    ans = 0;
  }else{
    ans = a[0] * a[1];
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int K,N;
      cin>>K>>N;
      vector<int>A(N);
      for(int i=0;i<N;i++){
        cin>>A.at(i);}
      A.push_back(A.at(0)+K);
      int l=0;
      for(int i=0;i<N;i++){
        l=max(l,A.at(i+1)-A.at(i));}
        int ans=K-l;
      cout<<ans<<endl;
      return 0;
    }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(long long i = 0; i < (long long)(n); i++)
#define ALL(x) (x).begin(),(x).end()

void solve(long long N, std::vector<long long> A){
  vector<long long> tmp = A;
  auto firstit = max_element(ALL(A));

  auto it = max_element(ALL(tmp));
  tmp.erase(it);
  auto secondit = max_element(ALL(tmp));

  REP(i, N) {
    cout << ((i == distance(A.begin(), firstit)) ? *secondit : *firstit) << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long LL;
const int INF = int(1e9);

int a[26] = {0};
int N,M;

int main()
{
    cin>>N>>M;
    for(int i = 1;i<=N;i++)
    for(int j = 1;j<=M;j++){
        char temp;
        cin>>temp;
        a[temp-'a']++;
    }
    int t4 = (N/2)*(M/2);
    int flag = 0;
    for(int i = 0;i<26;i++){
        if(a[i]==0)continue;
        if(a[i]>=4){
            if(a[i]/4<t4){
                t4 -= a[i]/4;
                a[i] = a[i]%4;
            }
            else{
                t4 = 0;
                a[i] = a[i] - t4*4;
            }
        }
        if(a[i]>1)
            a[i]%=2;
        if(a[i]==1&&flag==0)
            flag = 1;
        else if(a[i]==1&&flag==1)
            flag = 2;
        
    }
    if(t4<=0&&flag<=1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long long a,b,x,ans;
	scanf("%lld%lld%lld",&a,&b,&x);
	if(a==0){
		ans=(b/x)+1;}
	else
	{
		ans=((b/x)-(a-1)/x);
	}
	cout<<ans;
	return 0;
}

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

int main(){
    int A, B, C;
    cin >> A >> B >> C;

    if(A == B && B== C){
        cout << "No" << endl;
    }
    else if(A == C){
        cout << "Yes" << endl;
    }
    else if(B == C){
        cout << "Yes" << endl;
    }
    else if(A == B){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

const int MX=40,INF=1001001001,mod=1e9+7;
int dp[MX];

int main(){
    while(1){
        int n;
        cin>>n;
        if(n==0)break;
        rep(i,MX)dp[i]=0;
        dp[0]=1;
        rep(i,n){
            dp[i+1]+=dp[i];
            dp[i+2]+=dp[i];
            dp[i+3]+=dp[i];
        }
        int day;
        if(dp[n]%10==0)day=dp[n]/10;
        else day=dp[n]/10+1;
        int year;
        if(day%365==0)year=day/365;
        else year=day/365+1;
        cout<<year<<endl;
    }
}


Measured memory_bytes: 3068
//=============================================
// Author   :   NAVPUN31
// Name     :   Naveen Punjabi
//=============================================


#include <bits/stdc++.h>
using namespace std;
#define int     long long
#define ld      long double
#define pii     pair<int ,int>
#define pld     pair<ld ,ld>
#define F       first
#define S       second
#define mod     1000000007
#define pb      push_back
#define mp      make_pair
#define all(x)  x.begin(),x.end()
#define mset(x) memset(x, 0, sizeof(x));
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int Lcm(int x, int y){
    return (x*y) / __gcd(x,y);
}

void run(){
    int n;
    cin >> n;

    int a[n], mul = 1;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        mul *= a[i];
    }

    int lcm = a[0]; // numerator
    for(int i = 1; i < n; i++){
        lcm = Lcm(lcm, a[i]);
    }

    int den = 0; // denominator
    for(int i = 0; i < n; i++){
        den += (lcm / a[i]);
    }
    ld res = (ld)lcm / (ld)den;
    cout << res << endl;
}


void setup(){
    ios;
    cout << setprecision(20);
}


signed main(){
    setup();
    int tests = 1;
    // cin >> tests;
    for(int i = 1; i <= tests; i++) run();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repin(a, n)  \
    vector<ll> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
    vector<string> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
    vector<double> a(n); \
    rep(i, n) { cin >> a[i]; }
#define in(a) \
    ll a;     \
    cin >> a;
#define ins(a) \
    string a;  \
    cin >> a;
#define ind(a) \
    double a;  \
    cin >> a;
template <class T>
inline void out(T a) {
    cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x)        (x).begin(), (x).end()
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
#define yes           out("Yes");
#define no            out("No");

int main() {
    ins(s);
    ins(t);

    ll ans = 0;
    rep(i, s.size()) {
        if (s[i] != t[i]) {
            ans++;
        }
    }
    out(ans);
}

Measured memory_bytes: 3920
import numpy as np


def main():
    n, k = map(int, input().split())
    p = [int(i) - 1 for i in input().split()]
    c = [int(i) for i in input().split()]

    seen = set()
    loop_list = []
    for start in range(n):
        v = start
        loop = []
        while v not in seen:
            seen.add(v)
            loop.append(c[v])
            v = p[v]
        seen.add(v)
        if loop:
            loop_list.append(np.array(loop))

    ans = min(c)
    for loop in loop_list:
        loop_len = len(loop)
        loop_num = k // loop_len
        loop_mod = k % loop_len
        loop_sum = sum(loop)
        table = np.zeros((loop_len, loop_len), dtype=int)
        table[0] = loop.cumsum()
        table[:, -1] = loop_sum
        for i in range(loop_len - 1):
            table[i + 1, :-1] = (table[i] - loop[i])[1:]
        ans = max(table[:, :min(loop_len, k)].max(), ans)
        if loop_num > 0:
            ans = max(loop_sum * (loop_num - 1) + table[:, :loop_len].max(), ans)
            if loop_mod > 0:
                ans = max(loop_sum * loop_num + table[:, :loop_mod].max(), ans)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 223492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main() {
  string L;
  cin >> L;

  ll n = L.size();

  vector<ll> dp1(n + 1); // A + B is less than L
  vector<ll> dp2(n + 1); // A + B can be L
  dp2[0] = 1;

  for (ll i = 0; i < n; i++) {
    if (L[i] == '0') {
      dp1[i + 1] = dp1[i] * 3;  // 00, 01, 10
      dp2[i + 1] = dp2[i] * 1;  // 00
    } else {
      dp1[i + 1] = dp1[i] * 3 + // 00, 01, 10
                   dp2[i] * 1;  // 00
      dp2[i + 1] = dp2[i] * 2;  // 01, 10
    }
    dp1[i + 1] %= mod;
    dp2[i + 1] %= mod;
  }

  cout << (dp1[n] + dp2[n]) % mod << endl;
}


Measured memory_bytes: 2048
#include <iostream>

using namespace std;

int main() {
    int i, j, k;
    int n, b, f, r, v;
    int a_college[4][3][10] = { 0 };

    cin >> n;

    for (i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;

        a_college[b - 1][f - 1][r - 1] += v;

    }

    i = 0;
    j = 0;
    k = 0;

    while(k < 4) {
        cout << " " << a_college[k][j][i];

        i++;

        if (i == 10) {
            cout << endl;
            i = 0;
            j++;
        }

        if (j == 3) {
            j = 0;
            if (k < 3) cout << "####################" << endl;
            k++;
        }
    }

    return 0;
}


Measured memory_bytes: 3100
from collections import deque
q=int(input())
a=deque([])
for i in range(q):
    query=input()
    if query[0]=="0":
        q,d,x=query.split()
        if d=="1":
            a.append(x)
        else:
            a.appendleft(x)
    else:
        q,s=query.split()
        if q=="1":
            print(a[int(s)])
        else:
            if s=="1":
                a.pop()
            else:
                a.popleft()


Measured memory_bytes: 34508
import sys
input = sys.stdin.readline
n = int(input())

ss = list(input())
s = []
for i in range(n):
    s.append(1<<(ord(ss[i])-97))

#####segfunc######
def segfunc(x,y):
    return x | y

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = 0

#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

init(s)


def popcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c

q = int(input())

for i in range(q):
    qq,xx,yy = map(str,input().split())
    if qq == '1':
        xx = int(xx)
        update(xx-1,1<<(ord(yy)-97))
    else:
        xx,yy = int(xx),int(yy)
        res = query(xx-1,yy)
        print(popcnt(res))


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define rof_(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

int N, a[102];

int main() {
	cin >> N;
	for_(i,0,N) cin >> a[i];
	a[N] = 1L << 30;
	
	vector< int > v;
	int cnt = 1, prv = a[0];
	
	for_(i,1,N+1) {
		if (prv != a[i]) {
			v.push_back(cnt);
			cnt = 1;
		}
		else {
			++cnt;
		}
		prv = a[i];
	}
	
	int ans = 0;
	for (int x : v) ans += (x / 2);
	cout << ans << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//


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

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int n;
    cin >> n;

    long long ans = 0;
    for (int div = 1 ; div <= n ; div++)
        for (int mul = div ; mul <= n ; mul += div)
            ans += mul;

    cout << ans;
}

Measured memory_bytes: 3644
n = gets.to_s.to_i
S = Array.new(n){ gets.to_s.to_i }

h = Hash.new(0)
h[0] = 0
sum_z = 0

S.each do |s|
  
  if 0 == s % 10
    
    sum_z += s
    
  else
    d = h.dup
    h.each{ |k,v| d[(s+v)%10] = [d[(s+v)%10], v + s].max }
    h = d.dup
    # p h
    # p d
    # puts ""
  end
end

# p h
# p h.values

t = h.values.drop(1).max

puts t.nil? ? 0 : sum_z + t

Measured memory_bytes: 1916
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int k = sc.nextInt();

        int[] abc = new int[3];
        int sum = 0;
        for(int a = 1; a<=k; a++){
            for(int b = 1; b<=k; b++){
                for(int c = 1; c<=k; c++){
                    abc[0] = a;
                    abc[1] = b;
                    abc[2] = c;

                    sum += getMoreBigDiv(abc, 3);

                }
            }
        }

        System.out.println(sum);
    }

    public static int getBigDiv(int a, int b) {// 求两个数的最大公约数
        if (b == 0)
            return a;
        return getBigDiv(b, a % b);
    }

    public static int getSmallMul(int a, int b) {// 求两个数的最小公倍数
        return (a * b) / getBigDiv(a, b);
    }

    public static int getMoreBigDiv(int num[], int n) { // 求多个数的最大公约数
        if (n == 1)
            return num[n - 1];
        return getBigDiv(num[n - 1], getMoreBigDiv(num, n - 1));
    }

    public static int getMoreSmallMul(int num[], int n) {// 求多个数的最小公倍数
        if (n == 1)
            return num[n - 1];
        return getSmallMul(num[n - 1], getMoreSmallMul(num, n - 1));
    }
}


Measured memory_bytes: 35780
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
const int MAX = 1000;
const int INF = 1e9;

int main(){
    int N,M;
    cin >> N >> M;
    int a[MAX], b[MAX], c[MAX], d[MAX][MAX];

    for(int i=0;i<M;i++){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
    }

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j) d[i][j] = 0;
            else     d[i][j] = INF;
        }
    }

    for(int i=0;i<M;i++){
        d[a[i]][b[i]] = min(d[a[i]][b[i]],c[i]);
        d[b[i]][a[i]] = min(d[b[i]][a[i]],c[i]);
    }

    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }

    int ans = M;
    for(int i=0;i<M;i++){
        bool used = false;
        for(int j=0;j<N;j++){
            if(d[j][a[i]] + c[i] == d[j][b[i]]) used = true;
        }
        if(used) ans--;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	string ans = "Yay!";

	int a, b;
	cin >> a >> b;
	if (a > 8 || b > 8) {
		ans = ":(";
	}

	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

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

int main(void){
    int N,max=0,cnt=0;
    cin>>N;
    int H[N];
    for(int i=0;i<N;i++){
        cin>>H[i];
        if(H[i]>=max){
            max=H[i];
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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


int main() {
    int n; cin >> n;
    vector<int> a(n),b(n),A(n),B(n),C(n);
    rep(i,n) cin >> a.at(i);
    rep(i,n) cin >> b.at(i);
    A.at(0)=a.at(0);
    rep(i,n-1) A.at(i+1)=A.at(i)+a.at(i+1);
    reverse(b.begin(),b.end());
    B.at(0)=b.at(0);
    rep(i,n-1) B.at(i+1)=B.at(i)+b.at(i+1);
    rep(i,n) C.at(i)=A.at(i)+B.at(n-i-1);
    sort(C.begin(),C.end());
    cout << C.at(n-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
using namespace std;
int main()
{
    long long a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    long long sum=0,t;
    sum+=a/(b+c)*b;
    t=a%(b+c);
    if(t!=0)
    {
        if(t>b)
            sum+=b;
        else
            sum+=t;
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 256
/*
ACplease
　　 ●
　　/⌒ヽ
　 ｜ 　|/⌒ヽ(ヽ
　 (｀　∥ー⌒) |
　|￣||￣￣￣￣￣|
　|―||―――――|
　|　Ｕ　　　　　|
　|￣￣￣￣￣￣￣|
　|＿＿＿＿＿＿＿|
　　|―――――|
　　|―――――|
ｗｗＷｗｗＷｗＷＷｗ
*/
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#include <cassert>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}

//----------------------------------------------
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);
    srand((unsigned)time(NULL));
    
    int n; cin >> n;
    map<string,int> a;
    rep(i,n){
        string s; cin >> s;
        a[s]++;
    }
    int ma = 0;
    for(auto p : a) ma = max(ma,p.second);
    for(auto p : a){
        if(p.second != ma) continue;
        OUT(p.first);
    }

    return 0;
}

Measured memory_bytes: 23808
N,K = map(int,input().split())
S = input()
if S[K-1] == "A":
    print(S[:K-1]+"a"+S[K:])
if S[K-1] == "B":
    print(S[:K-1]+"b"+S[K:])
if S[K-1] == "C":
    print(S[:K-1]+"c"+S[K:])


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

string N;
unsigned int dp[2][2];

template<typename T> void minUpdate(T& a, T b) { a = min(a, b); }

int main() {
	cin >> N;
	
	int n = N.size();
	reverse(N.begin(), N.end());
	N += '0';
	
	fill(dp[0], dp[0]+2, 0);
	fill(dp[1], dp[1]+2, -1);
	for (int i=0; i<=n; ++i) {
		for (int f=0; f<2; ++f) {
			if (i == 0 and f == 1) continue;
			int x = int(N[i] - '0') + f;
			if (x == 10) {
				minUpdate(dp[1][1], dp[0][f]);
			}
			else {
				minUpdate(dp[1][1], dp[0][f] + 10 - x);
				minUpdate(dp[1][0], dp[0][f] + x);
			}
		}
		swap(dp[0], dp[1]);
		fill(dp[1], dp[1]+2, -1);
	}
	
	cout << min(dp[0][0], dp[0][1]) << endl;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int X,A,B;
  cin>>X>>A>>B;
  if((A-B)>=0){
    cout<<"delicious"<<endl;
    return 0;
  }
  if(abs(A-B)<=X){
    cout<<"safe"<<endl;
    return 0;
  }
  cout<<"dangerous"<<endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1000000009

template<class T>
void dijkstra(const vector<vector<pair<int,T>>> &vec, vector<T> &d, int from=0){
  using P = pair<T,int>;
  fill(all(d), INF);
  priority_queue<P, vector<P>, greater<P>> pq;
  d[from] = 0;
  pq.push(mp(0,from));
  while(!pq.empty()){
    auto p = pq.top(); pq.pop();
    int v = p.second;
    T dd = p.first;
    if(d[v] < dd) continue;
    for(auto to : vec[v]){
      T nd = dd + to.second;
      int ni = to.first;
      if(d[ni] > nd){
        d[ni] = nd;
        pq.push(mp(nd, ni));
      }
    }
  }
}

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

  vector<vector<pair<int,int>>> v(k);
  rep(i,k){
    v[i].pb(mp((i*10)%k, 0));
    v[i].pb(mp((i+1)%k, 1));
  }

  vector<int> d(k);
  dijkstra(v, d, 1);

  cout << d[0]+1 << endl;

  return 0;
}

// 46 2
// 47 2
// 55944 27


Measured memory_bytes: 6780
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MON 1000000007
#define INF (1<<29)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

class Edge{
public:
  int from, to, rev;
  Int cost, lim;
  Edge(int from, int to, Int cost, int lim = -1, Int rev = -1):
    from(from),to(to),cost(cost),lim(lim),rev(rev){}
};


class Graph{
public:
  int n;
  int m;
  vector<vector<Edge>> edge;
  Graph(int n = 0):n(n),m(0){
    edge = vector<vector<Edge>>(n);
  }
  void add_edge(int from, int to, int cost = 1, int lim = -1)
  {
    if(lim == -1){
      edge[from].push_back(Edge(from, to, cost));
      return;
    }
    edge[from].push_back(Edge(from, to, cost, lim, edge[to].size()));
    edge[to].push_back(Edge(to, from, -cost, 0, edge[from].size() - 1));
  }
};

Graph g;
vector<int> topo;
vector<int> come(10800, 0);
void dfs(int x){
  if(come[x])return;
  come[x] = true;
  for(auto e: g.edge[x]){
    dfs(e.to);
  }
  topo.push_back(x);
}
int n, m, u, v;
int main(){
  cin >> n >> m;
  g = Graph(n);
  for(int i = 0;i < m;i++){
    cin >> u >> v;
    g.add_edge(v, u, 1);
  }
  for(int i = 0;i < n;i++){
    dfs(i);
  }
  for(int i = 0;i < n;i++)cout << topo[i] << endl;
  return 0;
}


Measured memory_bytes: 5832