akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int Maxn = 500005;
int Tree[26][4*Maxn];
int N,Q;
string S;
void UpData(char a,int Poi,int poi,int Left,int Right)
{
	if(Right<Poi||Left>Poi)	return;
	if(Left == Right&&Left == Poi) 
	{
		Tree[a-'a'][poi] = 1;
		return;	
	}
	int Mid = Left + (Right - Left)/2;
	Tree[a -'a'][poi] = 1;
	UpData(a,Poi,poi*2,Left,Mid);
	UpData(a,Poi,poi*2+1,Mid+1,Right);
}
void print_Tree(int poi,int left,int right)
{
	printf("%d %d %d\n",left,right,Tree['b'-'a'][poi]);
	if(left==right) return;
	int Mid = (left + right)/2;
	print_Tree(poi*2,left,Mid);
	print_Tree(poi*2+1,Mid+1,right);
	return;
}
void UpData1(int Poi,char Begin,int poi,int Left,int Right)
{
	if(Right<Poi||Left>Poi)	return ;
	if(Left == Right &&Left == Poi)
	{
		Tree[Begin - 'a'][poi]  = 0;
		return;
	}
	int Mid = Left +(Right - Left)/2;
	UpData1(Poi,Begin,poi*2,Left,Mid);
	UpData1(Poi,Begin,poi*2+1,Mid+1,Right);
	if(Tree[Begin - 'a'][poi*2]==Tree[Begin -'a'][poi*2+1]&&Tree[Begin - 'a'][poi*2]==0)
		Tree[Begin - 'a'][poi] = 0;
	else
		Tree[Begin - 'a'][poi] = 1;
	return;
}
bool Search(int poi,int Left,int Right,char a,int L,int R)
{
	if(Left > R||Right<L)	return false;
	if(Tree[a-'a'][poi]==0)	return false;
	if(L<=Left&&Right<=R&&Tree[a-'a'][poi]==1) return true;
	int Mid = Left + (Right -Left)/2;
	if(Search(poi*2,Left,Mid,a,L,R))
		return true;
	if(Search(poi*2+1,Mid+1,Right,a,L,R))
		return true;
	return false;
}
int main()
{
	
	cin>>N>>S>>Q;
	for(int i=0;i<S.length();i++)
	{
		UpData(S[i],i+1,1,1,N);	//字符串是从1开始的所以位置往后面移动一个 
	}
	while(Q--)
	{
		int zz;
		cin>>zz;
		if(zz==1)
		{
			int poi;
			char change;
			cin>>poi>>change;
			if(change == S[poi-1])
				continue;
			UpData(change,poi,1,1,N);
			UpData1(poi,S[poi-1],1,1,N);
			S[poi-1] = change;
		}
		else
		{
			int Left, Right;
			cin>>Left>>Right;
			int ans =0;
			for(int i=0;i<26;i++)
			{
				if(Search(1,1,N,'a'+i,Left,Right))
				{
					ans++;
				}
			}
			printf("%d\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 160644
x,y,a,b,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort()
q.sort()
r.sort()

usep = a - x
useq = b - y
ans = sum(p[usep:]) + sum(q[useq:])
p.append(10 ** 9 + 1)
q.append(10 ** 9 + 1)

for i in range(c):
    if p[usep] < q[useq]:
        if r[c - i - 1] > p[usep]:
            ans = ans + r[c - i - 1] - p[usep]
            usep += 1
        else:
            break
    else:
        if r[c - i - 1] > q[useq]:
            ans = ans + r[c - i - 1] - q[useq]
            useq += 1
        else:
            break

print(ans)

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

int main(){
    string s;
    cin >> s;
    int x=0;
    rep(i,4){
        if(s[i]=='+'){
            x++;
        }else if(s[i]=='-'){
            x--;
        }
    }
    cout << x << endl;
}


Measured memory_bytes: 3596
#include<stdio.h>
int main()
{
    int a,b,c;
    // 整数の入力
    scanf("%d", &a);
    scanf("%d",&b);
  	scanf("%d",&c);
    if(a==7||b==7||c==7)
      if((a==5&&b==5)||(b==5&&c==5)||(c==5&&a==5)){
        printf("YES");
      }
  	else printf("NO");
    return 0;
}

Measured memory_bytes: 128
n = int(input())
A = list(map(int,input().split()))
q = int(input())
m = list(map(int,input().split()))

cand = []
for i in range(2**n):
    tmp = 0
    for j in range(n):
        if (i>>j)&1:
            tmp += A[j]
    cand.append(tmp)

for i in m:
    if i in cand:
        print("yes")
    else:
        print("no")   


Measured memory_bytes: 43080
readlines.each do |line| 
  ans = 0
  line = line.split
  case line[1]
  when "?"
    break
  when "+"
    ans = line[0].to_i + line[2].to_i

  when "-"
    ans = line[0].to_i - line[2].to_i

  when "*"
    ans = line[0].to_i * line[2].to_i

  when "/"
    ans = line[0].to_i / line[2].to_i
  end
  puts ans.to_s
end


Measured memory_bytes: 6872
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;

typedef tree<pair<ll, int>, null_type, less<pair<ll, int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//Ordered set
//pbds s1

int IsTriangle (ll a, ll b, ll c) {
    if (a+b > c && b+c>a && a+c>b)
        return 1;
    return 0;
}

void testCase() {
    int n;
    cin >> n;
    ll length[n+2];
    for (int i=0; i<n; i++)
        cin >> length[i];
    ll ans = 0;
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            for (int k=j+1; k<n; k++) {
                if (length[i]!=length[j] && length[i]!=length[k] && length[j]!=length[k]) {
                    if (IsTriangle (length[i], length[j], length[k])) {
                        //cout << "YO:" << i << " " << j << " " << k << endl;
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
int main(void) {
    int n,x,t;
    cin >> n >> x >> t;
    int cnt=x;
    int time = t;

    while(n>cnt) {
        cnt += x;
        time += t;
    }
    cout << time << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
const double pie  =3.141592653589793238463;
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define POP(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(),A.end());
#define REV(A) reverse(A.begin(), A.end());
#define lenth length()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n" 
const ll dx[4] = { -1, 1, 0, 0};
const ll dy[4] = {0, 0, -1, 1};
ll XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
ll YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
#define precise(x) cout<<fixed<<setprecision(x)
#define t1(x)                cerr<<#x<<": "<<x<<endl
#define t2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
void SieveOfEratosthenes(ll n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // for (ll p=2; p<=n; p++) 
       // if (prime[p]) 
          // cout << p << " "; 
} 

ll power(ll x, ll y) 
{ 
    ll res = 1; 
    while (y > 0) 
    { 
        if (y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x * x; 
    } 
    return res; 
}
int main()
{
    fastio
    ll t,i,j,k,l,m,n,a,x,b,y,z,c,h,d,e,p,nl,np,q,r;

    string s;
    ll f=0;
    cin>>n>>l;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(j+i==n && (j*4 + i*2)==l)
                f=1;
        }
    }
    if(f==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;



}

Measured memory_bytes: 3624
#include<iostream>
#include<deque>
#include<vector>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include <math.h>
using namespace std;

#define SIZEOF(x) (sizeof x) / (sizeof x[0])


int main(){
    int n ,d;
    cin >> n >> d;
    int x[n][d];
    for(int i = 0; i < n ; i++){
        for(int t = 0 ; t<d;t++){
            cin>>x[i][t];
        }
    }
    int sum =0 ;

    for (int i = 0; i<n-1;i++){
        for(int j = i+1 ; j<n ; j++){

            long k=0;
            for (int s = 0; s<d;s++){
                k += (x[i][s]-x[j][s])*(x[i][s]-x[j][s]);

            }
            double p = pow(k,0.5);
            for(long r = 0; r<100000 ; r++){
                if(p==r){
                    sum+=1;
                }
            }




        }
    }
    cout << sum;

    return 0;
}

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

typedef struct point{
	int x,y;
} t_point;

bool cmp(const t_point& a, const t_point& b)
{
	if( a.x < b.x )return true;
	else if( a.x > b.x )return false;
	return a.y < b.y;
}

int main()
{
	int n;
	t_point points[3000];
	
	while(cin>>n,n){
		for(int i=0; i<n; i++)
			cin >> points[i].x >> points[i].y ;
		sort( points, points+n, cmp );
		
		int ans = 0;
		for(int i=0; i<n-1; i++){
			for(int j=i+1; j<n; j++){
				t_point p3 = {points[i].y-points[j].y+points[j].x,
											points[j].x-points[i].x+points[j].y};
				t_point p4 = {points[i].y-points[j].y+points[i].x,
											points[j].x-points[i].x+points[i].y};
				int left = 0;
				int right = n-1;
				int diff;
				while( left<=right ){
					diff = (left+right)/2;
					if( points[diff].x==p3.x && points[diff].y==p3.y )break;
					if( cmp(points[diff],p3) )
						left = diff+1;
					else
						right = diff-1;
				}
				if( left>right )continue;
				left = 0;
				right = n-1;
				while( left<=right ){
					diff = (left+right)/2;
					if( points[diff].x==p4.x && points[diff].y==p4.y )break;
					if( cmp(points[diff],p4) )
						left = diff+1;
					else
						right = diff-1;
				}
				if( left>right )continue;
				ans = max(ans,(p3.x-p4.x)*(p3.x-p4.x)+(p3.y-p4.y)*(p3.y-p4.y));
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 896
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <boost/range/algorithm.hpp>
#include <boost/integer/common_factor_rt.hpp>
#define MAX 100000000

using namespace std;

int A, B;

int main()
{
    while (cin >> A >> B)
    {
        if (abs(A - B) % 2 == 0)
        {
            cout << abs(A - B) / 2 + min(A, B) << endl;
        }
        else
        {
            cout << "IMPOSSIBLE" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

typedef vector<vvi> vvvi;
struct app{
	int s,e,w;
	bool operator<(const app &other)const{
		return e<other.e;
	}
};
int main(){
	int n;
	while(cin>>n,n){
		vector<app>a(n);
		REP(i,n){
			cin>>a[i].s>>a[i].e>>a[i].w;
		}
		sort(ALL(a));
		vvvi dp(366,vvi(366,vi(2)));
		REP(i,n){
			REP(j,366){
				REP(k,366){
					if(j<a[i].s){
						dp[a[i].e][k][1]=max(dp[a[i].e][k][1],dp[j][k][0]+a[i].w);
					}
					if(k<a[i].s){
						dp[j][a[i].e][1]=max(dp[j][a[i].e][1],dp[j][k][0]+a[i].w);
					}
				}
			}
			REP(j,366){
				REP(k,366){
					if(j>0)dp[j][k][1]=max(dp[j][k][1],dp[j-1][k][1]);
					if(k>0)dp[j][k][1]=max(dp[j][k][1],dp[j][k-1][1]);
					dp[j][k][0]=dp[j][k][1];
				}
			}
		}
		int ans=0;
		REP(i,366){
			REP(j,366){
				REP(k,2){
					ans=max(ans,dp[i][j][k]);
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 8580
#include <stdio.h>
#include <math.h>
int N=100;

int main(){
  int n,p[N+1],m[N+1][N+1],i,l,j,tmp;
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
  }

  for(i=1;i<=n;i++) m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=10000000;
      for(int k=i;k<=j-1;k++){
	tmp=(m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
	if(m[i][j]>tmp)
	  m[i][j]=tmp;
      }
    }
  }

  printf("%d\n",m[1][n]);

  return 0;
}


  
      



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 

const int M_N=200001;

struct UnionFind{
    int par[M_N];
    int rank[M_N];
    LL number[M_N];
 
    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
            number[i]=1;
        }
    }
 
    int find(int x){
        if(par[x]==x){
            return x;
        }
        else{
            return par[x]=find(par[x]);
        }
    }
 
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
            number[y]+=number[x];
        }
        else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
            number[x]+=number[y];
        }
    }
 
    bool same(int x,int y){
        return find(x)==find(y);
    }
 
    int get(int x){
        return number[find(x)];
    }
 
};

vector<int> v[100001],u[100001];

int main(){
    int n;cin >> n;
    UnionFind uf;
    uf.init(100001);
    for (int i = 0; i < n; i++) {
        int x,y;cin >> x >> y;
        v[x].pb(y);
        u[y].pb(x);
    }
    for (int i = 1; i <= 100000; i++) {
        for (int j = 1; j < u[i].size(); j++) {
            uf.unite(u[i][j],u[i][j-1]);
        }
    }
    LL ans = 0;
    vector<bool> used(100001,false);
    for (int i = 1; i <= 100000; i++) {
        if(used[uf.find(i)]) continue;
        if(uf.get(i)==1){
            ans += (LL)v[i].size();
            continue;
        }
        UnionFind ut;
        ut.init(100001);
        LL t = 1;
        for (int j = 0; j < v[i].size(); j++) {
            ut.unite(v[i][j],0);
        }
        for (int j = i+1; j <= 100000; j++) {
            if(!uf.same(i,j)) continue;
            t++;
            for (int k = 0; k < v[j].size(); k++) {
                ut.unite(v[j][k],0);
            }
        }
        used[uf.find(i)]=true;
        ans += (ut.get(0)-1)*t;
    }
    cout << ans-n << endl;
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (to_string(i).length() % 2) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

using maze = std::vector<std::string>;

struct Point
{
  int x;
  int y;

  Point() : x(0), y(0) {}
  Point(int x, int y) : x(x), y(y) {}

  bool operator==(const Point& rhs) const
  {
    return x == rhs.x && y == rhs.y;
  }
};

namespace std {

template<>
struct hash<Point>
{
  std::size_t operator()(const Point& p) const
  {
    return std::hash<int>{}(p.x) ^ std::hash<int>{}(p.y);
  }
};

}

bool is_in(int h, int w, const Point& p)
{
  return p.x >= 0 && p.x < w
      && p.y >= 0 && p.y < h;
}

bool move(
    int h,
    int w,
    const Point& p,
    maze& m,
    std::queue<Point>& q)
{
  if (!is_in(h, w, p)) return false;

  auto& v = m[p.y][p.x];
  if (v == '#' || v == 'x') return false;
  v = 'x';
  q.push(p);
  return true;
}

void print(const maze& m)
{
  for (const auto& row : m) {
    std::cerr << row << std::endl;
  }
}

//void check_warp(int h, int w, const Point& p, maze& m)
//{
//  for (int x = std::max(0, p.x - 2); x < std::min(w, p.x + 3); ++x) {
//    for (int y = std::max(0, p.y - 2); y < std::min(h, p.y + 3); ++y) {
//      auto& v = m[y][x];
//      if (v == '.') v = 'w';
//    }
//  }
//}

int solve(int h, int w, const Point& start, const Point& goal, maze& m)
{
  int result = 0;
  std::queue<Point> q;

  q.push(start);

  while (true) {
    std::unordered_set<Point> warps;
    while (!q.empty()) {
      auto p = q.front();
      q.pop();

      if (p == goal) return result;
      m[p.y][p.x] = 'x';

      move(h, w, Point{p.x + 1, p.y}, m, q);
      move(h, w, Point{p.x - 1, p.y}, m, q);
      move(h, w, Point{p.x, p.y + 1}, m, q);
      move(h, w, Point{p.x, p.y - 1}, m, q);

      for (int x = std::max(0, p.x - 2); x < std::min(w, p.x + 3); ++x) {
        for (int y = std::max(0, p.y - 2); y < std::min(h, p.y + 3); ++y) {
          auto& v = m[y][x];
          if (v == '.') warps.emplace(x, y);
        }
      }
    }

    ++result;

    for (const auto& p : warps) {
      q.push(p);
    }
    if (q.empty()) return -1;
  }
}

int main()
{
  int h, w;
  Point start, goal;
  std::cin >> h >> w >> start.y >> start.x >> goal.y >> goal.x;
  --start.x;
  --start.y;
  --goal.x;
  --goal.y;

  maze m(h);
  for (auto& row : m) {
    std::cin >> row;
  }

  std::cout << std::setprecision(20);
  std::cout << solve(h, w, start, goal, m) << std::endl;
}


Measured memory_bytes: 6056
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#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=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];

    ll ans = 0;
    FOR(i, 1, N-1) {
        if(a[i] + a[i-1] > x) {
            ans += a[i] + a[i-1] - x;
            if(a[i] > a[i] + a[i-1] - x) a[i] -= a[i] + a[i-1] - x;
            else a[i] = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
char st[999999];
int a[999999];
int len,num;
void add(int p)
{
	for (int i=1;;i++)
	{
		if (!p) return;
		num-=(a[i]==9);
		a[i]+=p;p=a[i]/10;a[i]%=10;
		num+=(a[i]==9);
	}
}
int main()
{
	scanf("%s",st+1);len=strlen(st+1);
	for (int i=1;i<=len;i++) a[i]=st[len-i+1]-'0';
	int d=0;
	for (int i=1;i<=len;i++)
	{
		int t=a[i]*9+d;
		d=t/10;a[i]=t%10;
	}
	if (d) a[++len]=d;
	for (int i=1;i<=len;i++) num+=(a[i]==9);
	int ans=0;
	for (int i=len;i>=2;i--)
	{
		if (num==i) break;
		int t=a[i];ans+=t;num-=(a[i]==9);a[i]=0;
		add(t);
		t=a[i];ans+=t;num-=(a[i]==9);a[i]=0;
		add(t);
	}
	ans+=(a[1]==9);if ((a[1]!=0)&&(a[1]!=9)) assert(0);
	printf("%d\n",(ans+8)/9);
}
		
		

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

int main()
{
	int n;
	bool *taro,*hanako;
	while(cin >> n){
		if(n == 0)
			break;
		int card;
		taro = new bool[2*n+1];
		hanako = new bool[2*n+1];
		for(int i=0;i<2*n+1;i++){
			taro[i] = false;
			hanako[i] = true;
		}
		taro[0] = hanako[0] = false;

		for(int i=0;i<n;i++){
			cin >> card;
			taro[card] = true;
			hanako[card] = false;
		}

		int tn,hn;
		bool thk = true;
		tn = hn = n;
		do{
			int field = 0;
			if(thk == true)
				thk = false;
			else
				thk = true;
			for(int i=0;i<2*n+1;i++){
				if(taro[i] && i>field && !thk){
					field = i;
					taro[i] = false;
					tn--;
					thk = true;
				}else if(hanako[i] && i>field && thk){
					field = i;
					hanako[i] = false;
					hn--;
					thk = false;
				}
				if(tn == 0 || hn == 0)
					break;
			}
		}while( tn!=0 && hn!=0 );
		cout << hn <<endl;
		cout << tn <<endl;
		delete[] taro;
		delete[] hanako;
	}
	return 0;
}

Measured memory_bytes: 0
using System;

namespace ABC075_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var sss = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var H = sss[0];
            var W = sss[1];
            var board = new char[H, W];
            for (var i = 0; i < H; i++)
            {
                var sa = Console.ReadLine();
                for (var j = 0; j < W; j++)
                {
                    board[i, j] = sa[j];
                }
            }
            var xidou = new int[] { 1, 0, -1, 0, 1, -1, 1, -1 };
            var yidou = new int[] { 0, 1, 0, -1, -1, -1, 1, 1 };
            for (var i = 0; i < H; i++)
            {
                for (var j = 0; j < W; j++)
                {
                    int num = 0;
                    if (board[i, j] == '#')
                    {
                        Console.Write('#');
                        continue;
                    }
                    else
                    {
                        for (var k = 0; k < 8; k++)
                        {
                            var xv = j + xidou[k];
                            var yv = i + yidou[k];
                            if (yv < 0 || H <= yv)
                                continue;
                            if (xv < 0 || W <= xv)
                                continue;
                            if (board[yv, xv] == '#')
                                num++;
                        }
                        Console.Write(num);
                    }
                }
                Console.WriteLine();
            }
        }
    }
}


Measured memory_bytes: 13140
// abc174_f
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << "\n";}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;



template <typename T>
struct RangeTree {
    int n;
    vector<vector<T>> dat;
    vector<T> val;

    explicit RangeTree(vector<T>& val_): val(val_) {
        n = 1;
        while (n < val.size()) n <<= 1;
        dat.assign(n << 1, vector<T>());

        build(0, 0, val.size());
    }

    void build(int k, int l, int r) {
        if (r-l == 1) {
            dat[k].emplace_back(val[l]);
        } else {
            int lch = 2*k+1, rch = 2*k+2;
            build(lch, l, (l+r)/2);
            build(rch, (l+r)/2, r);
            dat[k].resize(r-l);
            merge(dat[lch].begin(), dat[lch].end(), dat[rch].begin(), dat[rch].end(), dat[k].begin());
        }
    }

    int query(int i, int j, T x) {
        return query(i, j, x, 0, 0, val.size());
    }

    int query(int i, int j, T x, int k, int l, int r) {
        if (j <= l || r <= i) return 0;
        // x以下の要素の数
//        if (i <= l && r <= j) return upper_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
        // x未満の要素の数
        if (i <= l && r <= j) return lower_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
        int lch = query(i, j, x, 2*k+1, l, (l+r)/2);
        int rch = query(i, j, x, 2*k+2, (l+r)/2, r);
        return lch+rch;
    }
};


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, Q;
    cin >> N >> Q;
    vector<int> C(N);
    REP(i, N) {cin >> C[i]; C[i]--;}

    vector<int> last(N, N);
    vector<int> nxt(N);
    REP_REV(i, N){
        nxt[i] = last[C[i]];
        last[C[i]] = i;
    }

    // [l,r)で、r未満の要素の数を数える
    RangeTree<int> rt(nxt);

    REP(i, Q){
        int l, r;
        cin >> l >> r; l--;
        int ans = r - l - rt.query(l, r, r);
        print(ans);
    }


    return 0;
}


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

int main(){
	
	int mp[10][10]={0};
	int dx[13]={0,0,1,0,-1,1,1,-1,-1,0,2,0,-2};
	int dy[13]={0,1,0,-1,0,1,-1,-1,1,2,0,-2,0};
	int x,y,s;
	int ans1=100,ans2=0;
	while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
		s=s*4+1;
		for(int i=0;i<s;i++){
			int X=x+dx[i];
			int Y=y+dy[i];
			if(0<=X && X<=9 && 0<=Y && Y<=9){
				if(mp[X][Y]==0)ans1--;
				mp[X][Y]++;
				ans2=max(ans2,mp[X][Y]);
			}
		}
	}
	cout<<ans1<<endl;
	cout<<ans2<<endl;
	
	return 0;
}


Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#define llint long long

using namespace std;

llint n;
char ans[1005][1005];
char c4[4][4] = {
	{0, 0, 2, 3},
	{1, 1, 2, 3},
	{4, 5, 6, 6},
	{4, 5, 7, 7}
};
char c5[5][5] = {
	{0, 0, 1, 1, 2},
	{3, 4, -1, -1, 2},
	{3, 4, -1, -1, 5},
	{6, -1, 7, 7, 5},
	{6, 8, 8, 9, 9}
};
char c6[6][6] = {
	{0, -1, -1, 1, 2, 2},
	{0, -1, -1, 1, -1, 3},
	{-1, 4, 4, 5, 5, 3},
	{6, 6, 7, 8, -1, -1},
	{9, -1, 7, 8, -1, -1},
	{9, 10, 10, -1, 11, 11}
};
char c7[7][7] = {
	{0, 0, 1, 1, 2, 2, -1},
	{6, 7, 7, -1, -1, -1, 3},
	{6, -1, 8, -1, -1, -1, 3},
	{9, 9, 8, -1, -1, -1, 4},
	{-1, -1, -1, 10, 12, 12, 4},
	{-1, -1, -1, 10, -1, 13, 5},
	{-1, -1, -1, 11, 11, 13, 5}
};

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	if(n <= 2){
		cout << -1 << endl;
		return 0;
	}
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			ans[i][j] = '.';
		}
	}
	if(n == 3){
		ans[1][1] = 'a';
		ans[2][1] = 'a';
		ans[3][2] = 'b';
		ans[3][3] = 'b';
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				cout << ans[i][j];
			}
			cout << endl;
		}
		return 0;
	}
	
	int rem = n, p = 1;
	while(1){
		if(rem >= 8){
			for(int i = 0; i < 4; i++){
				for(int j = 0; j < 4; j++){
					if(c4[i][j] >= 0) ans[p+i][p+j] = (char)(c4[i][j] + 'a');
				}
			}
			rem -= 4, p += 4;
		}
		else{
			if(rem == 4){
				for(int i = 0; i < 4; i++){
					for(int j = 0; j < 4; j++){
						if(c4[i][j] >= 0) ans[p+i][p+j] = (char)(c4[i][j] + 'a');
					}
				}
				break;
			}
			if(rem == 5){
				for(int i = 0; i < 5; i++){
					for(int j = 0; j < 5; j++){
						if(c5[i][j] >= 0) ans[p+i][p+j] = (char)(c5[i][j] + 'a');
					}
				}
				break;
			}
			if(rem == 6){
				for(int i = 0; i < 6; i++){
					for(int j = 0; j < 6; j++){
						if(c6[i][j] >= 0) ans[p+i][p+j] = (char)(c6[i][j] + 'a');
					}
				}
				break;
			}
			if(rem == 7){
				for(int i = 0; i < 7; i++){
					for(int j = 0; j < 7; j++){
						if(c7[i][j] >= 0) ans[p+i][p+j] = (char)(c7[i][j] + 'a');
					}
				}
				break;
			}
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			cout << ans[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2176
N,L = (int(x) for x in input().split())
if L<=0 and L+N-1>=0:
        sum = N*(2*L+N-1)//2
elif L<0 and L+N-1<0:
        sum = (N-1)*(2*L+N-2)//2
else:
        sum = (N-1)*(2*L+N)//2
print(sum)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define MX 105
#define ll long long int
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x,y,sizeof(x))
using namespace std;
int main()
{
    ll d,n,ans=0;
    scanf("%lld%lld",&d,&n);
    for(ll i=1;i<=1010000;i++)
    {
        ll x=i,c=0;
        while(x%100==0)
        {
            x/=100;
            c++;
        }
        if(c==d)
        {
            ans++;
            if(ans==n)
            {
                printf("%lld\n",i);
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
n = int(input())
a = {}
for i in range(n):
    s = input()
    if s in a:
        a[s] += 1
    else:
        a[s] = 1
m = max(a.values())
l = []
for i,j in a.items():
    if j == m:
        l.append(i)
for i in sorted(l):
    print(i)

Measured memory_bytes: 32988
#include <stdio.h>
int main()
{
	int i, n, j;
	int a[205];
	while(scanf("%d",&n)!=EOF)
	{
		int vis = 1;
		for(i = 1 ; i <= n ;i++)
		{
			scanf("%d", &a[i]);
			if(a[i] % 2 == 1)
			{
				vis = 0;
			}
		}
		int count = 1;
		if(vis == 0)
		{
			printf("0\n");
		}
		else
		{
			for(;;)
			{
				for(j = 1 ; j <= n ;j++)
				{
					a[j] = a[j] / 2;
				}
				for(j = 1 ; j <= n ;j++)
				{
					if(a[j] % 2 == 1)
					{
						vis = 0;
					}
				}
				if(vis == 0)break;
				count++;
			}
			printf("%d\n",count);
		}
	}
	return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())
ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))

node = [[] for i in range(n)]
for i in range(m):
    node[ab[i][0] - 1].append(ab[i][1])
    node[ab[i][1] - 1].append(ab[i][0])

# print(node)
node_dic = [[] for i in range(n)]
now = [1]
while True:
    # print('now:{}'.format(now))
    flag = True
    next_node = []
    for i in range(len(now)):
        next_node_element = node[now[i] - 1]
        
        for j in range(len(next_node_element)):
            if not node_dic[next_node_element[j] - 1]:
                next_node.append(next_node_element[j])
                node_dic[next_node_element[j] - 1].append(now[i])
                flag = False
    # next_node = sum(next_node, [])
    # print('next_node: {}'.format(next_node))
    # print(node_dic)
    # print('next_node:{}'.format(next_node))
    now = []
    now = next_node
    if flag:
        break

for i in range(n):
    if i == 0:
        print('Yes')
        continue
    print(node_dic[i][0])

Measured memory_bytes: 67256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> a(100000);
  int b;
  REP(i,N){
    cin >> b;
    a[b]++;
  }
  int ans = 0;
  for(int i=1;i<99999;i++){
      int sum = a[i-1] + a[i] + a[i+1];
      ans = max(ans,sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
parseInt(x) = parse(Int, x)

function main()
	n = parseInt.(split(readline()))
	x = Array{Int}(2, n[1])
	for i in 1:n[1]
		x[:,i] = map(parseInt, split(readline()))
	end
	maxa = maximum(x[1,:])
	useb = Int[]
	for i in 1:n[1]
		if x[2,i] > maxa
			push!(useb, x[2,i])
		end
	end
	useb = sort(useb, rev=true)
	hp = n[2]
	count = 0
	for i in 1:length(useb)
		if hp > 0
			hp -= useb[i]
			count += 1
		end
	end
	if hp > 0
		if hp%maxa == 0
			count += div(hp, maxa)
		else
			count += div(hp, maxa)+1
		end
	end
	print(count)
end

main()

Measured memory_bytes: 162848
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N     = ~~arg[0];
    const table = arg.slice(1, 3).map(n=>n.split(" ").map(l=>~~l));
    
    let cnt = 0;
    
    for(let down=0; down<N; down++) {
        let sum = 0;
        
        for(let i=0; i<N; i++) {
            if(i <= down) {
                sum += table[0][i];
            }
            if(i >= down) {
                sum += table[1][i];
            }
        }
        
        cnt = Math.max(cnt, sum);
    }
    
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  int N;
  int k;
  int t = 1;

  cin >> N >> k;

  for (int i = 0; i<N; i++){
    if (t * 2 < t + k)
      t *= 2;
    else
      t += k;
  }

  cout << t;
}


Measured memory_bytes: 256
#  x' = ( A * x + B) mod C
def random(a,b,c,x):
    li = [x]
    for i in range(100000):
        x = (a * x + b) % c
        li.append(x)
    return li

while True:
    n,a,b,c,x = [int(i) for i in input().split()]
    if n == a == b == c == x == 0: 
        break

    y_lis = [int(y) for y in input().split()]
    x_lis = random(a,b,c,x)
    f = 0
    r = 0
    if set(y_lis) & set(x_lis) == set():
        print(-1)
    else:
        while f <= 10000:
            if x_lis[f] == y_lis[r]:
                r += 1
            if r == n:
                break
            f += 1
        if r == n:
            print(f)
        else:
            print(-1)


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b;
	string s;
	cin >>a >>b >>s;
	int ok =1;
	if(sz(s) != a+b+1){ ok=0; puts("No"); return 0;}
	rep(i,a) if(!isdigit(s[i])) ok =0;
	if(s[a] != '-') ok=0;
	rep(i,b) if(!isdigit(s[a+1+i])) ok =0;
	cout << (ok? "Yes":"No")<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
long long n, r, count;
typedef long long ll;
//下面是一个输出函数
char ss[2000];
int number = 0;
void print(ll x)
{
	if (x <= 9)//当这个余数小于9的时候直接将这个数输出就行 
		ss[number++] = x + 48;
	else//如果是16进制，应该将这个数做相应的处理 
		ss[number++] = x + 55;//这个数减去10再加上'A'或者是65
		//'A'阿斯特码对应65 
}
void change(ll n, ll r)
{
	if (n)
		//n不为零时就进行如下转换 
	{
		change(n / r, r);//函数递归调用 
		print(n % r); //每次调用输出这个余数，直到n为零 
	}
}
int main()
{
	scanf("%lld%lld", &n, &r); //主函数部分比较简单
	//上变是数据的输入 
	change(n, r);//进制转换的关键过程
	char ss2[200];
	for (int i = 0; i < number; i++)
		ss2[number - 1 - i] = ss[i];//完成转换 
	printf("%d\n", number);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

const ll MOD = 1000000007;

struct mint {
    ll x;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    mint operator-() const {
        return mint(-x);
    }
    mint &operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t / 2);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

ostream &operator<<(ostream &os, const mint &a) {
    return os << a.x;
}

int main() {
    int N;
    cin >> N;
    vec<ll> A(N), B(N);
    map<pair<ll, ll>, ll> P;
    rep(i, N) {
        cin >> A[i] >> B[i];
        ll g = gcd(abs(A[i]), abs(B[i]));
        if ((A[i] > 0 && B[i] > 0) || (A[i] < 0 && B[i] < 0)) {
            ++P[{abs(A[i]) / g, abs(B[i]) / g}];
        } else if (A[i] == 0 && B[i] == 0) {
            ++P[{0, 0}];
        } else if (A[i] == 0) {
            ++P[{0, -1}];
        } else if (B[i] == 0) {
            ++P[{1, 0}];
        } else {
            ++P[{abs(A[i]) / g, -1 * abs(B[i]) / g}];
        }
    }

    mint ans     = 1;
    mint anszero = 0;
    map<pair<ll, ll>, bool> checked;
    for (auto [f, s] : P) {
        ll A = f.first;
        ll B = f.second;
        if (s == 0 || checked[{A, B}]) continue;
        if (A == 0 && B == 0) {
            anszero = s;
        } else {
            checked[{A, B}] = true;
            ll VS;
            if (B > 0) {
                checked[{B, -A}] = true;
                VS               = P[{B, -A}];
            } else {
                checked[{-B, A}] = true;
                VS                = P[{-B, A}];
            }
            mint c1 = mint(2).pow(s) - 1;
            mint c2 = mint(2).pow(VS) - 1;
            ans *= (c1 + c2 + 1);
        }
    }
    cout << ans - 1 + anszero << endl;
}


Measured memory_bytes: 56192
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
#define pb push_back
#define pll pair<ll, ll>
#define mll map<ll, ll>
#define ff first
#define oo 1000000000000000005
#define ss second
#define el "\n"
#define maxS 100005
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    // ll t;cin>>t;while(t--)
    {
        ll n;
        cin>>n;
        unordered_set<string> s;
        while(n--)
        {
            string tmp;
            cin>>tmp;
            s.insert(tmp);
        }
        
        cout<<s.size();
    }
    return 0;
}

Measured memory_bytes: 17756
#include <bits/stdc++.h>
#include <stdio.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 rep(i,n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()

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

int a,b,c,d,e,f;

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

	cin>>a>>b>>c>>d>>e>>f;
	int wa=1,su=1;
	rep(i,f/(100*a)) {
		int x=i*a*100;
		if(x>f) break;
		rep(j,f/(100*b)) {
			int y=j*b*100;
			if(x+y>f) break;
			REP(k,f/c) {
				int z=k*c;
				if(x+y+z>f) break;
				REP(l,f/d) {
					int n=l*d;
					if(x+y+z+n>f) break;
					if((z+n)>(x+y)/100*e) break;
					if((x+z+y+n)*su<=(z+n)*(su+wa)) su=z+n,wa=x+y;
				}
			}
		}
	}

	cout << su+wa << ' ' << su << endl;

	return 0;
}


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

void printc(char c,int n)
{
	for(int i=0;i<n;i++)cout << c;
	return;
}

int main()
{
	int n;
	string S;
	int al[55][26]={};
	int tmp;
	
	cin >> n;
	
	for(int i=0;i<n;i++)
	{
		cin >> S;
		for(int j=0;j<S.size();j++)
		{
			al[i][S[j]-'a']++;
		}
	}
	
	for(int i=0;i<26;i++)
	{
		tmp=1e3;
		for(int j=0;j<n;j++)
			tmp=min(tmp,al[j][i]);
		printc(i+'a',tmp);
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <iomanip>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n,k;
    cin>>n>>k;
    vector<double> v(n);
    REP(i,n){
        cin>>v[i];
        v[i]=(1.+v[i])/2.;
        //cout<<v[i]<<endl;    
    }
    double result = 0;
    REP(i,k){
        result += v[i];
    }
    double tmp=result;
    FOR(i,k,n){
        
        tmp += v[i] - v[i - k];
        result = max(result, tmp);

    }
    std::cout << std::fixed;
std::cout << std::setprecision(10)<< result << endl;
    return 0;
}


Measured memory_bytes: 1792
T1,T2=[int(s) for s in input().split()]
ls1=[int(s) for s in input().split()]
ls2=[int(s) for s in input().split()]
A1,A2=ls1
B1,B2=ls2

#1ループした際の移動距離が同じなら、infinity
if  A1*T1+A2*T2==B1*T1+B2*T2:
  print('infinity')
else:
  if A1*T1+A2*T2-B1*T1-B2*T2<0: #1ループで長距離進むのはAとする
    A1,A2=ls2
    B1,B2=ls1
  d=A1*T1+A2*T2-B1*T1-B2*T2 #1ループで着く差
  x=(B1-A1)*T1
  ####ループ開始時に差がxメートル以内なら、２回交わる
  ####ループ開始時に差がちょうどxメートルなら、１回交わる
  ####xが負なら永久に交わらない
  if x<0:
    print(0)
  elif x%d==0:
    print(2*(x//d))
  else:
    print(2*(x//d)+1)

Measured memory_bytes: 38496
#include<bits/stdc++.h>
using namespace std;
stack<int>st;
queue<int>q;
vector<int>v,v1,v2,v3;
set<int>stt;
set<int>::iterator set_it;
map<string,int>mp;
//initialy map er all index er value zero thake;
//map er jonno this pointer(->) use korte hoy
//akta value dakhar jonno staristics pointer(*) use  korte hoy
// one more value print korar jonno this pointer(->) use korte hoy (must be)
map<string,int>::iterator map_it;
long long int a[20007];
long long int i,j,k,l,m,n,cnt=0,sum=0,mx=0,mn=0;
string s,s1,s2;
int main()
{
    cin>>n;
    sum=0;
    for(i=1; i<=n; i++)
    {
        if(i%3!=0&&i%5!=0)
        {

            sum+=i;
        }
       // cout<<sum<<endl;
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Scanner;

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

        char[] c = s.toCharArray();
        Arrays.sort(c);

        if (c[0] == c[1] && c[2] == c[3] && c[1] != c[2]) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 21844
str = gets.chomp
q = gets.chomp.to_i
q.times {
    order = gets.chomp.split(" ")
    if order[0] == "print"
        print(str[order[1].to_i..order[2].to_i],"\n")
    elsif order[0] == "reverse"
        str[order[1].to_i..order[2].to_i] = str[order[1].to_i..order[2].to_i].reverse
    elsif order[0] == "replace"
        str[order[1].to_i..order[2].to_i] = order[3]
    end
}

Measured memory_bytes: 8736
line = list(map(int,input().split()))
dx = line[2]-line[0]
dy = line[3]-line[1]
for i in range(dx):
	print('R',end='')
for i in range(dy):
	print('U',end='')
for i in range(dx):
	print('L',end='')
for i in range(dy+1):
	print('D',end='')
for i in range(dx+1):
	print('R',end='')
for i in range(dy+1):
	print('U',end='')
print('LU',end='')
for i in range(dx+1):
	print('L',end='')
for i in range(dy+1):
	print('D',end='')
print('R')


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define MOD1 1000000007
#define MOD2 1000000009
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ffl fflush(stdout);
#define all(x) (x).begin,(x).end()
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }
typedef long long int ll;
typedef long int li;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main() 
{
	#ifndef ONLINE_JUDGE
	freopen("G:/coding/CPP/input.txt", "r", stdin);
	freopen("G:/coding/CPP/output.txt", "w", stdout);
	#else
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	#endif
	int n;
	cin>>n;
	long int given = 1000;
	while(given < n) {
		given+=1000;
	}
	long int ans = given-n;
	cout<<ans;

}


Measured memory_bytes: 3636
// -D_GLIBCXX_DEBUG
#include <bits/stdc++.h>
    using namespace std;
#define int long long int
// #include "../../Template.cpp"

const int mod = (1e9) + 7;

int n;
vector<vector<int>> arr;
vector<vector<int>> dp;
int limit = 0;

void add_self(int&a , int b) {
    a += b;
    if(a>mod) {
        a -= mod;
    }
}

void solve() {
    for(int j = 0; j <= limit; j ++) {
        int i = __builtin_popcount(j);
        if(i == 0) {
            dp[i][j] = 1LL;
            continue;
        }
        for(int w = 1; w <= n; w ++) {
            if(arr[i][w] && (j&(1LL<<(w-1)))) {
                int newmask = j^(1LL<<(w-1));
                add_self(dp[i][j], dp[i-1][newmask]);
            }
        }
    }
    int ans = dp[n][limit]%mod;
    cout << ans << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    arr.assign(n+1, vector<int>(n+1, 0));
    for(int i = 1; i <= n; i ++) {
        for(int j = 1; j <= n; j ++) {
            cin >> arr[i][j];
        }
    }
    limit = (1<<n) - 1;
    dp.assign(n+1, vector<int>(limit+1, 0));
    solve();
    return 0;
}

Measured memory_bytes: 377216
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 30;

int n,m;
int a[100005];
int b[200005],c[100005],cnt=0;

void s0(){
	int s=n;
	b[++cnt]=1;-- s;
	for(int i=1;i<=m-1;i++)b[++cnt]=a[i], s -= a[i];
	if(s==0)return ;
	-- s; s>>=1;
	
	for(int i=1;i<=s/2;i++)b[++cnt]=2;b[++cnt]=1;
	for(int i=s/2+1;i<=s;i++)b[++cnt]=2;
} // 1 a[1] .. a[m-1] 2 2 .. 2 1 2 .. 2 2

void s1(){
	for(int i=1;i<=a[1]/2;i++)b[++cnt]=2;
	for(int i=2;i<=m;i++)b[++cnt]=a[i];
	b[++cnt]=1;
} // 2 2 .. 2 a[2] .. a[m] 1

void s2(){
	b[++cnt]=a[1]+1;
	for(int i=2;i<m;i++)b[++cnt]=a[i];
	for(int i=1;i<=a[m]/2;i++)b[++cnt]=2;
} // a[1]+1 a[2] .. a[m] 2 2 .. 2 2

int main(){
	int od=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]), od += (a[i]&1);
	if(od>2)return puts("Impossible"),0;
	
	int cnt2=0;
	for(int i=1;i<=m;i++)
		if(a[i]&1)c[++ cnt2]=i;
	if(cnt2>=1)swap(a[1],a[c[1]]);
	if(cnt2>=2)swap(a[m],a[c[2]]);
	for(int i=1;i<=m;i++)printf("%d ",a[i]);puts("");
		
	if(cnt2==0)s0();
	if(cnt2==1)s1();
	if(cnt2==2)s2();
	
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)printf("%d ",b[i]);puts("");

	return 0;
}


Measured memory_bytes: 512
import math
import itertools
n = int(input())
x = []
y = []
p = []
seq = []
for i in range(n):
    a,b = map(float,input().split())
    x.append(a)
    y.append(b)
    seq.append(i)
p = list(itertools.permutations(seq))
li = []
for s in p:
    l = 0.0
    for i in range(n-1):
        l += math.sqrt((x[s[i]] - x[s[i+1]]) ** 2 + (y[s[i]] - y[s[i+1]]) ** 2)
    li.append(l)
print(sum(li) / len(p))

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

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

    vector<string> s(n);

    for(int i=0; i<n; i++){

        cin>>s[i];

        sort(s[i].begin(),s[i].end());
    }

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

    int count=0;

    long long  int ans =0;

    //

    for(int i=1; i<n; i++){
            if(s[i-1] == s[i]){
                 count++;
                 ans += count;
            }

            else count=0;
    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 7296