akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
 
int main() {
	int N, K;
	cin >> N >> K;

	if (K == 10) {
		string _s = to_string(N);
		cout << _s.length() << endl;
		return 0;
	}

	int times = 1;
	while (N / K >= 1)
	{
		N /= K;
		times++;
	}
	
	cout << times << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define int long long
#define all(x) (x).begin(), (x).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define eb emplace_back
#define pii pair<int, int>

using namespace std;

const int mxn = 300005;
vector<int> fx(mxn, 0), fy(mxn, 0);
void solve()
{
    int h, w, m;
    cin >> h >> w >> m;
    set<pii> s;
    int x, y;
    while (m--)
    {
        cin >> x >> y;
        fx[x]++, fy[y]++;
        s.insert({x, y});
    }
    int mx = *max_element(fx.begin(), fx.end()), my = *max_element(fy.begin(), fy.end());
    vector<int> xx, yy;
    for (int i = 1; i <= h; i++)
    {
        if (fx[i] == mx)
        {
            xx.eb(i);
        }
    }
    for (int i = 1; i <= w; i++)
    {
        if (fy[i] == my)
        {
            yy.eb(i);
        }
    }
    int res = 0;
    for (auto &i : xx)
    {
        for (auto &j : yy)
        {
            if(res == 0)
                res = max(res, mx + my - (s.count({i, j}) == 1));
            if(s.count({i, j}) == 0) {
                res = max(res, mx + my);
                break;
            }
        }
    }
    cout << res;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // int t;
    // cin >> t;
    // while (t--)
    solve();
    return 0;
}

Measured memory_bytes: 35012
#include<stdio.h>

int main(void){

    int inputNum;
    long int answer = 0;

    //入力部分
    scanf("%d",&inputNum);

    //計算部分
    for(int i = 1; i <= inputNum; i++){
        if(i % 3 != 0 && i % 5 != 0)answer += i;
    }

    //出力部分
    printf("%ld\n",answer);
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << "-->" << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
    #define mod 998244353
 
#define fi first
#define se second

int32_t main() 
{
  int n;
  cin>>n;
  vec v(n);
  fo(i,n)
  cin>>v[i];
  int ans = 0;
  fo(i, n)
      ans += v[i];
  
  
//  den
  int pos = (ans / n);
  
  int anss = 1e9;
  ans = 1e9;
  for (int pos = 0; pos <= 200;pos++)
      {
          anss = 0;
          
          fo(i, n)
          {
              anss += (v[i] - pos) * (v[i] - pos);
      }
      ans = min(ans, anss);
      }
  cout << ans;

} 

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

MOD = 2019

"""
gcd(10, 2019) = 1 互いに素(最大公約数が1)
-> 10のmod2019での逆元(1/10)が存在
"""
S = input().rstrip()
s_list = list(map(int, list(S)))[::-1]

counts = [0] * MOD
counts[0] = 1

num = 0
for i, s_element in enumerate(s_list):
    num += s_element * pow(10, i, MOD)
    num %= MOD
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans)


Measured memory_bytes: 12224
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    OPT[i][j][k] - sum is i, j number of elements, first k elements
    OPT[i][j][k] = OPT[i-x[k]][j-1][k-1] if j-th element is taken
                   OPT[i][j][k-1]

    OPT[A*j][j][k] for all k
    """
    N, A = read_ints()
    x = read_ints()
    OPT = [[[0 for _ in range(51)] for _ in range(51)] for _ in range(2501)]
    for k in range(N+1):
        OPT[0][0][k] = 1
    for i in range(len(OPT)):
        for j in range(1, N+1):
            for k in range(1, N+1):
                if i-x[k-1] >= 0:
                    OPT[i][j][k] += OPT[i-x[k-1]][j-1][k-1]
                OPT[i][j][k] += OPT[i][j][k-1]
    T = 0
    for j in range(1, N+1):
        T += OPT[A*j][j][N]
    return T


if __name__ == '__main__':
    print(solve())


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



struct Graph
{
    struct edge
    {
        int to;
        int cap;
        int rev;
    };

    int n;
    vector<vector<edge>> edges;

    Graph(int N)
    {
        n = N;
        edges.resize(n,vector<edge>());
    }

    int size() const
    {
        return n;
    }

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




struct Dinic
{
    int N;
    vector<int> level;
    vector<int> itr;

    Dinic(int n) : N(n)
    {
    }

    bool g_level(Graph& G,int s,int t)
    {
        level.assign(N,-1);
        queue<int> que;
        que.push(s);
        level[s] = 0;
        while(!que.empty())
        {
            int v = que.front();
            que.pop();
            for(auto& e : G[v])
            {
                if(e.cap > 0 && level[e.to] == -1)
                {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
        return level[t] >= 0;
    }

    int dfs(Graph& G,int v,int t,int f)
    {
        if(v == t) return f;

        for(int& i = itr[v];i < G[v].size();i++)
        {
            auto& e = G[v][i];
            if(e.cap > 0 && level[e.to] > level[v])
            {
                int mi_f = dfs(G,e.to,t,min(f,e.cap));
                if(mi_f > 0)
                {
                    e.cap -= mi_f;
                    G[e.to][e.rev].cap += mi_f;
                    return mi_f;
                }
            }
        }
        return 0;
    }

    int max_flow(Graph& G,int s,int t)
    {
        int result = 0;
        int flow;
        while(g_level(G,s,t))
        {
            itr.assign(N,0);
            while((flow = dfs(G,s,t,1e9)) > 0) result += flow;
        }
        return result;
    }
};

int main()
{
    int V,E;
    cin >> V >> E;
    Graph g(V);
    for(int i = 0;i < E;i++)
    {
        int s,t,c;
        cin >> s >> t >> c;
        g[s].push_back({t,c,(int)g[t].size()});
        g[t].push_back({s,0,(int)g[s].size() - 1});
    }
    Dinic di(V);
    cout << di.max_flow(g,0,V - 1) << endl;
}


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

#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()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

vector<int64_t> fct, inv;
void finit(int cmx, ll mod =MD){
	fct.resize(cmx+20); inv.resize(cmx+20);
	fct[0] = fct[1] = inv[1] = inv[cmx] = 1;
	for(int i=2;i<cmx+3;i++) fct[i] = fct[i-1] * i % mod;
	for(ll x=fct[cmx], n=mod-2; n > 0; n >>=1, x = x*x %mod)
		if(n & 1) inv[cmx] = inv[cmx] * x %mod;
	for(int i=cmx;i>=1;i--) inv[i-1] = inv[i] * i % mod;
}
ll nCk(ll n, ll k, ll mod =MD) {
	if(k > n || n <0 || k <0) return 0;
	ll ret =fct[n] * inv[k] % mod * inv[n-k] % mod;
	return ret;
}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	VL a(n);
	rep(i, n) cin >>a[i];
	sort(all(a));
	finit(200100);
	
	ll ans =0;
	rep(i, n){
		(ans += a[i] * nCk(i, k-1)) %=MD;
		(ans += MD - (a[i] * nCk(n-1-i, k-1)) % MD ) %=MD;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 4224
#include <cstdio>

int main(){
    int n,x,y;
    for (n = 1;n <= 3000;n++){
        scanf("%d %d",&x,&y);

        if(x == 0 && y == 0)break;

        else if(x <= y){printf("%d %d\n",x,y);}

        else if(x > y){printf("%d %d\n",y,x);}
    }

}


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

using namespace std;

signed main() {
    string s;
    cin >>s;
    int cnt = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'g') cnt++;
        else cnt--;
    }
    cout << cnt/2;
}


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

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin >> s;
	long long sum = 0;
	for(auto &c: s){
		int x = int(c)-48;
		sum += 1LL * x;
	}
	if(sum%9) cout << "No\n";
	else cout << "Yes\n";
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
long long int n,m,ans=1,a,b,k;


int main(){
    cin>>a>>b>>k;
    for(int i=0;i<k;i++){
        if(i%2==0){
            if(a%2==1){
                a-=1;
            }b+=a/2;
            a-=a/2;
        }

        if(i%2==1){
            if(b%2==1){
                b-=1;
            }a+=b/2;
            b-=b/2;
        }
    }
    cout<<a<<" "<<b<<endl;

}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	m := map[int]bool{1: true, 2: true, 3: true}
	for i := 0; i < 2; i++ {
		fmt.Scan(&N)
		m[N] = false
	}
	for k, v := range m {
		if v {
			fmt.Printf("%v\n", k)
		}
	}
}


Measured memory_bytes: 1832
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
  ll x;
  cin >> n >> x;
  vl a(n);
  ll count = 0;

  rep(i,n){
    cin >> a[i];
    if(a[i] > x){
      count += a[i]-x;
      a[i] = x;
    }
  }

  rep(i,n-2){
    if(a[i]+a[i+1] > x){
      if(a[i+1]+a[i+2] > x){
        count += a[i]+a[i+1]-x;
        a[i+1] -= a[i]+a[i+1]-x;
      }else{
        count += a[i]+a[i+1]-x;
        a[i] -= a[i]+a[i+1]-x;
      }
    }
  }
  if(a[n-2]+a[n-1] > x){
    count += a[n-2]+a[n-1]-x;
    a[n-2] -= a[n-2]+a[n-1]-x;
  }
  cout << count << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int			long long
#define ll 			long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  22

ll n;
bool a[N][N];
ll dp[N][1ll<<21];

ll calc(ll men, ll mask){
	if(mask==0)return 1;
	if(dp[men][mask]!=-1)return dp[men][mask];
	ll temp=mask;
	ll shift=0;
	ll ans=0;
	while(temp>0){
		bool bit = temp&1;
		if(bit){
			if(a[men][shift+1]){
				ll newmask = mask^(1ll<<shift);
				ans=(ans+calc(men-1,newmask))%hell;	
			}
		}
		temp>>=1;
		shift++;
	}
	return dp[men][mask]=ans;
}


void solve()
{
	cin>>n;
	rep(i,1,n+1){
		rep(j,1,n+1){
			cin>>a[i][j];
		}
	}
	memset(dp,-1LL,sizeof(dp));
	cout<<calc(n,(1ll<<n)-1)<<endl;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 364060
#include<iostream>
#include<stdio.h> 
#include<algorithm>
#include<string.h>
#include<math.h>
#include<queue>
#include<map>
#include<stack>
#define go(i,a,b) for (int (i)=(a);(i)<=(b);(i)++)
#define ll long long
#define N 100005
using namespace std;

ll a[N],a1[N],b[N],n,sum,t[N*8];
void insert(int k, int l, int r, int pos){
	if (l>pos||r<pos) return;
	if (l==r&&r==pos){
		t[k]++;
		return;
	}
	ll m=(l+r)/2;
	insert(k*2,l,m,pos);insert(k*2+1,m+1,r,pos);
	t[k]=t[k*2]+t[k*2+1];
};
ll query(int k, int l, int r, int left, int right){
	if (l>right||r<left){
		return 0;
	}
	if (left<=l&&r<=right){
		return t[k];
	}
	ll m=(l+r)/2;
	return query(k*2,l,m,left,right)+query(k*2+1,m+1,r,left,right);
}

bool check(ll mdi){
	ll maxn=N;
	b[0]=N;
	go(i,1,n){
		if (a[i]>mdi) b[i]=b[i-1]+1;
		else b[i]=b[i-1]-1;
		maxn=max(maxn,b[i]);
	}
	//cout<<"maxn"<<maxn<<endl;
	memset(t,0,sizeof(t));
	ll tot=0;
	insert(1,1,maxn,N);
	go(i,1,n){
		tot+=(b[i]==maxn?0:query(1,1,maxn,b[i]+1,maxn));
		//cout<<tot<<endl;
		insert(1,1,maxn,b[i]);
	}
	/*
	cout<<mdi<<" "<<tot<<endl;
	go(i,1,n){
		cout<<b[i]<<" ";
	}
	cout<<endl;
	*/
	return (tot>=n*(n+1)/2/2+1);
}

/*
用这个可以直接求的是中位数肯定比这个数小的1 2 3 4  


*/

ll doit(){
	ll l=1,r=sum;
	//go(i,1,sum) cout<<check(a1[i])<<endl;
	
	while (l!=r){
		ll m=(l+r)/2;
		if (check(a1[m])){
			r=m;
		}
		else {
			l=m+1;
		}
	}
	
	return a1[l];
}
int main(){
		scanf("%d",&n);
		go(i,1,n){
			scanf("%d",&a[i]);
			a1[i]=a[i];
		}
		sort(a1+1,a1+1+n);
		sum=0;
		go(i,1,n){
			if (i==1||a1[i-1]!=a1[i])sum++;
			a1[sum]=a1[i];
		}
		ll ans=doit();
		printf("%lld\n",ans);
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll const mod=1e9+7;
double const pi=acos(-1);
int main()
{
	string s1,s2;
	s1="ABC";
	s2="ARC";
	string s;
	cin>>s;
	if(s1==s)
	{
		cout<<s2<<endl;
	}
	else
	{
		cout<<s1<<endl;
	}
	
	
	
	
    return 0;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        String word = sc.nextLine();
        int count = 0;
        while(true){
            String lines = sc.nextLine();
            if(("END_OF_TEXT").equals(lines)){
                break;
            }
            
            String line[] = lines.split(" ");
            for(String a : line){
                if(a.equalsIgnoreCase(word)){
                    count++;
                }
                
            }
        }
     System.out.println(count);       
    }
}



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

int main(){
  string S; cin >> S;
  int k=S.size();
  vector<char> s(k);
  for(int i=0;i<k;i++){
    s.at(i)=S.at(i);
  }
  sort(s.begin(), s.end());
  int count=0;
  for(int i=k-1;i>=1;i--){
    if(s.at(i)==s.at(i-1)){
      s.at(i)='A';
      count++;
    }
  }
  sort(s.begin(),s.end());
  if(k<count+26){
    s.push_back('A');
  }
  vector<char> alpha={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  for(int i=count;i<s.size();i++){
    if(s.at(i)!=alpha.at(i-count)){
      cout << alpha.at(i-count) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}
    

Measured memory_bytes: 512
#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(){
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    int redf = 0;
    int grnf = 0;
    int cou = 0;
    ll ans = 0;

    vector<ll> red(A);
    rep(i, A) cin >> red.at(i);
    sort(red.begin(), red.end());
    vector<ll> grn(B);
    rep(i, B) cin >> grn.at(i);
    sort(grn.begin(), grn.end());
    vector<ll> whi(C);
    rep(i, C) cin >> whi.at(i);
    sort(whi.begin(), whi.end());

    int redi = red.size()-1;
    int grni = grn.size()-1;
    int whii = whi.size()-1;
    while(cou < X+Y){
        ll max = 0;
        int sai = -1;
        if(redf == 0 && grnf == 0 && whii >= 0){
            if(max < red.at(redi)){ max = red.at(redi); sai = 0;}
            if(max < grn.at(grni)){ max = grn.at(grni); sai = 1;}
            if(max < whi.at(whii)){ max = whi.at(whii); sai = 2;}
            if(sai == 0) redi--;
            if(sai == 1) grni--;
            if(sai == 2) whii--;
        }else if(redf == 1 && grnf == 0 && whii >= 0){
            if(max < grn.at(grni)){ max = grn.at(grni); sai = 1;}
            if(max < whi.at(whii)){ max = whi.at(whii); sai = 2;}
            if(sai == 1) grni--;
            if(sai == 2) whii--;
        }else if(redf == 0 && grnf == 1 && whii >= 0){
            if(max < red.at(redi)){ max = red.at(redi); sai = 0;}
            if(max < whi.at(whii)){ max = whi.at(whii); sai = 2;}
            if(sai == 0) redi--;
            if(sai == 2) whii--;
        }else if(redf == 1 && grnf == 1 && whii >= 0){
            if(max < whi.at(whii)){ max = whi.at(whii); sai = 2;}
            if(sai == 2) whii--;
        }else if(redf == 0 && grnf == 0 && whii == -1){
            if(max < red.at(redi)){ max = red.at(redi); sai = 0;}
            if(max < grn.at(grni)){ max = grn.at(grni); sai = 1;}
            if(sai == 0) redi--;
            if(sai == 1) grni--;
        }else if(redf == 1 && grnf == 0 && whii == -1){
            if(max < grn.at(grni)){ max = grn.at(grni); sai = 1;}
            if(sai == 1) grni--;
        }else if(redf == 0 && grnf == 1 && whii == -1){
            if(max < red.at(redi)){ max = red.at(redi); sai = 0;}
            if(sai == 0) redi--;
        }
        if(red.size()-1-redi == X) redf = 1;
        if(grn.size()-1-grni == Y) grnf = 1;
        cou++;
        ans += max;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
using System;
using System.Linq;

namespace _0594
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] first = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int output = 0;
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 1; i < first[2]; i++)
            {
                int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int xsa = input[0] - x[0];
                int ysa = input[1] - x[1];
                if (Math.Max(xsa, ysa) > 0 && 0 > Math.Min(xsa, ysa))
                {
                    output += Math.Abs(xsa) + Math.Abs(ysa);
                }
                else if (Math.Min(xsa, ysa) >= 0)
                {
                    output += Math.Max(xsa, ysa);
                }
                else
                {
                    output += Math.Abs(Math.Max(xsa, ysa));
                    output += Math.Abs((Math.Min(xsa, ysa) - Math.Max(xsa, ysa)));
                }
                x[0] = input[0];
                x[1] = input[1];
            }
            Console.WriteLine(output);
        }
    }
}

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

int main()
{
	int r; cin >> r;
	
	string ans;

	if (r < 1200) {
		ans = "ABC";
	}
	else if (1200 <= r && r < 2800) {
		ans = "ARC";
	}
	else {
		ans = "AGC";
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;


int d,g;



 
int main() {
  cin>>d>>g;
  vector<int> p(d), c(d);
  for(int i=0;i<d;i++){
    cin>>p.at(i)>>c.at(i);
  }

  int ans=10000;
  for(int tmp=0;tmp<(1<<d);tmp++){
    bitset<10> s(tmp);/*下i桁が1なら100(i+1)点(p[i]個)を全部とく*/
    int score=0;
    int solved_number=0;
    for(int i=0;i<d;i++){
      if(s.test(i)){
        score+=100*(i+1)*p[i]+c[i];
        solved_number+=p[i];
      }
    }

    /*scoreがg以上なら終わり*/
    if(score>=g){
        ans=min(ans,solved_number);
        continue;
      }
    /*そうでないとき*/
    for(int j=0;j<d;j++){
      /*100(j+1)点を解いていないとき*/
      if(!s.test(j)){
        int a=g-score;
        int b=100*(j+1);
        int need=(a+b-1)/b;

        /*p[j]個以上必要なら終わり*/
        if(need>=p[j]){
          continue;
        }

        solved_number+=need;
        ans=min(ans,solved_number);

      }
      
    }
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>

using namespace std;

int bubble(int n, int bubble[], int count);

int main(void)
{
	int ans, n;
	while(cin >> n, n){
		int num[100];
		for(int i = 0; i < n; i++){
			cin >> num[i];
		}
		ans = bubble(n, num, 0);
		cout << ans << endl;
	}
	
	return 0;
}

int bubble(int n, int bubble[], int count)
{
	int temp = n;
	for(int ii = 0; ii < n; ii++){
		for(int i = 0; i < temp-1; i++){
			if(bubble[i] > bubble[i+1]){
				count++;
				int temp;
				temp = bubble[i];
				bubble[i] = bubble[i+1];
				bubble[i+1] = temp;
			}
		}
		temp--;
	}
	
	return count;
}

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

#define fio() ios_base::sync_with_stdio(false);\
cin.tie(NULL);
#define md 1000000007
#define mem(ar,avg) memset(ar,avg,sizeof(ar))
#define pb push_back

typedef long long int lli;
typedef float fl;


int main()
{
	fio();
	int t;
	//cin >> t;
	//while (t--)
	{
		lli n, m;
		cin >> n;
		if (n >= 30) cout << "Yes\n";
		else cout << "No\n";


	}

}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  while(1) {
    C -= B;
    if(C<=0) {
      cout << "Yes";
      return 0;
    }
    A -= D;
    if(A<=0) {
      cout << "No";
      return 0;
    }
  }
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long int li;


int main(void){
    int ans=0;
    int n;
    int x=0;
    cin >> n;
    char a[n],b[n],c[n];
    cin >> a ;cin >> b;cin >> c;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]&&c[i]!=b[i]&&a[i]!=c[i])ans+=2;
        else if(a[i]==b[i]&&c[i]==b[i]&&a[i]==c[i]);
        else if(a[i]==b[i]&&c[i]!=b[i]&&a[i]!=c[i])ans++;
        else if(a[i]!=b[i]&&c[i]==b[i]&&a[i]!=c[i])ans++;
        else if(a[i]!=b[i]&&c[i]!=b[i]&&a[i]==c[i])ans++;
    }
    
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
N,A,B=map(int,input().split())

num_A=int(N/(A+B))
sur=int(N-(A+B)*num_A)

if A==0:
    print(0)
elif A!=0 and N>(A+B) and sur>=A:
    print(num_A*A+A)
elif A!=0 and N>(A+B) and sur<A:
    print(num_A*A+sur)
elif A!=0 and N<=(A+B) and N>=A:
    print(A)
elif A!=0 and N<=(A+B) and N<A:
    print(N)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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


int N;

int par[111111];
set<pint>s[111111];
int ev[111111];
int find(int x){
    return x==par[x]?x:par[x]=find(par[x]);
}

signed main(){
    cin>>N;
    vector<tuple<int,int,int>>es;
    rep(i,N-1){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        es.pb(make_tuple(c,a,b));
    }
    sort(all(es));
    reverse(all(es));

    rep(i,N){
        par[i]=i;
        s[i].insert({i,0});
    }

    for(auto &w:es){
        int a,b,c;
        tie(c,a,b)=w;
        a=find(a);b=find(b);

        ev[a]+=s[b].size()*c;
        ev[b]+=s[a].size()*c;

        if(s[a].size()<s[b].size())swap(a,b);

        for(auto &p:s[b]){
            pint q=p;
            q.se+=ev[b];
            q.se-=ev[a];
            s[a].insert(q);
        }

        par[b]=a;
    }

    for(auto &p:s[find(0)]){
        cout<<p.se+ev[find(0)]<<endl;
    }
    return 0;
}


Measured memory_bytes: 53232
#include <iostream>
#include <cmath>
#include <iostream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  vector<int> B(N);
  int S=0;
  for(int i=0;i<N-1;i++){
    cin>>B[i];
  }
  vector<int> A(N);
  A[0]=B[0];
  for(int i=1;i<N-1;i++){
    A[i]=min(B[i],B[i-1]);
  }
  A[N-1] = B[N-2];
  for(int i=0;i<N;i++){
    S+=A[i];
  }
    cout<<S<<endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> Counter(N);
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    Counter.at(a-1)++;
    Counter.at(b-1)++;
  }
  for(int i=0;i<N;i++){
    cout << Counter.at(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int H = sc.nextInt();
    int W = sc.nextInt();
    String[][] a = new String[H][W];

    for (int i = 0; i < H; i++) {
      String a_ = sc.next();
      a[i] = a_.split("");
    }

    sc.close();

    boolean[] deleteH = new boolean[H];
    boolean[] deleteW = new boolean[W];

    // 行がすべて.かを調べる
    for (int i = 0; i < H; i++) {
      boolean valid_ = true;
      for (int j = 0; j < W; j++) {
        if (a[i][j].equals("#")) {
          valid_ = false;
          break;
        }
      }
      if (valid_) {
        deleteH[i] = true;
      }
    }

    // 列がすべて.かを調べる
    for (int i = 0; i < W; i++) {
      boolean valid_ = true;
      for (int j = 0; j < H; j++) {
        if (a[j][i].equals("#")) {
          valid_ = false;
          break;
        }
      }
      if (valid_) {
        deleteW[i] = true;
      }
    }

    // 出力
    for (int i = 0; i < H; i++) {
      if (!deleteH[i]) {
        for (int j = 0; j < W; j++) {
          if (!deleteW[j]){
            System.out.print(a[i][j]);
          }
        }
        System.out.println("");
      }
    }

  }

}

Measured memory_bytes: 26904
def restore(s):
  ret = ""
  ind = 0
  end = len(s)
  while ind < end:
    if s[ind] == "@":
      ret += s[ind + 2] * int(s[ind + 1])
      ind += 3
    else:
      ret += s[ind]
      ind += 1
  return ret

while True:
  try:
    print(restore(input()))

  except EOFError:
    break


Measured memory_bytes: 5600
def read():
    A = int(input().strip())
    B = int(input().strip())
    return A, B

def solve(A, B):
    answers = set([1, 2, 3])
    answers.remove(A)
    answers.remove(B)
    return answers.pop()


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


Measured memory_bytes: 2940
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>  
#include<cstdio>  
#include<fstream>  
#include<iomanip>
#include<algorithm>  
#include<cmath>  
#include<deque>  
#include<vector>  
#include<assert.h>
#include<bitset>
#include<queue>  
#include<string>  
#include<cstring>  
#include<map>  
#include<stack>  
#include<set>
#include<functional>
#define pii pair<int, int>
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))  
#define rson(x) ((x<<1)|1) 
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
 
const int maxn = 1e5 + 5;
class node {
public:
	int u, v, w;
	node(int a, int b, int c) :u(a), v(b), w(c) {};
};
int fa[maxn];
int getf(int i) { return i == fa[i] ? i : fa[i] = getf(fa[i]); }
vector<node>edge;
bool cmp(const node&a, const node&b)
{
	return a.w < b.w;
}
class T {
public:
	int value, id;
	T(int ta, int tb) :id(ta), value(tb) {};
	bool operator<(const T &a)
	{
		return value < a.value;
	}
	T(){};
};
T sx[maxn], sy[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	int i, j, k, m, n, ta, tb;
	cin >> n;
	for (int i = 1; i <= n; ++i)fa[i] = i;
	for (int i = 1; i <= n; ++i)
	{
		cin >> sx[i].value >> sy[i].value;
		sx[i].id = sy[i].id = i;
	}
 
	sort(sx + 1, sx + n + 1);
	sort(sy + 1, sy + 1 + n);
	edge.push_back(node(sx[1].id, sx[2].id, abs(sx[1].value - sx[2].value)));
	edge.push_back(node(sx[n].id, sx[n - 1].id, abs(sx[n].value - sx[n - 1].value)));
	edge.push_back(node(sy[1].id, sy[2].id, abs(sy[1].value - sy[2].value)));
	edge.push_back(node(sy[n].id, sy[n - 1].id, abs(sy[n].value - sy[n - 1].value)));
	for (int i = 2; i < n; ++i)
	{
		edge.push_back(node(sx[i].id, sx[i - 1].id, abs(sx[i].value - sx[i - 1].value)));
		edge.push_back(node(sx[i].id, sx[i + 1].id, abs(sx[i].value - sx[i + 1].value)));
		edge.push_back(node(sy[i].id, sy[i + 1].id, abs(sy[i].value - sy[i + 1].value)));
		edge.push_back(node(sy[i].id, sy[i - 1].id, abs(sy[i].value - sy[i - 1].value)));
	}
	sort(edge.begin(), edge.end(), cmp);
	ll ans = 0;
	for (i = 0; i <edge.size(); ++i)
	{
		if (getf(edge[i].u) != getf(edge[i].v))
		{
			ans += edge[i].w;
			fa[getf(edge[i].u)] = getf(edge[i].v);
		}
	}
	cout << ans << endl;
	return 0;
}

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


int main()
{
    string str;
    cin>>str;
    int l=str.size();
    int i;
    for(i=0;i<l;i++) {
        if(str[i]=='d'&&str[i+1]=='r'&&str[i+2]=='e'&&str[i+3]=='a'&&str[i+4]=='m') {
            if(i+4==l-1) { cout<<"YES";return 0; }
            else if(str[i+5]=='e'&&str[i+6]=='r') {
                if(i+6==l-1) { cout<<"YES";return 0; }
                else if(str[i+7]=='a'&&str[i+8]=='s'&&str[i+9]=='e') {
                    if(i+9==l-1) { cout<<"YES";return 0; }
                    else if(str[i+10]=='r') {
                        if(i+10==l-1) { cout<<"YES";return 0; }
                        else i=i+10;
                    }
                    else i=i+9;
                }
                else i=i+6;
            }
            else i=i+4;
        }
        else if(str[i]=='e'&&str[i+1]=='r'&&str[i+2]=='a'&&str[i+3]=='s'&&str[i+4]=='e') {
            if(i+4==l-1) { cout<<"YES";return 0; }
            else if(str[i+5]=='r') {
                if(i+5==l-1) { cout<<"YES";return 0; }
                else i=i+5;
            }
            else i=i+4;
        }
        else {cout<<"NO";return 0;}
    }

    cout<<"NO";




}


Measured memory_bytes: 512
#include<stdio.h>
int S[4*300010];
int T,NN=0;
//評価関数（今はMIN）
int hyoka(int a,int b){return a>b?a:b;}
//セグ木を長さnの数列dで初期化、構成
void sset(int n){
  int i;
  for(T=1;T<n;T*=2);
  for(i=0;i<T*2;i++)S[i]=NN;
}
//セグ木のupdate関数
//i番目の数値をnに変更、再構成
void sud(int i,int n){for(S[i+=T]=n;i/=2;)S[i]=hyoka(S[i*2],S[i*2+1]);}
//セグ木のfind関数
//[a,b)区間の呼び出しはsout(a,b,1,0,T);
int sout(int a,int b,int i,int l,int r){
  if(r<=a||b<=l)return NN;
  if(a<=l&&r<=b)return S[i];
  return hyoka(sout(a,b,i*2,l,(l+r)/2),sout(a,b,i*2+1,(l+r)/2,r));
}
int sget(int a,int b){return sout(a,b,1,0,T);}
int MAX(int a,int b){return a<b?b:a;}
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,m,i,a,b,ans=0,l,r;
  scanf("%d %d",&n,&m);
  sset(300005);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    l=MAX(0,a-m);
    r=MIN(T,a+m+1);
    b=sget(l,r);
    sud(a,b+1);
    ans=MAX(ans,b+1);//printf("%d %d\n",a+1,ans);
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 5792
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N;

int main()
{
	in >> N;
	out << (N / 111 + (N % 111 == 0 ? 0 : 1)) * 111 << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

//const ll nmax=100001;
const ll inf=1000000000+7;
const ll nmax=100;
ll a[nmax];


int main(){
    ll N,sum,ans;
    cin>>N;
    sum=0;
    for(ll i=0;i<N;i++){
        cin>>a[i];
        sum+=a[i];
        a[i]*=N;
    }
    ll dif=inf;
    for(ll i=0;i<N;i++){
        if(abs(sum-a[i])<dif){
            dif=abs(sum-a[i]);
            ans=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

struct Edge
{
    int to;  //辺の行先
    ll cost; //辺の重み
    Edge(int t, ll w) : to(t), cost(w) {}
};

/* dijkstra(G,s,dis)
    入力:グラフ G, 開始点 s,距離を格納する dis
    計算量 : O(|E|log|V|)
    副作用 : disが書き換えられる
*/
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;
void dijkstra(const Graph &G, int s, vector<ll> &dis, vector<int> &prev)
{
    int N = G.size();
    dis.resize(N, INF); // Gの大きさで初期化
    prev.resize(N, -1);
    priority_queue<P, vector<P>, greater<P>> pq; // [仮の最短経路,頂点]が小さい順で並ぶ
    dis[s] = 0;                                  //スタート地点の距離は0
    pq.emplace(dis[s], s);                       // スタート地点を代入
    while (!pq.empty())
    {
        P p = pq.top(); // 最短経路が一番小さいものを取得
        pq.pop();
        int V = p.second; // 頂点
        if (dis[V] < p.first)
        { // 最短経路で無い場合は無視
            continue;
        }
        for (auto &e : G[V])
        {
            if (dis[e.to] > dis[V] + e.cost)
            { //最短経路なら
                dis[e.to] = dis[V] + e.cost;
                prev[e.to] = V; //頂点vを通って　e.toにたどり着いた
                pq.emplace(dis[e.to], e.to);
            }
        }
    }
}

int main(){
    int n;
    cin >> n;
    Graph G(n);
    rep(i, n-1)
    {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].push_back(Edge(b, c));
        G[b].push_back(Edge(a, c));
    }
    int q,k;
    cin >> q >> k;
    vector<ll> mincost;
    vector<int> prev;
    k--;
    dijkstra(G, k, mincost, prev);
    rep(i, q)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << mincost[x] + mincost[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 11504
s=input()
l=list(s)
m=0
for i in range(len(l)):
    if l[i]!="A" and l[i]!="T" and l[i]!="C" and l[i]!="G":
        l[i]="."

ss="".join(l)
ll=ss.split(".")
lll=[0]
for i in ll:
    lll.append(len(i))
print(max(lll))


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int N=1e5+5;
int a[N],k;
ll la(int x)
{
    ll L=2,R=(ll)4e18;
    while(L<=R)
    {
        ll mi=(L+R)/2;
        for(int i=1;i<=k;i++)mi=mi/a[i]*a[i];
        if(mi>x)R=(L+R)/2-1;
        else L=(L+R)/2+1;
    }
    L--;
    ll t=L;
    for(int i=1;i<=k;i++)
    L=L/a[i]*a[i];
    if(L==x)return t;
    else return 0;

}
ll lb(int x)
{
    ll L=2,R=(ll)4e18;
    while(L<=R)
    {
        ll mi=(L+R)/2;
        for(int i=1;i<=k;i++)mi=mi/a[i]*a[i];
        if(mi<x) L=(L+R)/2+1;
        else R=(L+R)/2-1;
    }
    ll t=L;
    for(int i=1;i<=k;i++)
    L=L/a[i]*a[i];
    if(L==x)return t;
    else return 0;
}
int main()
{
    scanf("%d",&k);
    for(int i=1;i<=k;i++)scanf("%d",&a[i]);
    ll x=lb(2),y=la(2);
    if(!x)printf("-1");
    else printf("%llu %llu",x,y);
    return 0;
}


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

int main() {

    int N, A, B;
    cin >> N >> A >> B;

    int ans = 0;

    for (int i = 1; i <= N; ++i) {
        int a = i;
        int sum = 0;
        while (a >= 1) {
            sum += a%10;
            a /= 10;
        }
        if (sum >= A and sum <= B) ans += i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;


int main() {
	while(1) {
		int x, y;
		cin >> y >> x;
		if(x==0 && y==0) break;
		int field[x][y];
		for(int i=0; i<x; i++) {
			for(int j=0; j<y; j++) {
				cin >> field[i][j];
			}
		}
		int dp[x+1][y];
		for(int i=0; i<x+1; i++) {
			for(int j=0; j<y; j++) {
				dp[i][j] = 0;
			}
		}
		for(int i=0; i<x; i++) {
			for(int j=0; j<y; j++) {
				if(i==0 && field[i][j] == 0) dp[i][j] = 1;
				else {
					if(field[i][j] == 0) {
						if(0<j && field[i-1][j-1] == 0) dp[i][j] += dp[i-1][j-1];
						if(field[i-1][j] == 0) dp[i][j] += dp[i-1][j];
						if(j<y-1 && field[i-1][j+1] == 0) dp[i][j] += dp[i-1][j+1];
					}
					if(field[i][j] == 2) {
						if(field[i-1][j] == 0) dp[i][j] += dp[i-1][j];
						if(field[i+2][j] != 1) dp[i+2][j] += dp[i][j];
					}
				}
			}
		}
		for(int i=0; i<y; i++) dp[x][i] += dp[x-1][i];

		int sum=0;
		for(int i=0; i<y; i++) sum += dp[x][i];
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int ans[N];

int32_t main(){_

   cin>>n;

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

   int vals = 0;//, ptr = 0;
   a[n] = -inf;
   for (int i = 0; i+1 < n; )
   {
      int j = i, pos = i;
      for (j = i; j < n; ++j)
      {
         pos = j + 1;
         if(a[j] >= a[j+1]);
         else{
            break;
         }
      }
      tr(i, pos);
      smax(vals, pos-1-i);
      i = pos;
   }

   cout<<vals;

/*   int vals = 0;
   for (int i = n-1; i >= 0; --i)
   {
      if(i == n-1){
         ans[i] = 0;
      }
      else{
         if(a[i] >= a[i+1]){
            ans[i] = 1 + ans[i+1];
         }
         else{
            ans[i] = 0;
         }
      }
      smax(vals, ans[i]);
   }

   cout<<vals;*/

   return 0;
}

Measured memory_bytes: 4352
fun main(args: Array<String>) {
    diverta20192b()
}

private data class Coordinate(val x: Long, val y: Long) {
    operator fun minus(other: Coordinate): Coordinate = Coordinate(x - other.x, y - other.y)
}

fun diverta20192b() {
    val n = readLine()!!.toInt()
    val coordinates = (1..n).map { readLine()!!.split(' ').map { it.toLong() } }
        .map { Coordinate(it[0], it[1]) }.sortedBy { it.y }.sortedBy { it.x }

    if (n == 1) return println(1)

    val diffMap = mutableMapOf<Coordinate, Int>()

    for (c1iv in coordinates.withIndex()) {
        for (c2 in coordinates.drop(c1iv.index + 1)) {
            val diff = c1iv.value - c2
            diffMap.put(diff, diffMap.getOrElse(diff, { 0 }) + 1)
        }
    }

    val answer = n - diffMap.map { it.value }.max()!!

    println(answer)
}


Measured memory_bytes: 38172
from copy import copy
import random
import math
import sys
input = sys.stdin.readline
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last = [0]*26
ans = [0]*D
score = 0
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    ans[i] = idx+1
    score += max(ps)
T = 3000
for i in range(40000):
    na = copy(ans)
    x = random.randint(1,365)
    y = random.randint(1,365)
    if x == y:
        continue
    na[x-1],na[y-1] = na[y-1],na[x-1]
    last = [0]*26
    ns = 0
    for i in range(D):
        last[na[i]-1] = i+1
        ns += s[i][na[i]-1]
        for j in range(26):
            ns -= c[j]*(i+1-last[j])
    p = pow(math.e,-abs(ns-score)/T)
    if ns > score or random.random() < p:
        ans = na
        score = ns
    T *= 0.99
for a in ans:
    print(a)

Measured memory_bytes: 86892
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

ll f(string s) {
  ll res = 0, a = 0;
  rep(i,sz(s)) {
    if (s[i] == 'a') ++a;
    else res += a;
  }
  return res;
}

int main() {
  string s;
  cin>>s;
  string t;
  ll ans = 0;
  int n = sz(s); s += 'X';
  rep(i,n) {
    if (s[i] == 'A') t += 'a';
    else if (s[i] == 'C') {
      ans += f(t);
      t = "";
    } else {
      if (s[i+1] == 'C') t += 'b', ++i;
      else {
        ans += f(t);
        t = "";
      }
    }
  }
  ans += f(t);
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 904
# coding: utf-8
# 整数の入力
a, b, c, d = [int(i) for i in input()]
# 計算
if a+b+c+d == 7:
    s = "{}+{}+{}+{}=7"
elif a+b+c-d == 7:
    s = "{}+{}+{}-{}=7"
elif a+b-c+d == 7:
    s = "{}+{}-{}+{}=7"
elif a+b-c-d == 7:
    s = "{}+{}-{}-{}=7"
elif a-b+c+d == 7:
    s = "{}-{}+{}+{}=7"
elif a-b+c-d == 7:
    s = "{}-{}+{}-{}=7"
elif a-b-c+d == 7:
    s = "{}-{}-{}+{}=7"
elif a-b-c-d == 7:
    s = "{}-{}-{}-{}=7"
# 出力
print(s.format(a, b, c, d))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e3+4;
const int MOD = 1e9+7;

int32_t main(){
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif
	int n;
	cin>>n;
	vector<int> a,b;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		a.push_back(x+y);
		b.push_back(x-y);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	cout<<max(abs(a[n-1]-a[0]),abs(b[0]-b[n-1]));
} 



Measured memory_bytes: 6692
N,K=map(int, input().split())
K2 = 2*K
inmap = [[0]*(K) for _ in range(K2)]
accmap = [[0]*(K+1) for _ in range(K2+1)]
inmapdeb = {}
for i in range(N):
    line = input().split()
    x, y, wb = int(line[0]), int(line[1]), line[2]
    if wb == 'W':
        x += K
    y %= K2
    if y >= K:
        y = y%K
        x = (x+K) %K2
    else:
        x = x % K2
    inmap[x][y] += 1
#     if not (x,y) in inmapdeb:
#         inmapdeb[(x,y)] = 1
#     else:
#         inmapdeb[(x,y)] += 1
# print(inmapdeb)

def calc(x, y):
    return accmap[x][y] \
        + (accmap[x+K][K] - accmap[x][K] - accmap[x+K][y] + accmap[x][y]) \
        + (accmap[K2][y] - accmap[x+K][y])

for i in range(K2):
    for j in range(K):
        accmap[i+1][j+1] = inmap[i][j] + accmap[i+1][j] + accmap[i][j+1] - accmap[i][j]

res = 0
for i in range(K):
    for j in range(K):
        # print(i,j)
        cand = calc(i, j)
        # print("i{} j{} res:{}".format(i,j,cand))
        res = max(res, cand, N-cand)

print(res)


Measured memory_bytes: 78680
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var t = int.Parse(line[1]);
        var amax = 0d;
        for (int i = 0; i < n; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var x = int.Parse(line[0]);
            var h = int.Parse(line[1]);
            amax = Math.Max(amax, (double)(h * t) / x);
        }
        Console.WriteLine(amax);
    }
}


Measured memory_bytes: 9296
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 505;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}
template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

int n, p[N * N], inv[N][N], f[N][N], dx[4] = {1, 0, -1, 0}, dy[4] = {0, -1, 0, 1}, ans = 0;
int que[N * N], l = 0, r = 0;

int main () {
	read(n);
	for (int i = 0; i < n * n; i++) {
		read(p[i]);
		inv[(p[i] - 1) / n][(p[i] - 1) % n] = i;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			f[i][j] = min(min(i + 1, n - i), min(j + 1, n - j));
		}
	}
	
	for (int i = 0; i < n * n; i++) {
		int x = (p[i] - 1) / n, y = (p[i] - 1) % n;
		ans += --f[x][y];

		int sz = n * n + 1, now = 1;
		l = r = 0, que[0] = x * n + y;
		while (now) {
			int ux = que[l] / n, uy = que[l] % n;
			l = (l + 1) % sz, now--;
			for (int j = 0; j < 4; j++) {
				int tx = ux + dx[j], ty = uy + dy[j];
				if (tx < 0 || tx >= n || ty < 0 || ty >= n) continue;
				if (inv[tx][ty] > i && f[tx][ty] > f[ux][uy] + 1) {
					f[tx][ty] = f[ux][uy] + 1;
					now++, que[r = (r + 1) % sz] = tx * n + ty;
				}
				if (inv[tx][ty] <= i && f[tx][ty] > f[ux][uy]) {
					f[tx][ty] = f[ux][uy];
					now++, que[l = (l + sz - 1) % sz] = tx * n + ty;
				}
			}
		}
	}
	write(ans), putchar('\n');
	return 0;
}

Measured memory_bytes: 6908
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int k,l,m;
   cin >> k;
   l = k/2;
   m = k%2;
 if(m == 0){
   cout << l*l << endl;
 }
 else{
   cout << l*(l+1) << endl;
 }
}

Measured memory_bytes: 384