akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

int main(void){

  int N;
  scanf("%d",&N);

  double sum = 0;
  double x;
  char u[4];
  for(int i = 0 ; i < N ; i++){
    scanf("%lf %s",&x , u);

    if(strcmp(u , "JPY") == 0){
      sum += x;
    }else if(strcmp(u , "BTC") == 0){
      sum += x * 380000.0;
    }

  }

  printf("%lf", sum);


  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int N, M, K;
ll dp[20004];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M >> K;
  int A[N];
  FOR(i,0,N) cin >> A[i];
  FOR(i,0,N+1) dp[i] = 1e18;
  dp[0] = 0;
  FOR(i,0,N) {
    int mn = 1e9;
    int mx = 0;
    for(int j = i; j >= 0 && j >= i - M + 1; j--) {
      mx = max(mx, A[j]);
      mn = min(mn, A[j]);
      dp[i+1] = min(dp[i+1], dp[j] + K + ll(i - j + 1) * (mx - mn));
    }
  }
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 3440
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int k;
  cin >>k;
  vector<int> n = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << n.at(k-1) << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
int main(void){
	int a[100],n,i;

	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[100-i]);
	}
	for(i=(100-n);i<=99;i++){
		printf("%d",a[i]);
		if(i!=99){
			printf(" ");
		}
	}
printf("\n");
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int s =0;
  if (a != b){
    s++;
  }
  if (a != c){
    s++;
  }
  if (c != b){
    s++;
  }
  if(a==b && b==c){
    s=1;
  }
  cout<<s<<endl;
  
}



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

namespace ITP1
{
    class ITP1_5_B
    {
        static void Main(string[] args)
        {
            int h, w;
            List<int> dataSet;

            while (true)
            {
                dataSet = Console.ReadLine().Split().Select(int.Parse).ToList();
                h = dataSet[0];
                w = dataSet[1];

                if (h == 0 && w == 0)
                {
                    break;
                }

                for (int i = 1; i <= h; i++)
                {
                    for (int j = 1; j <= w; j++)
                    {
                        if (i == 1 || i == h)
                        {
                            Console.Write("#");
                        }
                        else if (j == 1 || j == w)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");
                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}



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

using namespace std;

const int N = 2e5 + 5;

long long segTree[4*N];
long long upd;
int n;

inline void update(int l, int r, int node, int index){
  if(l > r) return ;
  if(index < l || index > r) return ;
  if(l == r && l == index){
    segTree[node] = upd;
    return ;
  }
  int left = node<<1, right = left|1, mid = l+r>>1;
  update(l, mid, left, index);
  update(mid + 1, r, right, index);
  segTree[node] = max(segTree[left], segTree[right]);
}

inline long long query(int l, int r, int node, int lq, int rq){
  if(l > r) return LLONG_MIN;
  if(l > rq || lq > r) return LLONG_MIN;
  if(l >= lq && r <= rq) return segTree[node];
  int left = node<<1, right = left|1, mid = l+r>>1;
  long long lres = query(l, mid, left, lq, rq);
  long long rres = query(mid + 1, r, right, lq, rq);
  return max(lres, rres);
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n;
  int order[n], price[n];
  for(int i = 0; i < n; ++i) {
    cin >> order[i];
    --order[i];
  }
  for(int i = 0; i < n; ++i) {
    cin >> price[i];
  } 
  for(int i = 0; i < n; ++i) {
    long long q = query(0, n - 1, 1, 0, max(0, order[i] - 1));
    upd = q + price[i];
    update(0, n - 1, 1, order[i]);
  }
  auto ans = query(0, n - 1, 1, 0, n - 1);
  cout << ans << '\n';
}

Measured memory_bytes: 8064
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int main() {
	string st; cin >> st;
	if (st.size()>=4&&st.substr(0,4) == "YAKI")cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

	int N, M, K; cin >> N >> M >> K;
	bool ok = false;
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= M; ++j) {
			int a = i*M + j*N - i*j;
			if (a == K)ok = true;
		}
	}
	if (ok)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int x;
    Scd(x);

    int cnt = 0;
    int leng = 0;
    for( int i = 1; i < 1000000 ;i++){
        cnt++;
        leng+=i;
        if( leng >= x ) break;
    }

    printf ("%d\n", cnt);

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
const int RMQ=0;

struct SegmentTree{
	using Func=function<ll(ll,ll)>;
	using Attr=tuple<ll,Func,Func>;
	int n;
	vl val;
	ll e;
	Func f,g;
	const vector<Attr> tmpAttr{
		Attr((1ll<<31)-1,[](ll a,ll b){return min(a,b);},[](ll a,ll b){return b;}),
	};
	SegmentTree(int N){
		n=1;
		while(n<N)n*=2;
	}
	SegmentTree(int N,int t):SegmentTree(N){tie(e,f,g)=tmpAttr[t];val.assign(n*2,e);}
	SegmentTree(int N,ll E,Func F,Func G):SegmentTree(N){tie(e,f,g)=Attr(E,F,G);val.assign(n*2,e);}
	void update(ll k,ll a){
		k+=n;
		val[k]=g(val[k],a);
		while(k){
			k/=2;
			val[k]=f(val[k*2],val[k*2+1]);
		}
	}
	ll query(int a, int b){return query(a,b,1,0,n);}
	ll query(int a, int b, int k, int l, int r){
		if(r<=a or l>=b) return e;
		if(a<=l and r<=b) return val[k];
		int m=(l+r)/2;
		return f(query(a,b,k*2,l,m),query(a,b,k*2+1,m,r));
	}	
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	SegmentTree st(n,RMQ);
	rep(i,m){
		ll t,a,b;
		cin>>t>>a>>b;
		if(t==0) st.update(a,b);
		else puta(st.query(a,b+1));
	}

	return 0;
}


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

int N, A;
int x[55];
long long dp[55][55][55 * 55];

int main() {
    scanf("%d%d", &N, &A);
    for (int i = 1; i <= N; ++i) scanf("%d", &x[i]);
    dp[0][0][0] = 1;
    for (int i = 1; i <= N; ++i) for (int j = 0; j <= i; ++j) for (int k = 0; k < 55 * 55; ++k) {
        dp[i][j][k] += dp[i - 1][j][k];
        if (j && k >= x[i]) dp[i][j][k] += dp[i - 1][j - 1][k - x[i]];
    }
    long long answer = 0;
    for (int i = 1; i <= N; ++i) answer += dp[N][i][A * i];
    printf("%lld\n", answer);
    return 0;
}

Measured memory_bytes: 65792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i< (n) ; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
  int n;
  ll d;
  int ans = 0;
  cin >> n >> d;
  rep(i,n){
   ll x, y;
    cin >> x >> y;
  if(x*x+y*y <= d*d) ans++;
  }
  cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    long a = Integer.parseInt(scan.next());
    long b = Integer.parseInt(scan.next());
    long c = Integer.parseInt(scan.next());
    long d = Integer.parseInt(scan.next());

    long[] respondents = new long[4];
    respondents[0] = a * c;
    respondents[1] = a * d;
    respondents[2] = b * c;
    respondents[3] = b * d;
    long max = respondents[0];
    for (int i = 1; i < respondents.length; i++) {
      max = Math.max(max, respondents[i]);
    }
    out.println(max);
    out.flush();
  }
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */
lint dp[MAX];
int main(){
    int n, k; cin >> n >> k;
    vector<lint> h(n); rep(i, n) cin >> h[i];

    rep(i, n) dp[i] = INF; dp[0] = 0;
    rep(i, n){
        repn(j, k){
            if(i + j >= n) continue;
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }

    out(dp[n-1]);
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	string n;
	string ans="ABC";
	
	cin>>n;
	ans+=n;
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    string s; cin >> s;

    string ans = "Yes";
    rep(i, s.size()) {
        if (i == a) {
            if (s.at(a) != '-') {
                ans = "No";
                break;
            }
        }
        else if (!(0 <= (s.at(i) - '0') &&  (s.at(i) - '0') <= 9)) {
                ans = "No";
                break;
        }
    }

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

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

using namespace std;
const int MAXN = 100100;

int N;
vector <int> edge[MAXN];
int cv[MAXN];
bool used[MAXN];
int ans;
int path_ans;
int dp[MAXN]; // longest chain downward ending in i

void flood (int cloc, int last)
{
    if (cv[cloc])
        used[cloc] = true;
    for (int i = 0; i < edge[cloc].size(); i++)
    {
        int neigh = edge[cloc][i];
        if (neigh == last) continue;
        flood (neigh, cloc);

        if (used[neigh])
        {
            used[cloc] = true;
            cv[cloc] = 1 - cv[cloc];
            cv[neigh] = 1 - cv[neigh];
            ans += 2;
        }
    }
}

void flood2 (int cloc, int last)
{
    int cscore = cv[cloc];
    int d1 = 0, d2 = 0;
    for (int i = 0; i < edge[cloc].size(); i++)
    {
        int neigh = edge[cloc][i];
        if (neigh == last) continue;
        flood2 (neigh, cloc);

        dp[cloc] = max (dp[cloc], dp[neigh] + cscore);
        if (dp[neigh] > d1)
        {
            d2 = d1;
            d1 = dp[neigh];
        }
        else if (dp[neigh] > d2)
        {
            d2 = dp[neigh];
        }
    }
    path_ans = max (path_ans, d1 + d2 + cscore);
    path_ans = max (path_ans, dp[cloc]);
}

int main()
{
    cin >> N;
    for (int i = 0; i + 1 < N; i++)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }

    for (int i = 0; i < N; i++)
    {
        char c;
        cin >> c;
        if (c == 'B')
            cv[i] = 0;
        else
            cv[i] = 1;
    }

    int start = -1;
    for (int i = 0; i < N; i++)
        if (cv[i])
            start = i;

    if (start == -1)
    {
        cout << "0\n";
        return 0;
    }

    for (int i = 0; i < N; i++)
    {
        used[i] = false;
        dp[i] = 0;
    }
    ans = 0;
    flood (start, -1);

    path_ans = 0;
    flood2 (start, -1);
    //cout << ans << " " << path_ans << "\n";
    for (int i = 0; i < N; i++)
    {
        ans += cv[i];
    }
    if (ans == 1)
        ans = 3;
    //cout << ans << " " << path_ans << "\n";
    cout << ans - 2 * path_ans << "\n";
}

Measured memory_bytes: 14464
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        if(B > A){
            long tmp = A;
            A = B;
            B = tmp;
        }
        System.out.println((A - B) % 2 == 0 ? ((A - B) / 2) + B : "IMPOSSIBLE");
    }
}


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

int main() 
{
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	int n,k,t;
	vector <int> v;

	cin >> n >> k;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		v.push_back(t);
	}

	sort(v.rbegin(),v.rend());

	if(k<n)
	{
		cout << v[k] << '\n';
		return 0;
	}
	long long int lo = 1;
	long long int hi = 1e9;
	long long int res = 1e18;
	while(lo<=hi)
	{
		long long int sum = 0;
		long long int mid = (lo + hi)/2;
		for(int i=0;i<n;i++)
		{
			sum += ((v[i]*1.0)/mid);
		}
		//cout << sum << ' ' << mid << '\n';
		if(sum <= k)
		{
			res = min(res,mid);
			hi = mid - 1;
		}
		else
		{
			lo = mid + 1;
		}
	}
	cout << res << '\n';

	/*
	priority_queue <double> pque;
	for(int i=0;i<n;i++)
	{
		pque.push(v[i]);
	}

	for(int i=0;i<k;i++)
	{
		if(pque.top()<=1.0)
		{
			break;
		}
		double x = pque.top();
		pque.pop();
		pque.push(x/2);
		pque.push(x/2);
	}

	cout << (long long int)(ceil(pque.top())) << '\n';
	*/

	return 0;
}


Measured memory_bytes: 4276
n,m,q = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(m)]
p = [list(map(int, input().split()))+ [i] for i in range(q)]
l.extend(p)
l = sorted(l,key= lambda x:x[1])
ka = [0] * n
ans = []
for i in l:
  if len(i) == 2:
    ka[i[0]-1] += 1
  else:
    ans.append([i[2],sum(ka[i[0]-1:i[1]])])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i][1])

Measured memory_bytes: 122584
"use strict";
var fs = require("fs");
var input = fs.readFileSync("/dev/stdin", "utf8");
var _a = input.split(" ").map(function (char) { return parseInt(char, 10); }), N = _a[0], D = _a[1];
var answer = Math.ceil(N / (D * 2 + 1));
console.log(answer);


Measured memory_bytes: 7372
[N,K] = list(map(int,input().split()))
A = list(map(int,input().split()))

flag=[0]*N
patt=[]
i=0
while True:
    patt.append(i)
    if flag[i]==1:
        break
    flag[i]=1
    i=A[i]-1

srt = patt.index(patt[-1])
end = len(patt)-2
ptrn = patt[srt:end+1]

if K<srt:
    print(patt[K]+1)
else:
    B = (K-srt) % len(ptrn)
    print(ptrn[B]+1)

Measured memory_bytes: 95228
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    string s,t;cin>>s>>t;
    int a=s.size(),b=t.size();
    string tmp;
    int ans=inf;
    rep(i,a-b+1){
        tmp=s.substr(i,b);
        int res=tmp.size();
        int sum=0;
        rep(j,res)if(t[j]!=tmp[j])sum++;
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;
using tp = tuple<ll,ll,ll,ll>;

// タプルの最初の要素から順番に比較　もしその要素が同じなら次の要素で比較
bool mycompare( const tp &lhs, const tp &rhs )
{
    return std::get<2>(lhs) < std::get<2>(rhs);
}


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

    //write here
    ll N,M;
    vector<tp> pv;

    cin >> N >> M;
    REP(i,M){
        ll p,y;
        cin >> p >> y;
        pv.push_back(make_tuple(p,y,i,0));
    }

    sort(ALL(pv));

    int p = 0;
    int counter =0;
    REP(i,M){
        counter++;
        if( p == std::get<0>(pv[i])){
            std::get<3>(pv[i]) = counter;
        }
        else{
            counter = 1;
            std::get<3>(pv[i]) = counter;
            p = get<0>(pv[i]);
        }
    }

    sort(pv.begin(),pv.end(),mycompare);

    REP(i,M){
        std::ostringstream su;
        su << std::setw(6) << std::setfill('0') << get<0>(pv[i]);
        std::ostringstream sl;
        sl << std::setw(6) << std::setfill('0') << get<3>(pv[i]);

        string s(su.str() + sl.str());
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 6576
#include <iostream>

void printResult(int a, char op, int b) {
	int result = 0; 
	if (op == '+')
		result = a + b;
	else if (op == '-')
		result = a - b;
	else if (op == '*')
		result = a * b;
	else if (op == '/')
		result = a / b;
	std::cout << result << "\n";
}

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

	while (op != '?') {
		printResult(a, op, b);
		std::cin >> a >> op >> b;
	}
    return 0;
}




Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

char ans[100123];
int x[101];

int main()
{
	int n;
	cin >> n;
	LL sum = 0;
	for(int i = 'A'; i <= 'C'; ++i) cin >> x[i], sum += x[i];
	if(sum == 0) {
		puts("No");
		return 0;
	}
	else if(sum == 1) {
		char a, b;
		Rep(i, n) {
			scanf(" %c%c", &a, &b);
			if(x[a] < x[b]) swap(a, b);
			if(x[a] == 0) {
				puts("No");
				return 0;
			}
			x[a] = 0; x[b] = 1; ans[i] = b;
		}
	}
	else if(sum == 2) {
		char a, b, s[3];
		Rep(i, n) {
			scanf(" %c%c", &a, &b);
			if(x[a] < x[b]) swap(a, b);
			if(x[a] == 0) {
				puts("No");
				return 0;
			}
			if(x[b] == 1) {
				scanf("%s", s);
				char c = a;
				rep(i, 2) if(s[i] == b) c = b;
				char d = a + b - c;
				x[d] = 0; ans[i++] = c;
				rep(i, 2) if(s[i] != c) d = s[i];
				x[d] = 1; ans[i] = d;
			}
			else --x[a], ++x[b], ans[i] = b;
		}
	}
	else {
		char a, b;
		Rep(i, n) {
			scanf(" %c%c", &a, &b);
			if(x[a] < x[b]) swap(a, b);
			if(x[a] == 0) {
				puts("No");
				return 0;
			}
			--x[a]; ++x[b]; ans[i] = b;
		}
	}
	puts("Yes");
	Rep(i, n) printf("%c\n", ans[i]);
	return 0;
}


Measured memory_bytes: 3880
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    vector<ll> a(m);
    rep(i, m) cin >> a[i];
    vector<ll> dp(n+100, 0);
    dp[0] = 1;
    dp[1] = 1;
    if(binary_search(all(a), 1)) dp[1] = 0;
    for(ll i = 2; i <= n; i++){
        if(binary_search(all(a), i)) continue;
        if(!(binary_search(all(a), i)))
            dp[i] = ((dp[i-1] % MOD) + (dp[i-2] % MOD)) % MOD ;
    }
    cout << dp[n];
    cout << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <cassert>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

struct Work {
  int id;
  int s;
  int t;
  int x;

  Work (int id = -1, int s = -1, int t = -1, int x = -1) {
    this->id = id;
    this->s = s;
    this->t = t;
    this->x = x;
  }

  bool operator>(const Work &w) const {
    return x > w.x;
  }
};

int main() {
  int N, Q;
  cin >> N >> Q;

  vector<Work> works;
  int s, t, x;
  for (int i = 0; i < N; ++i) {
    cin >> s >> t >> x;

    works.push_back(Work(i, s, t, x));
  }

  vector<int> D;
  int d;
  for (int i = 0; i < Q; ++i) {
    cin >> d;
    D.push_back(d);
  }
  D.push_back(INT_MAX);

  map<int, vector<Work> > start_works;
  map<int, vector<int> > finish_works;

  for (int i = 0; i < N; ++i) {
    Work work = works[i];

    int start_time = work.s - work.x;
    int finish_time = work.t - work.x - 1;

    int left = lower_bound(D.begin(), D.end(), start_time) - D.begin();
    int right = upper_bound(D.begin(), D.end(), finish_time) - D.begin();

    start_works[left].push_back(work);
    finish_works[right].push_back(work.id);
  }

  priority_queue <Work, vector<Work>, greater<Work> > pque;

  bool finished[N];
  memset(finished, false, sizeof(finished));

  for (int i = 0; i < Q; ++i) {
    for (int j = 0; j < start_works[i].size(); ++j) {
      Work work = start_works[i][j];
      pque.push(work);
    }

    for (int j = 0; j < finish_works[i].size(); ++j) {
      int work_id = finish_works[i][j];
      finished[work_id] = true;
    }

    while (!pque.empty() && finished[pque.top().id]) {
      pque.pop();
    }

    if (pque.empty()) {
      cout << -1 << endl;
    } else {
      cout << pque.top().x << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 50796
#include <iostream>
using namespace std;
int main()
{
    int H, W;
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
            
        }
        for(int j = 0; j < W; j++) {
            cout << '#';
        }
        cout << endl;
        for(int i = 1; i < H-1; i++){
                cout << '#';
                for(int j = 1; j < W-1; j++) {
                     cout << '.';
            }
            cout << '#' << endl;
        }
        for(int j = 0; j < W; j++) {
        cout << '#';
        }
        cout << endl << endl;
    } 
    
}



Measured memory_bytes: 3108
x, y, z = input().split()
x = int(x)
y = int(y)
z = int(z)

tmp = None


if x > z:
    tmp = x
    x = z
    z = tmp
if x > y:
    tmp = x
    x = y
    y = tmp
if y > z:
    tmp = y
    y = z
    z = tmp

print(str(x) +' ' + str(y) + ' ' + str(z))


Measured memory_bytes: 5592
#include <cstdio>
#include <queue>
using namespace std;

struct PROCESS{
    char name[11];
    int time;
};

int main(int argc, char const *argv[]) {
    int n, q, total_time = 0;
    queue<PROCESS> process_queue;
    PROCESS process;

    scanf("%d %d", &n, &q);
    for(int i=0 ; i<n ; i++){
        scanf("%s %d", process.name, &process.time);
        process_queue.push(process);
    }

    // ?????\?????????????????£????????????
    while(!process_queue.empty()){
        process = process_queue.front();
        // ????????????????????????????????\????????´???
        if(process.time <= q){
            total_time += process.time;
            printf("%s %d\n", process.name, total_time);
        }
        // ????????????????????????????????????????????´???
        else{
            total_time += q;
            process.time -= q;
            process_queue.push(process);
        }
        process_queue.pop(); // ??????????´??????????
    }

    return 0;
}

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

using namespace std;

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

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int count = 0;
    rep(i, n - 2) if(s.substr(i,3) == "ABC")  count++;
    cout << count;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int K, A, B;
    cin >> K >> A >> B;

    bool ok= (A%K== 0 || B%K == 0 || A/K<B/K);

    cout << (ok ? "OK" : "NG") << endl;

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    string wb="01";
    string bw="10";
    int ans=0;
    int temp1=0,temp2=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=wb[i%2])temp1++;
        if(s[i]!=bw[i%2])temp2++;
    }
    ans=min(temp1,temp2);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
PROGRAM Onigiri
 IMPLICIT NONE
 INTEGER::X,a
 INTRINSIC INT
 READ(*,*)X
 
 a=int(X/100)
 IF(X <= 105*a)THEN
   WRITE(*,*) 1
  ELSE
   WRITE(*,*) 0
 END IF

END PROGRAM Onigiri

Measured memory_bytes: 768
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*  ________       __      ________  _    __       __       ________               *
* |  ______|     /  \    |  ____  || |  / /      /  \     |  ____  |              *
* | |______     / /\ \   | |____| || |_/ /      / /\ \    | |____| |              *
* |______  |   / /__\ \  |  __  __||  __ \     / /__\ \   |  __  __|              *
*  ______| |  / ______ \ | |  \ \  | |  \ \   / ______ \  | |  \ \                *
* |________| /_/      \_\|_|   \_\ |_|   \_\ /_/      \_\ |_|   \_\               *
*                                                                                 *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________

#include<bits/stdc++.h>
using namespace std;


int main()
{
	long long N,i,cnt = 0;

    cin >> N;
    long long A[N+1];

    for(i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A,A+N);
    for(i = 0; i < N-1; i++)
    {
        if(A[i] == A[i+1])
        {
            cnt++;
            cout << "NO" << endl;
            break;
        }
    }
    if(cnt == 0)
    {
        cout << "YES" << endl;
    }

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long int idx[100001];
long long int power(long long int x,long long int y,long long int z)
{
    long long int res=1;
    x%=z;
    while(y>0)
    {
        if(y&1)
        res=(res*x)%z;
        x=(x*x)%z;
        y/=2;
    }
    return res;
}

long long int power1(long long int x,long long int y)
{
    long long int res=1;
    while(y>0)
    {
        if(y&1)
        res=(res*x);
        x=(x*x);
        y/=2;
    }
    return res;
}

long int root(long int x)
{
    while(idx[x]!=x)
    x=idx[x];
    return x;
}

void union1(long int x,long int y)
{
    idx[root(x)]=root(y);
}
long int n,w;
pair<long int,long int> a[101];
int main() {
	
	cin>>n>>w;
     for(long int i=0;i<n;i++)
     {
         cin>>a[i].first>>a[i].second;
     }
     
long long int dp[n+1][100001];
	for(long int i=0;i<=n;i++)
	{
	    for(long int j=0;j<100001;j++)
	    dp[i][j]=pow(10,18);
	}
	dp[0][0]=0;
	for(long int i=1;i<=n;i++)
	{
	    for(long int j=0;j<100001;j++)
	    {
	        dp[i][j]=min(dp[i][j],dp[i-1][j]);
	        if(j+a[i-1].second<100001)
	        {
	            dp[i][j+a[i-1].second]=min(dp[i][j+a[i-1].second],dp[i-1][j]+a[i-1].first);
	        }
	    }
	}
	long long int ans=0;
	for(long int i=0;i<100001;i++)
	{
	    if(dp[n][i]<=w)
	    ans=i;
	}
	cout<<ans;
	return 0;
}

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

const int mod = 1000000007;
// const int mod = 998244353;

struct mint
{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint &operator+=(const mint m)
    {
        if((x += m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-=(const mint m)
    {
        if((x += mod - m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator*=(const mint m)
    {
        (x *= m.x) %= mod;
        return *this;
    }
    mint operator+(const mint m) const
    {
        return mint(*this) += m;
    }
    mint operator-(const mint m) const
    {
        return mint(*this) -= m;
    }
    mint operator*(const mint m) const
    {
        return mint(*this) *= m;
    }
    mint pow(ll n) const
    {
        if(!n) return 1;
        mint m = pow(n>>1);
        m *= m;
        if(n & 1) m *= *this;
        return m;
    }
    mint inv() const { return pow(mod-2);}
    mint &operator/=(const mint m) { return *this *= m.inv();}
    mint operator/(const mint m) const { return mint(*this) /= m;}
};
istream &operator>>(istream &is, mint &m) { return is >> m.x;}
ostream &operator<<(ostream &os, const mint &m) { return os << m.x;}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    ll sum = accumulate(A.begin(), A.end(), 0LL);
    mint ans = 0;
    for(int i=0; i<N; i++)
    {
        ans += ((sum - A[i]) % mod) * A[i];
    }
    cout << ans / 2 << endl;

    return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll k;
ll a[100005];
ll dp[45][2];
int main(){
	cin>>n>>k;
	repn(i,n){
		scanf("%lld",&a[i]);
	}
	rep(a,45)rep(b,2)dp[a][b]=-10000000LL;
	dp[41][0] = 0;//cout<<dp[41][1]<<endl;
	for(int i=40;i>=0;i--){
		ll x = (((k>>i)&1LL)); //cout<<x<<endl;
		int cnt1 = 0;
		repn(j,n) cnt1 += (((a[j]>>i)&1LL));
		int cnt = n-cnt1;
		//cout<<cnt1<<endl;
		//cout<<(1LL<<i)*1LL*cnt1<<endl;
		if(dp[i+1][0]>=0) dp[i][(x==1)] = max(dp[i][(x==1)],dp[i+1][0]+(1LL<<i)*1LL*cnt1);
		if(dp[i+1][0]>=0 && x==1) dp[i][0] = max(dp[i][0],dp[i+1][0]+(1LL<<i)*1LL*cnt);
		if(dp[i+1][1]>=0) dp[i][1] = max(dp[i][1],dp[i+1][1]+(1LL<<i)*1LL*max(cnt,cnt1));
		//cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
	}
	cout<<max(dp[0][0],dp[0][1])<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,  x,  y) for(int i = x; i <= y; i ++)
#define ll long long
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define ls rt << 1
#define rs rt << 1 | 1
#define INF 0x3f3f3f3f
#define mod 1000000007
using namespace std;
ll a, b;
int main()
{
	cin >> a >> b;
	b /= a;
	int ans = 0;
	while (b) b >>= 1, ans ++;
	cout << ans;
	return 0;
}

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

int main() {
  int N;  cin >> N;
  int a[N][N]; REP(i, N) REP(j, N){cin >> a[i][j];}
  vector<vector<ll>> dp(N, vector<ll>(1<<N, 0));

  REP(k, N){
    if(a[0][k] == 0) continue;
    dp[0][1<<k] = 1;
  }

  REP(i, N-1) REP(k, 1<<N) if(dp[i][k]){
    REP(j, N){
      if(a[i+1][j] == 1 && !(1<<j & k) ){
        (dp[i+1][k+(1<<j)] += dp[i][k]) %= MOD;
      }
    }
  }

  ll ans = 0;
  REP(k, 1<<N){
    (ans += dp[N-1][k]) %= MOD;
  }
  
  cout << ans << endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	unordered_map<string, string> mp;
	mp["Sunny"]  = "Cloudy";
	mp["Cloudy"] = "Rainy";
	mp["Rainy"]  = "Sunny";
	string s;
	cin >> s;
	cout << mp[s];
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define int long long
const int N = 2001;
int a[N], b[N], s[N], n, m, k;
const int mod = 1e9 + 7;
long long ans = 0;

signed main() {
	cin >> n >> k;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i], b[a[i]] ++;
		m = max(m, a[i]);
	}
	
	for(int i = 1; i <= m; ++i) s[i] = s[i - 1] + b[i];
	
	for(int i = 1; i < n; ++i)
		for(int j = i + 1; j <= n; ++j)
			if(a[i] > a[j]) ++ans;
	
	ans = (ans * k) % mod;
	
	for(int i = 1; i <= m; ++i) {
		ans = (ans + 1LL * b[i] * s[i - 1] % mod * (k * (k - 1) / 2 % mod))% mod;
	}
	
	printf("%lld\n", ans % mod);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long

signed main() {
  int r;
  cin >> r;
  if (r < 1200) {
    cout << "ABC" << endl;
  } else if (r < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
template<typename tn> void read(tn &a){
    tn x=0,f=1;char c=' ';
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar() ) x=x*10+c-'0';
    a=x*f;
}
const int N=1e5+5;
int n,a[N],f[N],ans;
int main(){
    read(n);
    for(int i=1;i<=n;i++) read(a[i]);
    for(int i=1;i<=n;i++)
        if(a[i]<=a[i-1]) f[i]=f[i-1]+1,ans=max(ans,f[i]);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <utility>
#include <tuple>
#include <map>
#include <stack>
#include <queue>
#include <ctype.h>
#include <iomanip>
#include <bitset>
#include <set>
#include <ios>
#include <cstdlib>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    string S; cin >> S;
    int res=0;
    for (int i=2;i<N;i++){
        if (S[i-2]!='A'||S[i-1]!='B'||S[i]!='C') continue;
        res++;
    }
    cout << res << endl;
    return 0;
}

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

typedef long long ll;

#define REP(var,n) for(int var=0;var<(n);var++)
#define REPP(var,n) for(int var=1;var<(n);var++)
#define ALL(c) (c).begin(),(c).end()

int last_val(vector<int>& x){
    int tmp = x[x.size()-1];
    x.pop_back();
    return tmp;
}

int main(){
    int H,W;
    int tmp = 0;
    vector<int> x;
    vector<int> y;
    ll count = 0;

    cin >> H >> W;

    int a[H][W];
   
    // parse input data into list 
    REP(i, H){
        REP(j, W){
            cin >> tmp;
            tmp = tmp&1;
            a[i][j] = tmp;
        }
    }

    REP(i, H-1){
        REP(j, W){
            if(a[i][j] == 1){
                a[i][j] = 0;
                a[i+1][j] += 1;
                a[i+1][j] = a[i+1][j]&1;
                x.push_back(i);
                x.push_back(j);
            }
        }
    }

    REP(j,W-1){
        if(a[H-1][j] == 1){
            a[H-1][j] = 0;
            a[H-1][j+1] += 1;
            a[H-1][j+1] = a[H-1][j+1]&1;
            y.push_back(H-1);
            y.push_back(j);
        }
    }

    int x_len = x.size()/2;
    int y_len = y.size()/2;
    cout << (x_len + y_len) << endl;
    REP(a, x_len){
        int j = last_val(x);
        int i = last_val(x);
        cout << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
    }

    REP(a, y_len){
        int j = last_val(y);
        int i = last_val(y);
        cout << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
    }
}


Measured memory_bytes: 4212
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    s=input()
    s_c=Counter(s)
    if len(s)==1:
        print("YES")
    elif len(s)==2 and s[0]!=s[1]:
        print("YES")
    elif len(s)==3 and len(s_c.items())==3:
        print("YES")
    else:
        s_list=sorted(s_c.values())
        if len(s_list)==3:
            if s_list[2]-s_list[0]<=1:
                print("YES")
            else:
                print("NO")
        else:
            print("NO")

if __name__=='__main__':
    main()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  const int n = 3;

  int k;
  cin>>k;

  using M = Mint<int>;
  vector<M> dp(k+1,0);

  M ans{0};
  for(int i=k;i>0;i--){
    dp[i]=M(k/i).pow(n);
    for(int j=i+i;j<=k;j+=i)
      dp[i]-=dp[j];
    ans+=M(i)*dp[i];
  }

  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 3652
#include <iomanip>
#include <limits>
#include <thread>
#include <utility>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <list>
#include <functional>
#include <bitset>
#include <complex>
#include <tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;
typedef complex<D> P;
const ll E = 1e18 + 7;
const ll MOD = 1000000007;
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define fill(x, y) memset(x, y, sizeof(x))
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
template <class... A>
void prints() { cout << endl; }
template <class... A>
void prints_rest() { cout << endl; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

template <class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    int a;
    cin >> a;
    prints(3*a*a);

    return 0;
}



Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> x;
	int ans=0;
	for(int i=0;i!=n;++i){
		int temp;
		cin>>temp;
		ans+=temp-1;
	}
	cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int b = sc.nextInt();
		int w = sc.nextInt();
		long bunbo = 1;
		long allB = 0; //(i-1)CW+...+(i-1)C(i-1) at end
		long allW = 0; //(i-1)CB+...+(i-1)C(i-1) at end
		long tmp1 = 0; //(i-1)C(W-1) at end
		long tmp2 = 0; //(i-1)C(B-1) at end
		for (int i=1;i<=b+w;i++) {

			allB = (allB*2+tmp1)%MOD;
			allW = (allW*2+tmp2)%MOD;

			//System.out.println(allB+" "+allW);
			System.out.println(div((bunbo+allB-allW+MOD)%MOD, bunbo*2%MOD));
			
			//System.out.println(bunbo+allB-allW+" "+bunbo*2);
			
			tmp1 = (i-1>w-1)? div(tmp1*(i-1),i-1-w+1) : (i-1==w-1)? 1 : 0;
			tmp2 = (i-1>b-1)? div(tmp2*(i-1),i-1-b+1) : (i-1==b-1)? 1 : 0;
			
			//System.out.println(tmp1+" "+tmp2);
			bunbo = bunbo*2%MOD;
			
			
		}
	}
	public static long pow (long a, long b) {
		if (b==0) {
			return 1;
		} else if (b%2==0) {
			long tmp = pow(a,b/2);
			return tmp * tmp % MOD;
		} else  {
			long tmp = pow(a,b/2);
			return (tmp * tmp % MOD)*(a%MOD)%MOD;
		}
	}
	public static long div  (long a, long b) {
		return ((a%MOD) * pow(b, MOD-2))%MOD;
	}

}


Measured memory_bytes: 44384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
#define int long long
signed main()
{
    
    
    rep(i,5){
        int n;cin >>n;
        if(n == 0)return 0;
        rep(i,9){
            int x;cin >> x;
            n -= x;
        }
        cout << n << endl;


    }
    
    return 0;
}


Measured memory_bytes: 3004