akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int n;
  cin >> n;
  ll sum = 0;
  map<ll,ll> mp;
  rep(i,n) {
    ll x;
    cin >> x;
    mp[x]++;
    sum += x;
  }
  int q;
  cin >> q;
  vector<ll> s(q+1);
  s[0]=sum;
  for(int i=1; i<=q; i++) {
    ll b, c;
    cin >> b >> c;
    if(!mp.count(b)) {
      s[i]=s[i-1];
      continue;
    }
    s[i] = s[i-1]+(c-b)*mp.at(b);
    mp[c]+=mp.at(b);
    mp.erase(b);
  }
  for(int i=1; i<=q; i++) cout << s[i] << endl;
  return 0;
}

Measured memory_bytes: 8004
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B;
  cin >>  A >> B;
  if(B%A==0)
  {
    cout << A+B << endl;
  }
  else
  {
    cout << B-A << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n, k, r, s, p;
  cin >> n >> k;
  cin >> r >> s >> p;
  vector<ll> d(n, 0);
  vector<char> a(n);
  rep(i, n) {
    char temp;
    cin >> temp;
    a[i] = temp;
    if (temp == 'r') d[i] = p;
    if (temp == 's') d[i] = r;
    if (temp == 'p') d[i] = s;
  }
  for (ll i = 0; i + k < n; i++) {
    if (a[i + k] == a[i]) {
      d[i + k] = 0;
      a[i + k] = '\0';
    }
  }
  cout << accumulate(ALL(d), 0LL) << endl;

  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
/*bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}*/

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL<<29;
const double PI = 3.14159265358979323846;


// ******************************CODE**********************************//




int s[510][510];

int main(){

        int n,m,q;
        cin >> n >> m >> q;
        int l,r;
        for(int i = 0; i < m; i++)
        {
                cin >> l >> r;
                s[l][r]++;
        }
        //二次元累積和テーブルを作る。
        for(int i = 1; i <= n; i++)
                for(int j = 1; j <= n; j++)
                {
                        s[i][j] += s[i-1][j] + s[i][j-1] - s[i-1][j-1];
                }
        //クエリに答えていく。
        for(int i = 0; i < q; i++)
        {
                cin >> l >> r;
                cout << s[r][r] - s[r][l-1] - s[l-1][r] + s[l-1][l-1] << endl;
        }

}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define Nitroboost  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int 
const int mod=1e9+7;
const int N=1e6+5;



int main()
    {
        Nitroboost;
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif

        int n,m;
        cin>>n>>m;
        map<int,int>mp;
        for(int i=1;i<=m;i++)
            mp[i]=i;

        multiset<int>v;
        for(int i=1;i<=m;i++)
            v.insert(0);

        for(int i=1;i<=n;i++)
        {
            int l,r;
            cin>>l>>r;
            r++;
            auto it=mp.lower_bound(l);
            int t=-1;
            while(it!=mp.end() && it->first<=r)
            {
                t=max(t,it->second);
                v.erase(v.find(it->first-it->second));
                mp.erase(it++);
            }
            if(t!=-1 && r<=m)
            {
                v.insert(r-t);
                mp[r]=t;
            }

            if(v.size()>0)
            cout<<i+(*v.begin())<<"\n";
            else
                cout<<"-1\n";
        }
    }


Measured memory_bytes: 22300
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n; ll x;
ll f[55], p[55];

ll dfs(int n, ll x) {
    if (n == 0) {
        return x <= 0 ? 0 : 1;
    } else if (x <= 1 + f[n - 1]) {
        return dfs(n - 1, x - 1);
    } else {
        return p[n - 1] + dfs(n - 1, x - f[n - 1] - 2) + 1;
    }
}

int main() {
    scanf("%d %lld", &n, &x);
    f[0] = p[0] = 1;
    for (int i = 1; i <= n; i++) {
        f[i] = 2 * f[i - 1] + 3;
        p[i] = 2 * p[i - 1] + 1;
    }
    printf("%lld\n", dfs(n, x));
    return 0;
}

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

int main() {
  string S;
  long K;
  cin >> S >> K;

  int N = S.size();
  string s = S;
  s.erase(unique(s.begin(), s.end()), s.end());
  if (s.size() == 1) return cout << N * K / 2 << "\n", 0;

  string T = S + ' ';
  int t = 0;
  for (int i = 0, cnt = 1; i + 1 < T.size(); i++) {
    if (T.at(i) != T.at(i + 1)) t += cnt / 2, cnt = 1;
    else cnt++;
  }

  string R = S + S + ' ';
  int r = 0;
  for (int i = 0, cnt = 1; i + 1 < R.size(); i++) {
    if (R.at(i) != R.at(i + 1)) r += cnt / 2, cnt = 1;
    else cnt++;
  }

  cout << ((K == 1) ? t : t + (r - t) * (K - 1)) << "\n";
}

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


int main() {
  char a, b;
  cin >> a >> b;
  if(a > b){
    cout << '>';
  }
  if(a < b){
    cout << '<';
  }
  if(a == b){
    cout << '=';
  }
  return 0;
}






Measured memory_bytes: 3592
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace kyoupuro
{
    class MainClass
    {
        public static void Main()
        {
            MainClass mainClass = new MainClass();
            //var myarray = mainClass.IntInit();
            //var myarray = new List<int>(Console.ReadLine().Split(' ').Select(int.Parse));
            mainClass.Start();
        }

        List<List<String>> Init() {
            int maxindex = int.Parse(Console.ReadLine());

            List<List<String>> array = new List<List<String>>();

            for (int i = 0; i < maxindex; i++)
                array.Add(new List<String>(Console.ReadLine().Split(' ')));

            return array;
        }

        List<List<int>> IntInit() {
            int maxindex = int.Parse(Console.ReadLine());

            List<List<int>> array = new List<List<int>>();

            for (int i = 0; i < maxindex; i++) {
                array.Add(new List<int>(
                    Console.ReadLine().Split(' ').Select(int.Parse)));
            }

            return array;
        }

        void Start() {
            var n = int.Parse(Console.ReadLine());
            var array = new List<int>(Console.ReadLine().Split(' ').Select(int.Parse));

            Console.WriteLine(array.Aggregate((now, next) => gcd(now, next)));
        }

        int gcd(int a, int b){
            int r = a % b;
            while(r != 0) {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }
    }
}


Measured memory_bytes: 21344
#include <bits/stdc++.h>
using namespace std;
struct union_find{
	static const int DEFAULT = 200200;
	vector<int> parent;
	int N, num_comps;
	union_find(int N = DEFAULT) : N(N) {
		clear();
	}
	void clear(){
		num_comps = N;
		parent.assign(N, -1);
	}
	int find(int u){
		return (parent[u] < 0) ? u : parent[u] = find(parent[u]);
	}
	bool is_connected(int u, int v){
		return find(u) == find(v);
	}
	bool join(int u, int v){
		u = find(u);
		v = find(v);
		if (u != v){
			num_comps--;
			if (parent[u] > parent[v])
				swap(u, v);
			parent[u] += parent[v];
			parent[v] = u;
		}
		return u != v;
	}
	int size(int u){
		return -parent[find(u)];
	}
	int comps(){
		return num_comps;
	}
};
int main(){
	int n, q; long long m; cin >> n >> m >> q;
	vector<pair<int,int> > bad;
	union_find uf(n);
	for(int i = 0; i < q; i++){
		int u, v, w; cin >> u >> v >> w;
		if(w) bad.push_back({u, v});
		else uf.join(u, v);
	}
	for(auto e : bad) if(uf.is_connected(e.first, e.second)) return !printf("No\n");
	if(m == n - 1){
		if(bad.empty()) printf("Yes\n");
		else printf("No\n");
		return 0;
	}
	int cc = uf.comps();
	if(m <= n - cc + 1ll * cc * (cc - 1) / 2) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 1784
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;

#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);

#define csh(a,n) memset(a,n,sizeof(a));
int main(){
	int t,n;
	char arr[1000];
	cin>>arr;
	cout<<"ABC"<<arr<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i< (int)(n); i++)
int main(){
    int64_t A,V,B,W,T;
    cin >> A >> V >> B >> W >> T;
    if((abs(A-B)<=T*(V-W))) cout << "YES" << endl;
    else cout << "NO" << endl;


}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define MP make_pair
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> P;

int main(){
	int n, w, d;
	while(cin >> n >> w >> d, n|w|d){
		vector<P> cake;
		cake.push_back(MP(w, d));
		rep(i, n){
			//cout << "cutcount:" << i << endl;
			//rep(j, cake.size()){
			//	cout << " (" << cake[j].first << ", " << cake[j].second << ")";
			//}
			int p, s;
			cin >> p >> s;
			P piece = cake[p-1];
			int pw = piece.first;
			int pd = piece.second;
			cake.erase(cake.begin()+p-1);
			s %= (pw+pd);
			int w1, d1, w2, d2;
			if(s <= pw){
				d1 = d2 = pd;
				w1 = s;
				w2 = pw-s;
			}else{
				w1 = w2 = pw;
				d1 = s-pw;
				d2 = pw+pd-s;
			}
			if(w1*d1 > w2*d2){
				cake.push_back(MP(w2,d2));
				cake.push_back(MP(w1,d1));
			}else{
				cake.push_back(MP(w1,d1));
				cake.push_back(MP(w2,d2));
			}
		}
		vector<int> ans;
		rep(i, cake.size()){
			//cout << " (" << cake[i].first << ", " << cake[i].second << ")";
			ans.push_back(cake[i].first*cake[i].second);
		}
		sort(all(ans));
		rep(i, ans.size()){
			cout << (i?" ":"") << ans[i];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    int n;cin>>n;
    vector<int>V(n);rep(i,n)cin>>V[i];
    int count=0;
    sort(all(V));
    cout<<V[n/2]-V[n/2-1];
}

Measured memory_bytes: 1024
// In the name of God

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn=5010,mod=1e9+7;

vector<int>v[maxn];
int dp[maxn][maxn],ans[maxn],SZ[maxn],tmp[maxn],f[maxn];

void dfs(int u,int par=-1){
    SZ[u]=1;
    dp[u][1]=1;
    for(int y:v[u]){
	if(y!=par)
	    dfs(y,u);
    }
    for(int y:v[u]){
	if(y!=par){
	    fill(tmp,tmp+SZ[u]+SZ[y]+2,0);
	    for(int i=1;i<=SZ[u];i++)
		for(int j=1;j<=SZ[y];j++)
		    tmp[i+j]=(1ll*tmp[i+j]+1ll*dp[u][i]*dp[y][j])%mod;
	    for(int i=1;i<=SZ[u];i++)
		tmp[i]=(1ll*tmp[i]-1ll*dp[u][i]*ans[y])%mod;
	    SZ[u]+=SZ[y];
	    for(int i=0;i<=SZ[u];i++)
		dp[u][i]=tmp[i];
	}
    }
    for(int i=1;i<=SZ[u];i++)
	ans[u]=(1ll*ans[u]+1ll*f[i]*dp[u][i])%mod;
    //    cout<<u<<" "<<ans[u]<<" "<<dp[u][0]<<" "<<dp[u][1]<<" "<<dp[u][2]<<" "<<dp[u][3]<<" "<<dp[u][4]<<endl;
}

int main(){
    f[0]=1;
    for(int i=2;i<maxn;i++)
	f[i]=1ll*(i-1)*f[i-2] %mod;
    int n;cin>>n;
    for(int i=2;i<=n;i++){
	int a,b;cin>>a>>b;
	v[a].PB(b);
	v[b].PB(a);
    }
    dfs(1);
    if(ans[1]<0) ans[1]+=mod;
    cout<<ans[1]<<endl;
    return 0;
}


Measured memory_bytes: 97536
n = int(input())
d = {}

for i in range(n):
    a = input()
    if a not in d:
        d[a] = 1
    else:
        d[a] = d[a] + 1

ans = 0
for val in d.values():
    if val % 2 == 1:
        ans += 1
    else:
        continue
print(ans)


Measured memory_bytes: 17884
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){    
        string s,t; cin>>s>>t;
    int n=s.size(),m=t.size();
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1]) dp[i][j]=1+dp[i-1][j-1];
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int index = dp[n][m];
    char ans[index+1];
    ans[index]='\0';
    int i=n,j=m;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            ans[--index]=s[i-1];
            i--,j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]) i--;
        else j--;
    }
    cout<<ans;
    }   
}

Measured memory_bytes: 73956
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=5e5+10;
const int maxm=20e5+10;
char s[maxn],t[maxn],all[maxm];
int ns,nt,n;
int fail[maxm],to[maxn],dp[maxn];
vector<int> rev[maxn];
queue<int> que;
void kmp()
{
	fail[0]=-1;
	int k;
	for(int i=1;i<=nt;i++)
	{
		k=fail[i-1];
		while(k>=0)
		{
			if(t[k]==t[i-1])break;
			k=fail[k];
		}
		fail[i]=k+1;
	}
	k=0;
	for(int i=0;i<n;i++)
	{
		while(k>=0&&t[k]!=all[i])k=fail[k];
		k++;
		if(k==nt)
		{
			if(i-nt+1<ns)to[i-nt+1]=(i+1)%ns;//cout<<i-nt+1<<" "<<i+1<<endl;
			k=fail[k];
		}
	}
} 
int main()
{
	scanf("%s",s);ns=strlen(s);
	scanf("%s",t);nt=strlen(t);
	while(n<ns+nt)
	{
		for(int i=0;i<ns;i++,n++)
			all[n]=s[i];
	}
	memset(to,-1,sizeof(to));
	memset(dp,-1,sizeof(dp));
	kmp();
	for(int i=0;i<ns;i++)
	{
		if(to[i]==-1)
		{
			dp[i]=0;
			que.push(i);
		}
		else
		{
			rev[to[i]].emplace_back(i);
		}
	}
	while(!que.empty())
	{
		int x=que.front();
		que.pop();
		for(int i=0;i<rev[x].size();i++)
		{
			dp[rev[x][i]]=dp[x]+1;
			que.push(rev[x][i]);
		}
	}
	int ans=0;
	for(int i=0;i<ns;i++)
	{
		if(dp[i]==-1)
		{
			printf("-1");
			return 0;
		}
		ans=max(ans,dp[i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 37632
import sys
from math import ceil

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    P = [INT() for _ in range(5)]
    print(ceil(N/min(P)) + 4)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
		long startCpuTime = threadMXBean.getCurrentThreadCpuTime();

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\0540_input.txt"));

		while (scan.hasNext()) {

			int n = scan.nextInt();
			if (n == 0)
				break;
			int m = scan.nextInt();
			int h = scan.nextInt();
			int k = scan.nextInt();
			Amida a = new Amida(n, m, k);
			for (int i = 1; i <= n; i++)
				a.addScore(i, scan.nextInt());
			for (int i = 1; i <= m; i++)
				a.addH(i, scan.nextInt(), scan.nextInt());

			System.out.println(a.jscore());
		}

		scan.close();
		long stopCpuTime = threadMXBean.getCurrentThreadCpuTime();
		// System.out.println("CPU=" + (stopCpuTime - startCpuTime) / 1000000);

		System.exit(0);
	}
}

class Amida {
	class Bar {
		public Bar(int _a, int _b) {
			a = _a;
			b = _b;
		}

		int a, b, chg;
	}

	List<Bar> bar = new ArrayList<Bar>();

	int[] sc;
	boolean[] nu;

	public Amida(int n, int m, int k) {
		sc = new int[n + 1];
		nu = new boolean[n + 1];
		for (int i = 1; i <= k; i++)
			nu[i] = true;
	}

	class barCompare implements Comparator<Bar> {

		@Override
		public int compare(Bar o1, Bar o2) {
			if (o1.b > o2.b)
				return 1;
			else if (o1.b == o2.b)
				return 0;
			else
				return -1;
		}

	}

	public int jscore() {
		// this.sort();
		Collections.sort(bar, new barCompare());
		int s = this.down() - this.up();
		return s;
	}

	private int up() {
		int max = 0;
		for (int i = bar.size() - 1; i >= 0; i--) {
			int c = (sc[bar.get(i).a] - sc[bar.get(i).a + 1]) * bar.get(i).chg;
			if (c > max)
				max = c;
			int t = sc[bar.get(i).a];
			sc[bar.get(i).a] = sc[bar.get(i).a + 1];
			sc[bar.get(i).a + 1] = t;
		}

		return max;
	}

	private void sort() {
		for (int i = bar.size() - 2; i >= 0; i--)
			for (int j = i + 1; j < bar.size(); j++)
				if (bar.get(j - 1).b > bar.get(j).b) {
					int t = bar.get(j - 1).a;
					bar.get(j - 1).a = bar.get(j).a;
					bar.get(j).a = t;
					t = bar.get(j - 1).b;
					bar.get(j - 1).b = bar.get(j).b;
					bar.get(j).b = t;
				}
	}

	private int down() {
		for (int i = 0; i < bar.size(); i++) {
			if (nu[bar.get(i).a])
				if (nu[bar.get(i).a + 1])
					continue;
				else
					bar.get(i).chg = -1;
			else if (nu[bar.get(i).a + 1])
				bar.get(i).chg = 1;
			else
				continue;
			nu[bar.get(i).a] ^= true;
			nu[bar.get(i).a + 1] ^= true;
		}
		int s = 0;
		for (int i = 1; i < nu.length; i++)
			if (nu[i])
				s += sc[i];
		return s;
	}

	public void addH(int m, int a, int b) {
		bar.add(new Bar(a, b));
	}

	public void addScore(int n, int s) {
		sc[n] = s;
	}
}

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

int main(){
  string s,t; cin >> s >> t;
  string test=s+s;
  
  if(test.find(t)!=-1) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    ll n, k;
    cin >> n >> k;
    vector<pair<int, int> >p(n);
    for(int i = 0; i < n; i++){
        cin >> p.at(i).first >> p.at(i).second;
    }
    sort(p.begin(), p.end());
    for(int i = 0; i < n; i++){
        if(k > p.at(i).second) k -= p.at(i).second;
        else{
            cout << p.at(i).first << endl;
            break;
        }
    }
    solve();
    return 0;
}



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

int modl(_LL a)
{
    a %= g_bm;
    if( a < 0 ) a += g_bm * ( 1 - (a + 1) / g_bm );
    return a;
}

int modadd(_LL a, _LL b)
{
    return modl(a + b);
}

int main()
{
    _LL n, k;
    cin >> n >> k;
    int ans = 0;
    for(_LL l = k; l <= n + 1; l++)
    {
        ans = modadd(ans, (n - l + 1 + n) * l / 2 - (l - 1) * l / 2 + 1);
    }
    cout << ans << endl;

}

Measured memory_bytes: 3592
import java.util.*;
import java.math.*;
public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        /*if(n==k){
            System.out.println(1);
            for(int i = 1;i < k;i++){
                System.out.println(0);
            }
            return;
        }*/
        for(int i = 0;i < k;i++){
            if(i>n-k){
                System.out.println(0);
                continue;
            }
            long ans = nCk(k-1,k-i-1,MOD);//iH(k-i)
            ans *= nCk(n-k+1,i+1,MOD);
            System.out.println(ans%MOD);
        }
    }       
    public static int nCk(int n, int k, int M) {
		long ret = 1;
		int min = Math.min(k, n - k);
		for (int i = 1; i <= min; i++) {
			ret = (ret * pow(i, M - 2, M)) % M;
		}
		for (int i = n - min + 1; i <= n; i++) {
			ret = (ret * i) % M;
		}
		return (int) ret;
    }
    public static long pow(long a, long b, int M) {
		long ret = 1;
		long tmp = a;
		while (b > 0) {
			if ((b & 1) == 1)
				ret = (ret * tmp) % M;
			tmp = (tmp * tmp) % M;
			b = b >> 1;
        }
		return ret;
    }
  
   
}






Measured memory_bytes: 22484
N, K = map(int, input().split())
mod = 10**9+7

a = [0]*(K-1+1)
#comb[i] = nCi
comb_a = [0]*(K-1+1)
comb_a[0] = 1
for i in range(1, K-1+1):
    a[i] = pow(i, mod-2, mod)
    comb_a[i] = comb_a[i-1]*(K-1-i+1)*a[i]%mod

b = [0]*(N-K+1+1)

#comb[i] = nCi
comb_b = [0]*(N-K+1+1)
comb_b[0] = 1
for i in range(1, N-K+1+1):
    b[i] = pow(i, mod-2, mod)
    comb_b[i] = comb_b[i-1]*(N-K+1-i+1)*b[i]%mod

for idx in range(1, K+1):
    ans = comb_a[idx-1]
    if 0 <= idx <= N-K+1:
        ans *= comb_b[idx]
        ans %= mod
    else:
        ans = 0
    print(ans)

Measured memory_bytes: 42096
from math import ceil
import numpy as np
N,K=map(int, input().split())
#サイコロを振る　１以上K未満→コイン　K以上ゲーム終了、す抜けのかち
#コイン　表なら２倍　裏なら０　０なったら負け
ans=max( (N-K+1),0) /N

#(K-1)/N
# M*(2**x)>=K M:サイコロの目
# x*log(2)>=log(K/M)
lim=min(K-1,N)
for i in range(1,lim+1):
    x=ceil(np.log(K/i)/np.log(2))
    ans+=(1/N)*((0.5)**x)
print(ans)

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

struct Edge{
    int to;
    ll yen, snuuk;
    Edge(int to, ll yen, ll snuuk): to(to), yen(yen), snuuk(snuuk){}
};

int n,m;
vector<Edge> G[200000];
map<ll, ll> d[2]; // 0 yen 1 snuuk

void dijkstra(ll start, int is_snuuk){
    priority_queue< Pll, vector<Pll>, greater<Pll> > que;
    d[is_snuuk][start] = 0;
    que.push(Pll(0, start));
    
    while(!que.empty()){
        Pll v = que.top(); que.pop();
        if(d[is_snuuk].find(v.second) != d[is_snuuk].end() && d[is_snuuk][v.second] < v.first) continue;
        for(Edge e: G[v.second]){
            ll dcost;
            if(is_snuuk){
                dcost = e.snuuk;
            }else{
                dcost = e.yen;
            }
            if(d[is_snuuk].find(e.to) == d[is_snuuk].end() || d[is_snuuk][e.to] > d[is_snuuk][v.second] + dcost){
                d[is_snuuk][e.to] = d[is_snuuk][v.second] + dcost;
                que.push(Pll(d[is_snuuk][e.to], e.to));
            }
        }
    }
}

int main(){
    int s,t,u,v;
    ll a,b;
    cin >> n >> m >> s >> t;
    rep(m){
        cin >> u >> v >> a >> b;
        G[u].emplace_back(Edge(v,a,b));
        G[v].emplace_back(Edge(u,a,b));
    }
    dijkstra(s, 0);
    dijkstra(t, 1);

    priority_queue<Pll, vector<Pll>, greater<Pll> > que;
    reppp(i, 1, n+1){
        que.emplace(d[0][i] + d[1][i], i);
    }
    Pll p = que.top(); que.pop();
    rep(n){
        while(!que.empty() && p.second <= i){
            p = que.top();que.pop();
        }
        cout << 1000000000000000 - p.first << endl;
    }
}



Measured memory_bytes: 28344
var
	A,B,C,K:Longint;
begin
	read(A,B,C,K);
	while A>=B do begin
		dec(K);
		B:=B*2;
	end;
	while B>=C do begin
		dec(K);
		C:=C*2;
	end;
	if K<0 then writeln('No')else writeln('Yes');
end.

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

int main(){
  
  vector<int> v(6);
  int i, j;
  
  for (i = 0; i < 6; i++){
    cin >> v.at(i);
  }
  
  for (i = 0; i < 5; i++){
    for (j = i + 1; j < 5; j++){
      
      if(abs(v.at(i) - v.at(j)) > v.at(5)){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define debug(x) cerr<<#x<<" = "<<(x)<<endl
#define eps 1e-8
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN=(int)3e5+5;
const int MOD=(int)1e9+7;
char str[MAXN];
int main()
{
    int n;
    cin>>n>>str;
    int num=0;
    for(int i=0;i<n;i++){
        if(str[i]=='E')num++;
    }
    int ans=num;
    int stp=0;
    for(int i=0;i<n;i++){
        if(str[i]=='E')num--;
        ans=min(ans,num+stp);
        if(str[i]=='W')stp++;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
	// ?????°??£?¨?
	int a;
	int b;
	int c;
	int ans = 0;

	// ??\???
	cin >> a >> b >> c;

	for (int x = a; x <= b; x++)
	{
		if (c % x == 0)
		{
			ans++;
		}
	}

	// ??????
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

int p[300000];
int index[300000];

int ans;
int num = 1;

int main() {

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

	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}

	for (int i = 1; i <= n; i++) {
		if (i == 1)continue;
		else if (i == n) {
			if(index[i]>index[i-1])ans = max(ans, num + 1);
			else ans = max(ans, num);
		}
		else if (index[i] > index[i - 1])num++;
		else {
			ans = max(ans, num);
			num = 1;
		}
	}
	cout << n - ans << endl;

	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			String qwright = "nmhjklyuiop" ;
			
			int n = sc.nextInt();
			String[] u = new String[n];
			//String uu = "";
			for(int i=0; i<n; i++) {
				u[i] = sc.next();
				//uu += sc.next() + ",";
			}
			int m = sc.nextInt();
			int flag = 0;
			for(int i=0; i<m; i++) {
				String t = sc.next();
				
				for(int j=0; j<n; j++) {
					boolean look = false;
					for(int k=0; k<n; k++) {
						if(u[k].equals(t)) {
							look = true;
							break;
						}
					}
					if(look) {
						if(flag == 0) {
							System.out.println("Opened by "+ t);
							flag = 1;
							break;
						}else if(flag == 1){
							System.out.println("Closed by "+ t);
							flag = 0;
							break;
						}
					}else {
						System.out.println("Unknown "+ t);
						break;
					}
				}
				
				
			}
			
			
			
			
			
		}
	}
}




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

struct Problem {
    UL N, M, Q;
    UL V[50][4];

    int A[10];

    UL DFS(UL p) {
        UL tmp = 0;
        if (p == N) {
            rep(i, Q) if (A[V[i][1]] - A[V[i][0]] == V[i][2]) tmp += V[i][3];
            return tmp;
        }
        for (UL i = A[p - 1]; i < M; i++) {
            A[p] = i;
            tmp = max(tmp, DFS(p + 1));
        }
        return tmp;
    }

    void Solve() {
        cin >> N >> M >> Q;
        rep(i, Q) {
            UL a, b, c, d; cin >> a >> b >> c >> d;
            V[i][0] = a - 1;
            V[i][1] = b - 1;
            V[i][2] = c;
            V[i][3] = d;
        }
        UL ans = 0;
        rep(i, M) {
            A[0] = i;
            ans = max(ans, DFS(1));
        }
        cout << ans << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    p->Solve();
    return 0;
}


Measured memory_bytes: 3604
#[allow(unused_imports)]
use std::io::Write;

// {{{1
#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// }}}

fn main() {
    input! {
        n: usize,
        q: usize,
        queries: [(usize, usize, usize); q],
    }

    let mut uf = UnionFind::new(n);
    for (com, x, y) in queries {
        if com == 0 {
            // unite
            uf.unite(x, y);
        } else {
            // same
            let ans = if uf.same(x, y) { 1 } else { 0 };
            println!("{}", ans);
        }
    }
}

struct UnionFind {
    parent: Vec<usize>,
    rank: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        let mut parent = vec![];
        for i in 0..n {
            parent.push(i);
        }
        UnionFind {
            parent: parent,
            rank: vec![0; n],
        }
    }

    fn find(&mut self, i: usize) -> usize {
        if self.parent[i] == i {
            i
        } else {
            let p_i = self.parent[i];
            self.parent[i] = self.find(p_i);
            self.parent[i]
        }
    }

    fn unite(&mut self, i: usize, j: usize) {
        let i = self.find(i);
        let j = self.find(j);
        if i == j {
            return;
        }

        if self.rank[i] < self.rank[j] {
            self.parent[i] = j;
        } else {
            self.parent[j] = i;
            if self.rank[i] == self.rank[j] {
                self.rank[i] += 1;
            }
        }
    }

    fn same(&mut self, i: usize, j: usize) -> bool {
        self.find(i) == self.find(j)
    }
}



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

int main(void)
{
  int price_sum = 0;
  double num_sum = 0;
  int i;
  for (i=0; ;i++)
  {
    int price;
    int num;
    char dummy;
    cin >> price >> dummy >> num;
    if ( cin.eof() ) break;
    price_sum += price * num;
    num_sum += num;
  }

  int avg = (int)( (num_sum / i) + 0.5 );
  cout << price_sum << endl
       << avg << endl;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var masterArray = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var left = new int[N + 1];
            var right = new int[N + 1];
            var ans = new int[N];

            left[0] = 0;
            right[N] = 0;

            for (int i = 0; i < N; i++)
            {
                left[i + 1] = Gcd(left[i], masterArray[i]);
            }

            for (int i = N; i > 0; i--)
            {
                right[i - 1] = Gcd(right[i], masterArray[i - 1]);
            }

            for (int i = 0; i < N; i++)
            {
                ans[i] = Gcd(left[i], right[i + 1]);
            }

            Console.WriteLine(ans.Max());
        }

        static int Gcd(int m, int n)
        {
            if (n > m) return Gcd(n, m);
            if (n == 0) return m;
            return Gcd(n, (m % n));
        }
    }
}

Measured memory_bytes: 28348
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
long double x[110];
long double y[110];
long double r[110];
const long double EPS = 1e-20;
const long double INF = 1e+20;
const long double PI = acos(-1);
int sig(long double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
inline long double ABS(long double a){return max(a,-a);}
struct Pt {
	long double x, y;
	Pt() {}
	Pt(long double x, long double y) : x(x), y(y) {}
	Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
	Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
	Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
	Pt operator-() const { return Pt(-x, -y); }
	Pt operator*(const long double &k) const { return Pt(x * k, y * k); }
	Pt operator/(const long double &k) const { return Pt(x / k, y / k); }
	long double ABS() const { return sqrt(x * x + y * y); }
	long double abs2() const { return x * x + y * y; }
	long double arg() const { return atan2(y, x); }
	long double dot(const Pt &a) const { return x * a.x + y * a.y; }
	long double det(const Pt &a) const { return x * a.y - y * a.x; }
};
long double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }

pair<Pt,Pt> pCC(Pt a,long double r, Pt b,long double s) {
	long double d = (b - a).ABS();
	long double x = (d * d + r * r - s * s) / (d * 2);
	//printf("%.20Lf %.20Lf\n",d,r*r-x*x);
	Pt e = (b - a) / d, w = e * Pt(0, 1) * sqrt(max(r * r - x * x, 0.0L));
	return make_pair(a + e * x - w, a + e * x + w);
}
Pt p[110];
bool oth;
int n;
bool chk(int a,int b,int c,Pt d){
	if(a!=b&&a!=c&&(p[a]-d).ABS()>r[a])return false;
	oth=true;
	for(int i=a+1;i<n;i++){
		if(i==b||i==c)continue;
		if((p[i]-d).ABS()<r[i])return false;
	}
//	printf("%d %d %d %Lf %Lf\n",a,b,c,d.x,d.y);
	return true;
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		n=a;
		for(int i=0;i<a;i++)scanf("%Lf%Lf%Lf",x+i,y+i,r+i);
		for(int i=0;i<a;i++)p[i]=Pt(x[i],y[i]);
		int ret=0;
		vector<Pt> v;
		for(int i=0;i<a;i++)for(int j=i+1;j<a;j++){
			long double d=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
			if(d>r[i]-r[j]&&d<r[i]+r[j]){
				pair<Pt,Pt> tmp=pCC(p[i],r[i],p[j],r[j]);
				v.push_back(tmp.first);
				v.push_back(tmp.second);
			}
		}
		for(int i=0;i<a;i++){
			bool dame=false;
			
			for(int j=i+1;j<a;j++){
				if(i==j)continue;
				long double d=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
				if(d<r[j]-r[i])dame=true;
			}
			if(dame)continue;
		//	printf("%d ",i);
			oth=false;
			for(int j=i;j<a;j++)for(int k=j+1;k<a;k++){
				long double d=(p[k]-p[j]).ABS();
			//	printf("%d %d %d: %.20Lf\n",i,j,k,d);
				if(d>r[k]-r[j]&&d<r[k]+r[j]){
					pair<Pt,Pt> tmp=pCC(p[j],r[j],p[k],r[k]);
					if(chk(i,j,k,tmp.first)||chk(i,j,k,tmp.second)){
					//	printf("%d: %d %d %Lf %Lf %Lf %Lf\n",i,j,k,tm);
						ret++;
						goto owari;
					}
				}
			}
			owari:;
			if(!oth)ret++;
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1200
S=input()
ans=1
tmp=S[0]
i=1
while i<len(S):
  if S[i] == tmp:
    i+=1
    ans+=1
    tmp+=S[i%len(S)]
  else:
    ans+=1
    tmp=S[i]
  i+=1
if i == len(S)+1:
  ans-=1
print(ans)

Measured memory_bytes: 3500
#include <iostream>
using namespace std;
#include<algorithm>
static const int MAX = 200000;
int main() {
	
		int R[MAX], n;
		cin >> n;
		for (int i = 0;i < n;i++) cin >> R[i];
		int maxv = -2000000000;
		int minv = R[0];
		for (int i = 1;i < n;i++){
			maxv = max(maxv, R[i] - minv);
			minv = min(minv, R[i]);
		
	}
		cout << maxv << endl;

}

	




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

int f( int x )
{
	int sum = 0;
	int d;
	while( x > 0 ) {
		d = x % 10;
		x /= 10;
		sum += d;
	}
	return sum;
}

int main()
{
	int ans = 0;
	int n;

	cin >> n;

	if( ( n % f( n ) ) == 0 ) {
		ans = 1;
	}

	if( ans != 0 ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    string s;
    cin >> N >> s;

    vector<vector<int>> a(2, vector<int>(N + 1));

    FOR(i, 1, N + 1) {
        if (s[i - 1] == 'W') {
            a[0][i] = a[0][i - 1] + 1;
            a[1][i] = a[1][i - 1];
        } else {
            a[0][i] = a[0][i - 1];
            a[1][i] = a[1][i - 1] + 1;
        }
    }
    int ans = INF32;
    FOR(i, 1, N + 1) { chmin(ans, a[0][i - 1] + a[1][N] - a[1][i]); }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4244
n = int(input())

ans = [0] * 110000

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            num = x**2 + y**2 + z**2 + x*y + y*z + x*z
            ans[num] += 1

for i in range(1, n + 1):
    print(ans[i])

Measured memory_bytes: 9856
using System;

namespace abc122_a
{
    class Program
    {
        static void Main(string[] args)
        {
            char a = char.Parse(Console.ReadLine());
            if (a == 'A')
            {
                Console.WriteLine('T');
            }
            else if (a == 'T')
            {
                Console.WriteLine('A');
            }
            else if (a == 'C')
            {
                Console.WriteLine('G');
            }
            else if (a == 'G')
            {
                Console.WriteLine('C');
            }
            else
            {
                Console.WriteLine("正しい文字を入力してください");
            }


        }
    }
}


Measured memory_bytes: 13140
// https://atcoder.jp/contests/abc171/tasks/abc171_a
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}


Measured memory_bytes: 3624
str = gets

check1 = str[0] == "A"
check2 = str.slice(2, str.length - 4).split("").select { |c| c == "C" }.length == 1
check3 = (str.split("") - ["A", "C"]).all? { |c| c == c.downcase }

if check1 && check2 && check3
  puts "AC"
else
  puts "WA"
end


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

const int N = 1e5 + 10;

int n;
int a[N], b[N], c[N];
long long sum[N];

void load() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", a + i);
    for (int i = 1; i <= n; ++i) scanf("%d", b + i);
    for (int i = 1; i <= n; ++i) scanf("%d", c + i);
}

void process() {
    sort(a + 1, a + n + 1); sort(b + 1, b + n + 1);
    for (int i = 1; i <= n; ++i) {
        sum[i] = lower_bound(a + 1, a + n + 1, b[i]) - a - 1;
        //cerr << lower_bound(a + 1, a + n + 1, b[i]) - a - 1<< "\n";
    }
    for (int i = 1; i <= n; ++i) sum[i] += sum[i - 1]; cerr << "\n";
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += sum[lower_bound(b + 1, b + n + 1, c[i]) - b - 1];
        //cerr << lower_bound(b + 1, b + n + 1, c[i]) - b - 1 << "\n";
    }
    printf("%lld\n", ans);
}

int main() {
//    freopen("input.in", "r", stdin);
//    freopen("output.out", "w", stdout);

    load();
    process();

    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;

static const int INF = INT_MAX;
static const int MIN = INT_MIN;
static const LL L_INF = LLONG_MAX;
static const int MOD = 1000000000 + 7;
static const int SIZE = 100005;

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

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

    for( int i = 1; i < n; ++i ) {
        LL x = X;
        if( a[i] + a[i - 1] > x ) {
            LL tmp = a[i - 1] + a[i];

            if( tmp - a[i] > x ) {
                res += tmp - x;
                tmp -= a[i];
                a[i] = 0;
                a[i - 1] -= x;


            } else {
                res += tmp - x;
                a[i] -= tmp - x;

            }
        }
    }

    cout << res << endl;
    return 0;
}



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

using namespace std;

int main() {
  int a;
  std::cin >> a;
  bool lower3200s[8] = {};
  int lower3200 = 0;
  int upper3200 = 0;
  while (std::cin >> a) {
    int i = a / 400;
    if (i < 8) {
      if (!lower3200s[i]) {
        lower3200s[i] = true;
        lower3200++;
      }
    } else {
      upper3200++;
    }
  }
  std::cout << std::max(lower3200, 1) << " " << lower3200 + upper3200
            << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char num[1000];
void fix() {
	for(int i=0; i<strlen(num); i++) {
		if(num[i]=='2'&&num[i+1]=='0'&&num[i+2]=='1'&&num[i+3]=='7') {
			num[i+3]='8';
			return;
		}
	}
}
int main () {
	int a,b,c,d,x,y,z;
	memset(num,0,sizeof(num));
	scanf("%s",num);
	fix();
	printf("%s\n",num);
	return 0;
}

Measured memory_bytes: 256