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

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

	int borrowing = 100000 / 1000;

	for(int i = 0; i < n; ++i) {
		borrowing = ceil(borrowing * 1.05);
	}

	cout << borrowing * 1000 << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

//void bfs()

int main()
{
    string s,t;
    map<char,ll> ss,tt;
    cin >> s >> t;
    rep(i,s.size()){
        ss[s[i]]++;
        tt[t[i]]++;
        if(ss[s[i]]!=tt[t[i]]){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, 0, n) cin >> a[i] >> b[i];
    ll ans = 0;
    ll cnt = 0;
    for(int i = n-1; i >= 0; i--){
        if((a[i] + cnt)%b[i] == 0) continue;
        ans += b[i] - (a[i] + cnt)%b[i];
        cnt += b[i] - (a[i] + cnt)%b[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4052
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    map<char,int> m;
    m['a']=0;
    m['b']=0;
    m['c']=0;
    for(auto ch:s) m[ch]++;
    int a=m['a'],b=m['b'],c=m['c'];
    if(abs(a-b)<=1 && abs(b-c)<=1 && abs(a-c)<=1)
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];
int prim(){
    int u,minv;
    int d[MAX],p[MAX],color[MAX];
    for(int i=0;i<n;i++){
        d[i]=INFTY;
        p[i]=-1;
        color[i]=WHITE;
    }
    d[0]=0;
    while(1){
        minv=INFTY;
        u=-1;
        for(int i=0;i<n;i++){
            if(minv>d[i]&&color[i]!=BLACK){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1)break;
        color[u]=BLACK;
        for(int v=0;v<n;v++){
            if(color[v]!=BLACK&&M[u][v]!=INFTY){
                if(d[v]>M[u][v]){
                    d[v]=M[u][v];
                    p[v]=u;
                    color[v]=GRAY;
                }
            }
        }
    }
    int sum=0;
    for(int i=0;i<n;i++){
        if(p[i]!=-1)sum+=M[i][p[i]];
    }
    return sum;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int e;cin>>e;
            M[i][j]=(e==-1)?INFTY:e;
        }
    }
    cout<<prim()<<endl;
    return 0;
}


Measured memory_bytes: 3136
(defun f(line0 line1)
  (let ((n 0))
		(when (char= (char line0 0) (char line1 0))
		  (incf n))
		(when (char= (char line0 1) (char line1 1))
		  (incf n))
		(when (char= (char line0 2) (char line1 2))
		  (incf n))
		n))

(format t "~A" (f (read-line nil nil) (read-line nil nil)))


Measured memory_bytes: 10720
N,K=map(x->parse(Int,x),split(readline()))
T=div((N-1)*(N-2),2)
if T<K
	println(-1)
	exit()
end
K=T-K
println(K+N-1)
for i=2:N
	println("1 $i")
end
u=2
v=3
for i=1:K
	println("$u $v")
	v+=1
	if v>N
		u+=1
		v=u+1
	end
end


Measured memory_bytes: 112004
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }

    ll ans = 1;
    int now = 0;

    rep(i, N - 1) {
        if (A[i] < A[i + 1]) {
            if (now == -1) {
                ans++;
                now = 0;
            } else {
                now = 1;
            }
        }

        if (A[i] > A[i + 1]) {
            if (now == 1) {
                ans++;
                now = 0;
            } else {
                now = -1;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3924
#include <iostream>
using namespace std;
string s;
int k, n, d;
int main() {
	cin>>s>>k;
	n = s.size();
	for(int i=0; i<n && k; i++) {
		if(s[i]=='a') continue;
		d = 'z' - s[i] + 1;
		if(k>=d) {
			k -= d;
			s[i] = 'a';
		}
	}
	s[n-1] += k%26;
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long LL;
const int maxn = 2e5 + 100;
LL n, T, a[maxn], ans;
int main()
{
    cin>>n>>T;
    for(int i = 0; i < n; i++) cin>>a[i];
    for(int i = 0; i < n-1; i++){
        if(a[i] + T < a[i+1]) ans += T;
        else ans += a[i+1] - a[i];
    }
    ans += T;
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    if (a[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    
    sort(all(a));
    rep3(i, 1, n) {
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    // cout << "a" << endl;
    
    
    map<int, int> mp;
    rep(i, n) {
        mp[a[i]]++;
    }
    vector<int> vv;
    for (auto e : mp) vv.eb(e.F);
    // rep(i, sz(vv)) cout << vv[i] << " "; cout << endl;
    rep3(i, 1, sz(vv)) if (vv[i] != vv[i - 1] + 1) {
        cout << 0 << endl;
        return 0;
    }
    // cout << "b" << endl;
    
    
    
    vv.clear();
    for (auto e : mp) vv.eb(e.S);
    // rep(i, sz(vv)) cout << vv[i] << " "; cout << endl;
    ll ans = 1;
    rep3(i, 2, sz(vv)) {
        rep(j, vv[i]) (ans *= vv[i - 1]) %= 998244353;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6016
S = list(input())

Flag = False
if S[0] == "A" and S[2:-1].count("C") == 1:
    S.remove("A")
    S.remove("C")
    string = "".join(S)
    if string.islower() or string.isupper():
        Flag = True

if Flag:
    print("AC")
else:
    print("WA")

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

using namespace std;

typedef long long ll;
const int MAX = 100005;
const int MOD = 1000000007;
#define F first

#define S second

void solve()
{
	ll n;
	cin>>n;
	vector<ll> arr(n);
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	ll ans=0;
	for(int i=1;i<n-1;i++)
	{
		if((arr[i]>arr[i-1]&&arr[i]<arr[i+1])||(arr[i]<arr[i-1]&&arr[i]>arr[i+1]))
			ans+=1;
	}
	cout<<ans<<endl;
	return;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans,z,Z[100],Cnt[100],sum,n,B[1003],A[1003],m,a;
void Check(int fo) {
	sum=0;
	for(int i=1; i<=n; i++) {
		B[i]=A[i]%fo,sum+=B[i];
	}
	sort(B+1,B+n+1);
	for(int i=n,j=sum/fo; j; j--,i--) {
		sum-=B[i];
	}
	if(sum<=m)ans=max(fo,ans);
}
void DFS(int i,int fo) {
	if(i==z+1) {
		Check(fo);
		return;
	}
	fo*=pow(Z[i],Cnt[i]);
	for(int j=Cnt[i]; j>=0; j--)DFS(i+1,fo),fo/=Z[i];
}
int main() {
	scanf("%d %d",&n,&m);
	for(int i=1; i<=n; i++)scanf("%d",&A[i]),a+=A[i];
	for(int i=2; i*i<=a; i++) {
		if(a%i==0) {
			Z[++z]=i;
			while(a%i==0)a/=i,Cnt[z]++;
		}
	}
	if(a!=1) Z[++z]=a,Cnt[z]=1;
	DFS(1,1);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define NINTH_POWER_OF_TEN 1000000000
#define LL_INF (numeric_limits<long long>::max()/2)
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

// const int kMaxN;

int A, B;
string ans;

signed main() {
  cin >> A >> B;

  if ((A*B)%2 == 0) {
    ans = "No";
  } else {
    ans = "Yes";
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 1e9 + 7;

void solve() {
    ll n;
    cin >> n;
    ll c0 = 0, c1 = 0, c2 = 0, c3 = 0;
    while(n--) {
        string s;
        cin >> s;
        if(s == "AC") c0++;
        else if(s == "WA") c1++;
        else if(s == "TLE") c2++;
        else if(s == "RE") c3++;
    }
    cout << "AC x " << c0 << "\n" << "WA x " << c1 << "\n" << "TLE x " << c2 << "\n" << "RE x " << c3 << "\n";
}       

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int a[10001];
int main()
{
    int n,b,c,m=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
 {   if(a[i]==1)continue;
   else
   {
     int t=0;
    b=sqrt(a[i]);
    for(int j=2;j<=b;j++)
    if(a[i]%j==0)t++;
    if(t==0)m++;
   }
 }
    printf("%d\n",m);
    return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll H,W,D;
  cin>>H>>W>>D;
  unordered_map<int,pair<int,int>> pos;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      int a;
      cin>>a;
      pos[a]=make_pair(i,j);
    }
  }
  int Q;
  cin>>Q;
  int A[Q][2];
  for(int i=0; i<Q; i++){
    int L,R;
    cin>>L>>R;
    A[i][0]=L;
    A[i][1]=R;
  }
//DP
  int DP[H*W+1];
  DP[0]=0;
  for(int k=1; k<=D; k++){
    int d=D;
    DP[k]=0;
    while(k+d<=H*W){
      int tmp=0;
      tmp+=abs(pos[k+d].first-pos[k+d-D].first);
      tmp+=abs(pos[k+d].second-pos[k+d-D].second);
      DP[k+d]=DP[k+d-D]+tmp;
      d=d+D;
    }
  }
  
  for(int i=0; i<Q; i++){
    int ans=DP[A[i][1]]-DP[A[i][0]];
    cout<<ans<<endl;
  }
}


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


int main(){
	/*input*/
	int n;
	cin >> n ;

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

	/*calc*/
    int ans = 0;
    float max_value = p[0];
    int max_value_index = 0;

    for(int i = 0; i < n; i++){
    	if(max_value < p[i]){
    		max_value = p[i];
    		max_value_index = i;
    	}
    }
    for(int i = 0; i < n; i++){
    	if(max_value_index == i) ans += p[i]/2;
    	else{
    		ans += p[i];
    	}
    }

    /*output*/
	cout<< ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define MOD 1000000007
#define pii pair<int,int>
#define unmap unordered_map<int,int>
#define ll long long int
using namespace std;

void solve() {
    int n;
    cin >> n;
    double ans = 3.141592;
    ans = ans * 2 * n;
    cout << fixed << setprecision(6) << ans;

}





int main()
{


    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3792
#include"bits/stdc++.h"
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

int main() {
	string s;
	bool ans = false;
	cin >> s;
	for (auto ss : s) {
		if (ss == '7')ans = true;
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,i,ans=0;
    cin >> n;
    vector<long long int>a(n);
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    for(i=0;i<n;i++){
        while(a[i]%2==0){
            a[i] = a[i]/2;
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3672
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        float hp = sc.nextInt();
        float at = sc.nextInt();
        float hp2 = sc.nextInt();
        float at2 = sc.nextInt();
        if(Math.ceil(hp/at2) >= Math.ceil(hp2/at)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35760
#include <iostream>
#include <string>
using namespace std;
    int main(){
    string S;
    cin >> S;
    int n=S.size();
    for(int i=0; i<n; i++){
        for(int j=0; j<i; j++){
            if(S[j]=='C' && S[i]=='F'){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    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;

typedef long long ll;

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

	ll n;
	cin >> n;

	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		ans += (n / i) * (i + i * (n / i)) / 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define ALL(a) (a).begin(),(a).end()
#define MOD 1e9+7
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main()
{
	int n;
	string a, b, c;
	cin >> n >> a >> b >> c;
	int ans = 0;
	rep(i, n)
	{
		set<char> tmp;
		tmp.insert(a[i]);
		tmp.insert(b[i]);
		tmp.insert(c[i]);
		if (tmp.size() == 2)ans++;
		else if (tmp.size() == 3)ans += 2;
	}
	co(ans);
	return 0;
}


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

int main() {
    int sum = 0,
        x = 0,
        y = 0;
    
    for (int i = 0; i < 6; i++) {
        int num;
        cin >> num;
        if (i <= 3) {
            sum += num;
            if (!(i) || (num < x)) {
                x = num;
            }
        } else if (i == 4) {
            y = num;
        } else {
            if (num > y) y = num;
        }
    }
    
    cout << (sum - x) + y << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(){
  int n,m,x,l,r,k;
  cin >> n >> m >> x;
  l = r = 0;
  REP(i,m){
    cin >> k;
    if (k<x) {
      l++;
    } else {
      r++;
    }
  }
  if (l<r) {
    cout << l;
  } else {
    cout << r;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;

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

  vector <vector<long long> > a(n, vector<long long> (3));
  vector <vector<long long> > actions(n, vector<long long> (3));

  for(int i = 0; i < n; i++){
    cin >> actions.at(i).at(0) >> actions.at(i).at(1) >> actions.at(i).at(2);
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < 3; j++){
      a.at(i).at(j) = -INF;
    }
  }

  for(int i = 0; i < n; i++){
    if(i == 0){
      for(int j = 0; j < 3; j++){
        a.at(i).at(j) = actions.at(i).at(j);
      }
    }else{
      for(int j = 0; j < 3; j++){
        int max_tmp = 0;
        for(int k = 0; k < 3; k++){
          if(j == k){
            continue;
          }else{
            if(max_tmp < a.at(i-1).at(k)){
              max_tmp = a.at(i-1).at(k);
            }else{
              continue;
            }
          }
        }
        a.at(i).at(j) = max_tmp + actions.at(i).at(j);
      }
    }
  }

  long long ans_max = 0;
  for(int i = 0; i < 3; i++){
    long long ans_max_tmp = a.at(n-1).at(i);
    if(ans_max < ans_max_tmp){
      ans_max = ans_max_tmp;
    }else{
      continue;
    }
  }

  cout << ans_max << endl;
}


Measured memory_bytes: 14064
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int a, b;
    char op;
    cin >> a >> op >> b;

    if(op == '+'){
        cout << a + b << endl;
    } else {
        cout << a - b << endl;
    }

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n;
    cin>>n;
    REP(i,(n/7)+1){
        REP(j,(n/4)+1){
            if(i*7+j*4==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;
typedef long long ll;

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

	ll N,K, tmp;
	vector<ll> monsters;

	cin >> N >> K;

	REP(i, N)
	{
		cin >> tmp;
		monsters.pb(tmp);
	}

	sort(monsters.begin(), monsters.end(), greater<ll>());

	REP(i, K)
	{
		monsters[i] = 0;
		if (i > N - 2)
			break;
	}

	cout << accumulate(monsters.begin(), monsters.end(), 0LL) << endl;

	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#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 fore(c,...) for (auto __VA_ARGS__:(c))
using namespace std;
typedef long long ll;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int n,m;
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<'\n';
}


Measured memory_bytes: 256
input()
a_list = [int(x) for x in input().split()]
n = len(a_list)
i=1
mae_height = a_list[0]
fumidai_sum = 0
sa = 0
while i<n:
  if a_list[i] < mae_height:
    sa = mae_height - a_list[i]
    fumidai_sum += sa
    mae_height = a_list[i] + sa
  elif a_list[i] >= mae_height:
    mae_height = a_list[i]
  i+=1
print(fumidai_sum)

Measured memory_bytes: 32116
import java.util.Scanner;
import java.math.BigDecimal;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		String[] n = str.split(" ");
		int a = Integer.parseInt(n[0]);
		int b = Integer.parseInt(n[1]);
		int d = a / b;
		int r = a % b;
		double f = (double)a / b;
		// 出力部分 桁数が大きくなると勝手にEを使って桁を省略されることが有る。　それを防ぐためにBigDecimal.valueOf(float or double).toPlainString()を使っている。
		System.out.println( d + " " + r + " " + BigDecimal.valueOf(f).toPlainString());

	}
}


Measured memory_bytes: 26576
#include<bits/stdc++.h>
using namespace std;
const double EPS=1e-9;

int main(){
  int n;
  while(cin>>n,n){
  int I[333],M=256;
  for(int i=0;i<n;i++)cin>>I[i];
  int as,aa,ac;
  double ah=11111;
  for(int S=0;S<16;S++)
    for(int A=0;A<16;A++)
      for(int C=0;C<16;C++){
	int R=S;
	int cnt[333]={};
	for(int i=0;i<n;i++){
	  R=(A*R+C)%M;
	  int o=(I[i]+R)%M;
	  cnt[o]++;
	}
	double h=0.0;
	for(int i=0;i<333;i++){
	  if(cnt[i]){
	    h-=(double)cnt[i]/(double)n*log((double)cnt[i]/(double)n);
	  }
	}
	if(h+EPS<ah){
	  ah=h;
	  as=S;
	  aa=A;
	  ac=C;
	}
      }
  cout<<as<<" "<<aa<<" "<<ac<<endl;
  }
  return 0;
}



Measured memory_bytes: 3328
import sys
import bisect
import heapq

sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline

def main():
    a,b,c = map(int,read().split())
    if a <= c and c <= b:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


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

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *NIL, *root;

void insert(int x) {
    Node *p = NIL;
    Node *u = root;
    Node *in = (Node *)malloc(sizeof(Node));
    in->key = x;
    in->left = NIL;
    in->right = NIL;

    while (u != NIL) {
        p = u;
        if (in->key < u->key) {
            u = u->left;
        } else {
            u = u->right;
        }
    }

    in->parent = p;
    if (p == NIL) {
        root = in;
    } else if (in->key < p->key) {
        p->left = in;
    } else {
        p->right = in;
    }
}

bool find(Node *u, int x) {
    while (u != NIL && u->key != x) {
        if (x < u->key) {
            u = u->left;
        } else {
            u = u->right;
        }
    }

    if (u == NIL) {
        return false;
    } else {
        return true;
    }
}

Node * findP(Node *u, int x) {
    while (u != NIL && u->key != x) {
        if (x < u->key) {
            u = u->left;
        } else {
            u = u->right;
        }
    }

    return u;
}

Node * getMinimum(Node *u) {
    while (u->left != NIL) {
        u = u->left;
    }

    return u;
}

Node * getSuccessor(Node *u) {
    if (u->right != NIL) {
        return getMinimum(u->right);
    }

    Node *d = u->parent;
    while (d != NIL && u == d->right) {
        u = d;
        d = d->parent;
    }

    return d;
}

void deleteNode(Node *u) {
    Node *d, *x;
    if (u->left == NIL || u->right == NIL) {
        d = u;
    } else {
        d = getSuccessor(u);
    }

    if (d->left != NIL) {
        x = d->left;
    } else {
        x = d->right;
    }

    if (x != NIL) {
        x->parent = d->parent;
    }

    if (d->parent == NIL) {
        root = x;
    } else if (d == d->parent->left) {
        d->parent->left = x;
    } else {
        d->parent->right = x;
    }

    if (d != u) {
        u->key = d->key;
    }
}

void printPre(Node *u) {
    if (u == NIL) {
        return;
    }

    printf(" %d", u->key);
    printPre(u->left);
    printPre(u->right);
}

void printIn(Node *u) {
    if (u == NIL) {
        return;
    }

    printIn(u->left);
    printf(" %d", u->key);
    printIn(u->right);
}

int main() {
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        string com;
        cin >> com;
        if (com == "insert") {
            int x;
            scanf("%d", &x);
            insert(x);
        } else if (com == "find") {
            int x;
            scanf("%d", &x);
            if (find(root, x)) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        } else if (com == "delete") {
            int x;
            scanf("%d", &x);
            auto u = findP(root, x);
            deleteNode(u);
        } else {
            printIn(root);
            printf("\n");
            printPre(root);
            printf("\n");
        }
    }

    return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int N, M;
    cin >> N >> M;
    // k回目で全てAC する確率は(1/2)^M * (1 - (1/2)^M)^(k - 1)
    // 期待値はr = (1/2)^M とおくと
    // (1900 * M + 100 * (N - M)) * (1 * r + 2 * r * (1 - r)+ ... + k * r * (1 - r)^(k - 1))
    // この期待値を計算してkを正の無限大としたときの極限値は
    // 1 / r = 2^M 
    // となる
    int ans = (1900 * M + 100 * (N - M));
    REP(i, M)
    {
        ans *= 2;
    }
    cout << ans << endl; 
}


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

int main(){
        string s;
        cin>>s;
        
        cout<< (s=="RRR"? 3:(s=="RRS" || s=="SRR" ? 2:(s=="SSS" ? 0:1)));
        cout<<"\n";
        return 0;

    }


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

vvector<int> edges;
vector<int> found_time;

void bfs(int start){
	found_time[start] = 0;
	queue<pii> que;
	que.emplace(start, 0);
	while(que.size()){
		pii d = que.front();
		que.pop();
		foreach(i, edges[d.first]){
			if(found_time[i]>=0)continue;
			found_time[i]=d.second+1;
			que.emplace(i, d.second+1);
		}
	}
}

int main(){
	int n;
	cin >> n;
	edges.resize(n);
	found_time.resize(n, -1);
	rep(i, n){
		int t;
		int time;
		cin >> t >> time;
		--t;
		rep(j, time){
			int to;
			cin >> to;
			--to;
			edges[t].push_back(to);
		}
	}
	bfs(0);
	rep(i, n){
		output(i+1);
		output(found_time[i]);
		outendl();
	}
	return 0;
}



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

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "No" << endl
#define PNG cout << "NG" << endl

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  int m;
  cin >> n >> m;
  if (n == m)
    PYES;
  else
    PNO;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;
char in[110000];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	int p=n+(in[0]==in[n-1]);
	if(p%2==0)printf("Second\n");
	else printf("First\n");
}

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

int main() {
  int n, k, c;
  cin >> n >> k;
  c = 1;
  
  for(int i = 0; i < n; i++) {
    int t1, t2;
    t1 = c * 2;
    t2 = c + k;
  	if( t1 > t2 ) {
      c = t2;
    } else {
      c = t1;
    }
  }
  cout << c << endl;  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>
#include <bitset>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> P;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define Rep(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える


int main(){
    ll n, k; cin >> n >> k;
    ll r = n%k;

    cout << min(r, k-r) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	long long ans=0,N, M;
	cin >> N >> M;
	vector<pair<long long, long long>> a(N);
	for (int i = 0; i < N; i++)cin >> a[i].first >> a[i].second;
	sort(a.begin(), a.end());
	long long y = M;
	for (int i = 0; i < N; i++) {
		if (a[i].second < y)ans += a[i].first * a[i].second;
		else { ans += y * a[i].first; break; }
		y -= a[i].second;
	}
	cout << ans << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

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

    int s1=0;
    int s2=0;
    vector<int> w(n);
    for(int i=0; i<n; i++){
        cin >> w[i];
        s2 += w[i];
    }
    int ans = 10000;
    for(int i=0; i<n; i++){
        s1 += w[i];
        s2 -= w[i];
        ans = min(abs(s2 - s1), ans);
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	string x;
	int cnt = 0;
	cin >> x;

	if (x[0] == x[1] && x[1] == x[2] || x[1] == x[2] && x[2] == x[3]) {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		cout << "No" << endl;
		return 0;

	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B;cin >> A >> B;
  cout << ((A%3==0 || B%3==0 || (A+B)%3 == 0) ? "Possible" : "Impossible") << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a=sc.nextInt();
		int b=sc.nextInt();
		String s=sc.next();
		boolean ans=true;
		if(s.matches("[0-9].*-[0-9].*")){
		}else{
			ans=false;
		}

		if(s.substring(a,a+1).equals("-")){
		}else{
			ans=false;
		}

		if(ans==true){
			put("Yes");
		}else{
			put("No");
		}


  }

	public static void put(String n){
		System.out.println(n);
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
long long n,a[1000000],i,j,flag=0,c=0;
int main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	while(n>c){
	     for(j=n-1;j>=1;j--){
		     if(a[j]<a[j-1]){
			    swap(a[j],a[j-1]);
			    flag++;
		     }
		 }
		 c++;
		 j=n-1;
	 } 
	    for(i=0;i<n;i++){
		   if(i==n-1){
		      cout<<a[i]<<endl;
		       cout<<flag<<endl;
		   }
		   else{
			   cout<<a[i]<<" ";
		   }
	    }
}	 



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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

string s;
int n, len;

int next(int t){
    int dep = 0;
    for (int i = t; i < len; ++i) {
        if (s[i] == '(') ++dep;
        if (s[i] == ')') --dep;
        
        if ((s[i] < '0' || s[i] > '9') && dep == 0) return i + 1;
    }
    return len;
}

// [l,r)
int count(int l, int r){
    if (l >= r) return 0;
    if (s[l] == '(' && next(l) == r) return count(l + 1, r - 1);
    
    if (s[l] >= 'A' && s[l] <= 'Z') return count(l + 1, r) + 1;
    int num = 0, k = l;
    while (s[k] >= '0' && s[k] <= '9') {
        num = num * 10 + s[k] - '0';
        ++k;
    }
    if (num == 0) num = 1;
    
    int ne = next(k);
    long long ret = num * (long long)count(k, ne) + count(ne, r);
    
    if (ret > n) ret = n + 1;
    
    return (int)ret;
}

int count(int l){
    return count(l, next(l));
}

char search(int m, int now) {
    if (s[now] == '(' || s[now] == ')') return search(m, now + 1);
    if (m == 0){
        for (int i = now; i < len; ++i) {
            if (s[i] >= 'A' && s[i] <= 'Z')
                return s[i];
        }
        return 'w';
    }
    int ne = next(now);
    int c = count(now, ne);
    if (c <= m){
        return search(m - c, ne);
    }
    int k = now;
    while (s[k] >= '0' && s[k] <= '9') {
        ++k;
    }
    int co = count(k, next(k));
    return search(m % co, k);
}

int main(){
    while (true) {
        cin >> s >> n;
        len = s.length();
        if (s == "0") break;
        
        if (count(0, len) <= n) {
            cout << 0 << "\n";
            continue;
        }
        
        cout << search(n, 0) << "\n";
    }
    return 0;
}

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

using namespace std;


int main(){
    string S,T;
    cin >> S;
    cin >> T;
    string S1 = S;
    while(1){
        if(S==T){
            cout << "Yes" << endl;
            break;
        }
        char a = S1[S1.size()-1];
        for(int i=S1.size()-1;i>0;i--){
            S1[i] = S1[i-1];
        }
        S1[0] = a;

        if(S1 == S){
            cout << "No" << endl;
            break;
        }
        if(S1 == T){
            cout << "Yes" << endl;
            break;
        }
        

    }
}

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

#define Ni 3

int Pz[Ni][Ni],tmp[Ni][Ni];
int Dx[4]={0,1,0,-1},Dy[4]={1,0,-1,0};

void emblem(int *a,int *b){
  int i,j;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      if(!Pz[i][j]){
	*a = j;
	*b=i;
      }
    }
  }
}

void swap(int *a,int *b){
  int tmp;
  tmp =*a;
  *a = *b;
  *b = tmp;
}

int check(){
  int i,A,S=0;
  for(i=0;i<9;i++){
    A = Pz[i/3][i%3];
    if(A){
      A--;
      S += abs(i/3-A/3) + abs(i%3 - A%3);
    }
  }
  return S;
}

int defain(int a,int b,int P,int D,const int shin){
  int i,hi,A,B,result;
  hi = check();
  if(hi==0){
    return D;
  }
  if(D+hi>shin){
    return -1;
  }

  for(i=0;i<4;i++){
    A = a+Dx[i];
    B = b+Dy[i];
    if(~P && i==(P+2)%4) {
      continue;
    }
    if(!(0<=A && A<3 && 0<=B && B<3)){
      continue;
    }
    swap(&Pz[b][a],&Pz[B][A]);
    result = defain(A,B,i,D+1,shin);
    if(~result){
      return result;
    }
    swap(&Pz[b][a],&Pz[B][A]);
  }
  return -1;
}

int main(){
  int i,j,li,TA,a,b;

  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&Pz[i][j]);
    }
  }

  emblem(&a,&b);
  for(li=0;li<100;li++){
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
	tmp[i][j]=Pz[i][j];
      }
    }
    TA = defain(a,b,-1,0,li);
    if(TA!=-1){
      printf("%d\n",TA);
      break;
    }

    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
	Pz[i][j]=tmp[i][j];
      }
    }

    TA = -1;
    if(li==99){
      printf("%d\n",TA);
    }
  }

  return 0;
}



Measured memory_bytes: 2108
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(obj) (obj).begin(), (obj).end() //sort(ALL(obj))みたいな



using namespace std;

int main() {
  int h,n,m;
  cin >> h >> n;
  int ans = 0;
  rep(i, n) {
    cin >> m;
    ans += m;
  }
  if (h <= ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    if(a[n-1]==0 && k&1){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1;
    if(a[n-1]<0 && k&1){
        for(int i=n-1;i>=(n-k);i--){
            (ans*=a[i])%=mod;
            (ans+=mod)%=mod;
        }
        cout<<ans<<endl;
        return 0;
    }
    int i=0,j=n-1;
    if(k&1){
        (ans*=a[j])%=mod;
        j--,k--;
    }
    for(int l=0;l<(k/2);l++){
        ll tmp1=a[i]*a[i+1];
        ll tmp2=a[j]*a[j-1];
        if(tmp1>=tmp2){
            tmp1%=mod;
            (ans*=tmp1)%=mod;
            (ans+=mod)%=mod;
            i+=2;
        }
        else{
            tmp2%=mod;
            (ans*=tmp2)%=mod;
            (ans+=mod)%=mod;
            j-=2;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5196
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> s;
typedef long long int ll;

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}

char S[5];

int main(){
  scanf("%s", S);
  char s_begin = S[0];
  char s_end = S[3];
  if((S[0]==S[1] && S[1] ==S[2]) || (S[1]== S[2] && S[2] == S[3])){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  
  int ans = 0;
  repm(i, a, b + 1){
    int o = i % 10, t = i / 10 % 10, th = i / 1000 % 10, tt = i / 10000;
    if (o == tt && t == th) ans++;
  }

  cout << ans << endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> c(n);
    rep(i, n)
    {
        cin >> p[i];
        c[i] = i + 1;
    }
    if (p == c)
    {
        cout << "YES" << endl;
        return 0;
    }
    rep(i, n)
    {
        rep(j, n)
        {
            if (i == j)
                continue;
            vector<int> p_copy(n, 0);
            rep(k, n) p_copy[k] = p[k];
            int tmp = 0;
            tmp = p_copy[i];
            p_copy[i] = p_copy[j];
            p_copy[j] = tmp;
            if (p_copy == c)
            {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    ll N; cin >> N;
    ll sum = 0;

    vector<ll> a(N),d(N);
    for(int i=0; i<N; ++i) { cin >> a[i]; sum += a[i]; }

    if(sum%(N*(N+1)/2) != 0){
        cout << "NO" << endl;
        return 0;
    }

    ll k = sum/(N*(N+1)/2);
    for(int i=0; i<N; ++i) d[i] = a[(i+1)%N] - a[i];
    for(int i=0; i<N; ++i) d[i] -= k;

    ll cnt = 0;
    for(int i=0; i<N; ++i){
        // d[i] > 0で弾くのを忘れずに
        if(d[i] > 0){
            cout << "NO" << endl;
            return 0;
        }
        else if((-d[i])%N != 0){
            cout << "NO" << endl;
            return 0;
        }
        else{
            cnt += (-d[i])/N;
        }
    }   

    if(cnt == k){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 1792
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include <iostream>
using namespace std;
typedef long long ll;

//マクロ
// forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
// FORAは範囲for文(使いにくかったら消す)
#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)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000  // 10^12:∞
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange
//略記
#define PB push_back  //挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素

signed main() {
  //入力の高速化用のコード
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int l, m, n;
  cin >> n;
  cout << (10000-n)%1000 << endl;
  return 0;
}

Measured memory_bytes: 3640