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

using namespace std;

int main(){
  int a, b, cnt=0;
  cin >> a >>b;
  for(int i=a;i<=b;i++){
    int tmp=i;
    bool ans=true;
    if(tmp/10000!=tmp%10){
      ans=false;
      continue;
    }
    tmp%=10000;
    tmp/=10;
    if(tmp/100!=tmp%10){
      ans=false;
      continue;
    }
    if(ans){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];
    vector<int> dp(n + 2, INF); //1-indexed
    dp[0] = 0;

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

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

Measured memory_bytes: 1024
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] h = new int[n+1];
        int[] h_res = new int[n+1];
        List<List<Integer>> route = new ArrayList<>();
        route.add(new ArrayList<Integer>());
        for(int i=1;i<=n;i++){
            h[i] = sc.nextInt();
            route.add(new ArrayList<Integer>());
        }
        for(int i=0;i<m;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            List<Integer> tmp = route.get(a);
            tmp.add(b);
            route.add(tmp);
            List<Integer> tmp2 = route.get(b);
            tmp2.add(a);
            route.add(tmp);
        }

        int count = 0;

        for(int i=1;i<=n;i++){
            boolean flag = true;
            int height = h[i];
            for(Integer nei : route.get(i)){
                if(height<=h[nei]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                count++;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 64920
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define np(v) next_permutation(v.begin(), v.end())
#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define ull unsigned long long
#define pii pair < int, int >
#define sz(a) (int)a.size()
#define sqr(x) ((x) * (x))
#define y1 stupid_cmath
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll long long
#define f first
#define s second

const int inf = (int)3e6;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

ll x, y;


int main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> x >> y;
    ll cur = x;
    int ans = 0;
    while(cur <= y){
        cur *= 2;
        ans++;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <queue>
#include <algorithm>
using namespace std;
const double eps=1e-6;
int main() {
    long long N,mid,tmp;
    scanf("%lld", &N);
    mid=int(sqrt(N)+eps);
    for(int i=mid;i>=1;i--){
        if(N%i==0){
            tmp=i;
            break;
        }
    }
    printf("%lld",tmp+N/tmp-2);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader buff = null;
		buff = new BufferedReader(new InputStreamReader(System.in));

		String[] box = buff.readLine().split(" ");
		int A = Integer.parseInt(box[0]);
		int B = Integer.parseInt(box[1]);
		int K = Integer.parseInt(box[2]);

		for(int i = 0; i < K; ++i){
			if(A + i > B - i){

			} else {
				System.out.println(A + i);
			}
		}
		for(int i = K - 1; i >= 0; --i){
			if(A + i >= B - i){

			} else {
				System.out.println(B - i);
			}
		}
	}

}


Measured memory_bytes: 23124
// https://atcoder.jp/contests/abc124/tasks/abc124_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

// Run length encoding
vector<pair<char, int>> encode(string code) {
    vector<pair<char, int>> ret;
    const int len = code.length();
    for (int i = 0; i < len; i++) {
        int count = 1;
        while (code[i] == code[i + 1] && i < len - 1) {
            count++;
            i++;
        }
        ret.emplace_back(code[i], count);
    }
    return ret;
}

template <class T> struct BinaryIndexedTree {
    vector<T> data;

    BinaryIndexedTree(int sz) { data.assign(++sz, 0); }

    // 区間 [0, k] の合計を求める(閉区間なので注意)
    T sum(int k) {
        T ret = 0;
        for (++k; k > 0; k -= k & -k)
            ret += data[k];
        return (ret);
    }

    // 要素kに値xを加える
    void add(int k, T x) {
        for (++k; k < (int)data.size(); k += k & -k)
            data[k] += x;
    }
};

void solve() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    auto v = encode(S);
    BinaryIndexedTree<int> bt(v.size());
    REP(i, v.size()) { bt.add(i, v[i].second); }
    int ans = 0;
    REP(i, v.size()) {
        int t1 = bt.sum(i);
        int idx = i - K * 2;
        if (v[i].first == '1') {
            idx--;
        }
        // 0-indexedなので0番目から値がある
        int t2 = (idx >= 0 ? bt.sum(idx) : 0);
        ans = max(ans, t1 - t2);
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 5728
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	unsigned long long int h, w;
	cin >> h >> w;
	if(h == 1 || w == 1)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << (h * w+ 1) / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int w[10],k[10];
	for(int i=0;i<10;i++)cin>>w[i];
	for(int i=0;i<10;i++)cin>>k[i];
	sort(w,w+10);sort(k,k+10);
	cout<<(w[7]+w[8]+w[9])<<' '<<(k[7]+k[8]+k[9])<<endl;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef double db;

#define rep_it(it,x) for (__typeof((x).begin()) it=(x).begin(); it!=(x).end(); it++)
#define ____ puts("\n_______________\n\n") 
#define debug(x) ____; cout<< #x << " => " << (x) << endl
#define debug_pair(x) cout<<"\n{ "<<(x).fi<<" , "<<(x).se<<" }\n"
#define debug_arr(x,n) ____; cout<<#x<<":\n"; rep(i,0,n+1) cout<<#x<<"["<<(i)<<"] => "<<x[i]<<endl
#define debug_arr2(x,n,m) ____; cout<<#x<<":\n"; rep(i,0,n+1) rep(j,0,m+1) cout<<#x<<"["<<(i)<<"]["<<(j)<<"]= "<<x[i][j]<<((j==m)?"\n\n":"    ")
#define debug_set(x) ____; cout<<#x<<": \n"; rep_it(it,x) cout<<(*it)<<" "; cout<<endl
#define debug_map(x) ____; cout<<#x<<": \n"; rep_it(it,x) debug_pair(*it)

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

const int N=1e5+5;
int n,p[N],tot=0; ll a[N]; bool check[N];

void init(int N) {
    rep(i,2,N+1)
        if (!check[i]) {
            p[++tot]=i;
            for (int j=i+i; j<=N; j+=i) check[j]=1;
        }
//    debug_arr(p,tot);
}

unordered_map<ll,ll> U,num,D; ll ans=0;

bool bat(ll x) {
    ll y=1,yy=1; ll &xx=U[x];
    for (int i=1; i<=tot && (ll)p[i]<=x; ++i)
        if (x%p[i]==0) {
            int t=0;
            while (x%p[i]==0) x=x/p[i],t++;
            t%=3;
            rep(j,0,t) y*=p[i];
            t=3-t,t%=3;
            rep(j,0,t) yy*=p[i];
        }
    if (x>1) {
		y*=x;
		ll tt=sqrt(x);
		if (tt*tt==x) yy*=tt; else yy*=x*x;
//        ans+=2;
//        xx=-1;
//        return 1;
    }
    xx=y;
    D[y]=yy,D[yy]=y;
    return 0;
}

int main() {
//    file_put();
    
    init(3000);
    scanf("%d",&n);
    rep(i,1,n+1) {
        scanf("%lld",&a[i]);
        if (!U.count(a[i])) bat(a[i]);
        if (U[a[i]]>0) num[U[a[i]]]++;
    }
    for (auto x:num)
        if (x.fi==1) ans+=2; else
        if (num.count(D[x.fi])) ans+=max(x.se,num[D[x.fi]]); else 
            ans+=2*x.se;
    printf("%lld\n",ans>>1);
//    debug_map(num);
//    debug_map(U);
    
	return 0;
}




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

//input
int a;
int b;
//output(count)
int d;


int main()
{
    // 整数の入力
  cin >> a >> b;
    //judge
  if (a<=b){
  d=a;}
  else {
  d=a-1;}

    // 出力
    cout <<d<< endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int a, b;
		cin >> a >> b;
		cout << a*b << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>
using namespace std;
int h[5],s[5];
int v[13][4];
int m[128];
int k[10];
int H()
{
	for(int i=1;i<5;++i)if(s[i]-s[i-1])return 0;
	return 1;
}
int X(){return h[1]+1==h[2]&&h[2]+1==h[3]&&h[3]+1==h[4];}
int S(){return X()&&h[0]+1==h[1];}
int R(){return X()&&h[0]==1&&h[4]==13;}
int F()
{
	if(H())
	{
		if(R())return 9;
		if(S())return 8;
		return 5;
	}
	else
	{
		if(h[0]==h[3]||h[1]==h[4])return 7;
		if(h[0]==h[1]&&h[2]==h[4] || h[0]==h[2]&&h[3]==h[4])return 6;
		if(S()||R())return 4;
		if(h[0]==h[2]||h[1]==h[3] || h[2]==h[4])return 3;
		if(h[0]==h[1])
			if(h[2]==h[3]||h[3]==h[4])return 2;
		if(h[1]==h[2]&&h[3]==h[4])return 2;
		if(h[0]==h[1]||h[1]==h[2]||h[2]==h[3]||h[3]==h[4])return 1;
		return 0;
	}
}
int main()
{
	int N,i,j,r,x=0;
	char c,d;
	m['A']=1;
	for(i=0;i<10;++i)m[i+'0']=i;
	for(i=0;i<4;++i)m["TJQK"[i]]=i+10,m["SCHD"[i]]=i;
	while(scanf("%d",&N)>=0)
	{
		if(x++)puts("");
		for(i=0;i<4;++i)for(j=0;j<13;++j)scanf("%d",&v[j][i]);
		for(i=1;i<10;++i)scanf("%d",&k[i]);
		while(N--)
		{
			for(r=i=0;i<5;++i)
			{
				scanf(" %c %c",&c,&d);
				h[i]=m[c];
				s[i]=m[d];
				r+=v[h[i]-1][s[i]];
			}
			sort(h,h+5);
			printf("%d\n",r*k[F()]);
		}
	}
	return 0;
}

Measured memory_bytes: 780
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int nums[200010];
int sorted_nums[200010];

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> nums[i];
        sorted_nums[i] = nums[i];
    }
    sort(sorted_nums, sorted_nums + N);

    int mid1 = sorted_nums[(N - 1) / 2];
    int mid2 = sorted_nums[N / 2];

    for(int i = 0; i < N; ++i) {
        if(nums[i] <= mid1) cout << mid2 << endl;
        else cout << mid1 << endl;
    }

    return 0;
}


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


int K, N;
int A[100000];

int main(){
  cin >> N >> K;
  int pos_1;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] == 1){
      pos_1 = i;
    }
  }
  cout << (N-1 + (K-2)) / (K-1) << endl;
  return 0;
}
	

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s = "afjawe";
	cin >> s;

	long long ans = 0;
	int cnt = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s.substr(i, 1) == "A") {
			cnt++;
		} else if (s.substr(i, 2) == "BC") {
			i++;
			ans += cnt;
		} else {
			cnt = 0;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second


signed main(){
	int h,w,x,y;
	cin>>h>>w>>x>>y;

	int a=h-y,b=y-1;
	int c=w-x,d=x-1;

	if(a%2&&b%2&&c%2==0&&d%2==0 || c%2&&d%2&&a%2==0&&b%2==0)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}


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

int main()
{
    int n, s = 0; cin >> n;
    int i = n;
    while (i != 0)
    {
        s += i%10;
        i /= 10;
    }
    
    cout << (n % s == 0 ? "Yes": "No") << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;

class Main{
	public static void main(String[] args)throws IOException{
		Scanner scan=new Scanner(System.in);
		int n;
		while((n=scan.nextInt())!=0){
			int[][] vec=new int[n+1][n+1];
			
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					int temp;
					temp=vec[i][j]=scan.nextInt();
					vec[n][j]+=temp;
					vec[i][n]+=temp;
				}
			}
			for(int i=0;i<n;i++){
				vec[n][n]+=vec[i][n];
			}
			for(int i=0;i<vec.length;i++){
				for(int j=0;j<vec[i].length;j++){
					System.out.printf("%5d",vec[i][j]);
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

int main()
{
    ll N ,M;
    cin >> N >> M ;


    vector<ll> P;
    rep(i, sqrt(M)+1){
        if(i == 0) continue;
        if(M%i == 0){
            P.pb(i);
            P.pb(M/i);
        }
    }
    sort(all(P));

    rep(i, P.size()){
        if(P[i] >= N){
            cout << M/P[i] << endl;
            return 0;
        }
    }





    return 0;
}

/*
/^[\w!\x22\#$%&@\'() * +,-.\/;:]+$/
*/


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

int main()
{
  int N;
  int res=0;
  cin >> N;

  if(N%2==0) res = N;
  else res = N*2;

  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
ll n,a,b;

bool check(ll x,vll h){
  bool ok=true;
  rep(i,0,n)h[i]-=b*x;
  rep(i,0,n){
   if(h[i]>0){
     x-=(h[i]+a-1)/a;
   }
    if(x<0)ok=false;
  }
 return ok; 
}




int main(){cout<<fixed<<setprecision(20);
		   
           cin>>n>>a>>b;
           a-=b;
           vll h(n);
           rep(i,0,n)cin>>h[i];
           //二分探索で行けそう
           //O(nlogh)
           ll ng=0;ll ok=1e9;
           while(ok-ng>1){
            ll mid=(ok+ng)/2;
             if(check(mid,h)){
               ok=mid;
             }
             else{
               ng=mid;
             }
           }
           cout<<ok<<endl;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long 
const int N=2e3+5;
int n;
vector<int>v;
int32_t main(){
	IOS;
	
	//code
	cin>>n;
	v.resize(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	int flag=0;
	for(int i=0;i<n;i++){
		if(v[i]%2==0){
			if(v[i]%3==0 || v[i]%5==0)
				continue;
			else {
				flag=1;
				break;
			}
		}
	}
	if(flag){
		cout<<"DENIED"<<endl;
	}
	else
		cout<<"APPROVED"<<endl;
	//code
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	ll ans = 0;
	int a;
	rep(i,N)
	{
		cin >> a;
		ans += a-1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int N;
int d[50];

signed main()
{
	cin >> N;
	REP(i, N) cin >> d[i];

	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			sum += d[i] * d[j];
		}
	}
	cout << sum << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n = int(input())
    l = []
    for i in range(n):
        s, p = input().split()
        l.append((s, int(p), i + 1))
    l.sort(key=lambda x: (x[0], -x[1]))
    print('\n'.join(str(e[2]) for e in l))

if __name__=="__main__":
    solve()


Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    vector<long long> a(5,0);
    for(int i=0;i<n;i++){
        cin >> s;
        if(s[0]=='M')a[0]++;
        else if(s[0]=='A')a[1]++;
        else if(s[0]=='R')a[2]++;
        else if(s[0]=='C')a[3]++;
        else if(s[0]=='H')a[4]++;
    }
    long long ans=0;
    ans+=a[0]*(a[1]*(a[2]+a[3]+a[4])+a[2]*(a[3]+a[4])+a[3]*a[4]);
    ans+=a[1]*(a[2]*(a[3]+a[4])+a[3]*a[4]);
    ans+=a[2]*a[3]*a[4];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int, input().split())))

while len(A) >= 2: #残りの数が1になったら終わり
  if A[0] == 1: break
  #余りが出る場合は、左側の数字と余りを入れ替える
  rem = A[1] % A[0] #余り
  if rem != 0: A[0], A[1] = rem, A[0]
  #余りが0の場合、そいつは下位互換なので要らない？
  else: del A[1]

print(A[0])

Measured memory_bytes: 14252
N = int(input())
A = [int(input()) for i in range(N)]

max_A = max(A)
max_A_count = A.count(max_A)

set_A = set(A)
len_set_A = len(set_A)

if(len_set_A > 1):
    set_A.remove(max_A)

max_set_A = max(set_A)

for i in range(N):
    if(A[i] < max_A):
        print(max_A)
    elif A[i] == max_A and max_A_count > 1:
        print(max_A)
    else:
        print(max_set_A)



Measured memory_bytes: 17188
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



class ConvexHullTrick {
	using Line = std::pair<int64_t, int64_t>;
	std::vector<Line> lines;
	bool f(const Line &a, const Line &b, const Line &c) const {
		return (int64_t)(a.first - b.first) * (b.second - c.second) < (int64_t)(c.first - b.first)*(b.second - a.second);
	}
	static int64_t eval(const Line &line, int64_t x) {
		return line.first * x + line.second;
	}
public:
	void add(int64_t a, int64_t b) { // strictly increase, strictly decrease
		Line line(a, b);
		while (2 <= lines.size() && !f(lines[lines.size() - 2], lines[lines.size() - 1], line)) {
			lines.pop_back();
		}
		lines.push_back(line);
	}
	int64_t min(int64_t x) const {
		int lb = 0, ub = lines.size();
		while (ub - lb > 1) {
			int mid = (lb + ub) / 2;
			if (eval(lines[mid - 1], x) > eval(lines[mid], x)) {
				lb = mid;
			}
			else {
				ub = mid;
			}
		}
		return eval(lines[lb], x);
	}
};

int n;
int64_t c;
int64_t h[200000];


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

	cin >> n >> c;
	rep(i, n)cin >> h[i];

	int64_t v;
	ConvexHullTrick cht;
	cht.add(-2 * h[0], h[0] * h[0]);
	for (int i = 1; i < n - 1; i++) {
		v = cht.min(h[i]) + 2 * h[i] * h[i] + c;
		cht.add(-2 * h[i], v);
	}
	cout << cht.min(h[n - 1]) + h[n - 1] * h[n - 1] + c << endl;


	return 0;
}


Measured memory_bytes: 7920
#include<stdio.h>

int main(void)
{
  int a,b,n,i,h=0,ans;

  scanf("%d %d",&a,&b);
  n = b - a;
  for(i=1;i<=n;i++)
    {
      h += i;
    }
  ans = h - b;
  printf("%d\n",ans);
  return 0;
}
  


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

int main(){
  long long x,w,sum;
  cin>>x;
  w=x/500;
  x=x-500*w;
  sum+=1000*w;
  w=x/5;
  x=x-5*w;
  sum+=5*w;
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 a,b,c;
cin>>a>>b>>c;
if(c>=a &&c<=b)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
//system("pause");
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 FOR(i,n,j) for(ll i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define NG cout <<"UNRESTORABLE" << endl;
#define INF 10101010
int main()
{
    int N,K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i,N)cin >> a[i];

    vector<int> num(N+1);
    rep(i,N+1)num[i]=0;
    rep(i,N)num[a[i]]++;
    vector<int> rank(N+1);
    rep(i,N+1)rank[i]=INF;
    int j=0;
    rep(i,N+1){
        if(num[i]!=0){
            rank[j++]=num[i];
        }
    }
    ssort(rank);
    int l=0;
    int count=0;
    while(rank[l]!=INF){
        count++;l++;
    }
    int ans=0;
    
    rep(i,count-K){
        ans+=rank[i];
    }
    cout << ans << endl;
    

}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>

using namespace std;

const int MAX_N = 100000;
int prime[MAX_N];
bool is_prime[MAX_N + 10000];

void sieve() {
	int p = 0;
	for (int i = 0; i < MAX_N + 10000; i++) {
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i < MAX_N + 10000; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = i * 2; j < MAX_N + 10000; j += i) {
				is_prime[j] = false;
			}
		}
	}
	return;
}

int matsuzaki_num(int n, int p) {
	int ans = 0;
	int i = 0;
	int j = 0;
	int k = 0;
	int prime2[100];
	int prime_sum[5050];
	while(j < 100) {
		if (prime[i] > n) {
			prime2[j] = prime[i];
			j++;
		}
		i++;
	}
	
	for (i = 0; i < 100; i++) {
		for (j = i; j < 100; j++) {
			prime_sum[k++] = prime2[i] + prime2[j];
			//cout << prime_sum[k - 1] << endl;
		}
	}
	sort(prime_sum, prime_sum + 5050);
	ans = prime_sum[--p];
	
	return ans;
}

int main() {
	int n, p;
	sieve();
	while (true) {
		cin >> n >> p;
		if (n == -1) {
			break;
		}
		cout << matsuzaki_num(n, p) << endl;
	}
	
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector <int> e,d;
    for(int i = 0; i < n; i++) {

        int x;
        cin >> x;
        if(x % 2 == 0) {
            e.push_back(x);
        }
    }
      for(int i = 0; i < e.size(); i++) {
        if(e[i] % 3 == 0 || e[i]% 5 == 0) {
            d.push_back(e[i]);
        }

    }
    if(e.size()== d.size()) {
        cout << "APPROVED" << endl;
    }
    else {
        cout << "DENIED" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    char c[6];
    for (int i = 0; i < 6; i++) {
        cin >> c[i];
    }

    int b = 1;
    for (int i = 0; i < 3; i++) {
        if (c[i] != c[6 - 1 - i]) b = 0;
    }

    cout << (b ? "YES" : "NO") << endl;

    return 0;
}

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

int main() {
  int N, A, B;
  cin >> N >> A;
  B = N - N / 500 * 500;
  if (N <= A) {
    cout << "Yes" << endl;
  }
  else if (B <= A ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
fn main(){
  loop {
    let xyz: Vec<usize> = read_vec();
    let x = xyz[0];
    let y = xyz[1];
    let z = xyz[2];

    if x == 0 && y == 0 && z == 0 { break; }
    
    let v: Vec<usize> = read_vec();

    let mut bd: Vec<(usize, usize)> = vec![(0, 0);y+1];
    
    for _ in 0 .. z {
      let nea: Vec<usize> = read_vec();
      let n = nea[0];
      let e = nea[1];
      let a = nea[2];
      bd[n] = (e, a);
    }

    let mut dp: Vec<Vec<f64>> = vec![vec![0.0 ; 5000] ; y + 1];
    dp[0][0] = 1.0;

    for i in 0 .. y {
      for j in 0 .. 5000 {
        for k in 0 .. x {
          let ni = if i + v[k] < y { i + v[k] } else { y };
          match bd[ni] {
            (1, a) => {
              let nni = if ni + a < y { ni + a } else { y };
              dp[nni][j] += dp[i][j] / (x as f64);
            },
            (2, a) => {
              if j + a < 5000 {
                dp[ni][j + a] += dp[i][j] / (x as f64);
              }
            },
            (3, a) => {
              dp[ni][if j > a { j - a } else { 0 }] += dp[i][j] / (x as f64);
            },
            (_, _) => {
              dp[ni][j] += dp[i][j] / (x as f64);
            },
          }
        }
      }
    }

    let ans: f64 = dp[y].iter().enumerate().map(|(i, &j)| (i as f64) * j).sum();
    println!("{}", ans as usize);
  }
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 7060
# coding: utf-8
N = int(input())
C = list(input())

R_cnt = 0

for i in range(N):
    if C[i] == "R":
        R_cnt += 1

ans = 0

for i in range(R_cnt):
    if C[i] == "W":
        ans += 1

print(ans)



Measured memory_bytes: 10764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

ll dp[51][51][2501];
int main(){
  //dp[i][j][k]
  //i番目までj個使って合計k

  int N, A; cin >> N >> A;
  vector<int> x(N); rep(i,N) cin >> x[i];
  rep(i,51) dp[i][0][0]=1;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=i;j++){
      for(int k=1;k<=2500;k++){
        dp[i][j][k] += dp[i-1][j][k];
        if(k-x[i-1]>=0) dp[i][j][k] += dp[i-1][j-1][k-x[i-1]];
      }
    }
  }
  ll ans = 0;
  for(int j=1;j<=N;j++){
    ans += dp[N][j][A*j];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 49024
#include <cstdio>
char s[100005];
inline int getstring(char *_s){
	int l=0;
	for(char ch=getchar();ch!='\n';ch=getchar(),l++)
		_s[l]=ch;
	return l;
}
int main(){
	int l=getstring(s);
	printf("%s",(s[0]==s[l-1])^(l%2)?"First":"Second");
	return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, p, d1, d2;
  while (cin >> n, n) {
    int md = -1, mp;
    while (n--) {
      cin >> p >> d1 >> d2;
      if (d1 + d2 > md) {
        md = d1 + d2;
        mp = p;
      }
    }
    cout << mp << " " << md << "\n";
  }
}



Measured memory_bytes: 3208
#include<iostream>

using namespace std;

int main(){

  int n;

  for( ; ; ){

  cin>> n;

  int A,B;

  A=0;
  B=0;

  if(n==0)break;

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

     cin>>a>>b;

     if(a>b){
       A=A+a+b;
     }
     if(a<b){
       B=B+a+b;
     }
     if(a==b){
       A=A+a;
       B=B+b;
     }
   }
   cout<<A<<" "<<B<<endl;
  }

  return 0;
}

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

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

const int INF = 1 << 28;

int main() {
    int N, M;
    std::cin >> N >> M;

    auto dist = Vec<int>(N, N, INF);
    for (int i = 0; i < M; ++i) {
        int u, v, d;
        std::cin >> u >> v >> d;
        dist[u][v] = d;
    }

    auto dp = Vec<int>(1 << (N - 1), N - 1, INF);
    // dp[b][i] = 集合bを探索済みで、今iにいるときの最小コスト
    // ただし頂点N-1を最初と最後に訪れるものとする

    for (int v = 0; v < N - 1; ++v) dp[1 << v][v] = dist[N - 1][v];

    for (int b = 0; b < (1 << (N - 1)); ++b) {
        for (int from = 0; from < N - 1; ++from) {
            if (((b >> from) & 1) == 0) continue;
            for (int to = 0; to < N - 1; ++to) {
                if (from == to || ((b >> to) & 1) == 0) continue;
                dp[b][to] = std::min(dp[b][to], dp[b ^ (1 << to)][from] + dist[from][to]);
            }
        }
    }

    int ans = INF;
    for (int v = 0; v < N - 1; ++v) {
        ans = std::min(ans, dp[(1 << (N - 1)) - 1][v] + dist[v][N - 1]);
    }

    std::cout << (ans == INF ? -1 : ans) << std::endl;
    return 0;
}



Measured memory_bytes: 4120
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<int>>A(H, vector<int>(W));
	rep(i, H) {
		rep(j, W) {
			cin >> A[i][j];
		}
	}
	rep(i, H) {
		rep(j, W) {
			A[i][j] = A[i][j] % 2;
		}
	}
	vector<vector<int>>B(H, vector<int>(W));
	rep(i, H) {
		rep(j, W) {
			B[i][j] = A[i][j];
		}
	}
	int cnt = 0;
	rep(i, H) {
		rep(j, W - 1) {
			if (B[i][j] == 1) {
				cnt++;
				//cout << i + 1 << ' ' << j + 1 << ' ' << i + 1 << ' ' << j + 2 << endl;
				B[i][j] = 0;
				B[i][j + 1]++;
				B[i][j + 1] %= 2;
			}
		}
	}
	rep(i, H - 1) {
		if (B[i][W - 1] == 1) {
			cnt++;
			//cout << i + 1 << ' ' << W << ' ' << i + 2 << ' ' << W << endl;
			B[i][W - 1] = 0;
			B[i + 1][W - 1]++;
			B[i + 1][W - 1] %= 2;
		}
	}
	cout << cnt << endl;
	rep(i, H) {
		rep(j, W-1) {
			if (A[i][j] == 1) {
				cout << i+1 << ' ' << j+1 << ' ' << i+1 <<' '<< j + 2 << endl;
				A[i][j] = 0;
				A[i][j + 1]++;
				A[i][j + 1] %= 2;
			}
		}
	}
	rep(i, H-1) {
		if (A[i][W - 1] == 1) {
			cout << i+1<<' ' << W<<' ' << i + 2<<' '<<  W << endl;
			A[i][W - 1] = 0;
			A[i + 1][W - 1]++;
			A[i + 1][W - 1] %= 2;
		}
	}
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#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 FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

int main(void)
{
    ll A;
    cin >> A;

    long double B;
    cin >> B;

    cout << (ll)(round(100*B)*A/100) << endl;

    return 0;
}


Measured memory_bytes: 3728
N, K, Q = map(int,input().split())
A = [int(input())-1 for i in range(Q)]
S = [0]*N
for i in range(Q):
  S[A[i]] += 1
ans = [K]*N
for i in range(N):
  ans[i] -= (Q-S[i])
for a in ans:
  if a > 0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 12568
#include <cstdio>
#include <algorithm>
using namespace std;

int n;
char s[101];
int x, ans;

int main(){
	scanf("%d %s", &n, s);
	for(int i=0; i<n; ++i){
		if(s[i]=='I') ++x;
		else --x;
		ans = max(ans, x);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================

// Template End =========================

int main(void){
  rep(i,3){
    char c; cin>>c;
    cout<<(c=='1'?9:1);
  }
}












Measured memory_bytes: 256
k = int(input())
luns = [i for i in range(1, 10)]

def generate_lunlun(p):
    end = p % 10
    if end - 1 >= 0:
        yield 10 * p + end - 1
    yield 10 * p + end
    if end + 1 <= 9:
        yield 10 * p + end + 1

p = 0
while len(luns) < k:
    for i in generate_lunlun(luns[p]):
        luns.append(i)
    p += 1
print(luns[k - 1])

Measured memory_bytes: 7144
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BFrog2 solver = new BFrog2();
        solver.solve(1, in, out);
        out.close();
    }

    static class BFrog2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int ds = in.nextInt();
            int k = in.nextInt();
            int[] H = new int[ds];
            int[] res = new int[ds];
            for (int i = 0; i < ds; i++) H[i] = in.nextInt();
            Arrays.fill(res, -1);
            for (int i = H.length - 2; i >= 0; i--) {
                for (int x = 1; x <= k; x++) {
                    if (i < H.length - x) {
                        if (Math.abs(H[i] - H[i + x]) + res[i + x] + 1 < res[i] || res[i] == -1) {
                            res[i] = Math.abs(H[i] - H[i + x]) + res[i + x];
                            if (res[i] == -1) res[i] = 0;
                        }
                    } else if (res[i] == -1) res[i] = Integer.MAX_VALUE / 2;
                }
            }
            //if(res[0] >= Integer.MAX_VALUE / 2) res[0] = 0;
            if (res[0] != 0) res[0]++;
            out.println(res[0]);
        }

    }
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll N, x;
  cin >> N;

  for (ll i = 1; i <= 3500; ++i) {
    for (ll j = 1; j <= 3500; ++j) {
      ll child = N * i * j;
      ll parent = 4 * i * j - N * j - N * i;
      if (parent != 0 && child % parent == 0) {
        x = child / parent;
        if (x > 0 && x <= 3500) {
          printf("%d %d %d\n", x, i, j);
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 256
#include<stdio.h> 

int main() { 
 double x[22], y[22], ans = 0; 
 int n = 0; 
 int l;
 while (scanf("%lf,%lf", &x[n], &y[n]) != -1) { 
  n++; 
 } 
 double s; 
 for (int i = 1; i < n; i++) { 
  s = (x[i] - x[0])*(y[(i + 1) % n] - y[0]) - (x[(i + 1) % n] - x[0])*(y[i] - y[0]); 
  if (s < 0)s = -s;
  ans += s;
 } 
 printf("%.8lf", ans/2.0); 
}


Measured memory_bytes: 2676
#include <cassert>
#include <deque>
#include <iostream>
#include <vector>

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

  std::deque<long long> dque;
  for (int i = 0; i < N; ++i) {
    int p = std::lower_bound(dque.begin(), dque.end(), A[i]) - dque.begin();
    if (p == 0)
      dque.push_front(A[i]);
    else
      dque[p - 1] = A[i];
  }
  std::cout << dque.size() << std::endl;

  return 0;
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
	"strings"
)

func main() {
	// Code for A - Three-letter acronym
	var s1, s2, s3 string
	fmt.Scanf("%s %s %s", &s1, &s2, &s3)

	fmt.Println(strings.ToUpper(s1[0:1]) + strings.ToUpper(s2[0:1]) + strings.ToUpper(s3[0:1]))
}


Measured memory_bytes: 1844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Acs
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            Console.WriteLine(A*B%2==1?"Yes":"No");
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <string.h>
const int MAXN=1e5+10;
long long a[MAXN],z[MAXN]={0};
int main()
{
    long long n;
    int i,j;
    int max=0;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        z[a[i]]++;
        z[a[i]+1]++;
        z[a[i]-1]++;
    }
    for(i=0;i<MAXN;i++)
    {
        if(z[i]>max)max=z[i];
    }
    printf("%d\n",max);
}


Measured memory_bytes: 4528
N=int(input())

warucount=0
count=0

for i in range(1,N+1):
    warucount=0
    for k in range(1,N+1):
        if i%2!=0:
            
            
            if i%k==0:
                warucount+=1
    if warucount==8:
        count+=1
        
    
print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

int main(){
    ll n,a; cin >> n;
    ll ans = 0;
    FOR(i,1,n){
        cin >> a;
        if (i%2&&a%2) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> tree(n+1);
    for (int i=1; i<n+1; ++i) cin >> tree.at(i).first >> tree.at(i).second;

    int m = min((1<<9), n+1);
    vector<vector<int>> dp(m, vector<int>(1e5+1));
    for (int i=1; i<m; ++i) {
        int par = i / 2;
        for (int j=0; j<1e5+1; ++j) {
            dp.at(i).at(j) = dp.at(par).at(j);
            if (j >= tree.at(i).second) chmax(dp.at(i).at(j), dp.at(par).at(j-tree.at(i).second) + tree.at(i).first);
        }
    }

    int q;
    cin >> q;
    for (int i=0; i<q; ++i) {
        int v, l;
        cin >> v >> l;
        vector<int> vec;
        while (v >= m) {
            vec.push_back(v);
            v /= 2;
        }
        int nn = (int)vec.size();
        int res = 0;
        for (int bits=0; bits<(1<<nn); ++bits) {
            int cw = 0, cv = 0;
            for (int j=0; j<nn; ++j) {
                if (bits & (1<<j)) {
                    cv += tree.at(vec.at(j)).first;
                    cw += tree.at(vec.at(j)).second;
                }
            }
            if (cw <= l) chmax(res, cv + dp.at(v).at(l-cw));
        }
        cout << res << '\n';
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 206480
N, M = list(map(int, input().split()))
AC = set()
WA = {}

for _ in range(M):
	p, S = input().split()
	p = int(p)
	if S == 'AC':
		AC.add(p)
	else:
		if p not in AC:
			if p in WA:
				WA[p] += 1
			else:
				WA[p] = 1
wa = 0
for k, v in WA.items():
	if k in AC:
		wa += v

print(len(AC), wa)

Measured memory_bytes: 17356
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	int i, j, h, b;
	while (1)
	{
		char r[5] = "", a[5] = "";
		cin >> r >> a;
		if (r[0] == '0' && r[1] == '\0' && a[0] == '0' && a[1] == '\0') break;
		h = b = 0;
		for (i = 0; i < 4; i++)
		{
			for (j = 0; j < 4; j++)
			{
				if (r[i] == a[j])
				{
					if (i == j)
						h++;
					else
						b++;
				}
			}
		}
		cout << h << " " << b << endl;
	}
}

Measured memory_bytes: 0