akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;


class Graph{
    struct edge{
        int vertice;
        ll weight;
    };

    vector<vector<edge>> g;
    unsigned int n;

public:
    Graph(unsigned int n): n{n}{
        g.resize(n);
    }

    void add_edge(int u, int v){
        g[u].emplace_back(edge{v, 1});
    };

    void add_edge(int u, int v, ll w){
        g[u].emplace_back(edge{v, w});
    }

    vector<edge>& get_edge(int v){
        return g[v];
    }

    unsigned int size(){
        return n;
    }

    vector<edge>& operator[](int v){
        return get_edge(v);
    }
};

void dfs(int v, int prev, vector<int>& dp, vector<int>& a, Graph& g, int inf, vector<int>& res){
    int x = a[v];
    auto itr = upper_bound(dp.begin(), dp.end(), x);
    int updatedIndex = itr - dp.begin();
    int updatedValue = dp[updatedIndex];

    if(itr != dp.begin()) {
        itr--;
        if(*itr < a[v]) {
            dp[updatedIndex] = a[v];
        }
    }
    else{
        dp[updatedIndex] = a[v];
    }

    res[v] = lower_bound(dp.begin(), dp.end(), inf) - dp.begin();


    for(auto e: g[v]){
        if(e.vertice == prev)   continue;
        dfs(e.vertice, v, dp, a, g, inf, res);
    }

    dp[updatedIndex] = updatedValue;

}


int main(){
    int n;  cin >> n;
    vector<int> a(n);
    Graph g(n);
    int inf = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        inf = max(a[i], inf);
    }
    inf += 10;

    for(int i = 0; i < n-1; i++){
        int u, v;   cin >> u >> v;
        u--; v--;
        g.add_edge(u, v);
        g.add_edge(v, u);
    }

    vector<int> dp(n+10, inf);
    vector<int> res(n);
    dfs(0, 0, dp, a, g, inf, res);

    for(int i = 0; i < n; i++){
        cout << res[i] << endl;
    }


    return 0;
}


Measured memory_bytes: 39476
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,Y;

int main(){
    cin>>N>>Y;
    rep(i,N+1){
        rep(j,N-i+1){
                if(i*1000+5000*j+10000*(N-i-j)==Y){
                    printf("%d %d %d\n",(N-i-j),j,i);
                    return 0;
                }    
        }
    }
    printf("-1 -1 -1\n");
}


Measured memory_bytes: 256
program derangement
  implicit none
  integer :: n, a(100000), i, b(100000), m
  a = 0
  b = 0
  read(*,*) n
  read(*,*) a(1:n)
  do i = 1, n
    b(i) = 1
    if (a(i).eq.i) then
      b(i) = -1
    end if
  end do
  m = 0
  do i = 1, n-1
    if (b(i).lt.0) then
      b(i) = 1
      b(i+1) = 1
      m = m + 1
    end if
  end do
  if (b(n).eq.-1) m = m + 1
  write(*,'(i0)') m
  stop
end program derangement

Measured memory_bytes: 1536
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        String T = br.readLine();
        ArrayList<String> ans = new ArrayList<>();
        for (int i=0;i<=S.length()-T.length();i++){
            if (dd(i,S,T)){
                ans.add(constract(i,S,T));
            }
        }
        if (ans.isEmpty()){
            System.out.println("UNRESTORABLE");
        } else {
            Collections.sort(ans);
            System.out.println(ans.get(0));
        }
    }

    static boolean dd(int k,String s,String t){
        for (int i=0;i<t.length();i++){
            // tのi文字目がsのi+k文字目と違う 且つ sのi+k文字目が?ではない
            // trueの条件 => tのi文字目がsのi+k文字目と同じ もしくは sのi+k文字目が?である
            if (!String.valueOf(t.charAt(i)).equals(String.valueOf(s.charAt(i+k))) && !String.valueOf(s.charAt(i+k)).equals("?")){
                return false;
            }
        }
        return true;
    }

    static String constract(int k,String s,String t){
        StringBuffer ans = new StringBuffer(s);
        for (int i=0;i<t.length();i++){
            ans.setCharAt(i+k,t.charAt(i));
        }
        for (int i=0;i<s.length();i++){
            if (String.valueOf(ans.charAt(i)).equals("?")){
                ans.setCharAt(i, 'a');
            }
        }
        return String.valueOf(ans);
    }
}

Measured memory_bytes: 21332
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
  if a[i]+a[i+1] > b[i]:
    cnt += b[i]
    if a[i]<b[i]:
      a[i+1] = a[i+1]-(b[i]-a[i])
  else:
    cnt += a[i]+a[i+1]
    a[i+1] = 0
print(cnt)
    

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

#define INF 1000000000

int N,  X;

int main(){
	cin >> N >> X;
	int m[N];
	int mass = INF;
	int ans =0;
	for(int i=0;i < N;i++){
		cin >> m[i];
		mass = min(mass,m[i]);
		X-=m[i];ans++;
	}
	while(X>=mass){
		X-=mass;ans++;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

using lint = long long;
using ldouble = long double;

const lint MOD = 1e9 + 7;

vector<int> rec(int K, bool head, bool third) {
    if (K == 0) return {0};

    auto res = rec(K - 1, head, false);
    vector<int> ret;

    // head -> 1 ~ 9 (A, B) or 0 ~ 8 (C)
    for (int d = head && !third; d <= 9 - (head && third); ++d) {
        for (auto i : res) {
            ret.push_back(i + d);
        }
    }
    return ret;
}

bool solve() {
    string A[3];
    for (int i = 0; i < 3; ++i) {
        cin >> A[i];
        if (i == 0 && A[i] == "0") return false;
    }

    for (char& c : A[2]) {
        if (c != '?') c = '9' - c + '0';
    }
    int N = A[0].length();

    vector<vector<lint>> dp(N + 1, vector<lint>(3, 0));
    dp[0][0] = 1;
    for (int n = 1; n <= N; ++n) {
        int h = 0, num = 0;
        bool third = false;

        for (int i = 0; i < 3; ++i) {
            char c = A[i][n - 1];
            if (c == '?') {
                ++h;
                if (i == 2) third = true;
            } else {
                num += c - '0';
            }
        }

        auto pos = rec(h, n == 1, third);

        for (auto p : pos) {
            for (int d = 0; d < 3; ++d) {
                int sum = p + d + num;
                if ((sum % 10) != 9) continue;
                
                int r = sum / 10;
                (dp[n][d] += dp[n - 1][r]) %= MOD;
            }
        }
    }

    cout << dp[N][0] << endl;
    return true;
}

int main() {
    while (solve()){}
    return 0;
}



Measured memory_bytes: 3216
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include "algorithm"
#include <time.h>
#include "set"
#include "vector"
#include <iterator>

using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int dx[] = { -1,0,1,0 ,0 }, dy[] = { 0,1,0,-1,0 };
#define nxnycon (0<=nx&&nx<h&&0<=ny&&ny<w) 
#define lo long long int
#define  NN cout << "No"<<endl;
#define  YY cout << "Yes"<<endl;

lo a, n, s;





int main() {

	cin >> n;
	fori1(5) {
		cin >> a;
		if (s > a || i == 1) { s = a; }
	}
	cout << (lo)ceil((double) n / s)+ 4<<endl;
	//cout << ceil((double)10 / 123);
	//system("pause");
	return 0;

}

Measured memory_bytes: 256
icase=0
if icase==0:
    import sys
    a,b=map(int,input().split())
    for i in range(1,999):
        isum=(i*(i+1))//2-a
        for j in range(i,1000):
            jsum=(j*(j+1))//2-b
            if jsum==isum and 1<=jsum and j==i+1:
                print(jsum)
                sys.exit()


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(v) (v).begin(),(v).end()

const int MOD = 1000000007;
const int N = 1005;
const double PI =4*atan(1);

ll dp[N][N];
char grid[N][N];
ll w,h;

bool ingrid(int i,int j){
	return i>=0 && j>=0 && grid[i][j]!='#';
}


int main(){
    ios::sync_with_stdio(0);
    //freopen("baklava.in","r",stdin);
    cin.tie(0);
    cout.tie(0);
    //start
	cin >> h >> w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> grid[i][j];
		}
	}
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(ingrid(i,j)==0)continue;
			if(ingrid(i,j-1)){dp[i][j]=(dp[i][j]+dp[i][j-1]+MOD)%MOD;}
			if(ingrid(i-1,j))dp[i][j]=(dp[i][j]+dp[i-1][j]+MOD)%MOD;
			//cout << dp[i][j] << endl;
		}
	}
	cout << dp[h-1][w-1];
    return 0;
}


Measured memory_bytes: 9088
#include <stdio.h>
#include <string.h>
int main()
{
  char s[1001];
  char t[1001];
  scanf("%s%s",&s,&t);
  int i,j,cnt,sum;
  cnt = 0;
  sum = 0;
  i = 0;
  while (s[i])
  {
    j = 0;
    cnt = 0;
    while (t[j])
    {
      if (t[j] == s[i])
        cnt++;
      if (s[i] == '\0')
      {
        cnt = 0;
        break;
      }
      j++;
      i++;
    }
    if (sum < cnt)
      sum = cnt;
    i -= j;
    i++;
  }
  printf("%d",strlen(t)-sum);
}

Measured memory_bytes: 1732
import bisect
n = int(input())
lis = sorted(list(map(int, input().split())))
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        ans += max(bisect.bisect_left(lis, lis[j]+lis[i]) - j - 1, 0)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
    using namespace std;
    const int N=2e3+20;
    typedef long long ll;
    int n,m,q;
    int f[N][N],h[N][N],g[N][N];//f[i][j] (0,0)~(i,j)中有多少个1 
    //h,g 水平和竖直相邻的边 
    char s[N][N];
    int main()
    {
    	while(cin>>n>>m>>q)
    	{
    		for(int i=1;i<=n;i++)
    			scanf("%s",s[i]+1);
    		memset(f,0,sizeof(f));
    		memset(h,0,sizeof(h));
    		for(int i=1;i<=n;i++)
    		{
    			for(int j=1;j<=m;j++)
    			{  
    				f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+(s[i][j]-'0');
    				int cnt=0,res=0;
    				if(s[i][j]=='1')
    				{
    					if(s[i-1][j]=='1')
    						res++;
    					if(s[i][j-1]=='1')
    						cnt++;
    				}
    				h[i][j]=h[i-1][j]+h[i][j-1]-h[i-1][j-1]+cnt;
    				g[i][j]=g[i-1][j]+g[i][j-1]-g[i-1][j-1]+res;
    			//	cout<<g[i][j]<<' ';
    			}
    		}
    		int x1,y1,x2,y2;
    		while(q--)
    		{
    			scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    			int ans=f[x2][y2]-f[x2][y1-1]-f[x1-1][y2]+f[x1-1][y1-1];
    			int cnt=h[x2][y2]-h[x2][y1]-h[x1-1][y2]+h[x1-1][y1];
    			int res=g[x2][y2]-g[x1][y2]-g[x2][y1-1]+g[x1][y1-1];	
    			ans-=cnt+res;
    			printf("%d\n",ans);
    		}
    	}
    	return 0;
    }

Measured memory_bytes: 53632
/*input
8
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
#define version 20190713
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main(){
	IOS;
	int n;
	cin>>n;
	if((1<<__lg(n))==n){
		cout<<"No\n";
		return 0;
	}
	cout<<"Yes\n";
	cout<<"1 2\n";
	cout<<"2 3\n";
	cout<<3<<' '<<n+1<<'\n';
	cout<<n+1<<' '<<n+2<<'\n';
	cout<<n+2<<' '<<n+3<<'\n';
	for(int i=4;i<n;i+=2){
		cout<<i+1<<' '<<i<<'\n';
		cout<<i<<' '<<1<<'\n';
		cout<<1<<' '<<i+1+n<<'\n';
		cout<<i+1+n<<' '<<i+n<<'\n';
	}
	if(n%2==0){
		int tmp=n^1;
		for(int i=tmp-1;i>=2;i--){
			int a=tmp^i,b=i;
			if(a==3||b==3||a==1||b==1) continue;
			if(a%2==1) a+=n;
			if(b%2==1) b+=n;
			cout<<n<<' '<<a<<'\n';
			cout<<b<<' '<<n+n<<'\n';
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 2304
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    int n, m;
    cin >> n >> m;
    int st = 0;
    for (int i = 0; i < n; i++)
    {
        st *= 2;
        int b;
        cin >> b;
        st += b;
    }
    int gt1 = 0, gt2 = 0;
    for (int i = 0; i < m; i++)
    {
        int p;
        cin >> p;
        gt1 = gt1 << p;
        gt2 = gt2 << p;
        if (i % 2)
        {
            gt2 += (1 << p) - 1;
        }
        else
        {
            gt1 += (1 << p) - 1;
        }
    }
    vector<int> d(1 << 20, INF);
    vector<int> tmp(n);
    queue<int> q;
    d[st] = 0;
    q.push(st);
    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        for (int i = 0; i < n; i++)
        {
            tmp[n - 1 - i] = (v >> i) & 1;
        }
        for(int i=0;i<n-1;i++){
            if(tmp[i] == tmp[i+1]) continue;
            swap(tmp[i], tmp[i+1]);
            int next=0;
            for(int j=0;j<n;j++){
                next *= 2;
                next += tmp[j];
            }
            swap(tmp[i], tmp[i+1]);
            if(d[next]!=INF) continue;
            d[next] = d[v] + 1;
            q.push(next);
        }
    }
    cout << min(d[gt1], d[gt2]) << endl;
}



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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

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

    //0のやつだけ使える
    int use[10]={0};
    rep(i,k)
    {
        int d;
        cin >>d;
        use[d]=1;
    }

    int ans=n;
    while(1)
    {
        //printf("ans= %d\n", ans);
        bool ok=true;
        int t=ans;
        while(t>0)
        {
            if(use[t%10])
            {
                ok=false;
                break;
            }
            t/=10;
        }

        if(ok) break;
        ++ans;
    }

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


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

int main() {
    int H, W;
    cin>>H>>W;

    for(int i=0; i<W+2; i++) cout<<'#';
    
    cout<<endl;

    for(int i=0; i<H; i++){
        cout<<'#';
        for(int j=0; j<W; j++){
            char a;
            cin>>a;
            cout<<a;
        }
        cout<<'#'<<endl;
    }
    
    for(int i=0; i<W+2; i++) cout<<'#';
    
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

   int n,b;
   cin>>n;

   if(n%1000==0)
    cout<<"0";

  if(n%1000!=0&&n>1000) {
    b=n/1000+1;


   cout<<b*1000-n;
  }


if(n<1000)
    cout<<1000-n;




}


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

int main()
{
 int X,Y;
 cin>>X>>Y;
 if((Y>=(2*X))&&(Y<=(4*X))&&(Y%2==0))
 {
     cout<<"Yes";
 }
 else
 {
     cout<<"No";
 }
 return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=1234;
void Main(){
    ll h;cin >> h;
    ll w;cin >> w;
    ll k;cin >> k;
    vector<string> s(h);
    For(i,0,h){
        cin >> s[i];
    }
    For(i,0,1<<(h-1)){
        ll num = 0;
        vector<int> divide;
        For(j,0,h-1){
            bool isdivide = 1 & (i >> j);
            if(isdivide) {
                num ++;
                divide.push_back(j);
            }
        }
        divide.push_back(h-1);
        vector<int> whitenum(divide.size(),0);
        For(j,0,w){
            int block = 0;
            For(t,0,h){
                if(s[t][j] == '1'){
                    whitenum[block] ++;
                }
                if(t == divide[block]) {
                    block ++;
                }
            }
            for(auto t:whitenum){
                if(t > k){
                    num ++;
                    goto clean;
                }
            }
            continue;
            clean:;
            For(t,0,whitenum.size()) whitenum[t] = 0;
            block = 0;
            For(t,0,h){
                if(s[t][j] == '1'){
                    whitenum[block] ++;
                }
                if(t == divide[block]) {
                    block ++;
                }
            }
            for(auto t:whitenum){
                if(t > k){
                    goto last;
                }
            }
        }
        ans = min (ans, num);
        //cout<<i<<" "<<num<<endl;
        last:;
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

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

	int result = 0;
	for(int i = 0; i < N; i++) {
		result += a.at(i) - 1;
	}

	std::cout << result << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long ll;
typedef vector<ll> VL;



VL Main(ll A, ll B, ll K)
{
    VL ans(2, 0LL);
    ans[0] = max(0LL, A-K);
    ans[1] = max(0LL, B-max(0LL, K-A));
    return ans;
}

int main(void){
    ll A, B, K;
    cin >> A >> B >> K;
    VL out = Main(A, B, K);
    cout << out[0] << ' ' << out[1] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ティツ?ェテ・ツ仰陛ァツ板淌ヲツ按静」ツ?陛」ツつ古」ツ?淌」ツδ。テ」ツつステ」ツδε」ツδ嘉」ツδサテ」ツつケテ」ツつソテ」ツδ?

		Scanner sc = new Scanner(System.in);
		InputData[] id = new InputData[9];
		
		for(int i = 0; i < 9; i++) {
			String name = sc.next();
			int am = sc.nextInt();
			int pm = sc.nextInt();
			
			id[i] = new InputData(name, am, pm);
		}
		
		for(int i = 0; i < 9; i++) {
			int sum = id[i].am + id[i].pm;
			int income = id[i].am * 200 + id[i].pm * 300;
			
			System.out.println(id[i].name + " " + sum + " " + income);
		}
		
	}

}

class InputData{
	
	String name;
	int am;
	int pm;
	
	public InputData(String n, int a, int p){
		this.name = n;
		this.am = a;
		this.pm = p;
	}
	
	
	
}

Measured memory_bytes: 15352
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

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

int main() {
    int n = 10;
    int r, d, x;
    cin >> r >> d >> x;
    REP(i, n) {
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Numerics;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

            BigInteger ans = 1;

            if (a.Contains(0))
            {
                ans = 0;
            }
            else
            {
                for (int i = 0; i < n; i++)
                {
                    if (a[i] > 1000000000000000000)
                    {
                        ans = -1;
                        break;
                    }

                    else
                    {
                        ans *= a[i];
                        if (ans > 1000000000000000000)
                        {
                            ans = -1;
                            break;
                        }
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> p(n);
  rep(i,n){
    int a, b;
    cin >> a >> b;
    p[i] = make_pair(b, a);
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());

  int dead = p[0].first;
  rep(i,n){
    dead -= p[i].second;
    if(dead > p[i+1].first) dead = p[i+1].first;
    if(dead < 0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

const long long MAX_N = 1e2 + 2, MAX_V = 1e5 + 5, inf = 1000000LL * 1000000LL * 1000000LL;
long long n, W, ans;
long long dp[MAX_N][MAX_V];

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	for (long long i = 0; i < MAX_N; i++)
		for (long long j = 1; j < MAX_V; j++)
			dp[i][j] = inf;

	cin >> n >> W;
	for (long long i = 1; i <= n; i++) {
		long long w, v;
		cin >> w >> v;
		for (long long j = 0; j < MAX_V; j++) {
			dp[i][j] = dp[i - 1][j];
			if (v <= j)
				dp[i][j] = min(dp[i][j], dp[i - 1][j - v] + w);
		}
	}

	for (long long i = 0; i < MAX_V; i++)
		if (dp[n][i] <= W)
			ans = i;

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 80000
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


ll N, D, A;
vector<pair<ll, ll>>p;

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

	cin >> N >> D >> A;
	p.resize(N);
	for (int i = 0; i < N; i++)cin >> p[i].first >> p[i].second;
	sort(all(p));


	ll curdam = 0;
	ll ans = 0;
	min_priority_queue<pair<ll, ll>>q;
	for (int i = 0; i < N; i++) {
		ll curx = p[i].first;
		ll curh = p[i].second;
		while (q.size()) {
			auto tp = q.top();
			if (tp.first < curx) {
				curdam -= tp.second;
				q.pop();
			}
			else break;
		}
		curh -= curdam;
		if (curh <= 0)continue;
		ll k = (curh + A - 1LL) / A;
		ans += (curh+A-1LL)/A;
		curdam += k * A;
		q.push({curx+2LL*D,k*A});
	}
	puts(ans);

	
	return 0;
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

#define A(a) ((a)<<1)
#define B(a) ((a)<<1|1)

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;
const int MAXH = 207;
const int MAXV = 1007;
const int MAXE = 1000007;

struct eT
{
	void setd ( int _u, int _v, int _l )
	{
		u = _u, v = _v, last = _l;
	}
	
	int u, v, last;
}edge[MAXE];

int n, H;
int ke, la[MAXV];
int va[MAXN], vb[MAXN], vc[MAXN], vd[MAXN];
int il[MAXN], ir[MAXN];
int deg[MAXV];
bool hve[MAXV];
bool vis[MAXV];

void init ();
void input ();
void work ();

void addedge ( int u, int v )
{
	edge[ke].setd ( u, v, la[u] );
	la[u] = ke++;
	++deg[u], --deg[v];
	hve[u] = hve[v] = true;
}

void dfs ( int now )
{
	if ( vis[now] ) return;
	vis[now] = true;
	for ( int i = la[now]; ~i; i = edge[i].last ) dfs ( edge[i].v );
}



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%d%d", &n, &H );
	lpi ( i, 1, n ) scanf ( "%d%d%d%d", &va[i], &vb[i], &vc[i], &vd[i] );
}

void work ()
{
	// main work
	
	INIT ( la, -1 );
	
	lpi ( i, 1, n ){
		if ( vc[i] ) il[i] = A ( vc[i] );
		else il[i] = B ( va[i] );
		if ( vd[i] ) ir[i] = A ( vd[i] );
		else ir[i] = B ( vb[i] );
		
		addedge ( A ( il[i] ), B ( ir[i] ) );
	}
	
	int u, v;
	lpi ( i, 0, H ){
		u = A ( A ( i ) );
		v = B ( B ( i ) );
		if ( deg[u] < 0 ){
			printf ( "NO\n" );
			return;
		}
		while ( deg[u] ) addedge ( v, u );
		
		v = B ( A ( i ) );
		u = A ( B ( i ) );
		if ( deg[v] > 0 ){
			printf ( "NO\n" );
			return;
		}
		while ( deg[v] ) addedge ( v, u );
	}
	
	lpi ( i, 0, H ){
		if ( deg[A(B(i))] < 0 || deg[B(B(i))] > 0 ){
			printf ( "NO\n" );
			return;
		}
	}
	
//	lp ( i, 0, ke ) cerr << edge[i].u << " " << edge[i].v << endl;
	
	lpi ( i, 0, H ) if ( deg[A(B(i))] > 0 ) dfs ( A ( B ( i ) ) );
	lp ( i, 0, MAXV ){
		if ( hve[i] && !vis[i] ){
			printf ( "NO\n" );
			return;
		}
	}
	
	printf ( "YES\n" );
}

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

typedef long long ll;


int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> P(N,K-Q);
    for (int i=0;i<Q;i++) {
        int A;
        cin >> A;
        A--;
        P[A]++;
    }
    for (int i=0;i<N;i++){
        if (P[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int N, M;
	int A[101];
	int i;
	int k;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	for (k = 1; k <= M; k++) {
		int baton = 1;
		while (baton != N) {
			if (A[baton] % k > A[baton + 1] % k) {
				int temp = A[baton];
				A[baton] = A[baton + 1];
				A[baton + 1] = temp;
			}
			baton = baton + 1;
		}
	}
	for (i = 1; i <= N; i++) {
		printf("%d\n", A[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

ll s[100050], t[100050], c[100050];
ll tt[100050], sm[100050];
int main(){FIN
    ll n,cha;cin>>n>>cha;
    REP(i,n){
        cin>>s[i]>>t[i]>>c[i];
    }
    FOR(i,1,cha){
        REP(j,100050) tt[j]=0;
        REP(j,n) if(c[j]==i) {
            tt[s[j]]++; 
            tt[t[j]+1]--;
        }
        REP(j,100050) tt[j] += tt[j-1];
        REP(j,100050) if(tt[j]) sm[j]++;
    }
    // REP(i,10) cout<<sm[i];
    // cout<<endl;
    ll mx=0;
    REP(i,100050) mx = max(mx, sm[i]);
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 7484
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

  vector<long long> A(N);
  for(int i = 0;i < N;i++) {
    cin >> A.at(i);
  }

  sort(A.begin(),A.end());

  long long sum = 0;
  if(N%2==0) {
    for(int i = 0;i < N;i++) {
      if(i < N/2) sum -= A.at(i);
      else sum += A.at(i);
    }
    sum *= 2;
    sum += A.at((N/2)-1) - A.at(N/2);
  }else {
    long long sum2 = 0;
    int n = (N-2)/2;
    for(int i = 0;i < N;i++) {
      if(i < n+1) sum -= 2*A.at(i);
      else if(n+1 <= i && i <= n+2) sum += A.at(i);
      else sum += 2*A.at(i);
    }

    for(int i = 0;i < N;i++) {
      if(i < n) sum2 -= A.at(i);
      else if(n <= i && i <= n+1) continue;
      else sum2 += A.at(i);
    }
    sum2 *= 2;
    sum2 -= A.at(n) + A.at(n+1);
    sum = max(sum,sum2);
  }

  cout << sum << endl;
}



Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int judge[128][128];

int main()
{
	char f[128][128];

	int w, h, i, j, ex, ey;

	while(cin >> h >> w, w || h)
	{
		i = 0; j = 0;

		for(int k = 0; k < h; k++)
		{
			cin >> f[k];
			for(int l = 0; l < w; l++)
			{
				judge[k][l] = 0;
			}
		}
		while(1)
		{
			if(judge[i][j] == 1)
			{
				ex = -1; ey = -1;
				break;
			}
			else if(f[i][j] == '.')
			{
				ex = j; ey = i;
				break;
			}

			judge[i][j] = 1;

			if(f[i][j] == '>')
			{
				++j;
			}
			else if(f[i][j] == '<')
			{
				--j;
			}
			else if(f[i][j] == '^')
			{
				--i;
			}
			else if(f[i][j] == 'v')
			{
				++i;
			}
		}

		if(ex == -1 && ey == -1)
		{
			cout << "LOOP" << endl;
		}
		else
		{
			cout << ex << ' ' << ey << endl;
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n;cin>>n;
  if(n%1000==0)cout<<0;
  else cout<<1000-n%1000<<'\n';
  
  return 0;
}
//2020.07.05 20:00:42


Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
	int n1;
	int yo;

	scanf("%d", &n1);

	yo = n1 % 10;

	if ( ( yo == 0 ) || ( yo == 1 ) || ( yo == 6 ) || ( yo == 8 ) )
		printf("pon \n");
	
	if ( ( yo == 2 ) || ( yo == 4 ) || ( yo == 5 ) || ( yo == 7 ) || ( yo == 9 ) )
		printf("hon \n");
	
	if ( yo == 3 )
		printf("bon \n");

	return 0;

}

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

string S;
int n, b, e;

int main(void) {
  cin >> S;
  n = S.size();

  b = 0;
  e = n - 1;
  while (b < e) {
    if (S[b++] != S[e--]) {
      cout << "No" << endl;
      return 0;
    }
  }

  b = 0;
  e = (n - 1) / 2 - 1;
  while (b < e) {
    if (S[b++] != S[e--]) {
      cout << "No" << endl;
      return 0;
    }
  }

  b = (n + 3) / 2 - 1;
  e = n - 1;
  while (b < e) {
    if (S[b++] != S[e--]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    string a, b;
    cin >> a >> b;
    if (find(b.begin(), b.end(), '1') == b.end()) {
        if (a != b) {
            cout << "-1\n";
        } else {
            cout << "0\n";
        }
        return 0;
    }
    int n = SZ(a);
    vector<int> firstLeft(n, 0);
    vector<int> firstRight(n, 0);
    for (int i = 0; i < n; ++i) {
        for (int j = i; b[j] != '1'; j = j == 0 ? n - 1: j - 1) {
            firstLeft[i]++;
        }
        for (int j = i; b[j] != '1'; j = j == n - 1 ? 0: j + 1) {
            firstRight[i]++;
        }
    }
    int ans = 0x3f3f3f3f;
    for (int shift = 0; shift < n; ++shift) {
        vector<int> nFirstLeft = firstLeft;
        vector<int> nFirstRight = firstRight;
        rotate(nFirstLeft.begin(), nFirstLeft.begin() + shift, nFirstLeft.end());
        rotate(nFirstRight.begin(), nFirstRight.begin() + shift, nFirstRight.end());
        string na = a;
        rotate(na.begin(), na.begin() + shift, na.end());
        vector<pair<int, int>> v;
        for (int i = 0; i < n; ++i) {
            if (b[i] != na[i]) {
                v.push_back(make_pair(nFirstLeft[i], nFirstRight[i]));
            }
        }
        sort(v.begin(), v.end());
        reverse(v.begin(), v.end());
        v.push_back(make_pair(0, 0));
        int sec = 0;
        for (const pair<int, int>& p: v) {
            int cost = p.first + sec;
            {
                int fcost = cost + p.first + min((shift + sec) % n, n - (shift + sec) % n);
                ans = min(ans, fcost + SZ(v));
            }
            {
                int fcost = cost + sec +
                    min((shift - p.first + n) % n, n - (shift - p.first + n) % n);
                ans = min(ans, fcost + SZ(v));
            }
            sec = max(sec, p.second);
        }
    }
    ans--;
    cout << ans << '\n';
}


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

int main(){
	int n;
	int a;
	int idx = 1;
	unordered_set<int> s;
	cin >> n;
	vector<int> v(n + 1);
	for(int i=1; i<=n; i++){
		cin >> a;
		v[i] = a;
	}
	while(1){
		if(s.count(v[idx])){
			cout << -1;
			return 0;
		} else {
			s.insert(v[idx]);
			if(v[idx] == 2) {
				cout << s.size();
				return 0;
			}
			idx = v[idx];
		}
	}
	return 0;
}



Measured memory_bytes: 4772
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
#include <cmath>
using namespace std;
 
int lislength(vector<int> &a){
    vector<int> lis;
    for(int i=0; i<a.size(); i++){
        auto itr = lower_bound(lis.begin(), lis.end(), a[i]);
        if(itr == lis.end())
            lis.push_back(a[i]);
        else
            *itr = a[i];
    }
    return lis.size();
}
bool comp(pair<int,int> a,pair<int,int> b)
{
     return a.second<b.second;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x1, y1, x2, y2, N;
    cin >> x1 >> y1 >> x2 >> y2 >> N;
    vector<pair<int, int>> XY(N);
    for(int i=0; i<N; i++)
        cin >> XY[i].first >> XY[i].second;
 
    x2 -= x1;
    y2 -= y1;
    for(int i=0; i<N; i++){
        XY[i].first -= x1;
        XY[i].second -= y1;
    }
    if(x2 < 0){
        x2 = -x2;
        for(int i=0; i<N; i++)
            XY[i].first = -XY[i].first;
    }
    if(y2 < 0){
        y2 = -y2;
        for(int i=0; i<N; i++)
            XY[i].second = -XY[i].second;
    }
    double ans = 100.0 * (x2 + y2);
    const double diff = 5.0 * M_PI - 20.0;
    sort(XY.begin(), XY.end(),comp);
 
    vector<int> a;
    for(auto xy : XY){
        if(0 <= xy.first && xy.first <= x2 && 0 <= xy.second && xy.second <= y2)
            a.push_back(xy.first);
    }
 
    const double diff2 = 10.0 * M_PI - 20.0;
 
    int ll = lislength(a);
    if(ll != min(x2, y2) + 1)
        ans += diff * ll;
    else
        ans += diff * (ll - 1) + diff2;
    cout << fixed << setprecision(32) << ans << endl;
    return 0;
}

Measured memory_bytes: 4212
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<int> a(n);
    for (size_t i=0; i<n; ++i)
        scanf("%d", &a[i]);

    sort(a.begin(), a.end());

    for (size_t i=0; i<n; ++i)
        printf("%d%c", a[i], i<n-1? ' ':'\n');

    return 0;
}

Measured memory_bytes: 9956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int x, n;
    cin >> x >> n;
    vector<int> p(102,0);
    REP(i,n) {
        int pi;
        cin >> pi;
        p[pi]++;
    }

    if (p[x] == 0) {
        cout << x << endl;
        return 0;
    }

    int ans = 0;
    int cnt = 1e9;
    REP(i,p.size()) {
        int s = abs(i - x);
        if (p[i] == 0 && cnt > s) {
            cnt = s;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    H = nl()
    ans = 0
    for i in range(n):
        for j in range(i):
            if H[j] > H[i]:
                break
        else:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9004
#include <bits/stdc++.h>
#define For(i, l, r) for(int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}

const int N = 1e5 + 1e3;
char str[N];

int tot1, tot2, score;

int main () {

#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif

	scanf ("%s", str + 1);

	int len = strlen(str + 1);
	For (i, 1, len) {
		if (str[i] == 'g') {
			if (tot1 < tot2) ++ tot1, ++ score;
			else ++ tot2;
		} else {
			if (tot1 < tot2) ++ tot1;
			else ++ tot2, -- score;
		}
	}
	printf ("%d\n", score);
    return 0;
}


Measured memory_bytes: 384
s = list(input())
for i in range(len(s)):
    if i == 0 and s[i] == "B":
        s[i] = ""
    elif s[i] == "B":
        s[i] = ""
        flg = 0
        back = 1
        while True:
            if s[i-back] == "":
                back += 1
            elif s[i-back] != "":
                s[i-back] = ""
                break
            if i-back<0: break
#            print(s)
print("".join(s))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int a, b;
    cin>>a>>b;
    if (a>0)
    {
        cout<<"Positive";
        return 0;
    }
    if (a<=0&&b>=0)
    {
        cout<<"Zero";
        return 0;
    }
    if (a<0&&b<0)
    {
        if (abs(a-b+1)%2==0)
        {
            cout<<"Positive";
            return 0;
        }
        else
        {
            cout<<"Negative";
            return 0;
        }

    }
    return 0;
}

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

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = 1<<30;
const ll MOD = 1e9+7;

vector<vector<ull> > matrix_mult(vector<vector<ull> > a, vector<vector<ull> > b){
	int m1 = a.size(), n1 = a[0].size();
	int m2 = b.size(), n2 = b[0].size();
	vector<vector<ull> > ans;
	if(n1 == m2){
		ans.assign(m1, vector<ull>(n2, 0));
		for(int i=0;i<m1;i++){
			for(int j=0;j<n2;j++){
				for(int k=0;k<n1;k++){
					ans[i][j] = (ans[i][j] + (a[i][k]*b[k][j])%MOD)%MOD;
				}
			}
		}
	}
	return ans;
}

vector<vector<ull> > binary_exp(vector<vector<ull> > b, ull pw){
	if(pw == 1)
		return b;
	vector<vector<ull> > tmp = binary_exp(b, pw/2);
	vector<vector<ull> > ans = matrix_mult(tmp, tmp);
	if(pw%2)
		ans = matrix_mult(ans, b);
	return ans;
}

int main(){
	int n;
	ull k;
	cin>>n>>k;
	vector<vector<ull> > adj(n, vector<ull>(n));
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>adj[i][j];

	vector<vector<ull> > ans = binary_exp(adj, k);

	ull numpath = 0;

	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			numpath = (numpath+ans[i][j])%MOD;

	cout<<numpath<<"\n";

	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
 
int main() {
  int n,d;
  cin >> n >> d;
  vector<ll> x(n), y(n);
  rep(i,n)
    cin >> x[i] >> y[i];
  /*rep(i,n){
    cout << x[i] << endl;
    cout << y[i] << endl;
  }*/
  int count=0;
  rep(i,n){
    //cout << sqrt(x[i]*x[i] + y[i]*y[i]) << endl;
    //if(sqrt(x[i]*x[i] + y[i]*y[i])<=d)
    ll di = x[i]*x[i] + y[i]*y[i];
    ll d2 = d*d;
    //cout << x[i]*x[i] << endl;
    //cout << x[i]*x[i] + y[i]*y[i] << endl;
    //cout << di << endl;
    //cout << sqrt(di) << endl;
    if(sqrt(di)<=d)
      count++;
  }
  cout << count << endl;
}



Measured memory_bytes: 6488
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

const long int MOD = 1e9 + 7;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base = base % modulus;
  T result = 1;
  while (exp > 0) {
    if (exp % 2 == 1) 
      result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp = exp/2;
  }
  return result;
}

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n,k;
   cin>>n>>k;

   long int ans = 0;
   vector<long int> dp(k + 1);

   for(long int i = k; i >= 1; i--){
     long int numChoices = k / i;
     dp[i] = modpow(numChoices,n,MOD);

     for(long int j = 2; i * j <= k; j++)
        dp[i] = (dp[i] - dp[i * j] + MOD) % MOD;

     ans = (ans + i * (dp[i])) % MOD;
   }

   cout<<ans;

   return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, M;
void func()
{
    cin>>N;
    string s[N];
    map<string, int> a;
    ll ans=0;
    rep(i, 0, N) {
        cin>>s[i];
        sort(s[i].begin(), s[i].end());
        if (a.count(s[i])==0)a[s[i]]=1;
        else {
            ans+=a[s[i]];
            ++a[s[i]];
        }
    }
    cout<<ans<<endl;

}
int main()
{
    func();
}

Measured memory_bytes: 14520