akhauriyash/Code-Regression huggingface dataset:
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
map<string,int>dp;
inline string operator &(const string &a,const string &b){
	R int n=a.length();string c(n,'0');
	fp(i,0,n-1)c[i]=(a[i]=='1'&&b[i]=='1'?'1':'0');
	return c;
}
int dfs(string s){
	if(s.empty())return 1;
	if(dp.count(s))return dp[s];
	if(s.length()==1)return s[0]-'0'+1;
	R int res=mul(s[0]=='1'?2:1,dfs(s.substr(1)));
	R int n=s.length();
	fp(d,1,n){
		string t=s.substr(0,d);
		for(R int k=d;k<=n-d;k+=d){
			t=t&s.substr(k,d);
			upd(res,mul(dfs(t),dfs(s.substr(k+d))));
		}
	}
	return dp[s]=res;
}
int main(){
	string s;cin>>s;
	printf("%d\n",dfs(s));
	return 0;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
 int N,M,i,j;
 cin >> N >> M;
 
 vector<vector<int>> s(M);
 vector<int> p(M);
 
 rep(j,M){
  int k; cin >> k;
  s[j].resize(k);
  rep(i,k){
   cin >>s[j][i];
   --s[j][i];
  }
 }
 rep(j,M){
 cin >> p[j];
 }
 
int c=0;
int ans=0;
 
rep(i,(1<<N)){
 bool ok = true;
 rep(j,M){
 c=0;
  for(int id : s[j]){
   if((i>>id) & 1) c++;
  }
  c=c%2;
  if(c != p[j]) ok=false;
 }
if(ok) ++ans;
}
 
cout << ans << endl;
 
return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    rep(i, 3001) {
        rep(j, 3001) {
            int need = N - i * R - j * G;
            if (need >= 0 && need % B == 0) {
                ans++;
                //cout << i << " " << j << " " << need << endl;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

long long unsigned int a[100000];

int main()
{
	int n;
	scanf("%d\n", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%llu\n", &a[i]);
	}
	sort(a, a + n);
	long long unsigned int addVal = 0;
	long long unsigned int minusVal = 0;
	int numOfAddOne = n % 2 == 0 ? 1 : 2;
	int numOfMinusOne = n % 2 == 0 ? 1 : 0;
	int numOfAddDouble = (n - 2) / 2;
	int numOfMinusDouble = (n - 2) / 2 + (n % 2 == 0 ? 0 : 1);
	for (int i = 0; i < n; ++i)
	{
		if (numOfMinusDouble > 0)
		{
			minusVal += 2 * a[i];
			--numOfMinusDouble;
		}
		else if (numOfMinusOne > 0)
		{
			minusVal += a[i];
			--numOfMinusOne;
		}
		else if (numOfAddOne > 0)
		{
			addVal += a[i];
			--numOfAddOne;
		}
		else if (numOfAddDouble > 0)
		{
			addVal += 2 * a[i];
			--numOfAddDouble;
		}
	}
	long long unsigned int diffA = addVal - minusVal;
	addVal = 0;
	minusVal = 0;
	numOfAddOne = n % 2 == 0 ? 1 : 0;
	numOfMinusOne = n % 2 == 0 ? 1 : 2;
	numOfAddDouble = (n - 2) / 2 + (n % 2 == 0 ? 0 : 1);
	numOfMinusDouble = (n - 2) / 2;
	for (int i = 0; i < n; ++i)
	{
		if (numOfMinusDouble > 0)
		{
			minusVal += 2 * a[i];
			--numOfMinusDouble;
		}
		else if (numOfMinusOne > 0)
		{
			minusVal += a[i];
			--numOfMinusOne;
		}
		else if (numOfAddOne > 0)
		{
			addVal += a[i];
			--numOfAddOne;
		}
		else if (numOfAddDouble > 0)
		{
			addVal += 2 * a[i];
			--numOfAddDouble;
		}
	}
	long long unsigned int diffB = addVal - minusVal;
	printf("%llu\n", diffA > diffB ? diffA : diffB);
	return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

void ask(string s) {
	cout << "? " << s << endl;
	return;
}

void ask(ll s) {
	cout << "? " << s << endl;
	return;
}

int main() {
	string ques = "999999999999999";
	bool isfirst = true;
	int i, j;
	for (i = 0; i < 10; i++) {
		if (!isfirst) {
			ques[i] = '0';
			ask(ques);
			char res;
			scanf(" %c", &res);
			if (res == 'Y') {
				continue;
			}
		}
		else {
			isfirst = false;
		}

		int left = 0, right = 9;
		while (left + 1 < right) {
			int mid = (left + right) / 2;
			ques[i] = mid + '0';
			ask(ques);
			char res;
			scanf(" %c", &res);
			if (res == 'Y') {
				right = mid;
			}
			else {
				left = mid;
			}
		}
		ques[i] = right + '0';
	}
	ques = ques.substr(0, 10);
	for (i = 9; i >= 0; i--) {
		if (ques[i] != '0') {
			break;
		}
	}
	int left = i;
	bool nine = true;
	for (i = 0; i <= left; i++) {
		if (ques[i] != '9') {
			nine = false;
		}
	}

	for (i = 10; i >= left + 1; i--) {
		string s = ques.substr(0, i);
		ll temp = stoll(s);
		temp += 1;
		ask(temp);
		char res;
		scanf(" %c", &res);
		if (i != left + 1) {
			if (res == 'N') {
				cout << "! " << ques.substr(0, i + 1) << endl;
			}
		}
		else {
			if (!nine) {
				if (res == 'N') {
					cout << "! " << ques.substr(0, i + 1) << endl;
				}
				else {
					cout << "! " << ques.substr(0, i) << endl;
				}
			}
			else {
				if (res == 'N') {
					cout << "! " << ques.substr(0, i) << endl;
				}
				else {
					cout << "! " << ques.substr(0, i + 1) << endl;
				}
			}
		}
	}
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    map<ll, ll> m;
    ll ans=0;
    for(int i=0; i<n; i++){
        if(m.count(i-a.at(i))){
            ans += m[i-a.at(i)];
        }
        m[i+a.at(i)]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 17004
S = input()
N = len(S)+1
x = [0 for _ in range(N)]
l = 0
while(l<N-1):
    r = l+1
    while(r<N-1 and S[r]==S[l]):
        r += 1
    if S[l]=='<':
        x[l] = 0
        for i in range(l+1, r+1):
            x[i] = max(x[i], x[i-1]+1)
    else:
        x[r] = 0
        for i in range(r-1, l-1, -1):
            x[i] = max(x[i], x[i+1]+1)
    l = r
print(sum(x))

Measured memory_bytes: 29672
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"
using namespace std;
#define int long long


class ACalc {
public:
  constexpr int mpow(const int &a, int n) noexcept  {
    if(n == 0) return 1;
    auto t = mpow(a, n / 2);
    t = t * t;
    if(n & 1) t = t * a;
    return t;
  }
	void solve(std::istream& in, std::ostream& out) {
    int a;
    in >> a;
    out << a + mpow(a,2) + mpow(a,3) << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	ACalc solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3616
gets
odd_negatives = false
min_abs = 10000000000
sum = 0
gets.split.map(&:to_i).each{|n|
    if n < 0
        odd_negatives = !odd_negatives
    end

    ab = n.abs
    sum += ab
    if min_abs > ab
        min_abs = ab
    end
}

if odd_negatives
    sum -= min_abs * 2
end

puts sum


Measured memory_bytes: 8580
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    cost = [[f_inf] * n for _ in range(n)]
    for i in range(n):
        cost[i][i] = 0

    edge = []
    for _ in range(m):
        a, b, c = map(int, input().split())
        cost[a - 1][b - 1] = c
        cost[b - 1][a - 1] = c
        edge.append([c, a - 1, b - 1])

    for k in range(n):
        for i in range(n):
            for j in range(n):
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])

    res = 0
    for d, x, y in edge:
        if cost[x][y] < d:
            res += 1
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9304
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; i++) cin >> v[i];
    map<int, int> me, mo;
    for(int i=0; i<n; i+=2)
        me[v[i]]++;
    for(int i=1; i<n; i+=2)
        mo[v[i]]++;

    vector<pair<int, int>> vo, ve;
    for(auto x : me)
        vo.push_back(make_pair(n/2-x.second, x.first));
    for(auto x : mo)
        ve.push_back(make_pair(n/2-x.second, x.first));

    vo.push_back(make_pair(n/2, -1));
    ve.push_back(make_pair(n/2, -1));

    sort(vo.begin(), vo.end());
    sort(ve.begin(), ve.end());

    if(vo[0].second != ve[0].second)
        cout << vo[0].first + ve[0].first << endl;
    else{
        int ans = min(vo[0].first + ve[1].first, vo[1].first + ve[0].first);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 6520
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
	/*	BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String f = r.readLine();
		int a = Integer.parseInt(f);
		int d = 1;
		if(a == 0){
			return;
		}else{
			System.out.println("Case "+d+": "+a);
			d++;
			while(a > 1){
				BufferedReader w = new BufferedReader(new InputStreamReader(System.in));
				String wf= r.readLine();
				int q = Integer.parseInt(wf);
				System.out.println("Case "+d+": "+q);
				d++;
			}
		}*/
		Scanner a = new Scanner(System.in);
		int b = a.nextInt();
		int d = 1;
		if(b == 0){
			return;
		}else{
			System.out.println("Case "+d+": "+b);
			b = a.nextInt();
			d++;
			while(b >0){
				System.out.println("Case "+d+": "+b);
				b = a.nextInt();
				d++;
			}
		}
	}

}

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

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

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

bool sort_pair( std::pair< int64_t, std::string > origin, std::pair< int64_t, std::string > another )
{
    return origin.first < another.first;
}


int main()
{

    int64_t a,b,c;
    
    std::cin>> a;
    std::cin>> b;
    std::cin>> c;

    std::vector< int > d( a, 0 );
    int f;
    
    for( int i = 0; i < c; i++ )
    {
        std::cin>> f;
        d[f-1] += 1;
    }

    for( int i = 0; i < a; i++ )
    {
        int aa = c - d[i];
        
        if( b -aa  <= 0 )
        {
            std::cout<< "No" << "\n";
        } else
        {
            std::cout<< "Yes" << "\n";
        }
    }

}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n; cin >> n;
  vector<vector<int> > x(n), y(n);
  REP(i, n) {
    int a; cin >> a;
    x[i].resize(a);
    y[i].resize(a);
    REP(j, a) {
      cin >> x[i][j] >> y[i][j]; --x[i][j];
    }
  }
  int ans = 0;
  FOR(i, 1, 1 << n) {
    vector<bool> honest(n);
    REP(j, n) honest[j] = i >> j & 1;
    bool ok = true;
    REP(j, n) if (honest[j]) {
      int a = x[j].size();
      REP(k, a) {
        if (y[j][k] == 0 && honest[x[j][k]]) ok = false;
        if (y[j][k] == 1 && !honest[x[j][k]]) ok = false;
      }
    }
    if (ok) ans = max(ans, __builtin_popcount(i));
  }
  cout << ans << '\n';
  return 0;
}


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

int main(void){
	string S;
	cin >> S;
	int Slen = S.size();
	long long ans = 0;
	for(int i=0;i< (1<<Slen-1);i++){
		//iが00000から11111で
		//1だったら+がそこに存在するということで
		long long sum = 0;
		for(int j=0;j<Slen;j++){
			//jはS[]の添字に対応している
			if(j>0 && (i>>(j-1))&1){
				ans += sum;
				sum = S[j]-'0';
			}else{
				sum = 10*sum + S[j]-'0';
			}
		}
		ans += sum;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
using namespace std;
int visited[110][110][110];
int main() {
	int q, w, e;
	scanf("%d %d %d", &q, &w, &e);
	queue<pair<int, pair<int, int>>>qu;
	qu.push({ q,{w,e} });
	int cnt = 0;
	while (qu.size())
	{
		int ps = qu.size();
		while (ps--)
		{
			int a = qu.front().first;
			int b = qu.front().second.first;
			int c = qu.front().second.second;
			if (a == b&&b == c)
			{
				printf("%d", cnt);
				return 0;
			}
			qu.pop();
			if (!visited[a + 1][b + 1][c])
			{
				visited[a + 1][b + 1][c] = 1;
				qu.push({ a + 1,{b + 1,c} });
			}
			if (!visited[a + 1][b][c+1])
			{
				visited[a + 1][b][c+1] = 1;
				qu.push({ a + 1,{ b,c +1} });
			}
			if (!visited[a ][b + 1][c+1])
			{
				visited[a][b + 1][c+1] = 1;
				qu.push({ a,{ b + 1,c+1 } });
			}
			if (!visited[a + 2][b ][c])
			{
				visited[a +2][b][c] = 1;
				qu.push({ a+2,{ b,c } });
			}
			if (!visited[a][b+2][c])
			{
				visited[a][b+2][c] = 1;
				qu.push({ a ,{ b+2,c } });
			}
			if (!visited[a][b][c+2])
			{
				visited[a][b][c+2] = 1;
				qu.push({ a,{ b,c+2 } });
			}
		}
		cnt++;
	}
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>

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

typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const int sz=2e5+100;
int main()
{
    Khela
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    int t,cs;
    while(cin>>n)
    {
        ll sum=0;
        ll ara[n];
        for(i=0;i<n;i++) cin>>ara[i];
        for(i=0;i<n;i++)
        {
            for(j=i+1;j<n;j++)
            {
                if(i != j) sum+=(ara[i]*ara[j]);
            }
        }
        cout<<sum<<endl;
    }


}


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


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>n;
    ll aa[n];
    for0(n)
    {
        cin>>aa[i];
        if(i)c^=aa[i];
        else c=aa[i];
    }
    vector<ll> v;
    for0(n)
    {
        x=c^aa[i];
        v.push_back(x);
    }
    for0(v.size())
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}



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

using namespace std;

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

  vector<int> h(N, 0), dp(N+1, 1<<30);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }

  dp[0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 1; j <= K; j++) {
      dp[i+j] = min(dp[i+j], abs(h[i+j] - h[i]) + dp[i]);
    }
  }

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


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


int main(){
     stack<char>st;

     string s;
     cin>>s;

     int ans=0;

     for(int i=0;i<s.size();i++){
          if(st.empty())
            st.push(s[i]);

          else{
              char x=st.top();

              if(s[i]=='0' && x=='1'){
                st.pop();
                ans=ans+2;
                continue;
              }

              if(s[i]=='1' && x=='0'){
                st.pop();
                ans=ans+2;
                continue;
              }

              else
                st.push(s[i]);
          }
     }

     cout<<ans<<endl;





}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int ans = 0;
  int size = (S.size()-1)/2;

  REP(i,size){
      bool ok = true;
      REP(j,i){
        if (S[j]!=S[i+1+j])ok=false;
      }
      if(ok)ans=2*(i+1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <sstream>
#include <string>
#include <cmath>
#include <array>

using Card = std::array<int, 3*3>;

bool check_col(const Card& c) {
    for (int i=0; i<3; ++i) {
        if (c[0+i] && c[3+i] && c[6+i]) return true;
    }
    return false;
}

bool check_row(const Card& c) {
    for (int i=0; i<3; ++i) {
        if (c[i*3] && c[i*3 + 1] && c[i*3 + 2]) return true;
    }
    return false;
}

bool check_diag(const Card& c) {
    if (c[0] && c[4] && c[8]) return true;
    if (c[2] && c[4] && c[6]) return true;
    return false;
}

void open_if_exist(const Card& c, Card& h, int val) {
    for (int i = 0; i < 9; ++ i) {
        if (c[i] == val) { 
            h[i] = 1;
            return;
        }
    }
}

bool check(const Card& card, std::list<int> val) {
    Card hole{0};

    for (auto v: val) {
        open_if_exist(card, hole, v);
    }

    return check_col(hole) || check_row(hole) || check_diag(hole);
}


int main(int argc, char const* argv[])
{
    Card card{};
    std::string line;
    std::string elem;

    for (int i = 0; i < 3; ++i) {
        getline(std::cin, line);
        std::stringstream ss(line);
        for (int j = 0; j < 3; ++j) {
            getline(ss, elem, ' ');
            card[i*3 + j] = std::stoi(elem);
        }
    }

    int n; 
    getline(std::cin, line);
    n = std::stoi(line);

    std::list<int> vallist{};
    while( getline(std::cin, line) ) {
        vallist.push_back(std::stoi(line));
    }

    std::cout << (check(card, vallist) ? "Yes" : "No") << std::endl;

    return 0;
}


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

int main(){
  int n,r;
  cin>>n>>r;
  if(n>=10){
    cout<<r<<endl;
  }
  else{
    cout<<r+100*(10-n)<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
/*************************
author : coldbeer
2019-05-25 05:56:09 PM IST
*************************/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

typedef long long ll;
vector<ll> arr;

int main()
{
	ll n,m; cin >> n >> m;
	arr.assign(n + 1,0);
	for(int i = 1;i < n + 1;i++)
		cin >> arr[i];

	sort(arr.begin() + 1,arr.end());
	ll curr = 0;
	vector<pair<ll,ll>> query(m);
	ll ctr = 0;
	while(ctr < m){
		ll b,c; cin >> b >> c;
		query[ctr] = {c,b};
		ctr++;
	}
	sort(query.rbegin(),query.rend());
	ctr = 0;
	while(ctr < m){
		ll c = query[ctr].first,b = query[ctr].second;
		if(curr + 1 < n + 1 && c >= arr[curr + 1]){
			auto it = lower_bound(arr.begin() + curr + 1,arr.end(),c + 1) - arr.begin();
			ll idx = it - 1;
			idx = min(idx - curr,b);
			curr += idx;
			arr[curr] = c;
		}
		ctr++;
	}
	ll ans = 0;
	ll mx = -1,idx = curr;
	for(int i = idx + 1;i < n + 1;i++) ans += arr[i];
	for(int i = idx;i >= 1;i--){
		mx = max(mx,arr[i]);
		ans += mx;
	}

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


Measured memory_bytes: 2560
#include <string>
#include <iostream>
using namespace std;
string s; int n, h;
int main() {
	while(cin >> s) {
		if(s == "-") break;
		cin >> n;
		for(int i = 0; i < n; i++) {
			cin >> h;
			s = s.substr(h, s.size() - h) + s.substr(0, h);
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3220
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        int sum1 = N*A;
        int sum2 = B;
        if(sum1<sum2){
            System.out.println(sum1);
        }else{
            System.out.println(sum2);
        }
    }
}


Measured memory_bytes: 35676
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cctype>
using namespace std;

int main(){
	string card;int h,m;
	string a,b;
	
	while(true){
		cin>>card;
		if(card=="-")break;
		cin>>m;
		for(int i=0;i<m;i++){
			cin>>h;
			a=card.substr(0,h);
			b=card.substr(h,card.size());
			card=b+a;
		}
		cout<<card<<endl;
	}

return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> vec;
    int n, i, t;
    int maxN, beforeMax;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &t);
        vec.push_back(t);
    }
    vector<int> tmpVec = vec;
    sort(tmpVec.begin(), tmpVec.end());
    maxN=tmpVec[n-1];
    beforeMax=tmpVec[n-2];
    for(i=0; i<n; i++){
        if(vec[i]!=maxN){
            printf("%d\n", maxN);
        }
        else if(vec[i]==maxN){
            printf("%d\n", beforeMax);
        }
    }
    return 0;
}


Measured memory_bytes: 3316
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, Q: int, A: "List[int]"):

    arr = [K - Q] * N

    for a in A:
        arr[a - 1] += 1

    for go_or_not in arr:
        if go_or_not > 0:
            print("Yes")
        else:
            print("No")

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(Q)]  # type: "List[int]"
    solve(N, K, Q, A)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10444
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 2600;
const int inf = 1001001001;
int N,M,P;
vector<int> V[max_n];
vector<int> rV[max_n];
bool from[max_n];
bool to[max_n];
bool ok[max_n];

void dfs(int x) {
    if(from[x])
        return;
    from[x] = true;
    for(auto u: V[x]) {
        dfs(u);
    }

    return;
}

void rdfs(int x) {
    if(to[x])
        return;
    to[x] = true;
    for(auto u: rV[x]) {
        rdfs(u);
    }

    return;
}

int main(void) {
    cin>>N>>M>>P;
    vector<tuple<int,int,int>> edges;

    for(int i = 0;i < M;i++) {
        int a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        c -= P;
        c = -c; //to solve minimize distance
        edges.emplace_back(a,b,c);
        V[a].push_back(b);
        rV[b].push_back(a);
    }

    dfs(0);
    rdfs(N-1);
    for(int i = 0;i < N;i++)
        ok[i] = to[i]&&from[i];

    {
        vector<int> d(N,inf);
        d[0] = 0;
        bool upd = true;
        int step = 0;
        while(upd) {
            upd = false;
            for(int i = 0;i < M;i++) {
                int a,b,c;
                tie(a,b,c) = edges[i];

                if(!ok[a])
                    continue;
                if(!ok[b])
                    continue;
                int newD = d[a]+c;
                if(newD < d[b]) {
                    upd = true;
                    d[b] = newD;
                }
            }
            step++;
            if(step > N) {
                cout<<-1<<endl;
                return 0;
            }
        }
        int ans = -d[N-1];
        cout<<max(ans,0)<<endl;
    }

    return 0;
}


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

int main()
{
	int a, b;
	string op = "";
	cin >> a >> op >> b;
	while (1)
	{
		if (op == "?")
		{
			return 0;
		}
		if (op == "+")
		{
			cout << a + b << "\n";
			cin >> a >> op >> b;

		}
		if (op == "-")
		{
			cout << a - b << "\n";
			cin >> a >> op >> b;

		}
		if (op == "*")
		{
			cout << a * b << "\n";
			cin >> a >> op >> b;

		}
		if (op == "/")
		{
			cout << a / b << "\n";
			cin >> a >> op >> b;
		}
	}

	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cerr << #v "=" << (v) << endl;
#define ppa(v) cerr << "- " << #v << endl; rep(i,v.size()) cerr << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define INF 0x3f3f3f3f
#define LLINF 1000111000111000111LL
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;

int main() {
  int n;cin>>n;
  vector<int> a(n); rep(i,n) cin>>a[i];
  int val = 1;
  rep(i,n) if (val==a[i]) val++;
  int ans = (val==1) ? -1 : n - val + 1;
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k;
	cin>>n>>k;
	vector<int> vec(n, 0);
	for(int i = 0; i < n; ++i){
		cin>>vec[i];
	}
	int res = 0;
	int cnt = 1;
	while(cnt < n){
		cnt += k - 1;
		res++;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	int n, k;
	cin >> n ;
	
	int tmp = 0;
	vector<int> num (n,0);
	
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		num.at(tmp-1) = i+1;
	}
	
	for ( int i = 0; i < n; i++) {
		if(i < n-1){
			cout << num.at(i) << " ";
		} else {
			cout << num.at(i) << endl;
		}
	}
	
	
	return 0;
}


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

int main() {
    long A, B;
    long long ans = 1;
    cin >> A >> B;

    for(long i = min(A,B); i > 1; --i){
        if(A % i == 0 && B % i == 0){
            ans *= i;
            A /= i;
            B /= i;
        }
    }
    ans *= A * B;

    cout << ans << endl;
}

Measured memory_bytes: 256
# チェスボードの描画

while True:
    H, W = map(int, input().split())
    if H==0 and W==0: # stop condition
        break

    for h in range(H):
        if h%2==0:
            for w in range(W):
                if w%2==0:
                    print("#", end="")
                else:
                    print(".", end="")
        else:
            for w in range(W):
                if w%2==0:
                    print(".", end="")
                else:
                    print("#", end="")
        print()
    print()



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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readA(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		K = Integer.parseInt(strArr[0]);
		N = Integer.parseInt(strArr[1]);
		// System.out.println(N);
	}

	int K;

	public void readA(String str) {
		String[] strArr = str.split("\\s+");
		int[] A = new int[N + 1];
		for (int i = 1; i <= N; i++) {
			A[i] = Integer.parseInt(strArr[i - 1]);
		}
		A[0] = A[N] - K;
		int dMax = A[1] - A[0];
		int start = 1;
		for (int i = 1; i <= N; i++) {
			if (A[i] - A[i - 1] > dMax) {
				dMax = A[i] - A[i - 1];
				start = i;
			}
		}
		System.out.println(K - dMax);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 50072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  while(cin>>n,n){
    int i;
    for(i=0;n!=1;i++) if(n%2) n=n*3+1; else n/=2;
    cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define MID ((l+r)>>1)
#define lc (rt<<1)
#define rc (rt<<1|1)
#define ls lc,l,MID
#define rs rc,MID+1,r
#define st 1,1,n
#define PII pair<int,int>
#define PLL pair<LL,LL>
using namespace std;
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
const int N=1e5+1;
const LL M=1e18;
/*int main(){Accel
	LL n,h,s=0,md=0,x,y;
	cin>>n>>h;
	priority_queue<LL>q;
	REP(i,n){
		cin>>x>>y;	
		q.push(y);
		md=max(md,x);
	}
	while(h>0&&q.size()){
		if(q.top()<=md)break;
		h-=q.top(),s++,q.pop();
	}
	while(h>0)h-=md,s++;
	cout<<s<<endl;
}*/
PII p[N];
bool cmp(PII a,PII b){
	return a.F>b.F;
}
int main(){Accel
	int n,h,s=0,md=0,x,y;
	cin>>n>>h;
	REP(i,n){
		cin>>x>>y;
		p[i].S=x,p[i].F=y;//b,a
		md=max(md,x);
	}
	sort(p,p+n,cmp);
	REP(i,n)
		if(p[i].F>md&&h>0)h-=p[i].F,s++;
	while(h>0)h-=md,s++;
	cout<<s<<endl;
	
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;

int main()
{
    ll q;
    cin >> q;
    ll tmp = 0;
    ll ans = 0;
    priority_queue<ll, vector<ll>, less<ll>> que1;
    priority_queue<ll, vector<ll>, greater<ll>> que2;
    for (int i = 0; i < q; i++)
    {
        ll x;
        cin >> x;
        if (x == 1)
        {
            ll a, b;
            cin >> a >> b;
            tmp += b;
            que1.push(a);
            que2.push(a);
            if (que1.top() > que2.top())
            {
                ll c = que1.top();
                ll d = que2.top();
                que1.pop();
                que2.pop();
                que1.push(d);
                que2.push(c);
                ans += (c - d);
            }
        }
        else
        {
            cout << que1.top() << " " << ans + tmp << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4588
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)
	ans := 0
	xorSeq := 0
	sum := 0
	r := 0
	for l := 0; l < N; l++ {
		for r < N && (xorSeq^A[r] >= sum+A[r]) {
			xorSeq ^= A[r]
			sum += A[r]
			r++
		}
		if xorSeq == sum {
			ans += r - l
		}
		if r == l {
			r++
		} else {
			xorSeq ^= A[l]
			sum -= A[l]
		}
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }

func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 5088
N = int(input())
A = input()
B = A.split()
for i in range(N) :
    for j in range(N-1, i, -1) :
        if int(B[j][1]) < int(B[j-1][1]) :
            B[j], B[j-1] = B[j-1], B[j]
print(" ".join(B))
print("Stable")

C = A.split()
for i in range(N) :
    mini = i
    for j in range(i, N) :
        if int(C[j][1]) < int(C[mini][1]) :
            mini = j
    C[i], C[mini] = C[mini], C[i]
print(" ".join(C))
if B == C :
    print("Stable")
else :
    print("Not stable")


Measured memory_bytes: 5600
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int S[101];
int top;

void initialize(){
	top = 0;
}

int isEmpty(){
	return top == 0;
}

int isFull(){
	return top >= 100;
}

void push(int x){
	if(isFull()){
		printf("error: stack full, can't push %d\n", x);
	}
	top++;
	S[top] = x;
}

int pop(){
	if(isEmpty()){
		return -1;
	}
	top--;
	return S[top+1];
}

int main(void){
	int a, c;
	int x;
	initialize();
	while((c = getchar()) != EOF){
		if(isdigit(c)){
			ungetc(c, stdin);
			scanf("%d", &x);
			push(x);
		}else{
			switch(c){
				case '+':
					push(pop()+pop());
					break;
				case '-':
					a = pop();
					push(pop()-a);
					break;
				case '*':
					push(pop()*pop());
					break;
				case '\n':
					printf("%d\n", pop());
					return 0;
				case ' ':
					break;
				default:
					printf("Invalid input.\n");
					break;
			}
		}
	}
}

Measured memory_bytes: 1768
#include <bits/stdc++.h>
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#include <iomanip>
//    int n=132;
//    bitset<16>binar(n);
//    int a = bitset<16>(binar).to_ulong();
//    cout<<a;
 
#define int long long
#define pb push_back
#define rep(i,b) for ( int i = 0; i < b; i++)
#define rep1(i,b) for ( int i = 1; i <= b; i++)
#define all(c) (c).begin(),(c).end()
#define MOD 100000007
#define pi  3.14159265358979323846
 
using namespace std;
 
signed main()
{
	string s,s1;
	cin>>s>>s1;
	bool b = true;
	rep(i,s.size()){
		if(s[i]!=s1[i]){
			b =false;
		}
	}
		
	if(b){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}	
		
	}
	
	
	

		
	
	


Measured memory_bytes: 3612
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	char s[50];
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	if (s[k - 1] == 'A')
		s[k - 1] = 'a';
	else if (s[k - 1] == 'B')
		s[k - 1] = 'b';
	else if (s[k - 1] == 'C')
		s[k - 1] = 'c';
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <fstream>
using namespace std;
int main(){
    long long x,y,i,s=0;
    cin>>x>>y;
    for(i=x; i<=y; i*=2)
        ++s;
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals
#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <numeric>
#include <map>

std::map<intmax_t, intmax_t> memo;

intmax_t f(intmax_t h) {
  if (h == 1) return 1;
  auto it = memo.find(h);
  if (it != memo.end()) return it->second;

  intmax_t res = 2 * f(h/2) + 1;
  memo[h] = res;
  return res;
}

int main() {
  size_t h, n;
  scanf("%zu %zu", &h, &n);

  std::vector<std::pair<size_t, int>> ab(n);  // {value, cost}
  for (auto& p: ab) {
    scanf("%zu %d", &p.first, &p.second);
  }

  int const inf = 1e9;
  size_t m = 1e5;
  std::vector<int> dp(m+1, inf);
  // dp[j]: 価値 j を達成するための最小コスト
  dp[0] = 0;
  for (size_t i = 0; i < n; ++i) {
    for (size_t j = 0; j <= m; ++j) {
      if (j-ab[i].first <= m)
        dp[j] = std::min(dp[j], dp[j-ab[i].first] + ab[i].second);
    }
  }

  for (size_t j = m; j--;)
    dp[j] = std::min(dp[j], dp[j+1]);

  printf("%d\n", dp[h]);
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/


int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    N%=100;
    N%=10;

    if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
        cout << "hon" << endl;
    }
    else if (N == 0 || N == 1 || N == 6 || N == 8) {
        cout << "pon" << endl;
    }
    else {
        cout << "bon" << endl;
    }

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=100005,mod=19260817;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int ans[max_n];
int a[max_n];//µãÈ¨
struct Edge
{
    int from,to;
};
vector<Edge>g[max_n];
void add(int u,int v)
{
    g[u].push_back({u,v});
    g[v].push_back({v,u});
}
int main()
{
    int n,m;cin>>n>>m;int x,y;
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
    	ans[i]=-1;
	}
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		add(x,y);
	}
	for(int i=1;i<=n;i++)
	{
		if(g[i].size()==0)
		{
			ans[i]=1;
		}
		else
		{
			if(ans[i]==-1)
			{
				ans[i]=1;
			}
			for(vector<Edge>::iterator it=g[i].begin();it!=g[i].end();it++)
			{
				if(a[i]<=a[it->to])
				{
					ans[i]=0;
				}
			}
		}
	}
	int ans1=0;
	for(int i=1;i<=n;i++)
	{
		if(ans[i])
		{
			ans1++;
		}
	}
	cout<<ans1;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  double ans = 0;
  for(int i=0;i<n;i++){
      double x;
      string s;
      cin >> x >> s;
      if(s=="JPY"){
          ans += x;
      }
      else{
          ans += x*380000.0;
      }
  }
  cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
N = gets.to_i
ary = gets.chomp.split(" ").map(&:to_i)
countary = Array.new(N, 0)
ans = 0

ary.each do |i|
    countary[i - 1] += 1 
end

countary.each do |a|
    if a >= 2
        ans += a * (a - 1) / 2
    end
end

N.times do |i|
    if countary[ary[i] - 1] >= 2
        puts ans - countary[ary[i] - 1] + 1
    else
        puts ans
    end
end



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

void fnInput(vector<int>& rvnElm, vector<int>& rvnTrg )
{
  int nElmCnt, nTrgCnt;
  cin >> nElmCnt;

  rvnElm.resize(nElmCnt);
  for (int i = 0; i < nElmCnt; i++)
    cin >> rvnElm[i];

  cin >> nTrgCnt;

  rvnTrg.resize(nTrgCnt);
  for (int i = 0; i < nTrgCnt; i++)
    cin >> rvnTrg[i];
}

void fnDPtblMake(vector<vector<int>>& rvvnDP, const vector<int>& cnrvnElm, int nMaxTrg)
{
  rvvnDP[cnrvnElm.size()][0] = 1;
  for (int j = 1; j <= nMaxTrg; j++)
    rvvnDP[cnrvnElm.size()][j] = 0;

  for (int i = cnrvnElm.size() - 1; i >= 0; i--)
    for (int j = 0; j <= nMaxTrg; j++)
      if (j < cnrvnElm[i])
        rvvnDP[i][j] = rvvnDP[i + 1][j];
      else
        rvvnDP[i][j] = rvvnDP[i + 1][j] || rvvnDP[i + 1][j - cnrvnElm[i]];
}

void fnExhSch(const vector<int>& cnrvnElm, const vector<int>& cnrvnTrg)
{
  vector<vector<int>> vvnDP(21, vector<int>(2001, -1));

  int nMaxTrg = cnrvnTrg[0]; 
  for (int i = 1; i < cnrvnTrg.size(); i++)
    nMaxTrg = max(nMaxTrg, cnrvnTrg[i]);

  fnDPtblMake(vvnDP, cnrvnElm, nMaxTrg);

  for (int i = 0; i < cnrvnTrg.size(); i++)
    if (vvnDP[0][cnrvnTrg[i]])
      cout << "yes" << endl;
    else
      cout << "no" << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnElm, vnTrg;

  fnInput(vnElm, vnTrg);
  fnExhSch(vnElm, vnTrg);

  return 0;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n,d;
cin>>n>>d;
vector<ll>x(n),y(n);
rep(i,n)cin>>x[i]>>y[i];
int res=0;
ll dd=d*d;
rep(i,n){
    if(x[i]*x[i]+y[i]*y[i]<=dd)res++;
}
cout<<res<<endl;
return 0;
}

Measured memory_bytes: 6368
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,x,y=map(int,input().split())
    x-=1; y-=1
    E=[[] for _ in range(n)]
    for _ in range(n-1):
        u,v=map(int,input().split())
        u-=1; v-=1
        E[u].append(v)
        E[v].append(u)

    # x,y それぞれの depth を計算する
    dx=[None]*n
    dx[x]=0
    Q=[(x,-1)]
    while(Q):
        v,p=Q.pop()
        for nv in E[v]:
            if(nv==p): continue
            dx[nv]=dx[v]+1
            Q.append((nv,v))

    dy=[None]*n
    dy[y]=0
    Q=[(y,-1)]
    while(Q):
        v,p=Q.pop()
        for nv in E[v]:
            if(nv==p): continue
            dy[nv]=dy[v]+1
            Q.append((nv,v))

    # x の方が y より近い点 v に対して、その1つ手前で捕まる
    ans=0
    for v in range(n):
        if(dx[v]<dy[v]):
            ans=max(ans,dy[v]-1)

    print(ans)
resolve()

Measured memory_bytes: 66616
//Let's join Kaede Takagaki Fan Club !!
//明日は高垣楓さんの誕生日！おめでとうございます！！！
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#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())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
int a[200005], b[200005], n, k;
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> k;
	repn(i, n) cin >> a[i];
	
	rep(loop, k){
		repn(i, n) if(a[i] != n) goto nxt;
		break;
		
		nxt:;
		memset(b, 0, sizeof(b));
		repn(i, n){
			int L = i - a[i], R = i + a[i];
			L = max(L, 1);
			R = min(R, n);
			b[L]++; b[R+1]--;
		}
		for(int i=2;i<=n;i++) b[i] += b[i-1];
		repn(i, n) a[i] = b[i];
	}
	repn(i, n) cout << a[i] << " "; cout << endl; return 0;
}


Measured memory_bytes: 5188