akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
using namespace std;
typedef pair<int,int> P;
#define int long long
string s;
int a[26];
main(){
	int sum=0;
	cin>>s;
	for(int i=s.size()-1;i>=0;i--){
		r(j,26)if(s[i]-'a'!=j)sum+=a[j];
		a[s[i]-'a']++;
	}
    cout<<sum+1<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	int N;
	cin >> N;

	int kazu[300] = {};
	rep(i, N) rep(j, N) {
		if (i - j >= 0) kazu[i - j]++;
	}

	string S[300];
	rep(i, N) cin >> S[i];

	int kotae = 0;
	rep(k, N) {
		int OK = 1;
		rep(i, N) {
			rep(j, N) {
				if (S[(i - k + N) % N][j] != S[(j - k + N) % N][i]) OK = 0;
			}
		}
		if (OK) kotae += kazu[k];
	}
	rep1(k, N - 1) {
		int OK = 1;
		rep(i, N) {
			rep(j, N) {
				if (S[i][(j - k + N) % N] != S[j][(i - k + N) % N]) OK = 0;
			}
		}
		if (OK) kotae += kazu[k];
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n; cin >> n;
	double a[101], sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i]; sum += a[i];
	}
	sum /= n;
	double d = abs(sum - a[0]); int ans = 0;
	for (int i = 1; i < n; i++) {
		if (d > abs(sum - a[i])) {
			d = abs(sum - a[i]);
			ans = i;
		}
	}
	cout << ans << endl;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  char data[x][y] = {};
  for (int i = 0; i < x; i++) {
   for (int j = 0; j < y; j++) {
     cin >> data[i][j];
   }
  }
  for (int i = 0; i < y + 2; i++) {
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < x; i++) {
    cout << '#';
    for (int j = 0; j < y; j++) {
    cout << data[i][j];
   }
    cout << '#' << endl;
  }
  for (int i = 0; i < y + 2; i++) {
    cout << '#';
  }
}
    

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

def max(a,b)
  return a>b ? a : b
end
s=gets.chomp.codepoints
s_size=s.size
t=gets.chomp.codepoints
t_size=t.size
dp=Array.new(s_size+1){Array.new(t_size+1,0)}
0.upto(s_size-1).each do|i|
  dp_current,dp_next=dp[i],dp[i+1]
  0.upto(t_size-1).each do|j|
    if s[i]==t[j]
      dp_next[j+1]=dp_current[j]+1
    else
      dp_next[j+1]=dp_current[j+1]>dp_next[j] ? dp_current[j+1] : dp_next[j]
    end
  end
end
ans=""

while s_size>0
  if dp[s_size][t_size]==dp[s_size-1][t_size]
    s_size-=1
  elsif dp[s_size][t_size]==dp[s_size][t_size-1]
    t_size-=1
  else #dp[s_size][t_size]==dp[s_size-1][t_size-1]
    s_size-=1
    t_size-=1
    ans<<s[s_size]
  end
end
puts ans.reverse

Measured memory_bytes: 72956
#include<stdio.h>

int max(int x,int y){
	if(x>y)return x;
	return y;
}

int min(int x,int y){
	if(x<y)return x;
	return y;
}

int main(){
	int A,B,C,X,Y,ans=1000000000;
	scanf("%d%d%d%d%d",&A,&B,&C,&X,&Y);
	
	C*=2;
	for(int i=0;i<=max(X,Y);i++)ans=min(ans,C*i+A*max(X-i,0)+B*max(Y-i,0));
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
h, w, k = [int(i) for i in input().split()]
mas = [input() for _ in range(h)]

ans = 0

for h_1 in range(2**h):
    for w_1 in range(2**w):
        black = 0

        for i in range(h):
            for j in range(w):
                if (h_1 >> i) & 1 == 0 and (w_1 >> j) & 1 == 0 and mas[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1
print(ans)

Measured memory_bytes: 9176
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define nmax 200001
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}

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

    vector<pll> A(n);
    vector<ll> ys(n); 
    for(int i=0;i<n;i++) {
        scanf("%lld%lld",&A[i].first, &A[i].second);
        ys[i] = A[i].second;
    }

    sort(ys.begin(), ys.end());
    for(int i=0;i<n;i++) {
        int a = lower_bound(ys.begin(), ys.end(), A[i].second)-ys.begin();
        A[i].second = a+1;
    }

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

    ll base = 1;
    while(base<=n)
        base*=2;

    vector<int> left(n,0), right(n,0);  // smaller y coord
    vector<ll> tree(2*base,0), tree2(2*base,0);
    
    for(int i=0;i<n;i++) {
        int x = base+A[i].second;
        int c = tree[x];

        while(x>1) {
            if(x%2==1)
                c += tree[x-1];
            x/=2;
        }

        left[i] = c;
        x = base+A[i].second;
        while(x>0) {
            tree[x] += 1;
            x/=2;
        }
    }

    for(int i=n-1;i>=0;i--) {
        int x = base+A[i].second;
        int c = tree2[x];

        while(x>1) {
            if(x%2==1)
                c += tree2[x-1];
            x/=2;
        }

        right[i] = c;
        x = base+A[i].second;
        while(x>0) {
            tree2[x] += 1;
            x/=2;
        }
    }

    // for(int i=0;i<n;i++)
    //     cout<<left[i]<<" ";
    // cout<<endl;

    // for(int i=0;i<n;i++)
    //     cout<<right[i]<<" ";
    // cout<<endl;

    vector<ll> pows(n+1,1);
    for(int i=1;i<=n;i++)
        pows[i] = ((ll)2*pows[i-1])%N2;

    int res = 0;
    for(int i=0;i<n;i++) {
        int sl = left[i], sr = right[i];
        int gl = i-left[i], gr = (n-i-1)-right[i];

        res = (res+pows[i]+pows[n-i-1]-1)%N2; 
        res = (res+(pows[i]-1)*(pows[n-i-1]-1))%N2;
        res = (res+(pows[i]-1)*(pows[n-i-1]-1))%N2;
        res = (res-(pows[sl]-1)*(pows[sr]-1))%N2;
        res = (res-(pows[gl]-1)*(pows[gr]-1))%N2;
        // cout<<i<<" "<<res<<endl;
    }
    cout<<(res+N2)%N2<<endl;

    return 0;
}



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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int k;
  scanf("%d", &k);
  std::vector<int> h;
  int m;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &m);
    h.push_back(m);
  }
  std::sort(h.begin(), h.end(), std::greater<int>());
  int g, l;
  int min = INT_MAX;
  for (int i = k - 1; i < n; ++i) {
    g = h[i - (k - 1)];
    l = h[i];

    if (g - l < min) {
      min = g - l;
    }
  }
  printf("%d\n", min);

  return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15); 
    const int mod = 1000000007; 
    int n, m; 
    cin >> n >> m; 
    vector<int> a(n + 1), b(n + 1);
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) cin >> b[i]; 
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
    vector<vector<int>> pw(n + 1, vector<int>(m + 1, 0)); 
    for (int i = 1; i <= n; ++i) {
        vector<int> tmp(b[i] - a[i] + 1, 1);  
        for (int j = 0; j <= m; ++j) {
            for (int k = 0; k <= b[i] - a[i]; ++k) {
                pw[i][j] = (pw[i][j] + tmp[k]) % mod; 
            }
            for (int k = 0; k <= b[i] - a[i]; ++k) {
                tmp[k] = 1ll * tmp[k] * (k + a[i]) % mod;
            } 
        }
    } 
    dp[0][0] = 1; 
    for (int i = 1; i <= n; ++i)
        for (int j = 0; j <= m; ++j) 
            for (int k = 0; k <= j; ++k) {
                dp[i][j] = (dp[i][j] + 1ll * dp[i - 1][j - k] * pw[i][k] % mod) % mod; 
            }
    cout << dp[n][m] << endl; 
    return 0; 
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  long long int n,k,a[200000],N=0,i=0;
  cin >> n >> k;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<int>());
  i=0;
  while(i<k){
    i++;
  }
  while(i<n){
    N+=a[i],i++;
  }
  cout << N << endl;
  return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;

int main () {
	int tt;
	cin >> tt;
	for (int it = 0; it < tt; it++) {
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		int ok = 1;
		if (a < b) {
			ok = 0;
		} else {
			a %= b;
			ll k = gcd (b, d);
//			cout << a << " " << b << " " << c << " " << d << " " << k << endl;
			if (d < b) {
				if (a % k + d < b) {
					ok = 0;
				}
			}
			if (c < b - 1) {
				d %= b;
				if (a > c) {
					ok = 0;
				} else {
					if (d != 0) {
						ll cc = c + (a % k) - (c % k);
						if (cc <= c) cc += k;
						if (cc < b) {
							ok = 0;
						}
					}	
				}
			}
		}
		if (ok) printf ("Yes\n"); else printf ("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから

// func declaration
template <class T> void printVec(vector<T>);
template <class T> void calcVec(vector<T>&, int, char);
bool checkMultiple(vector<int>&, int);

// const
const int INF = 10000000;

/*MEMO
辞書順
abc < abcd, atcoder < atlas
*/

int main() {
    string str, kara = "";
    cin >> str;
    size_t num = str.size();
    sort(ALL(str));
    UNIQUE(str);

    if (num == str.size()) cout << "yes" << endl;
    else cout << "no" << endl;

    return 0;
}


// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    if (ch == '+') {
        REP(i, vec.size()) {
            vec.at(i) += num;
        }
    } else if (ch == '-') {
        REP(i, vec.size()) {
            vec.at(i) -= num;
        }
    } else if (ch == '*') {
        REP(i, vec.size()) {
            vec.at(i) *= num;
        }
    } else if (ch == '/'){
        REP(i, vec.size()) {
            vec.at(i) /= num;
        }
    } else if (ch == '%') {
        REP(i, vec.size()) {
            vec.at(i) %= num;
        }
    }
}

bool checkMultiple(vector<int> &vec, int num) {
    // vecの中身が、numの倍数かどうかのチェック
    int count = 0;
    REP(i, vec.size()) {
        if (vec.at(i)%num != 0) count++;
    }
    return (count == 0);
}


Measured memory_bytes: 256
n = int(input())
t_list=[int(s) for s in input().split()]
total=sum(t_list)

m = int(input())
drink=[]
for _ in range(m):
    p,x=map(int,input().split())
    drink.append((p,x))

for p,x in drink:
    print(total - t_list[p-1] + x)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

//System.out.println();
public class Main implements Runnable { //クラス名はMain3

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		FastScannerMain3 sc = new FastScannerMain3(System.in);

		try {
			int N = sc.nextInt();
			int M = sc.nextInt();
			int[] s = new int[M];
			int[] c = new int[M];
			int ans = -1;
			boolean judge = true;
			HashMap<Integer, Integer> hm = new HashMap<>();

			for (int i = 0; i < M; i++) {
				int si = sc.nextInt();
				int ci = sc.nextInt();

				s[i] = si;
				c[i] = ci;
				if (N != 1 && si == 1 && ci == 0) {
					judge = false;
					break;
				}
				if (hm.containsKey(si)) {
					if (hm.get(si) != ci) {
						judge = false;
						break;
					}
				} else {
					hm.put(si, ci);
				}
			}

			if (judge) {
				ans = 0;
				for (int n = 1; n <= N; n++) {
					//System.out.println("n " + n);
					if (n == 1 && !hm.containsKey(n)) {
						if (N != 1) {
							ans += (int) (1 * (Math.pow(10, (N - n))));
						}
					} else if (hm.containsKey(n)) {
						ans += (int) (hm.get(n) * (Math.pow(10, (N - n))));
					}
				}

			}
			//System.out.println(judge);
			System.out.println(ans);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

//高速なScanner
class FastScannerMain3 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMain3(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


Measured memory_bytes: 27860
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	//MON,TUE,WED,THU,FRI,SAT
	if(s=="SUN")cout << 7 << endl;
	else if(s=="MON")cout << 6 << endl;
	else if(s=="TUE")cout << 5 << endl;
	else if(s=="WED")cout << 4 << endl;
	else if(s=="THU")cout << 3 << endl;
	else if(s=="FRI")cout << 2 << endl;
	else if(s=="SAT")cout << 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    ll N, M;
    cin >> N >> M;
    ll ans = 0;
    ll tmp = (ll)sqrt(M);
    REP(i,1,  tmp+1) {
//        cout << "hell" << endl;
        if (M % i == 0 && M / i >= N) {
            chmax(ans, (ll)i);
            if (i >= N) {
                chmax(ans, (ll)M/i);
            }
        }
    }

    if (N == 1) {
        ans = M;
    }

    cout << ans << endl;



}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {

	int a, b, c;

	cin >> a >> b >> c;

	if (a <= b&&b <= c) {

		cout << a << " " << b << " " << c<<endl;

	}
	else if (a >= b&&a <= c) {

		cout << b << " " << a << " " << c<<endl;

	}
	else if (a<=c&&b>=c) {

		cout << a << " " << c << " " << b<<endl;
		
	}
	else if (a >= b&&b>=c) {

		cout << c << " " << b << " " << a << endl;
 
	}
	else if (a <= b&&a>=c) {

		cout << c << " " << a << " " << b << endl;

	}
	else if (a >= c&&b<=c) {

		cout << b << " " << c << " " << a << endl;

	}

	return 0;

}




Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define rer(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<ll> vi;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest) { 
	cout << arg << " "; Debug(rest...); }
template<class T>ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<< ", ";out<<v.back();}out << "]";return out;}
template<class S, class T>ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";return out;}
const int MAX_N = 200010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

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

int N, M;
int A[MAX_N];

void solve() {
	cin >> N >> M;
	rep(i, 0, N) cin >> A[i];
	if(N == 1) {
		if(A[0] == M) {
			cout << "POSSIBLE\n";
		}
		else cout << "IMPOSSIBLE\n";
		return;
	}

	int res = gcd(A[0], A[1]);
	int m = max(A[0], A[1]);

	rep(i, 2, N) {
		res = gcd(A[i], res);
		MAX(m, A[i]);
	}

	if(m >= M) {
		if((M - m) % res == 0) cout << "POSSIBLE\n";
		else cout << "IMPOSSIBLE\n";
	}
	else cout << "IMPOSSIBLE\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(5);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}





Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>

#define INF 1 << 30
#define MOD 1000000007
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second
#define setp(x) setprecision(x)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

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

int main() { 
        string s;
        cin >> s;
        bool flag = true;
        for (int i = s.size() - 1; i >= 0; i--) {
                if (s.substr(i - 4, 5) == "erase" || s.substr(i - 4, 5) == "dream") {
                        i -= 4;
                } else if (s.substr(i - 5, 6) == "eraser") {
                        i -= 5;
                } else if (s.substr(i - 6, 7) == "dreamer") {
                        i -= 6;
                } else {
                        flag = false;
                }
        }
        puts(flag ? "YES" : "NO");
        return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
  int a, b, k;
  cin >> k >> a >> b;
  int flg = 0;
  
  for(int i = a; i <= b; i++){
    if(i % k == 0)
      flg++;
    
  }
  
  if(flg > 0)
    printf("OK");
  
  else
    printf("NG");
  
}

int main()
{
  std::cout << std::fixed << std::setprecision(15);
  Main();
}

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

int main() {
  int n; cin >> n; string s; cin >> s;
  char last = '0'; int an = 0;
  for(int i=0; i<n; i++) {
    if (last != s[i]) {
      last = s[i];
      an ++;
    }
  }
  cout << an << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int N;
  while(cin >>N && N){
    string s;
    REP(i, N){
      string _s; cin >>_s;
      s += _s;
    }
    int ans = 0, r = 0, l = 0;
    for(int i = 0; i <= (int)s.length() - 4; i += 2){
      string s4 = s.substr(i, 4), s2 = s.substr(i, 2);
      if(l == 0 && r == 0 && (s4 == "luru" || s4 == "rulu")) ++ans;
      if(l == 1 && r == 1 && (s4 == "ldrd" || s4 == "rdld")) ++ans;
      if(s2 == "lu") l = 1; if(s2 == "ru") r = 1; if(s2 == "ld") l = 0; if(s2 == "rd") r = 0;
    }
    cout <<ans <<endl;
  }
  return 0;
}

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

typedef long long ll;

void printArray(vector<int> arr) {
	for (int a: arr) cout << a << " ";
	cout << '\n';
}

int main() {
	std::ios_base::sync_with_stdio(false);
	char input;
	cin >> input;
	cout << (input - 65 >= 32 ? "a" : "A") << '\n';
}



Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

int toInt(string s) {
	int res = 0;
	for (char c : s) {
		res = res * 10 + (c - '0');
	}
	return res;
}

int main(){
#ifdef LOCAL
	freopen("A_input.txt", "r", stdin);
	//freopen("A_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;
	vector <pair <ll, ll> > a;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		if (s.find('.') >= s.size()) {
			ll x = toInt(s);
			x = __gcd(x, (ll) 1e9);
			a.pb({x, 1});
		} else {
			int pos = s.find('.');
			string b = s.substr(pos + 1, s.size());
			while (b.size() < 9) {
				b.pb('0');
			}
			string aa = s.substr(0, pos);
			ll x = toInt(b);
			ll y = toInt(aa);
			ll kek = (ll)1e9 / __gcd(x, (ll)1e9);
			ll top = x / __gcd(x, (ll) 1e9);
			y = y * kek + top;
			ll det = __gcd(y, (ll) 1e9);

			a.pb({det, kek});
		}
	}
	map <pair <int, int>, int> cnt;
	for (auto t : a) {
		cnt[t]++;
		//cout << t.x << " " << t.y << endl;
	}
	ll res = 0;
	for (auto x : cnt) {
		auto numx = x.x;
		auto cntx = x.y;
		for (auto y : cnt) {
			auto numy = y.x;
			auto cnty = y.y;
			if (x < y) continue;
			if (x == y) {
				if (numx.y == 1) {
					res += cntx * (ll) (cntx - 1) / 2;
				}
				continue;
			}
			if (numx.x % numy.y == 0 && numy.x % numx.y == 0) {
				res += cntx * (ll) cnty;
			}
		}
	}
	cout << res << "\n";
}


Measured memory_bytes: 7404
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
int main(){
  int N;
  cin >> N;

  if(N & 1) cout << 0 << "\n";
  else cout << 1 << "\n";
  return 0;
}

Measured memory_bytes: 3628
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007
const int N = 501031;

int n,val;
vector<int> order;
int used[N];

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>val;
		order.push_back(val);
	}

	sort(order.begin(),order.end());
	reverse(order.begin(),order.end());

	vector<int> sides;

	for (int i=0;i+1<order.size();i++)
	{
		if (used[i]==0&&order[i]==order[i+1])
		{
			used[i]=used[i+1]=1;
			sides.push_back(order[i]);
		}
	}

	long long ans=0;
	if (sides.size()>=2)
		ans=1ll*sides[0]*sides[1];
	cout<<ans<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 1528
s = input()
n = len(s)
A = []

i = 0
while i < n-1:
    if s[i:i+2] == "BC":
        A.append("D")
        i += 2
    else:
        A.append(s[i])
        i += 1

t = "".join(A)
# print(t)

m = len(t)
i = 0
p = 0
ans = 0
while i < m:
    while i < m and (t[i] == "A" or t[i] == "D"):
        if t[i] == "A":
            p += 1
        else:
            ans += p
        i += 1
    p = 0
    i += 1

print(ans)

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

#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int main(){
  int n;cin >> n;
  vector<ll> vec(n);
  rep(i,n) cin >> vec[i];
  sort(rall(vec));
  pair<ll,ll> com = {vec[0],vec[1]};
  ll tmp = 10000000000;
  ll mid = vec[0]/2;
  rep(i,n){
    if(i == 0) continue;
    if(abs(vec[i]-mid) < tmp){
      tmp = abs(vec[i]-mid);
      com.second = vec[i];
    }
  }
  cout << com.first << " " << com.second << "\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A;
  float C;
  cin >> A;
  vector<string>W(A);
  vector<float>H(A);
  for(int i=0;i<A;i++)cin >> H[i] >> W[i];
  for(int i=0;i<A;i++){
    if(W[i]=="BTC")C+=H[i]*380000;
    else C+=H[i]*1.0;
  }
  cout << C << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if( (abs(a-b) <= d and abs(b-c) <= d) or abs(a-c) <= d)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

my $s;
{
  my $in = <STDIN>;
  chomp $in;
  $s = $in;
}
my $ans = "No";
$ans = "Yes" if $s eq "hi" || $s eq "hihi" || $s eq "hihihi" || $s eq "hihihihi" || $s eq "hihihihihi";
say $ans;

Measured memory_bytes: 768
using System;

namespace abc127_a
{
    class Program
    {
        static void Main(string[] args)
        {
            //年齢、金額の入力（空白区切り）
            string[] input = Console.ReadLine().Split(' ');
            int age = Convert.ToInt32(input[0]);
            int price = Convert.ToInt32(input[1]);
            //価格の判定
            int cost = price;
            if(12>=age && age >= 6)
            {
                cost = cost / 2;
            }
            else if(age<=5)
            {
                cost = 0;
            }
            //出力
            Console.WriteLine(cost);
        }
    }
}


Measured memory_bytes: 13268
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ii> vii;
typedef map<int,int> mii;
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 7;


int main(){
	int n; cin>>n;
	vii v(n);
	for(int i = 0; i < n; i++){
		int t; cin>>t;
		v[i]={t,i+1};
	}
	sort(all(v));
	for(int i = 0; i < n; i++){
		cout<<v[i].S<<" ";
	}
}

Measured memory_bytes: 1536
def solve(ls, k):
	dp = [False for i in range(k + 1)]
	for i in range(k + 1):
		for stone in ls:
			if stone <= i and not dp[i - stone]:
				dp[i] = True
	return dp[k]


n, k = map(int, input().split())
ls = list(map(int, input().split()))
if solve(ls, k):
	print('First')
else:
	print('Second')


Measured memory_bytes: 3928
#include <stdio.h>

long long int x[200010];
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++) scanf("%lld",&x[i]);
	for(int i=1;i<=a;i++) x[i]*=2;
	
	long long int min = 1, max = 2000000000;
	long long int ans = 2000000000;
	while(min<=max)
	{
		long long int h = (min+max)/2;
		long long int C = 0;
		for(int i=1;i<=a;i++)
		{
			long long int c = ((x[i]-1)/h)+1;
			C += (c-1);
		}
		if(C>b) min = h+1;
		else
		{
			ans = h;
			max = h-1;
		}
	}
	printf("%lld",(ans+1)/2);
}

Measured memory_bytes: 3244
int n,m,l[31];s(a){if(a<2)return 1;else if(a<3)return 2;if(l[a]<1)l[a]=s(a-1)+s(a-2)+s(a-3);return l[a];}main(){while(scanf("%d",&n)){if(n<1)break;m=s(n);if(m%10)m+=9;m/=10;if(m%365)m+=365;printf("%d\n",m/365);}}

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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<string> vec(h);
  rep(i,h) cin >> vec[i];
  vector<bool> J(h,1);
  rep(i,h) {
    bool X=1;
    rep(j,w) {
      if(vec[i][j]=='#') X=0;
    }
    if(X) {vec[i] = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
    J[i] = 0;}
  }
  
  rep(i,w) {
    bool Y =1;
    rep(j,h) {
      if(vec[j][i]=='#') Y=0;
    }
    if(Y) rep(j,h)vec[j][i] = '0';
  }
    
  rep(i,h){
    rep(j,w) {
      if(vec[i][j]=='0') {
        continue;
      }
      cout<<vec[i][j];
    }
    if(J[i])cout<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m;
vector<int> v;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;
  ll sum = 0;
  REP(i, n) {
    int a;
    cin >> a;
    sum += a;
    while(0 < a) {
      int a2 = a / 2;
      v.push_back(a - a2);
      a = a2;
    }
  }

  sort(v.begin(), v.end(), greater<int>());

  REP(i, min(m, (int)v.size())) {
    sum -= v[i];
  }

  cout << sum << endl;
}


Measured memory_bytes: 18280
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int d[100010];

int main(void){
	int i;

	cin.tie(0);
	ios_base::sync_with_stdio(false);

	string s;
	int T;
	cin >> s >> T;

	int n=s.size();
	for(i=0;i<n;i++){
		if(s[i]!='a') d[i]=26-(s[i]-'a');
		else d[i]=0;
	}

	for(i=0;i<n;i++){
		if(T==0) break;
		if(d[i]!=0){
			if(T-d[i]>=0){
				s[i]='a';
				T-=d[i];
			}else{
				continue;
			}
		}
	}

	if(T!=0){
		T=T%26;
	}

	s[n-1]=(char)((s[n-1]-'a'+T)%26+'a');

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 976
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class CBuildStairs {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,h,m,M;
        in>>n>>M;
        m=M-1;
        fr(i,n-1){
            in>>h;
            if(m>h){
                out<<"No"<<endl;
                return;
            }
            if(m==h) m=M=h;
            else M=h,m=h-1;
        }
        out<<"Yes"<<endl;

    }
};

int main() {
    CBuildStairs solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

#define deb(x) cout << #x << " " << x << "\n";
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define endl "\n"
#define ll long long
#define vi vector<int>



int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);


	ll a[200001], b[200001], t;
	int n, m, i, j, ans;
	a[0] = 0;
	b[0] = 0;
	cin >> n >> m >> t;
	fo(i, n) {
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	fo(i, m) {
		cin >> b[i + 1];
		b[i + 1] += b[i];
	}

	j = m;
	ans = 0;

	fo(i, n + 1) {
		if (a[i] > t) break;
		while (b[j] > t - a[i])
			j--;
		ans = max(ans, i + j);
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 6780
def main():
    N, M = map(int, input().split())
    G = [[] for _ in range(N)]
    D = [-1 for _ in range(N)]
    E = [0 for _ in range(N)]
    for _ in range(M):
        l, r, d = map(int, input().split())
        G[l - 1].append((r - 1, d))
        E[r - 1] = 1
    for i in range(N):
        if E[i] == 1:
            continue
        s = [i]
        while len(s) > 0:
            ll = s.pop()
            for rr, dd in G[ll]:
                if D[rr] == -1:
                    D[rr] = D[ll] + dd
                    s.append(rr)
    for l in range(N):
        for r, d in G[l]:
            if D[l] + d != D[r]:
                print('No')
                return
    print('Yes')


main()


Measured memory_bytes: 41340
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")

l=["dream","dreamer","erase","eraser"]

def solv(s):
  while len(s)>0:
    x=s
    for y in l:
      i=-1*len(y)
      if y==s[i:]: s=s[:i]
    p(x,s)
    if x==s:
      print("NO")
      exit()
  print("YES")

Q=1
for i in range(Q):
  s=input()
  p(i,s,s[-5:],s[:-5])
  solv(s)


Measured memory_bytes: 4036
using System;
class Program
{
	static void Main(string[] args)
	{
		string input = Console.ReadLine();
      int ans = 0;
switch(input){
  case "SUN" :
  ans++;
    goto case "MON";
  case "MON" :
  ans++;
    goto case "TUE";
  case "TUE" :
  ans++;
    goto case "WED";
  case "WED" :
  ans++;
    goto case "THU";
  case "THU" :
  ans++;
    goto case "FRI";
  case "FRI" :
  ans++;
    goto case "SAT";
  case "SAT" :
  ans++;
    break;
 }
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13152
//	0582: Triangle Types
//	2018.3.21

#include <stdio.h>
int
main (void)
{
  int a, b, c, temp;
  int tyokkaku, eikaku, donkaku;
  tyokkaku = eikaku = donkaku = 0;

  while (1)
    {
      scanf ("%d %d %d\n", &a, &b, &c);

      if (a >= b)
	{
	  temp = a;
	  a = b;
	  b = temp;
	}
      if (b >= c)
	{
	  temp = b;
	  b = c;
	  c = temp;
	}
      if (a >= b)
	{
	  temp = a;
	  a = b;
	  b = temp;
	}

      if (c >= a + b)
	{
	  break;
	}

      if (c * c == a * a + b * b)
	{
	  tyokkaku++;
	}
      else if (c * c < a * a + b * b)
	{
	  eikaku++;
	}
      else
	{
	  donkaku++;
	}
    }
  
  printf ("%d %d %d %d\n", tyokkaku + eikaku + donkaku, tyokkaku, eikaku,
	  donkaku);
  return 0;
}



Measured memory_bytes: 2040
/**
  *  Author: dhruv_gheewala
  *  Problem: E - Rem of Sum is Num
  *  Date:   11.09.2020
  *  Time:   13:05:29
**/

#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;
    
    #define fundri 108
    #define debug(...) 1729
#endif

#define int int64_t
typedef pair<int, int> pii;
typedef vector<int> vi;

const bool testcases = false;
#define ff first
#define ss second
#define endl '\n'
#define all(s) s.begin(), s.end()

// if vector isn't soted then it will remove consecutive same elements
#define make_unique(vec) vec.erase(unique(all(vec)), vec.end())
#define test int TC = 1;if(testcases)cin >> TC;for(int tc = 1 ; tc <= TC ; tc++)solve(), fundri
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})
// clears stdin
#define flush(ch) cin.ignore(std::numeric_limits<std::streamsize>::max(), ch) // default, EOF

int seed; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = INT_MAX) {return uniform_int_distribution<int>(l, r)(rng);}

inline bool in_range(int a, int l, int r) {return (a >= l && a <= r);}
template<typename H, typename ...T>void inp(H &head) {cin >> head;}
template<typename H, typename ...T>void inp(H &head, T &...tail) {cin >> head;inp(tail...);}
template<typename T>bool isPrime(T n) {for(T i = 2; i * i <= n; i++)if(n % i == 0)return false; return n >= 2;}
template<typename T>inline istream &operator >>(istream &in, vector<T> &a) {for(T &x : a)in >> x; return in;}
template<typename T, typename U>inline istream &operator >>(istream &in, pair<T, U> &a) {in >> a.ff >> a.ss; return in;}

void solve();
void fast_io();

int32_t main(int32_t argc, char **argv)
{
    fast_io();
    test;
    return 0;
}

void solve()
{
    int n, k;
    cin >> n >> k;
    vi a(n);
    cin >> a;

    vi pref(n + 1, 0);
    for(int i = 1 ; i <= n ; i++)
    	pref[i] = pref[i - 1] + a[i - 1];

    int sum, ans = 0;
    map<int, int> mp;
    mp[0]++;

    int K = min(n, k - 1);
    for(int i = 0 ; i < K ; i++) {
    	// Adding
    	sum = (pref[i + 1] - (i + 1)) % k;
    	if(mp.count(sum)) {
    		debug(mp, mp[sum], sum, i);
    		ans += mp[sum];
    		mp[sum]++;
    		continue;
    	}
    	mp[sum] = 1;
    }

    for(int i = K ; i < n ; i++) {
    	// Removing
    	sum = (pref[i - K] - (i - K)) % k;
    	mp[sum]--;
    	if(mp[sum] == 0)
    		mp.erase(sum);

    	// Adding
    	sum = (pref[i + 1] - (i + 1)) % k;
    	if(mp.count(sum)) {
    		debug(mp, mp[sum], sum, i);
    		ans += mp[sum];
    		mp[sum]++;
    		continue;
    	}
    	mp[sum] = 1;
    }
    cout << ans << endl;
}

void fast_io()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef DHRUV_GHEEWALA
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif
}

Measured memory_bytes: 18820
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int l = scn.nextInt();
		int[] a = new int[n+1];
      	a[0] = 0;
		for(int i=1; i<=n; i++){
			a[i] = l + i -1;
		}
      	int sum = 0;
      	for(int i=1; i<=n; i++){
          sum += a[i];
        }
      	int low = Math.abs(a[1]);
      	int num = 0;
      	int eat = 0;
      	for(int i=1; i<=n; i++){
          num = Math.abs(a[i]);
          if(low>=num){
            low = num;
            eat = a[i];
          }
        }
      	System.out.println(sum-eat);
	}
}


Measured memory_bytes: 35724
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
}


Measured memory_bytes: 256
s = input()
a = [0]
l = len(s)
for i in s:
    i = int(i)
    a.append((a[-1] + i * pow(10, l, 2019)) % 2019)
    l -= 1

b = [0] * 2019
for i in a:
    b[i] += 1
ans = 0
for i in b:
    ans += i * (i - 1) // 2
print(ans)


Measured memory_bytes: 76080
x, k,d = map(int, input().split())
x = abs(x)
ans = 0
if x//d>k:
    ans = abs(x-d*k)
else:
    tmp = x//d
    k -= tmp
    x -= tmp*d
    if k%2 == 1:
        ans = abs(x-d)
    else:
        ans = abs(x)
print(ans)

Measured memory_bytes: 9204
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;
template <typename T>
vector<T> vec1d_init(int len){
    vector<T> vec(vector<T>(len, 0));
    return vec;
}
vector<string> vec1d_init(int len){
    vector<string> vec(vector<string>(len, ""));
    return vec;
}
template <typename T>
vector<T> vec1d_sort(vector<T> vec, bool min_to_max=true){
    sort(vec.begin(), vec.end(), [min_to_max](const T a, const T b){return (min_to_max == true) ? (a < b) : (b < a);});
    return vec;
}
template <typename T>
void vec1d_show(vector<T> vec){
    for(int i = 0; i < vec.size(); i++){
        cout << vec[i] << " ";
    }
    cout << endl;
}
int main(){
    string s;
    cin >> s;
    auto vec = vec1d_init<int>(26);
    for(int i = 0; i < s.length(); i++){
        int tmp = s[i] - 'a';
        vec[tmp]++;
    }
    for(int i = 0; i < 26; i++){
        if(vec[i] == 0){
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

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

int main(){
  int N,x;
  cin >> N >> x;
  vector<int> a (N);
  for (int i = 0;i < N;i++)
    cin >> a.at(i);
  sort(a.begin(),a.end());
  int sum = 0,i = 0;
  while (i < N){
    sum += a.at(i);
    if(sum <= x){
      if (N - 1 == i && sum - x!= 0);
      else i++;
    }
    else break;
  }
  cout << i << endl;
}

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

int main(){
  int T,D,L;
  while(cin>>T>>D>>L,T){
    int sum=0;
    int pre=0;
    int wle=0;
    for(int i=0;i<T;i++){
      int a;
      cin>>a;
      //if(wle)sum++;
      if(wle)sum++;
      if( L<=a ){
        pre = i;
        wle=1;
      }
      //if(wle)sum++;
      if(i-pre>=D) wle=0;
    }
    cout<<sum<<endl;
  }
}



Measured memory_bytes: 3080
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
bool is_integer(double x)
{
  return floor(x) == ceil(x);
}
int main()
{
  int sum = 0;
  char c;

  while (true)
  {
    cin.get(c);
    if (c == '\n')
    {
      break;
    }
    sum += atoi(&c);
  }

  // for (;;)
  // {
  //   sum += n % 10;
  //   n = n / 10;
  //   if (n == 0)
  //     break;
  // }
  if (sum % 9 == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main()
{
    i64 a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    if(k>a){
        ans+=a;
        k-=a;
        k-=b;
        if(k>0){
            if(k>c) ans-=c;
            else ans-=k;
        }
    }
    else {
        ans+=k;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

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

int N, Q, M, D;
int S[101];

int main() {
	while(cin>>N>>Q, N|Q) {
		fill(S, S+101, 0);
		rep(i,N) {
			cin >> M;
			rep(j,M) {
				cin >> D;
				S[D]++;
			}
		}

		int m = Q-1;
		int d = 0;
		rep(i,101) {
			if(S[i] > m) {
				d = i;
				m = S[i];
			}
		}
		cout << d << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> nowW;
	int sum = 0;

	int answer = 0;



	string s;
	cin >> s;
	for (int i = 0; i < n; i++) {
		int a = (s.substr(i, 1) == "W") ? 1 : 0;
		sum += a;
		if (i == 0) {
			nowW.push_back(a);
			continue;
		}

		nowW.push_back(a);
	}

	int dMove = 0;
	for (int i = n - 1; i >= n - sum; i--) {
		if (nowW[i]) {
			dMove++;
		}
	}

	cout << sum - dMove << endl;

}

Measured memory_bytes: 4456