akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// Begin Header {{{
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
using namespace std;
using Graph = vector<vector<lli>>;
using P = pair<int, int>;
// }}} End Header

int main(){
	string s;
	cin >> s;
	if(s[0] == '9' || s[1] == '9') puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std ;

double A, B ; 

int main(){
	cin >> A >> B ;
	for (double i = 1.0 ; i <= 10000000.0 ; ++ i)
		if (floor(0.08 * i) == A && floor(0.1 * i) == B) return cout << (int)i << endl, 0 ; 
	return cout << -1, 0 ;
}

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

int main(void){
    int n,m;
    cin >> n >> m;
    long long x,y,z,ppp[n],ppn[n],pnp[n],npp[n],pnn[n],npn[n],nnp[n],nnn[n];
    rep(i,n){
        cin >> x >> y >> z;
        ppp[i] = x+y+z;
        ppn[i] = x+y-z;
        pnp[i] = x-y+z;
        npp[i] = -x+y+z;
        pnn[i] = x-y-z;
        npn[i] = -x+y-z;
        nnp[i] = -x-y+z;
        nnn[i] = -x-y-z;
    }
    sort(ppp,ppp+n,greater<long long>());
    sort(ppn,ppn+n,greater<long long>());
    sort(pnp,pnp+n,greater<long long>());
    sort(npp,npp+n,greater<long long>());
    sort(pnn,pnn+n,greater<long long>());
    sort(npn,npn+n,greater<long long>());
    sort(nnp,nnp+n,greater<long long>());
    sort(nnn,nnn+n,greater<long long>());
    long long ans[8] = {};
    rep(i,m){
        ans[0] +=ppp[i];
        ans[1] +=ppn[i];
        ans[2] +=pnp[i];
        ans[3] +=npp[i];
        ans[4] +=pnn[i];
        ans[5] +=npn[i];
        ans[6] +=nnp[i];
        ans[7] +=nnn[i];
    }
    sort(ans,ans+8,greater<long long>());
    cout << ans[0] << endl;
    return 0;
}

Measured memory_bytes: 256
import math
x,n = map(int,input().split())
p = list(map(int,input().split()))

if n == 0:
    print(x)
    exit()

ans = math.inf
off = 0
while ans == math.inf:

    left = x - off
    right = x + off

    try:
        p.index(left)
    except:
        print(left)
        exit()

    try:
        p.index(right)
    except:
        print(right)
        exit()
    off+=1

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

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

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*------------------------------------/
for library*/

/*------------------------------------*/

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

    int N;
    cin>>N;
    vector<ll> a(N);
    rep(i,N)cin>>a[i];
    map<ll,int> map;
    rep(i,N){
        map[a[i]]++;
    }
    int cnt = 0;
    for(auto x:map){
        cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 9812
import itertools
def main():
    n,m,r=map(int,input().split())
    rx=[int(i) for i in input().split()]
    inf=100000000
    wf=[[inf]*n for i in range(n)]
    for i in range(n):
        wf[i][i]=0

    for i in range(m):
        a,b,c=map(int,input().split())
        wf[a-1][b-1]=c
        wf[b-1][a-1]=c

    for k in range(n):
        for i in range(n):
            for j in range(n):
                if wf[i][j]>wf[i][k]+wf[k][j]:
                    wf[i][j]=wf[i][k]+wf[k][j]
    cnt=0
    l=list(itertools.permutations([i for i in range(r)]))
    cnt=inf
    for i in l:
        cnt_sub=0
        for j in range(r-1):
            cnt_sub+=wf[rx[i[j]]-1][rx[i[j+1]]-1]
        cnt=min(cnt,cnt_sub)
    print(cnt)
main()


Measured memory_bytes: 9576
#include <bits/stdc++.h>
using namespace std;
int const m = 10000;

int dp[100][4][4]={}; // i日目の、[当日パスタ]、[前日パスタ]の場合の数
int p[100]={},n,k;

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

    cin>>n>>k;
    for (int i = 0; i < k; i++){
        int a,b; cin>>a>>b; p[--a]=b;
    }
    if(p[0])dp[0][p[0]][0]=1;
    else for (int i = 1; i < 4; i++)dp[0][i][0]=1;
    for (int i = 1; i < n; i++){
        for (int j = 0; j < 4; j++){
            for (int l = 0; l < 4; l++){
                if(p[i]){
                    if(p[i]!=j||j!=l)dp[i][p[i]][j]+=dp[i-1][j][l]%m;
                }else{
                    for (int o = 1; o < 4; o++){
                        if(o!=j||j!=l)dp[i][o][j]+=dp[i-1][j][l]%m;
                    }
                }
            }
        }
    }
    int ans=0;
    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 4; j++)ans+=dp[n-1][i][j];
    }
    cout<<ans%m<<'\n';
}


Measured memory_bytes: 3152
#include <stdio.h>
#include <string.h>
#define N 1005


main(){
  
  int n,i;
  char X[N],Y[N];
  
  
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    scanf("%s%s",X+1,Y+1);
    Lcs(X,Y);
  }
  
  return 0;
  
}
int Lcs(char *X,char *Y)
{
  
  int m,n,i,j;
  int Z[N][N];
  
  m = strlen(X+1);
  n = strlen(Y+1);

  for(i = 0; i <= m; i++){
    Z[i][0] = 0;
  }
  for(j = 0; j <= n; j++){
    Z[0][j] = 0;
  }
  
  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      
      if(X[i] == Y[j]){
	Z[i][j] = Z[i-1][j-1] +1;
      }
      else if(Z[i-1][j] >= Z[i][j-1]){
	Z[i][j] = Z[i-1][j];
      }
      else {
	Z[i][j] = Z[i][j-1];
      }
    }
  }
  
  
  printf("%d\n",Z[i-1][j-1]);
}

Measured memory_bytes: 4544
n = int(input())
a = list(map(int,input().split()))
mxm = max(a)
div = []
for i in range(n):
    div.append(abs(mxm/2.0-a[i]))
mini = min(div)
ind = div.index(mini)

if n == 2:
    print(max(a),min(a))
else:
    print(mxm,a[ind])

Measured memory_bytes: 14428
#include <bits/stdc++.h>
#define For(i, j, k) for (int i = j; i <= k; i++)
using namespace std;
const int N = 2e5 + 10;
int n; int pa[N], fa[N], w[N]; int c0[N], c1[N];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
struct Node { int o, x, y; bool operator < (const Node B) const { return 1ll * y * B.x > 1ll * x * B.y; } };
priority_queue<Node> q;
int main() {
	scanf("%d", &n);
	For(i, 2, n) scanf("%d", &pa[i]);
	For(i, 1, n) { scanf("%d", &w[i]), fa[i] = i; c0[i] = !w[i], c1[i] = w[i]; if (i > 1) q.push((Node){i, c0[i], c1[i]}); }
	long long ans = 0;
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int o = find(s.o); if (c0[o] != s.x || c1[o] != s.y) continue;
		int f = find(pa[o]); ans += 1ll * c1[f] * c0[o]; fa[o] = f, c0[f] += c0[o], c1[f] += c1[o];
		if (f != 1) q.push((Node){f, c0[f], c1[f]});
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 8560
int main(void){
int h, w, i, j;
	for(;;){scanf("%d %d", &h, &w);
		if(h == 0 && w == 0){
			break;}
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
	printf("#");
			}
			printf("\n");
	}
		printf("\n");
	}
return 0;
	}


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

int main() {
  int n;
  cin >> n;
  vector<double>data(n);
  for(int i = 0;i < n;i++){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  for(int i = 0;i < n-1;i++){
    data.at(i+1) = (data.at(i)+data.at(i+1))/2;
    data.at(i) = 0;
    sort(data.begin(),data.end());
  }
  cout << data.at(n-1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int n;
    cin >> n;
    double x, ans = 0;
    string u;
    while(n--){
        cin >> x >> u;
        if(u == "JPY")
            ans += x;
        else
            ans += x * 380000;
    }
    cout << setprecision(15) << ans << endl;
}


Measured memory_bytes: 256
#include <cassert>// c
#include <ctime>
#include <iostream>// io
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>// container
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <algorithm>// other
#include <utility>
#include <complex>
#include <numeric>
#include <functional>
#include <random>
#include <regex>

using namespace std;
typedef long long ll;

#define ALL(c) (c).begin(),(c).end()
#define FOR(i,l,r) for(int i=(int)l;i<(int)r;++i)
#define REP(i,n) FOR(i,0,n)
#define FORr(i,l,r) for(int i=(int)r-1;i>=(int)l;--i)
#define REPr(i,n) FORr(i,0,n)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end())
//debug
#define DUMP(x)  cerr << #x << " = " << (x)
#define LINE()    cerr<< " (L" << __LINE__ << ")"

template<typename T,typename U> T pmod(T x,U M){return (x%M+M)%M;}

stringstream ss;
int INF=1<<28;
int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	ss   <<fixed <<setprecision(20);
	cout <<fixed <<setprecision(20);
	cerr <<fixed <<setprecision(20);

	while(true){
	    int W,H;cin >>W >> H;if(W==0)break;
	    int f,m,o;cin >> f >> m >> o;
	    vector<vector<int> > board(H,vector<int>(W));
	    REP(y,H)REP(x,W)cin >> board[y][x];
	    
	    
	    int dp[H+1][W][m+1];
	    fill_n(dp[0][0],(H+1)*W*(m+1),INF);
	    
	    REP(x,W)dp[0][x][o]=0;

	    for(int ny=1;ny<=H;ny++){
		for(int nx=0;nx<W;nx++)for(int ox=0;ox<=m;ox++){
			for(int x=0;x<W;x++){
			    //(x,y-1)->(nx,y)
			    int nox=ox;int cost=0;bool is_valid=true;
			    for(int tx=min(x,nx);tx<=max(x,nx);tx++){
				if(board[ny-1][tx]<0){
				    cost+=-board[ny-1][tx];
				    nox--;
				    if(nox<=0)is_valid=false;
				}else{
				    nox--;
				    if(nox<=0)is_valid=false;
				    nox=min(m,nox+board[ny-1][tx]);
				}
			    }
			    if(is_valid)dp[ny][nx][nox]=min(dp[ny][nx][nox],dp[ny-1][x][ox]+cost);
			}
		}
	    }

	    int res=INF;
	    REP(x,W)REP(ox,m+1)res=min(res,dp[H][x][ox]);

	    if(res<f)cout << res <<endl;
	    else cout <<"NA"<<endl;

	}

 	return 0;
 }

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

int main() {
  int n, m;
  cin >> n >> m;
  if (n % 2 == 1) {
    for (int i = 0; i < m; i++) {
      cout << i + 1 << " " << n - i << endl;
    }
  } else {
    for (int i = 0; i < m; i++) {
      cout << i + 1 << " " << n - i - (2 * i >= m) << endl;
    }
  }
  return 0;
}

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

int main()
{
	int N = 0;
	std::cin >> N;

	std::vector<int> d(N);
	for (int i = 0; i < N; ++i)
	{
		std::cin >> d.at(i);
	}

	int answer = 0;
	for (int i = 0; i < N - 1; ++i)
	{
		for (int j = i + 1; j < N; ++j)
		{
			answer += d.at(i) * d.at(j);
		}
	}

	std::cout << answer << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
    int n,d,x,ans=0;
    cin>>n>>d>>x;
    rep(i,n){
        int a;
        cin>>a;
        ans+=(d-1)/a+1;
    }
    ans+=x;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int x,y;
    int t;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0) break;
    if(x>y){
        t=x;
        x=y;
        y=t;
    }
    printf("%d %d\n",x,y);    
    }
    return 0;
}


Measured memory_bytes: 2036
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

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

	ll x = n / k;

	ll ans = 0;
	ans = abs(k - n % k);
	ans = min(n%k, ans);

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


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

double p[3009], d[3009][3009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	d[0][0] = 1;
	for (int i = 1; i <= n; i++)
		cin >> p[i];
	for (int i = 1; i <= n; i++) {
		d[i][0] = d[i - 1][0] * (1 - p[i]);
		for (int j = 1; j <= i; j++)
			d[i][j] = d[i - 1][j] * (1 - p[i]) + d[i - 1][j - 1] * p[i];
	}
	double ans = 0;
	for (int i = (n + 1) / 2; i <= n; i++)
		ans += d[n][i];
	cout.setf(ios::fixed);
	cout.precision(20);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 69120
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.06.09 20:55:23
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int main() {
    int n, w[110];
    scanf("%d", &n);
    rep(i, n) scanf("%d", &w[i]);
    int ret = 10000000;
    rep(i, n - 1) {
        int sum1 = 0, sum2 = 0;
        for (int j = 0; j <= i; j++) {
            sum1 += w[j];
        }
        for (int j = i + 1; j < n; j++) {
            sum2 += w[j];
        }
        ret = min(ret, abs(sum1 - sum2));
    }
    printf("%d\n", ret);

    /* --------------------------------- */
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string n;
	cin>>n;
	REP(i, n.size()){
		if(n[i]=='1'){
			cout<<9;
		}
		else{
			cout<<1;
		}
	}
	return 0;
}


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

int main(){

  while(1){
    int x, y;
    cin>>x>>y;
    if(x == 0 && y ==0 ) break;

    if(x > y) swap(x, y);
    cout<<x<<" "<<y<<endl;
  }

  return 0;
}



Measured memory_bytes: 3104
#include<stdio.h>

int main(void) {
  int a, b, coin=0, i=0;
  scanf("%d %d", &a, &b);
  
  while(i<2) {
    if(a<=b) {
      coin += b;
      b--;
    }
    else {
      coin += a;
      a--;
    }
    i++;
  }
  
  printf("%d\n", coin);
  
  return 0;
}

    

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
  int w, h, x, y, r;

  scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

  if(x - r < 0 || x + r > w || y - r < 0 || y + r > h) {
    puts("No");
  }

  else
    puts("Yes");

  return 0;

}

Measured memory_bytes: 1816
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,C;
  string B;
  
  cin >> A >> B >> C;
  
  if ( B == "+" ) {
    
    cout << A + C;
    
  } else if ( B == "-" ) {
    
    cout << A - C;
    
  }  
  
}

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

int main(){
    int N;
    cin >>N;
    vector<int> X(N);
    for(int i=0;i<N;i++) cin >>X.at(i);
    int maxx = -100000;
    int minx =  100000;
    for(int i=0;i<N;i++){
        if(maxx < X.at(i)){
            maxx = X.at(i);
        }
        if(minx > X.at(i)){
            minx = X.at(i);
        }
    }
  	vector<int> D(maxx-minx+1);
    int i =0;
    for(int p = minx;p<=maxx;p++){
        for(int j=0;j<N;j++){
            D.at(i) += (X.at(j)-p)*(X.at(j)-p);
        }
        i++;
    }
    int minD = D.at(0);
    for(int d:D){
        if(minD > d){
            minD = d;
        }
    }
    cout <<minD<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	n := readInt()
	var ans int
	v := make([]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		v[i] = readInt()
	}
	for i := 0; i < n; i++ {
		c[i] = readInt()
	}
	for i := range v {
		t := v[i] - c[i]
		if t > 0 {
			ans += t
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a < b) {
			System.out.printf("a < b\n");
		}else if (a > b) {
			System.out.printf("a > b\n");
		}else{
			System.out.printf("a == b\n");
		}

	}

}


Measured memory_bytes: 26176
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
int a[100],b,c,n,o;
int maxx,minn=10000,i,ans;
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&o);
		if (o<=399) a[1]=1;
		else if (o<=799) a[2]=1;
		else if (o<=1199) a[3]=1;
		else if (o<=1599) a[4]=1;
		else if (o<=1999) a[5]=1;
		else if (o<=2399) a[6]=1;
		else if (o<=2799) a[7]=1;
		else if (o<=3199) a[8]=1;
		else b++;
	}
	for (i=1;i<=8;i++) ans+=a[i];
	if (ans==0)
	{
		cout<<1<<" "<<b;
	}
	else 
	cout<<ans<<" "<<ans+b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t X;
  bool c=false;
  cin>>X;
  if(X>2){
    for(int j=X;j<=1000000;j++){
      for(int i=2;i<j;i++){
        if(j%i==0) break;
        if(i==j-1) c=true;
      }
      if(c){
        cout<<j<<endl;
        break;
      }
    }
  } else{
    cout<<X<<endl;
  }
}
    
      
      

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

int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	int x,y,memo[k][k][2]={};
	char c;
	for (int i = 0; i < n; ++i)
	{
		cin>>x>>y>>c;
		x%=2*k;y%=2*k;
		int a;
		if (c=='W')
		{
			a=0;
		}
		else
		{
			a=1;
		}
		if (x>=k)
		{
			x%=k;
			++a;
		}
		if (y>=k)
		{
			y%=k;
			++a;
		}
		++memo[x][y][a%2];
	}
	int s[k+5][k+5][2]={};
	for (int i = 0; i < k; ++i)
	{
		for (int j = 0; j < k; ++j)
		{
			s[i][j+1][0]=s[i][j][0]+memo[i][j][0];
			s[i][j+1][1]=s[i][j][1]+memo[i][j][1];
		}
	}
	for (int i = 0; i <= k; ++i)
	{
		for (int j = 0; j < k; ++j)
		{
			s[j+1][i][0]+=s[j][i][0];
			s[j+1][i][1]+=s[j][i][1];
		}
	}
	int ans=0;
	for (int i = 0; i < k; ++i)
	{
		for (int j = 0; j < k; ++j)
		{
			int nans1=0,nans2=0;
			if (i==0)
			{
				if (j==0)
				{
					nans1=s[k][k][0];
					nans2=s[k][k][1];
				}
				else
				{
					nans1+=s[k][k][0]-s[k][j][0];
					nans1+=s[k][j][1];
					nans2+=s[k][k][1]-s[k][j][1];
					nans2+=s[k][j][0];
				}
			}
			else
			{
				if (j==0)
				{
					nans1+=s[k][k][0]-s[i-1][k][0];
					nans1+=s[i-1][k][1];
					nans2+=s[k][k][1]-s[i-1][k][1];
					nans2+=s[i-1][k][0];
				}
				else
				{
					nans1+=s[k][k][0]-s[i-1][k][0]-s[k][j][0]+2*s[i-1][j][0];
					nans1+=s[i-1][k][1]+s[k][j][1]-2*s[i-1][j][1];
					nans2+=s[k][k][1]-s[i-1][k][1]-s[k][j][1]+2*s[i-1][j][1];
					nans2+=s[i-1][k][0]+s[k][j][0]-2*s[i-1][j][0];
				}
			}
			ans=max({ans,nans1,nans2});
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

    vector<int>P(N);
    vector<int>Q(N);
    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];

    vector<int>key;
    rep(i,N) key.push_back(i+1);
    int p = 0;
    int q = 0;
    bool pFlag = true;
    bool qFlag = true;
    
    
    //cout << endl;
    do
    {
        //rep(i,key.size()) cout << key[i] << " ";
        
        if(pFlag)
        {
            if(key == P) pFlag = false;
            else p++;
        }
        if(qFlag)
        {
            if(key == Q) qFlag = false;
            else q++;
        }
    }
    while(next_permutation(all(key)));
    //cout << p << " " << q << endl;
    cout << abs(p-q) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string s;
    cin >> s;
    sort(all(s));

    if (s == "abc") cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(50000)
N,K= [int(v) for v in input().split()]
P = [int(v) - 1 for v in input().split()]
C = [int(v) for v in input().split()]

visited = [True for _ in range(N)]
cycle = []


ans = -float('inf')
for sn in range (N):
    cost = []
    nn = sn
    while True:
        cost.append(C[nn])
        nn = P[nn]
        if sn == nn:
            break
    total = sum(cost)
    l = len(cost)

    t = 0
    for i in range(l):
        t += cost[i]
        if i+1 > K: break
        now = t
        if total > 0:
            e = (K-i-1)//l
            now += total * e
        ans = max(ans,now)


print(int(ans))


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

using namespace std;

#define ll long long
#define pi pair<int, int>
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD =  1e9 + 7;
int arr[mxn];
int n, m, k, q;
string s, t;

void solve(){
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < 3; i++) cnt += (s[i] == 'R');
    if (cnt != 2) {
        cout << cnt << endl;
    } else {
        if (s[0] == s[2]) {
            cout << 1 << endl;
        } else {
            cout << 2 << endl;
        }
    }
}

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


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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  int n;
  cin >> n;
  if (n < 600 ) {
    cout << 8 << endl;
  }else if (n < 800 ) {
cout << 7 << endl;
  }else if (n < 1000 ) {
cout << 6 << endl;
  }else if (n < 1200 ) {
cout << 5 << endl;
  }else  if (n < 1400 ) {
cout << 4 << endl;
  }else if (n < 1600 ) {
cout << 3 << endl;
  }else if (n < 1800 ) {
    cout << 2 << endl;
  }else  {
cout << 1 << endl;
  }

}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int R,G,B,N;cin>>R>>G>>B>>N;

  int ans=0;
  for(int r=0;r*R<=N;r++){
    for(int g=0;r*R+g*G<=N;g++){
      //for(int b=0;r*R+g*G+b*B<N+2;b++){
        // print(r,g,"=",r*R+g*G);
        if((N-r*R-g*G)%B==0){
          ans++;
       //}
      }
    }
  }

  print(ans);


}


Measured memory_bytes: 256
L,R = gets.split.map(&:to_i)
Z = 2019
if R-L < 2019 then
    min = Z**2
    [*L..R].combination(2).to_a.each_with_index do |z, index|
        a = (z[0]*z[1])%Z
        min = a if a < min
        break if min == 0
    end
    puts min
else
    puts "0"
end

Measured memory_bytes: 114812
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val B = readLine()!!.split(" ").map { it.toInt() }

    println(C(n, B))
}

fun C(n: Int, b: List<Int>): Int {
    if (n !in 2..100) return 0
    val a = mutableListOf<Int>()
    
    for (i in (1 until b.size)) {
        a.add(Math.min(b[i - 1], b[i]))
    }
    
    a.add(0, b.first())
    a.add(b.last())

    return a.sum()
}

Measured memory_bytes: 36060
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e)  for(int i=s;i<=e;i++)
#define repd(i,s,e)  for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())

const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
signed main()
{
 
    fast;
    read(k);
    string s; cin >>s;
    int n =s.length();
    if(n<=k) cout<<s<<endl;
    else
    {
    	cout<<s.substr(0,k)<<"..."<<endl;
    }
    return 0;
}

/* Pooja Yadav */

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;


// At first, fix the number of red apple
// How to maximize Y selection
// get the best green apple numbers in 10^3
//max is Y.


int main(){
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a), q(b), r(c);
  rep(i,a) cin >> p[i];
  rep(i,b) cin >> q[i];
  rep(i,c) cin >> r[i];
  sort(p.rbegin(),p.rend());
  sort(q.rbegin(),q.rend());
  
  rep(i,x) r.push_back(p[i]);
  rep(i,y) r.push_back(q[i]);
  sort(r.rbegin(),r.rend());

  ll ans = 0;
  rep(i,x+y) ans += r[i];
  cout << ans << endl;
 }


Measured memory_bytes: 7868
#include<iostream>
#include<algorithm>
#include<vector>
#include<climits>

using namespace std;


int main() {
	int a, b, c, x, y;
	int cost;
	int min_cost = INT_MAX;
	cin >> a >> b >> c >> x >> y;
	for (int i = 0;i <= max(x, y);i++) {
		cost = 2 * i * c + a * max(0, x - i) + b * max(0, y - i);
		min_cost = min(cost, min_cost);
	}
	cout << min_cost << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace Competitive
{

    internal class Solution
    {
        public string S;
        public bool[] F;

        public void Run()
        {
            int ALFABET = 26;

            S = Console.ReadLine();
            F = new bool[ALFABET];

            for (int c = 0; c < ALFABET; c++) F[c] = false;
            for (int i = 0; i < S.Length; i++)
            {
                F[ToInt(S[i])] = true;
            }

            if (S.Length < 26)
            {
                for (int c = 0; c < ALFABET; c++)
                {
                    if (F[c] == false)
                    {
                        string ret = S + ToChar(c);
                        Console.WriteLine(ret);
                        return;
                    }
                }
            }
            else
            {
                for (int i = S.Length - 1; i >= 0; i--)
                {
                    int ch = ToInt(S[i]);
                    for (int c = ch + 1; c < ALFABET; c++)
                    {
                        if (F[c] == false)
                        {
                            string ret = S.Substring(0, i) + ToChar(c);
                            Console.WriteLine(ret);
                            return;
                        }
                    }
                    F[ch] = false;
                }
            }

            Console.WriteLine(-1);
        }

        public int ToInt(char s)
        {
            return s - 'a';
        }

        public char ToChar(int x)
        {
            return Convert.ToChar('a' + x);
        }
    }

    // libs ----------
    
    // common ----------

    internal static class Input
    {
        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

using namespace std;

using ll = long long;

struct UnionFind {
    //各要素が属する集合の代表(根)を管理する
    //もし、要素xが根であればdata[x]は負の値を取り、-data[x]はxが属する集合の大きさに等しい
    vector<int> data;

    UnionFind(int sz) : data(sz, -1) {}

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return is_union;
    }

    int find(int x) {
        if (data[x] < 0) { //要素xが根である
            return x;
        } else {
            data[x] = find(data[x]); //data[x]がxの属する集合の根でない場合、根になるよう更新される
            return data[x];
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -data[find(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    ll ans = n;
    ans = ans * (n - 1) / 2;
    UnionFind uf(n);
    vector<ll> v(m);
    for (int i = m - 1; i >= 0; i--) {
        v[i] = ans;
        if (uf.same(a[i], b[i])) continue;
        ans -= uf.size(a[i]) * uf.size(b[i]);
        uf.unite(a[i], b[i]);
    }

    for (int i = 0; i < m; i++) {
        cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3328
S = input()
N = len(S)

ans = True
if S != S[::-1]:
    ans = False

st = S[:(N-1)//2]
en = S[(N+3)//2-1:]

if st != st[::-1] or en != en[::-1]:
    ans = False

# print(st, en)

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    // Your code here! scanf("%d %d",&a,&b);
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    
}


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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n;
vector <pair<int, int> > v;

signed main()
{
	IOS;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int e;
		cin >> e;
		v.push_back({e, i});
	}
	sort (v.begin(), v.end());
	for (auto i : v)
		cout << i.second << ' ';
	
	return 0;
}


Measured memory_bytes: 1780
$N,$A,$B,$C = gets.split.map(&:to_i)
$L = Array.new($N) {gets.to_i}
$INF = 10**9
$min = $INF

class Node
  attr_accessor :depth, :array

  def initialize(depth, array)
    @depth = depth
    @array = array
  end
end

def calc(array)
  mp = -30
  a = 0
  b = 0
  c = 0

  array.each_with_index do |v, i|
    case v
    when 0 then
      a+=$L[i];mp+=10
    when 1 then
      b+=$L[i];mp+=10
    when 2 then
      c+=$L[i];mp+=10
    end
  end

  if [a,b,c].min == 0 then
    return $INF
  else
    return mp + (a-$A).abs + (b-$B).abs + (c-$C).abs
  end
end

def dfs()
  stack = [Node.new(0,[])]
  while !stack.empty?

    v = stack.pop()

    if v.depth > $N-1 then
      c = calc(v.array)
      $min = c if $min > c
    else
      childs = Array.new(4) do |i|
        Node.new(v.depth+1, v.array+[i])
      end

      childs.each do |child|
        stack.push(child)
      end
    end
  end
end

dfs()
puts $min


Measured memory_bytes: 1916
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <stdio.h>
#include <math.h>
using namespace std;
 
#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
 
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, P> PP;
 
struct edge {
	int to, cost;
	edge(int t, int c) :to(t), cost(c) {}
};
 
int dx[] = { 1,-1,0,0 }, dy[] = { 0,0,1,-1 };
int ddx[] = { 1,1,1,0,-1,-1,-1,0 }, ddy[] = { 1,0,-1,-1,-1,0,1,1 };
 
ll mypow(ll x, ll n, ll m) {	//xのn乗をmで割った余り
	if (n == 0) return 1;
	if (n % 2 == 0) return mypow(x*x%m, n / 2, m);
	else return x*mypow(x, n - 1, m) % m;
}
 
//-----------------------------------------------------------------------------
 
string s,t;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
 
    cin>>s>>t;
	sort(ALL(s));
	sort(ALL(t));
	reverse(ALL(t));
    if(s<t) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;

  int64_t sum = 0;

  for (int64_t i = 1; i <= n; ++i) {
    int cnt = 0;
    int64_t j = i;
    while (j) {
      j /= 10;
      ++cnt;
    }
    if (cnt % 2 == 1) {
      ++sum;
    }
  }
  cout << sum << '\n';

  return 0;
}


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

//#define FILE_INPUT
//#define DEBUG_MODE

template<class T>
void DebugPrint(vector<T> a)
{
#ifdef DEBUG_MODE
	for (int i = 0; i < min(20, (int)a.size()); ++i) {
		if (a[i] > 1000000000) {
			cout << "-,";
		}
		else {
			cout << a[i] << ",";
		}
	}
	cout << endl;
#endif
}

int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */  

	int n, ww;
	cin >> n >> ww;

	vector<int> w(n);
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> w[i] >> v[i];
	}

	vector<int> dp(n * 1000 + 1, 1000000000 + 1);

	for (int i = 0; i < n; ++i) {
		for (int j = n * 1000; j >= 0; --j) {
			int j2 = j + v[i];
			if (j2 <= n * 1000) {
				if (dp[j2] > dp[j] + w[i]) {
					dp[j2] = dp[j] + w[i];
				}
			}
		}
		int j = v[i];
		if (dp[j] > w[i]) {
			dp[j] = w[i];
		}
		//DebugPrint(dp);
	}
	int max = 0;
	for (int j = n * 1000; j >= 0; --j) {
		if (dp[j] <= ww) {
			max = j;
			break;
		}
	}
	cout << max << endl;

	return 0;
}

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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

const int dx[] = { 0, -1,  1,  0, -1,  1, -1,  1}; 
const int dy[] = {-1,  0,  0,  1, -1, -1,  1,  1};

struct IoSetup { IoSetup(int x = 10){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input();
  int64 A = 0, B = 1;

  range(i, 0, N) {
    int q = input(), x = input();
    if (q == 1) {
      B *= x;
      A *= x;
    } else {
      A += (q == 2 ? -1 : 1) * x;
    }
  }

  cout << A << " " << B << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}



Measured memory_bytes: 3208
n = int(input())
s = input()

count = {'R': 0, 'G': 0, 'B': 0}
for l in s:
    count[l] += 1

a = 0
for i in range(n):
    d = 1
    while i+2*d <= n-1:
        if s[i] != s[i+d] and s[i+d] != s[i+2*d] and s[i] != s[i+2*d]:
            a += 1
        d += 1

print (count['R']*count['G']*count['B'] - a)

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

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976
const double PI = 3.1415926535897932;

int main()
{
    int n; cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    ll sum = 0,ans1 = 0,ans2 = 0;
    rep(i,n){
        sum += a[i];
        if(i % 2 == 0 && sum <= 0){
            ans1 += 1-sum;
            sum = 1;
        }
        if(i % 2 == 1 && sum >= 0){
            ans1 += sum+1;
            sum = -1;
        }
    }
    sum = 0;
    rep(i,n){
        sum += a[i];
        if(i % 2 == 1 && sum <= 0){
            ans2 += 1-sum;
            sum = 1;
        }
        if(i % 2 == 0 && sum >= 0){
            ans2 += sum+1;
            sum = -1;
        }
    }
    cout << min(ans1,ans2);
}

Measured memory_bytes: 1024
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    sx, sy, tx, ty = map(int, input().split())
    direction = ['U', 'R', 'D', 'L']
    path = ['']*4
    def inverse(s):
        ret = ''
        for x in s:
            if x == 'U':
                ret += 'D'
            if x == 'R':
                ret += 'L'
            if x == 'D':
                ret += 'U'
            if x == 'L':
                ret += 'R'
        return ret

    path[0] = 'R'*(tx-sx)+'U'*(ty-sy)
    path[2] = 'L'+'U'*(ty-sy+1)+'R'*(tx-sx+1)+'D'
    path[1] = inverse(path[0])
    path[3] = inverse(path[2])
    print(''.join(path))
    
        
    
if __name__ == '__main__':
    main()

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

typedef long long ll;
const int MOD=1e9+7;

int main(){
    int H,W,K; cin >> H >> W >> K;
    ll dp[H+1][W+1]={};
    dp[0][0]=1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            for(int mask=0;mask<(1<<W-1);mask++){
                bool flag=true;
                for(int k=0;k<W-2;k++){
                    if((mask&(1<<k))&&(mask&(1<<(k+1)))){
                        flag=false;
                    }
                }
                if(!flag) continue;
                if(mask&(1<<j)){
                    dp[i+1][j+1]+=dp[i][j]%MOD;
                    dp[i+1][j+1]%=MOD;
                }else if(j>0&&mask&(1<<(j-1))){
                    dp[i+1][j-1]+=dp[i][j]%MOD;
                    dp[i+1][j-1]%=MOD;
                }else{
                    dp[i+1][j]+=dp[i][j]%MOD;
                    dp[i+1][j]%=MOD;
                }
            }
        }
        
    }
    cout << dp[H][K-1]%MOD << endl;
}

Measured memory_bytes: 256