akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

int main()
{
    ll N, K, X, Y;
    cin >> N >> K >> X >> Y;

    cout << max(N - K, 0LL) * Y + min(N, K) * X << endl;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(void) {
int N ,K;
 char str[100];
 scanf("%d %d",&N,&K);
 scanf("%s",str);
 if(str[K-1]=='A')
  str[K-1]='a';
if(str[K-1]=='B')
  str[K-1]='b';
if(str[K-1]=='C')
  str[K-1]='c';
printf("%s\n",str);
  return 0;
}


Measured memory_bytes: 1584
import math
p,q= input().split()
a,b =(int(p), int(q))
ans_list = []
for i in range(a):
    blank_list = input().split()
    ans_list.append(blank_list)
a_list = [0,1,2,3,4,5,6,7,8,9]
count = 0

for x in range(a):
    a_list.pop(0)
    
    for y in range(a-x-1):
        total = 0 
        y_num = a_list[y]
        for i in range(b):
            
            total += (int(ans_list[x][i]) - int(ans_list[y_num][i]))** 2
            distance = total ** 0.5
        
        if distance == math.floor(distance):
            count += 1
print(count)
        

Measured memory_bytes: 3064
# Contest No.: ABC170
# Problem No.: C
# Solver:      JEMINI
# Date:        20200614

import sys
import heapq

def main():
    x, n = map(int, input().split()) 
    nums = list(map(int, sys.stdin.readline().split()))
    if x not in nums:
        print(x)
        return
    
    #nums.sort()
    ans = None
    diff = 1
    while True:
        if x - diff not in nums:
            ans = x - diff
            break
        elif x + diff not in nums:
            ans = x + diff
            break
        diff += 1

    print(ans)
        
        
    
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 62180
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1

using namespace std;

int main() {
  int n, days, y, m, d;
  cin >> n;
  while (n--) {
    days = 196470;
    cin >> y >> m >> d;
    if (d > 1) days -= d-1;
    while (--m) {
      if (y % 3 != 0 && m % 2 == 0) days -= 19;
      else days -= 20;
    }
    while (--y) {
      if (y % 3 == 0) days -= 200;
      else days -= 195;
    }
    cout << days << el;
  }
}

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

int main(){
    ll n;
    cin>>n;
    set<string> s;
    for(int i=0; i<n; i++){
        string x;
        cin>>x;
        s.insert(x);
    }
    cout<<s.size()<<endl;
    return 0;
}

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

int a[5000],b[5000],A,B;
int main(){
	cin >> A >> B;
	for(int i = 0 ; i < A ; i++) cin >> a[i];
	for(int i = 0 ; i < B ; i++) cin >> b[i];
	int ans = 0;
	for(int i = 0 ; i < B ; i++){
		int h = i , c = 0;
		for(int j = 0 ; j < A ; j++){
			if(h < B && a[j] == b[h]){
				c++;
				h++;
			}
		}
		ans = max(c,ans);
	}
	cout << ans << endl;
}

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

typedef struct {
  long x,y;
} star;

int comp(const void *a, const void *b){
  if(((star *)a)->x==((star *)b)->x){
    return ((star*)a)->y-((star*)b)->y;
  }
  return ((star*)a)->x-((star *)b)->x;
}

int main(){
  int m,n,i,j,c;
  star cons[200],map[1000],a;
  while (1) {
    scanf("%d",&n);
    if(n==0) break;
    for(i=0;i<n;i++){
      scanf("%ld %ld",&cons[i].x,&cons[i].y );
    }
    scanf("%d",&m);
    for(i=0;i<m;i++){
      scanf("%ld %ld",&map[i].x,&map[i].y);
    }
    qsort(cons,n,sizeof(star),comp);
    qsort(map,m,sizeof(star),comp);
    for(i=0;i<m;i++){
      a.x=map[i].x+cons[1].x-cons[0].x;
      a.y=map[i].y+cons[1].y-cons[0].y;
      c=1;
      for(j=i+1;j<m;j++){
        if(a.x==map[j].x && a.y==map[j].y){
          c++;
          if(c==n) break;
          a.x+=cons[c].x-cons[c-1].x;
          a.y+=cons[c].y-cons[c-1].y;
        }
      }
      if (c==n) break;
    }
    printf("%ld %ld\n",map[i].x-cons[0].x,map[i].y-cons[0].y);
  }
  return 0;
}

Measured memory_bytes: 672
loop do
  n,k = gets.split(" ").map(&:to_i)
  break if n == 0 && k == 0
  cards = Array.new(n+1)
  k.times do
    i = gets.to_i
    cards[i] = i
  end
  cards.compact!

  seq = 1
  max = 0
  # 白が含まれていない場合
  if cards[0] != 0
    1.upto(k-1) do |i|
      if cards[i] == cards[i-1] + 1
        seq += 1
      else
        max = seq if max < seq
        seq = 1
      end
    end
    # 最後が連続していた場合の処理
    max = seq if max < seq
  # 白が含まれている場合
  else
    seq_w = 1 # 白紙を使った場合の長さ
    use_w = false
    2.upto(k-1) do |i|
      if cards[i] == cards[i-1] + 1
        seq   += 1
        seq_w += 1
      elsif cards[i] == cards[i-1] + 2
        use_w = true
        max = seq if max < seq
        max = seq_w if max < seq_w
        seq_w = seq + 2
        seq = 1
      else
        max = seq if max < seq
        max = seq_w if max < seq_w
        seq = 1
        seq_w = 1
      end
    end
    # 最後が連続していた場合の処理
    max = seq if max < seq
    max = seq_w if max < seq_w
    max += 1 unless use_w
  end

  puts max
end

Measured memory_bytes: 9576
n,m = map(int,input('').split())
x = list(map(int,input('').split()))
x.sort()

dist = []
for i in range(len(x)-1):
    dist.append([x[i+1]-x[i],i])
sorted_dist = sorted(dist,key=lambda x:x[0])
top_n = sorted(sorted_dist[-1*n+1:],key=lambda x:x[1])

total = 0
idx = 0
for _,i in top_n:
    total += abs(x[i] - x[idx])
    idx = i+1
total += abs(x[-1] - x[idx])

if n==1: total =x[-1]-x[0]
print(total)

Measured memory_bytes: 24340
IDENTIFICATION DIVISION.
      PROGRAM-ID. 140A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 N PIC 9(1).
      01 ANS PIC 9(3).
      01 ANSS PIC Z(3).
      
      PROCEDURE DIVISION.
      ACCEPT N.
      COMPUTE ANS = N * N * N.
      MOVE ANS TO ANSS.
      DISPLAY ANSS.
      STOP RUN.

Measured memory_bytes: 892
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    char b;
    cin>> b;
    if(b=='A')cout<<'T'<<endl;
    if(b=='T')cout<<'A'<<endl;
    if(b=='G')cout<<'C'<<endl;
    if(b=='C')cout<<'G'<<endl;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

struct edge {
    int to, cost;
};

int n, m;
int l[200100], r[200100], d[200100];
vector<edge> G[100100];
int dist[100100];

bool calc(int k) {
    for (int i = 0; i < (int)G[k].size(); i++) {
        int v = G[k][i].to, c = G[k][i].cost;
        if (dist[v] != inf && dist[v] != dist[k] + c) return false;
        if (dist[v] == inf) {
            dist[v] = dist[k] + c;
            if (!calc(v)) return false;
        }
    }
    return true;
}

bool solve() {
    for (int i = 0; i < m; i++) {
        G[l[i]].push_back(edge{r[i], d[i]});
        G[r[i]].push_back(edge{l[i], -d[i]});
    }
    fill(dist, dist+n+10, inf);
    for (int i = 1; i <= n; i++) {
        if (dist[i] == inf) {
            dist[i] = 0;
            if (!calc(i)) {
                return false;
            }
        }
    }
    return true;
}

void input() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> l[i] >> r[i] >> d[i];
    }
}

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

    input();
    cout << (solve()?"Yes":"No") << endl;
}


Measured memory_bytes: 14336
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
a, b, c = gets_i_list.sort.reverse

ab = (a - b).abs
ac = (a - c).abs

if (ab + ac).even?
    puts (ab + ac) / 2
else
    puts (ab + ac + 1) / 2 + 1
end


Measured memory_bytes: 14596
#include<stdio.h>
int main()
{
	int x,n,y[100],flg1,a,b,i,cnt1,cnt2;
	scanf("%d %d",&x,&n);
	flg1=0;
	a=x;
	b=x;
	if(n==0){
		printf("%d\n",x);
		// printf("XX\n");
		flg1++;
	}
	else if(flg1==0){
		for(i=0;i<n;i++){
			scanf("%d",&y[i]);
		}
		while(1){
			cnt1=0;
			cnt2=0;
			for(i=0;i<n;i++){
				if(a==y[i]) {
					cnt1++;
				}
				if(b==y[i]){
					cnt2++;
				}
			}
			if(cnt1==0&&cnt2==0){
				printf("%d\n",b);
				// printf("AA\n");
				break;
			}
			else if(cnt1==0){
				printf("%d\n",a);
				// printf("BB\n");
				break;
			}
			else if(cnt2==0){
				printf("%d\n",b);
				// printf("CC\n");
				break;
			}
			a=a+1;
			b=b-1;
		}
	}
	return 0;
}

Measured memory_bytes: 1708
#define _USE_MATH_DEFINES
#include<iostream>
#include<sstream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<math.h>
#include<iterator>

using namespace std;

int a[100010]={};
int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    int buf;
    cin >>buf;
    a[i]=buf;
  }
  long long ans = 0;
  for(int i=0;i<n;i++){
    ans += a[i]/2;
    if(i+1<n && a[i]%2==1){
      if(a[i+1]!=0){
        a[i+1]--;
        ans ++;
      }
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <string.h>

using namespace std;

typedef struct a 
{
	bool exist[24];
}state;

void init_state(bool exist[24],int n)
{
	for (int i=0;i<n;++i) exist[i] = true;
}

int cal_state(bool exist[24],int n)
{
	int res = 0;
	for (int i=0;i<n;++i)
	{
		if (exist[i]) res += 1<<i; 
	}
	return res;
}

int cal_number(bool exist[24], int n)
{
	int res = 0;
	for (int i=0;i<n;++i)
	{
		if (exist[i]) ++res;
	}
	return res;
}

bool overlap(int x1,int y1,int r1,int x2,int y2,int r2)
{
	if ((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1) < (r1+r2)*(r1+r2)) return true;
	else return false;
}


bool s[1<<24];

int main()
{
	int n = 0;
	int x[24];
	int y[24];
	int r[24];
	int c[24];

	cin >> n;
	while (n)
	{
		for (int i=0;i<n;++i)
		{
			cin>>x[i]>>y[i]>>r[i]>>c[i];
		}

		int res = 0;
		queue<state> q;
		bool ontop[24];

		memset(s, 0, sizeof(s));
		s[(1<<n)-1] = true;

		state tmp;
		init_state(tmp.exist,n);
		q.push(tmp);
		
		while (!q.empty())
		{
			tmp = q.front();
			q.pop();
			
			init_state(ontop,n);
			res = max(res,n-cal_number(tmp.exist,n));
			
			if (res == n) break;
			
			for (int i=0;i<n;++i)
			{
				if (tmp.exist[i])
				{
					for (int j = i+1; j<n; ++j)
					{
						if (tmp.exist[j]&&ontop[j])
						{
							if (overlap(x[i],y[i],r[i],x[j],y[j],r[j])) ontop[j] = false;
						}
					}
				}
			}
			
			for (int i=0;i<n;++i)
			{
				if (tmp.exist[i]&&ontop[i])
				{
					for (int j=i+1;j<n;++j) 
					{
						if (tmp.exist[j]&&ontop[j]&&(c[i] == c[j]))
						{
							state tt = tmp;

							tt.exist[i] = false;
							tt.exist[j] = false;
							if (!s[cal_state(tt.exist,n)])
							{
								s[cal_state(tt.exist,n)] = true;
								q.push(tt);
							}
						}
					}
				}
			}
			
			
		}
		cout << res << endl;
		cin >>n;
	}

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;

#define FOR(i, b, e) for(int i=b; i<=e; i++)
#define FORD(i, b, e) for(int i=b; i>=e; i--)
#define SIZE(x) ((int)x.size())
#define pb push_back
#define st first
#define nd second
#define sp ' '
#define ent '\n'
//END OF TEMPLATE

ll n, m, ans;

ll check(ll a){
	m=n/a-1;
	if(a<m) return m;
	return 0;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin>>n;
	for(ll i=1; i*i<=n; i++){
		if(n%i) continue;
		ans+=check(i);
		if(i*i!=n) ans+=check(n/i);
	}
	cout<<ans<<ent;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;

ll dsu[SIZE], sz[SIZE];

ll find(int v) {
    if (dsu[v] == v) return v;
    else return dsu[v] = find(dsu[v]);
}

void uni(int v, int u) {
    v = find(v);
    u = find(u);
    if (u != v) {
        sz[v] += sz[u];
        dsu[u] = v;
    }
}

int main()
{
    fastInp;

    ll n, m;
    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        dsu[i] = i;
        sz[i] =  1;
    }

    for (int i = 0; i < m; i++) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        uni(u, v);
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll c = find(i);
        ans = max(ans, sz[c]);
    }

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 6920
#include<stdio.h>

int main(void)

{

int a,b;

scanf("%d",&a);

scanf("%d",&b);

if(a<b)

{

printf("a < b\n");

}

if(a>b)

{

printf("a > b\n");

}

if(a==b)

{

printf("a == b\n");

}

return 0;

}

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

int main() {
    int A, B, C;
    int X;
    cin >> A >> B >> C >> X;
    int res=0;
    for (int i=0; i<=A; i++) {
        for (int j=0; j<=B; j++) {
            for (int k=0; k<=C; k++) {
                if (i*500+j*100+k*50==X) res++;
            }
        }
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

int main(){
    int N;
    cin >> N;
    vector<i64> D(N);
    rep(i, N) cin >> D[i];

    i64 ans = 0;
    for(int i = 0; i < N; i++){
        for(int k = i+1; k < N; k++){
            ans += D[i] * D[k];
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll h,w;cin>>h>>w;
    vector<string> s(h);
    rep(i,h)cin>>s[i];

    vvl r(h,vl(w));
    rep(i,h)rep(j,w){
        if(s[i][j]=='#')continue;
        r[i][j]=(j?r[i][j-1]:0)+1;
        if(j==w-1||s[i][j+1]=='#'){
            ll id=j-1;
            while(id>=0&&s[i][id]=='.')r[i][id--]=r[i][j];
        }
    }
    vvl c(h,vl(w));
    rep(i,h)rep(j,w){
        if(s[i][j]=='#')continue;
        c[i][j]=(i?c[i-1][j]:0)+1;
        if(i==h-1||s[i+1][j]=='#'){
            ll id=i-1;
            while(id>=0&&s[id][j]=='.')c[id--][j]=c[i][j];
        }
    }

    ll ans=0;
    rep(i,h)rep(j,w){
        chmax(ans,c[i][j]+r[i][j]-1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 67200
from sys import stdin


def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


def lcm(x, y):
    return (x * y) // gcd(x, y)


def main():
    A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]
    min_c = A // C if A % C == 0 else A // C + 1
    max_c = B // C if B % C == 0 else B // C
    min_d = A // D if A % D == 0 else A // D + 1
    max_d = B // D if B % D == 0 else B // D
    cd = lcm(C, D)
    min_cd = A // cd if A % cd == 0 else A // cd + 1
    max_cd = B // cd if B % cd == 0 else B // cd

    print((B - A + 1) - ((max_c + 1 - min_c) + (max_d + 1 - min_d) - (max_cd + 1 - min_cd)))


if __name__ == "__main__":
    main()


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

using namespace std;

struct BIT
{
  vector< int > data;

  BIT(int sz) : data(++sz, 0) {}

  void set(int k, int x)
  {
    for(++k; k < data.size(); k += k & -k) data[k] = max(data[k], x);
  }

  int query(int k)
  {
    int ret = 0;
    for(++k; k > 0; k -= k & -k) ret = max(ret, data[k]);
    return (ret);
  }
};

int main()
{
  int N, A[100000], B[100000];
  vector< int > nums;

  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
    nums.push_back(A[i]);
    nums.push_back(B[i]);
  }

  sort(begin(nums), end(nums));
  nums.erase(unique(begin(nums), end(nums)), end(nums));

  vector< vector< int > > add1(nums.size()), add2(nums.size());
  for(int i = 0; i < N; i++) {
    A[i] = lower_bound(begin(nums), end(nums), A[i]) - begin(nums);
    B[i] = lower_bound(begin(nums), end(nums), B[i]) - begin(nums);
    add1[A[i]].push_back(B[i]);
    add2[B[i]].push_back(A[i]);
  }

  BIT latte(nums.size()), malta(nums.size());
  for(int i = 0; i < nums.size(); i++) {
    int aa = 0, bb = 0;
    vector< pair< int, int > > beet, uku;
    for(auto &s : add1[i]) beet.emplace_back(s, malta.query(s - 1) + 1);
    for(auto &s : add2[i]) uku.emplace_back(s, latte.query(s - 1) + 1);
    for(auto &s : beet) latte.set(s.first, s.second);
    for(auto &s : uku) malta.set(s.first, s.second);
  }

  cout << max(latte.query(nums.size() - 1), malta.query(nums.size() - 1)) << endl;
}

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

int main() {
  string s;
  cin >> s;
  // 左からと右から数える
  int n = s.length();
  vector<int> ans(n);
  int odd = 0; int even = 0;
  rep(i, n) {
    if (s[i] == 'R') {
      if (i&1) odd++;
      else even++;
    } else {
      if (i&1) {
        ans[i] += odd;
        ans[i-1] += even;
      } else {
        ans[i] += even;
        ans[i-1] += odd;
      }
      odd = 0; even = 0;
    }
  }
  //rep(i, n) cout << ans[i] << ' ';
  //cout << '\n';
  odd = 0; even = 0;
  for (int i = n-1; i >= 0; i--) {
    if (s[i] == 'L') {
      if (i&1) odd++;
      else even++;
    } else {
      if (i&1) {
        ans[i] += odd;
        ans[i+1] += even;
      } else {
        ans[i] += even;
        ans[i+1] += odd;
      }
      odd = 0; even = 0;
    }    
  }
  rep(i, n) cout << ans[i] << ' ';
  return 0;
}

Measured memory_bytes: 3844
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n  : _) <- map (unsafeSignedDecimal) . T.words <$> T.getLine :: IO [Int]
  let
    (q, r) = n `divMod` 2
  print (fromRational $ (toRational (q + r) / toRational n) :: Double)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
import numpy as np
def main():
    ttt = []
    n = int(input())
    N, M = map(int, input().split())
    e = list(map(int, input().split()))
    #e = [[int(i) for i in input().split()] for i in range(int(input()))]
    #n = 3
    #e = [[21,-11],[81234,94124,52141
    for j in range(n):
        t = N - e[j]*0.006
        tt = abs(M - t)
        ttt.append(tt)
    ttt = np.array(ttt)
    print(np.argmin(ttt)+1)
main()

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

int main()
{
	string s;
	cin >> s;
	map<char, int> M;
	for (int i = 0; i < s.size(); ++i)
	{
		M[s[i]] = 1;
	}
	cout << (M['N'] == M['S'] && M['E'] == M['W']?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let mut t = String::new();
    std::io::stdin().read_line(&mut t).ok();

    let mut ans = true;
    for i in 0..3 {
        if s.chars().nth(i) != t.chars().nth(2-i) {
            ans = false;
            break;
        }
    }
    if ans {
        println!("YES");
    }
    else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

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

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

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

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

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	_, a := readLengthAndSlice()

	m := make(map[int]int)
	for _, v := range a {
		m[v-1]++
		m[v]++
		m[v+1]++
	}
	var ans int
	for _, v := range m {
		if ans < v {
			ans = v
		}
	}
	println(ans)

}

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


Measured memory_bytes: 7680
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <stack>
#include <math.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int, int> pii;
int main(){
string s;
cin>>s;
if(s=="Sunny"){
  cout << "Cloudy"<<endl;
}else if(s=="Cloudy"){
  cout << "Rainy"<<endl;
}else{
  cout << "Sunny"<<endl;
}



}


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

int S[100000],top;

void push(int n){
  S[++top] = n;
}

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


int main(){
  char stack[100000];
  int status,a,b;
  while(1){
    status = scanf("%s", stack);
    if( status == -1) break;
    if( stack[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if( stack[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }
    else if( stack[0] == '*'){
      a = pop();
      b = pop();
      push( a * b);
    }
    else
      push(atoi(stack));
  }

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

  return 0;
}

      



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

struct DSU {
  vector<int> col, rk;
  vector<ll> add;
  vector<int> cnt;

  DSU(int n): col(n), rk(n), add(n), cnt(n, 1) {
    iota(col.begin(), col.end(), 0);
  }

  int get(int u) {
    if (u == col[u]) {
      return u;
    }
    return get(col[u]);
  }

  bool join(int u, int v) {
    u = get(u), v = get(v);
    if (u == v) {
      return false;
    }
    if (rk[u] > rk[v]) {
      swap(u, v);
    }
    if (rk[u] == rk[v]) {
      ++rk[v];
    }
    add[u] -= add[v];
    col[u] = v;
    cnt[v] += cnt[u];
    return true;
  }

  void inc(int u, ll delta) {
    add[get(u)] += delta;
  }

  ll get_val(int u) {
    if (u == col[u]) {
      return add[u];
    }
    return add[u] + get_val(col[u]);
  }

  int get_cnt(int u) {
    return cnt[get(u)];
  }
};

struct Edge {
  int u, v, w;
  bool operator<(const Edge& e) const {
    return w < e.w;
  }
};

signed main() {
#ifdef LOCAL
  assert(freopen("a.in", "r", stdin));
#endif
  vector<Edge> es;
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    --u, --v;
    es.push_back(Edge{u, v, w});
  }
  sort(es.begin(), es.end());
  reverse(es.begin(), es.end());
  DSU dsu(n);
  for (auto e : es) {
    dsu.inc(e.u, e.w * 1ll * dsu.get_cnt(e.v));
    dsu.inc(e.v, e.w * 1ll * dsu.get_cnt(e.u));
    assert(dsu.join(e.u, e.v));
  }
  for (int i = 0; i < n; ++i) {
    cout << dsu.get_val(i) << '\n';
  }
}


Measured memory_bytes: 4852
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int n;
  string s;
  cin>>n>>s;
  string l,r;
  l=s.substr(0,n);
  r=s.substr(n,n);
  reverse(r.begin(),r.end());
  //cout<<l<<" "<<r<<endl;
  map<pair<string,string>,int> mp;
  for(int i=0;i<(1<<n);i++){
    string sl="";
    string sr="";
    for(int j=0;j<n;j++){
      if(i&(1<<j)){
        sl.push_back(l[j]);
      }else{
        sr.push_back(l[j]);
      }
    }
    mp[make_pair(sl,sr)]++;
  }
  int ans=0;
  for(int i=0;i<(1<<n);i++){
    string sl="";
    string sr="";
    for(int j=0;j<n;j++){
      if(i&(1<<j)){
        sl.push_back(r[j]);
      }else{
        sr.push_back(r[j]);
      }
    }
    ans+=mp[make_pair(sl,sr)];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 91904
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> H(N);
    vector<ll> T(N, 0);
    REP(i, N) { cin >> H[i]; }
    REP(i, N - 1) {
        if(H[i + 1] > H[i]) {
            T[i + 1] = 0;
        } else {
            T[i + 1] = T[i] + 1;
        }
    }
    cout << *max_element(T.begin(), T.end()) << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int n, m;
ld x[14], y[14];
ld d[14][14];
ld rd[1 << 14];
bool can(int s,ld r) {
	vector<int> v;
	rep(i, n) {
		if (s&(1 << i))v.push_back(i);
	}
	if (v.size() <= 1)return true;
	int len = v.size();
	rep(i, len) {
		Rep(j, i + 1, len) {
			int id = v[i], jd = v[j];
			if (2*r < d[id][jd])return false;
			ld X = (x[jd] - x[id]) / 2.0;
			ld Y = (y[jd] - y[id]) / 2.0;
			ld dist = sqrt(pow(r, 2) - pow(d[id][jd] / 2.0, 2));
			ld sr = d[id][jd] / 2.0;
			ld x3 = Y * dist / sr; ld y3 = -X * dist / sr;
			ld midx = (x[id] + x[jd]) / 2.0, midy = (y[id] + y[jd]) / 2.0;
			ld cx = x3 + midx, cy = y3 + midy;
			bool valid = true;
			rep(k, len) {
				int kd = v[k];
				ld dis = sqrt(pow(cx - x[kd], 2) + pow(cy - y[kd], 2));
				if (dis > r+eps) {
					valid = false; break;
				}
			}
			if (valid)return true;
			valid = true;
			cx = -x3 + midx, cy = -y3 + midy;
			rep(k, len) {
				int kd = v[k];
				ld dis = sqrt(pow(cx - x[kd], 2) + pow(cy - y[kd], 2));
				if (dis > r+eps) {
					valid = false; break;
				}
			}
			if (valid)return true;
		}
	}
	return false;
}
ld dp[1 << 14], cop[1 << 14];
int main() {
	cin >> n >> m;
	rep(i, n) {
		cin >> x[i] >> y[i];
	}
	rep(i, n) {
		rep(j, n) {
			d[i][j] = sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
		}
	}
	rep(i, (1 << n)) {
		ld le = 0, ri = 200000;
		while (ri - le > eps) {
			ld r = (ri + le) / 2;
			if (can(i, r))ri = r;
			else le = r;
		}
		rd[i] = ri;
	}
	fill(dp, dp + (1 << n), mod);
	dp[0] = 0;
	rep(aa, m) {
		rep(j, (1 << n)) {
			cop[j] = dp[j];
		}
		rep(j, (1 << n)) {
			vector<int> v;
			rep(i, n) {
				if (j&(1 << i))continue;
				v.push_back(i);
			}
			int len = v.size();
			rep(i, (1 << len)) {
				int s = 0;
				rep(k, len) {
					if (i&(1 << k))s += (1 << v[k]);
				}
				cop[j + s] = min(cop[j + s], max(dp[j], rd[s]));
			}
		}
		rep(j, (1 << n)) {
			dp[j] = cop[j];
		}
	}
	cout << fixed << setprecision(5);
	cout << dp[(1 << n) - 1] << endl;
	//stop
	return 0;
}


Measured memory_bytes: 4064
# Aizu Problem 0095: Surf Smelt Fishing Contest
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


N = int(input())
A = sorted([[int(_) for _ in input().split()] for __ in range(N)], key=lambda x: (-x[1], x[0]))
print(A[0][0], A[0][1])

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


//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
using ll = long long;
using vi = vector<int>;
using ii = pair<int,int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define invec(v) for(auto& x : v)cin>>x;
#define Test int T;cin>>T;while(T--)
#define REP(i,j,k) for(int i=(j);(i)<(k);(i)++)
#define Time()	cerr <<'\n' << clock() * 1000 / CLOCKS_PER_SEC << "ms\n"
#define SZ(x) (int)x.size();
#define all(x) x.begin,x.end()
// no change 

//const int MxN = 1e9+5;

int main() {
	ll x;
	ll a,b,a5,b5;
	cin>>x;
	for(int i=-500;i<=500;i++){
		for(int j =-500 ;j<=500 ;j++){
		a = i;
		b = j;
		ll f = a-b;
		if(!f)continue;
		if( x%f == 0 ){
			a5 = (ll)(a*a*a*a*a);
			b5 = (ll)(b*b*b*b*b);
			f = a5 - b5;
			//debug()<<imie(f);
			if(x == f){
				cout<<a<< " "<<b;
				exit(0);
			}
		}
	}
}
	Time();
	
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
#define PP 1000000007
using namespace std;

ll N, Ans = 0;
int main(){
cin >> N;
vector<ll> V(N + 1);
map<ll, ll> M;

rep(i, 1, N + 1){

  cin >> V[i];

  M[V[i]]++;

}

for(auto x : M )Ans += x.second*(x.second - 1)/2;

rep(i, 1, N + 1)cout << Ans - M[V[i]]*(M[V[i]] - 1)/2 + (M[V[i]] - 1)*(M[V[i]] - 2)/2 << endl;

}

Measured memory_bytes: 12688
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, a;
  cin >> n >> a;
  vector<int> x(n);
  rep(i, n) cin >> x.at(i);
  vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(n+1, vector<ll>(2501, 0)));
  dp.at(0).at(0).at(0) = 1;
  rep(i, n){
    rep(j, n){
      rep(k, 2501){
        dp.at(i+1).at(j).at(k) += dp.at(i).at(j).at(k);
        if(x.at(i)+k <= 2500) dp.at(i+1).at(j+1).at(k+x.at(i)) += dp.at(i).at(j).at(k);
      }
    }
  }
  ll ans = 0;
  rep2(i, 1, n+1){
    ans += dp.at(n).at(i).at(i*a);
  }
  cout << ans << endl;
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int x;
    cin >> x;
    
    long double res = (x/(double)3);
    res=(res*res*res);
    
    cout << precise(6) << res;
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 256
N,M,X=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(N)]
  
ans=9999999999

for i in range(2**N):
  cost=0
  C=[0]*M
  for n in range(N):
    #右にずらして一桁目が1かどうかを判定
    if (i>>n) &1:
      cost += arr[n][0]
      for j in range(1,M+1):
        C[j-1] += arr[n][j]
  if min(C)>=X:
    ans=min(ans, cost)
    
if ans ==  9999999999:
  print(-1)
else:
  print(ans)

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    int n, x, y;
    cin >> n >> x >> y;

    vector<int> ans(n);
    for(int i = 1; i <= n - 1; i++)
    {
        for(int j = i + 1; j <= n; j++)
        {
            int dist = min(j - i, abs(i - x) + abs(j - y) + 1);
            ans[dist]++;
        }
    }

    for(int i = 1; i <= n - 1; i++)
        cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,l = iim()
aji = 0
flag = False

for i in range(1,n+1):
    if l+i-1 == 0:
        flag = True
    aji += l+i-1


if flag:
    print(aji)
elif l > 0:
    print(aji - l)
else:
    print(aji - (l+n-1))

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std; 
  
int main() {
int n;
cin>>n;
vector<int> a(n+1,0);
for(int i=1;i<=n;i++){
	for(int j=0;j<=n;j=j+i){
		a[j]++;
	}
}
long long int total=0;
for(long long int i=1;i<=n;i++){
	total=total+(i*(long long)a[i]);
}
cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 42328
N,M=map(int,input().split())

A=[]
for _ in range(N):
    A.append(list(map(int,input().split())))

now=[0]*N
is_hold=[1]*M

ans=10**9
for _ in range(M):
    sanka=[0]*M
    for i in range(N):
        #print(A[i])
        sanka[A[i][now[i]]-1]+=1
    
    temp=max(sanka)
    ans=min(ans,temp)
    #print(ans)
    for i in range(len(sanka)):
        if sanka[i]==temp:
            tgt=i
            break
    is_hold[tgt]=0
    #print(is_hold)
    
    if _ == M-1:
        break
    for i in range(N):
        #print(i)
        while is_hold[A[i][now[i]]-1]==0:
            #print(i,now[i])
            now[i]+=1
        
print(ans)    


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

int main(){
	int n ; cin >> n;
	int k = 1;
	vector<tuple<string,int,int>> t(n);
		for(int i=0 ; i < n ; i++){
		string a; cin>>a;
		int b ; cin >> b;
		b *= (-1);
		t.at(i) = make_tuple( a , b, k);
		k++;
}
	sort(t.begin(),t.end());
	for(int k = 0 ; k < n; k++){
		int z;
	tie(ignore, ignore, z) = t.at(k);
	cout << z << endl;
	}
}



	

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b,c;
	scanf("%d %d", &a, &b);
	if(a<10){
		c = 100 * (10-a);
		printf("%d", c+b);
	}
	else{
		printf("%d", b);
	}
	return 0;	
} 


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {

    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];

    a[0]--;
    for (int i = 1; i < n; ++i) {
        if(a[i-1]!=a[i])
            a[i]--;
    }


    for (int i = 0; i < n-1; ++i) {
        if(a[i]>a[i+1])
        {
            cout<<"No";
            return 0;
        }
    }

    cout<<"Yes";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//0　謎　１本と　
int n;


int main(){
	cin>>n;
	int  t[n][n]={};
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			t[i][j]= -1;
		}
	}
	int k=(1<<n)-1;
	//cout<<k<<endl;
	//cout<<"K="<<k<<endl;

	for(int i=0; i<n; i++){
		int a;
		cin>>a;
		for(int j=0; j<a; j++){
			int x,y;
			cin>>x>>y;
			x--;
			t[i][x]=y;
		}
	}
	//for(int i=0; i<n; i++){
	//	for(int j=0; j<n; j++){
	//		cout<<t[i][j]<<" ";
	//	}
	//	cout<<endl;
	//}
	//cout<<"a"<<endl;
	int ans=0;
	for(int i=0; i<=k; i++){//調子乗ってビットdpしたら怒られた
		int d[n]={};
		
		for(int j=0; j<n; j++){
			if(i>>j & 1){
				d[j] = 1;
			}
		}
		bool ok = true;
		for(int j=0; j<n; j++){
			if(d[j]==1){
				for(int q=0; q<n; q++){
					if(t[j][q] == -1) continue;
					if(t[j][q] != d[q]){
						ok = false;
					}
				}
			}
		}
					
		if(ok) ans=max(__builtin_popcount(i),ans);
	}

	
	cout<<ans<<endl;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

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

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    string S;
    cin >> S;
    S[3] = '8';
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
mod=10**9+7
Layer=[]
a=1
b=1
while(b<=N):
    a=b
    b=N//(N//a)+1
    Layer.append((a,b))
#print(Layer)
num=[x[1]-x[0] for x in Layer]
M=len(Layer)
#print(num)
dp=[[0 for j in range(M+1)] for i in range(K+1)]
dp[0][0]=1
sdp=[0 for i in range(M+2)]
for k in range(K):
    for j in range(M+1):
        sdp[j+1]=(dp[k][j]+sdp[j])%mod
    for j in range(M):
        dp[k+1][j]=(sdp[M-j]*num[j])%mod
ans=0
for j in range(M+1):
    ans+=dp[K][j]
    ans%=mod
print(ans)


Measured memory_bytes: 121372
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        string s,t;
        cin>>s>>t;
        map<char,vl> m;
        ll S=Size(s);
        ll T=Size(t);
        s+=s;
        rep(i,S*2){
            m[s[i]].pb(i+1);
        }
        ll last=0;
        rep(i,T){
            char ct=t[i];
            if(Size(m[ct])==0){
                cout<<-1<<endl;
                return 0;
            }
            ll x=last/S;
            ll y=last%S;
            auto itr=lower_bound(all(m[ct]),y+1);
            ll index=itr-m[ct].begin();
            last=m[t[i]][index]+x*S;
        }
        cout<<last<<endl;
    }

Measured memory_bytes: 2916
#include <bits/stdc++.h>  // This will work only for g++ compiler. 


#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based

//short hand for usual tokens
#define pb push_back
#define fi first
#define se second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)

// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(c,x) ((c).find(x) != (c).end())

//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())

// Avoiding wrap around of size()-1 where size is a unsigned int.
#define sz(a) int((a).size())

using namespace std;

// Shorthand for commonly used types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

const ll  inf= 1e18 +5 ;  

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
    
    int n , w ; 
    cin>> n >> w ; 
    vector < int > wight( n ) , value ( n ) ; 
	int sum=0 ; 
	for ( int i =  0 ; i < n ;i++)
	{
		cin>>wight[i] >> value[i] ; 
		sum += value [i] ; 
	}
    
    vector < ll > dp(sum+1 , inf) ; // the value could be sum ; 
    dp[0] = 0 ;
    
    for ( int i = 0 ; i< n ;i++)
    {
		
		int va= value[i]; 
		ll wi = wight[i] ; 
		for ( int j =sum - value[i] ; j >= 0 ; j--)
		{
			dp[j +va ] = min (dp[j+va] , dp[j] +wi) ; // here because of dp[j] ..j sometimes gonna be 0 so you need to say that dp[0] = 0 ;
		}
		
	}
	
	
	int answer = 0 ; 
	for (int i =0 ; i<= sum ;i++)
	{
		if (dp[i] <= w) 
		answer = max ( answer , i ) ; 
	}
    
    
    
    cout<< answer << endl; 
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 1024