akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

#define MOD 1000000007;

int main() {
  char s[100005];
  gets(s);
  int len = strlen(s), a;
  int dp[len+2][13];
  dp[0][0] = 1;
  for (size_t i = 1; i < 13; i++) {
    dp[0][i] = 0;
  }
  for (size_t i = 0; i < len; i++) {
    for (size_t j = 0; j < 13; j++) {
      dp[i+1][j] = 0;
    }
    a = (s[i] == '?') ? -1 : s[i] - '0';
    for (size_t j = 0; j < 13; j++) {
      if (a == -1) {
        for (size_t k = 0; k < 10; k++) {
          dp[i+1][(j*10+k)%13] += dp[i][j];
          dp[i+1][(j*10+k)%13] %= MOD;
        }
      }else {
        dp[i+1][(j*10+a)%13] += dp[i][j];
        dp[i+1][(j*10+a)%13] %= MOD;
      }
    }
  }
  printf("%d\n", dp[len][5]);
  return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

main(){
    int n,m;
    cin>>n>>m;
    int x;cin>>x;
    int c[n], a[n][m];
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++) cin>>a[i][j];
    }
    int skill[m];
    int globalmin = INT_MAX;
    int localmin,flag;
    for(int i=0;i<(1<<n);i++){
        localmin = 0;
        flag=1;
        memset(skill,0,sizeof(skill));
        for(int j=0;j<n;j++){
            if(i & (1<<j)){
                localmin+= c[j];
                for(int k=0;k<m;k++) skill[k]+= a[j][k];
            }
        }
        for(int k =0;k<m;k++){
            if(skill[k]< x){
                flag=0;
                break;
            }
        }
        if(flag){
          if(localmin<globalmin) globalmin = localmin;
        }
    }
    if(globalmin == INT_MAX) cout<<"-1";
    else cout<<globalmin;
}

Measured memory_bytes: 3564
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N ;
  const int lim = 55555;
  vi prime;
  {
    vector<bool> is_prime(lim+1,true);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2;i*i<=lim;i++){
      if(!is_prime[i]) continue;
      for(int j = 2; i*j <= lim; j++) is_prime[i*j] = false;
    }
    for(int i = 1;i <= lim; i++) if(is_prime[i]) prime.pb(i);
  }
  vi ans;
  for(auto i:prime){
    if(ans.size()==N) break;
    if(i%5==1) ans.pb(i);
  }
  if(ans.size()!=N) exit(1);
  rep(i,N) cout << ans[i] << (i==N-1 ? "\n" : " ");
  return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int H; cin >> H;
    int N; cin >> N;
    vpi data(N);
    F0R(i, N) {
        int A, B; cin >> A >> B; data[i] = {A, B};
    }
    int dp[H+1]; dp[0] = 0; FOR(i, 1, H+1) dp[i] = 1000000000;
 
    FOR(h, 1, H+1) {
        F0R(i, N) {
            dp[h] = min(dp[h], dp[max(h-data[i].f, 0)] + data[i].s);
        }
    }
 
    cout << dp[H] << endl;
 
	
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>


 int main(){
 	char S[5];
 	int D = 0;
 	scanf("%s", &S);
 	for(int i = 0; i < S[i]; i++){
 		if(S[i] == S[0] && S[i] == S[1] && S[i] == S[2]){
 			D++;
			 }
		 }
	if(D == 3){
		puts("No");
	}
	else{
		puts("Yes");
	}
	return 0;
	 }


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

int main() {
    int N, M;
    cin >> N >> M; // N種類,M個 N>= M
    vector<vector<long long>> a(N, vector<long long>(3));
    REP(i, N) { cin >> a[i][0] >> a[i][1] >> a[i][2]; }
    // 2^3の8パターン試す

    long long res = 0;
    for(int bit = 0; bit < (1 << 3); bit++) {
        vector<long long> b;
        for(int i = 0; i < N; i++) {
            long long tmp = 0;
            for(int j = 0; j < 3; j++) {
                if(bit & (1 << j)) {
                    tmp += a[i][j];
                } else {
                    tmp -= a[i][j];
                }
            }
            b.push_back(tmp);
        }
        sort(b.begin(), b.end(), greater<long long>());
        long long sum = 0;
        REP(i, M) { sum += b[i]; }
        res = max(res, sum);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = (ll)1e18;

class Key{
public:
	ll cost, canopen;
};

signed main() {
	ll N, M;
	cin >> N >> M;
	vector<Key> keys;
	for(ll i=0; i<M; i++){
		ll a, b;
		cin >> a >> b;
		Key k;
		k.cost = a;
		k.canopen = 0;
		for(ll j=0; j<b; j++){
			ll t;
			cin >> t;
			k.canopen |= (1<<(t-1));
		}
		keys.push_back(k);
	}

	vector<ll> dp(1 << N, INF);
	dp[0] = 0;
	for(Key k:keys){
		for(ll i=0; i<(1<<N); i++){
			ll j = i|k.canopen;
			dp[j] = min(dp[j], dp[i]+k.cost);
		}
	}

	ll ans = dp[(1<<N)-1];
	if(ans==INF) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}


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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    float pi = 3.14159;
    int r; cin >> r;
    cout << r * 2 * pi << endl;
}


Measured memory_bytes: 3260
#include <iostream>
#include <string>

using namespace std;

int main(){
	string str[3];
	cin >> str[0] >> str[1] >> str[2];
	int end1 = str[0].size();
	int end2 = str[1].size();
	if (str[0][end1-1] == str[1][0]){
		if (str[1][end2-1] == str[2][0]){
			cout << "YES" <<endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	else{
		cout << "NO" << endl;
	}
	
	return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    vector<ll> c(m);
    for(i = 0;i < m;++i){
        cin >> c.at(i);
    }
    vector<vector<ll>> dp(m+1,vector<ll>(n+1, 1e9));
    dp.at(0).at(0) = 0;
    for(i = 1;i <= m;++i){
        rep(j, n+1){
            if(j < c.at(i-1)) dp.at(i).at(j) = dp.at(i-1).at(j);
            else dp.at(i).at(j) = min({dp.at(i-1).at(j), dp.at(i-1).at(j - c.at(i-1)) + 1, dp.at(i).at(j - c.at(i-1)) + 1});
        }
    }
    cout << dp.at(m).at(n) << endl;
    return 0;
}


Measured memory_bytes: 11540
import sys
readline=sys.stdin.readline

N = int(readline())

DIV = 10 ** 9 + 7

# dp[i][j][k] = i - 1桁目で、すでに0が出た(j), すでに9が出た(k)

dp = [[[0] * 2 for j in range(2)] for i in range(N + 1)]

dp[0][0][0] = 1

for i in range(1, N + 1):
  dp[i][0][0] += dp[i - 1][0][0] * 8 # まだ0も9も出ない
  dp[i][0][0] %= DIV
  
  dp[i][1][0] += dp[i - 1][0][0] + dp[i - 1][1][0] * 9
  dp[i][1][0] %= DIV
  
  dp[i][0][1] += dp[i - 1][0][0] + dp[i - 1][0][1] * 9
  dp[i][0][1] %= DIV
  
  dp[i][1][1] += dp[i - 1][1][0] + dp[i - 1][0][1] + dp[i - 1][1][1] * 10
  dp[i][1][1] %= DIV
  
print(dp[-1][1][1])


Measured memory_bytes: 352376
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int n;
	cin>>n;
	if(n==25)cout<<"Christmas"<<endl;
	if(n==24)cout<<"Christmas Eve"<<endl;
	if(n==23)cout<<"Christmas Eve Eve"<<endl;
	if(n==22)cout<<"Christmas Eve Eve Eve"<<endl;
}

Measured memory_bytes: 256
/*
 *    FileName:
 *      Source:
 *        Date:
 *      Author: Mew
 *	  Function:
 */
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iomanip>
#include<fstream>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<iterator>
#include<ctime>
using namespace std;
int main()
{
	int n,a,b;
	int c = 0,cb = 0;
	cin>>n>>a>>b;
	string s;
	cin>>s;
	int l = s.length();
	for(int i=0;i<l;i++){
		if(s[i] == 'a'){
			c ++;
			if(c<=a+b)
				cout<<"Yes"<<endl;
			else{
				cout<<"No"<<endl;
				c--;
			}
		}
		else if(s[i] == 'b'){
			c ++;
			cb ++;
			if(c<=a+b && cb<=b)
				cout<<"Yes"<<endl;
			else{
				cout<<"No"<<endl;
				c--;
				cb--;
			}
		}
		else cout<<"No"<<endl;
	}
	return 0;
}



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

int c(const void *a, const void *b)
{
    return *(double*)a - *(double*)b;
}

int main()
{
    int N;
    scanf("%d", &N);
    double *v = malloc(sizeof(double) * N);
    for(int ni=0; ni<N; ni++){
        scanf("%lf", v+ni);
    }

    qsort(v, N, sizeof(double), c);

    for(int ni=0; ni<N-1; ni++){
        v[ni+1] = (v[ni+1] + v[ni]) / 2;
    }

    printf("%f\n", v[N-1]);

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <unistd.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main(void){
int n,i,j,a,b,c = 0;
char f[106] = {};
scanf("%d",&n);
if (n%2 == 0)
{
    for (i = 1;i < n+1;i++)
    {
        scanf("%s",&f[i]);
    }
    for (a = 1;a < (n/2)+1;a++)
    {
        if (f[a] == f[a+(n/2)])
        {
            c += 1;
        }
       // else if(f[1] == f[a] && a!=1){break;}
    }
    if (c == 0){printf ("No");}
    else if (c == n/2)
      {printf("Yes");}
    else
    {printf("No");}
}
else
{printf("No");}
return 0;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n), c(m), d(m);
  for (int i=0; i<n; i++)
    cin >> a.at(i) >> b.at(i);
  for (int i=0; i<m; i++)
    cin >> c.at(i) >> d.at(i);
  
  for (int i=0; i<n; i++) { // 学生
    int tmp = 0; // ポイント0が最短とする
    for (int j=0; j<m; j++) { // チェックポイント
      if (abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j))
          < abs(a.at(i)-c.at(tmp))+abs(b.at(i)-d.at(tmp)))
          tmp = j;
    }
    cout << tmp+1 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long long n, i, j, k, total, MOD = 1000000007, a, b;
	string s1, s2;
	cin >> n >> s1 >> s2;

	vector<vector<vector<long long>>> dp(n, vector<vector<long long>>(3, vector<long long>(3, 0)));

	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			if ((i == j) && (s1[0] != s2[0])) continue;
			if ((i != j) && (s1[0] == s2[0])) continue;
			dp[0][i][j]++;
		}
	}

	for (k = 1; k < n; k++) {
		for (i = 0; i < 3; i++) {
			for (j = 0; j < 3; j++) {
				if ((i == j) && (s1[k] != s2[k])) continue;
				if ((i != j) && (s1[k] == s2[k])) continue;
				
				for (a = 0; a < 3; a++) {
					for (b = 0; b < 3; b++) {
						if ((s1[k] == s1[k - 1]) && (a != i)) continue;
						if ((s1[k] != s1[k - 1]) && (a == i)) continue;
						if ((s2[k] == s2[k - 1]) && (b != j)) continue;
						if ((s2[k] != s2[k - 1]) && (b == j)) continue;

						dp[k][i][j] = (dp[k][i][j] + dp[k - 1][a][b]) % MOD;
					}
				}
			}
		}
	}


	total = 0;
	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) total = (total + dp[n - 1][i][j]) % MOD;
	}
	cout << total << "\n";
	

	return 0;
}


Measured memory_bytes: 256
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (1<<19);

int n, q, op, x, drz[2][2*N];

int get(int v, int kt) {
  v += N;
  int res = drz[kt][v];
  while (v > 1) {
    v /= 2;
    res = min(res, drz[kt][v]);
  }
  return res;
}

void add(int v, int p, int q, int kt) {
  p += N;
  q += N;
  drz[kt][p] = min(drz[kt][p], v);
  drz[kt][q] = min(drz[kt][q], v);
  while (p/2 != q/2) {
    if (p%2 == 0)
      drz[kt][p+1] = min(drz[kt][p+1], v);
    if (q%2 == 1)
      drz[kt][q-1] = min(drz[kt][q-1], v);
    p /= 2;
    q /= 2;
  }
}

signed main() {
  init_ios();
  cin >> n >> q;
  for (int i = 0; i < 2*N; ++i)
    drz[0][i] = drz[1][i] = n;
  int res = (n-2)*(n-2);
  // cout<<"pocz="<<res<<"\n";
  while (q--) {
    cin >> op >> x;
    if (op == 1) {
      int pos = get(x, 0);
      add(x, 1, pos, 1);
      res -= pos-2;
    }
    else {
      int pos = get(x, 1);
      add(x, 1, pos, 0);
      res -= pos-2;
    }
    // cout<<"teraz "<<res<<"\n";
  }
  cout<<res<<"\n";
}

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

int main(){
	string str;
	cin >> str;
	int len;
	len = str.length();
	string s[len];
	for(int i=0; i<len; ++i){
		s[i]=str.substr(i,1);
	}
	int max = pow(2,len-1);
	long sum[max];
	bool swi[max][len-1];
	for(int i=0; i<max; ++i){
		for(int j=0; j<len-1; ++j){
			if( i% (int)pow(2,j+1) >= (int)pow(2,j)){
				swi[i][j]=true;
			} else {
				swi[i][j]=false;
			}
		}
	}
	string merge[len];
	long sos=0;
	for(int times=0; times<max; ++times){
		merge[0]=s[0];
		for(int i=0; i<len-1; ++i){
			if(swi[times][i]){
				merge[i+1] = merge[i]+s[i+1];
				merge[i]="0";
			} else {
				merge[i+1] = s[i+1];
			}
		}
		sum[times]=0;
		for(int i=0; i<len; ++i){
			sum[times]+=stol(merge[i]);
		}
		sos += sum[times];
	}

	cout << sos << endl;
	return 0;
}

Measured memory_bytes: 512
k = int(input())
l = []
for i in range(1, 10):
    l.append(i)
judge = l
for d in range(1, 10):
    tmp = []
    for i in range(len(judge)):
        val = judge[i]
        for j in range(-1, 2):
            add = val%10 + j
            if add >= 0 and add <= 9:
                tmp.append(val*10 + add)
    for i in range(len(tmp)):
        l.append(tmp[i])
    judge = tmp
print(l[k-1])

Measured memory_bytes: 56500
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
int main() {
    string s;
    int a, b;
    cin >> a >> b >> s;
    bool ok = s[a] == '-';
    for(int i = 0; i < (int)s.length(); i++){
        if(i == a)continue;
        if(s[i] > '9' or s[i] < '0')ok = 0;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 504
#include <stdio.h>

int main(){
    int h, w, n, cnt=0, i, draw=0;

    scanf("%d",&h);
    scanf("%d",&w);
    scanf("%d",&n);

    if(h<w){
        while(draw<n){
            draw += w;
            cnt++;
        }
    }
    else{
        while(draw<n){
            draw += h;
            cnt++;
        }
    }

    printf("%d", cnt);
}

Measured memory_bytes: 128
n = gets.to_i
h = gets.chomp.split
n.times do |i|
    h[i] = h[i].to_i
end

flowers = Array.new(n, 0)
water = 0
i = 0
while i < n
    if flowers[i] == h[i]
        i += 1
        next
    end

    j = 0
    loop do
        break if flowers[i+j] == h[i+j]
        flowers[i+j] += 1
        j += 1
    end

    water += 1
end

puts water

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x[5],y[5];
  cin>>x[1]>>y[1]>>x[2]>>y[2];
  x[3]=x[2]+y[1]-y[2];
  y[3]=y[2]+x[2]-x[1];
  x[4]=x[3]+y[2]-y[3];
  y[4]=y[3]+x[3]-x[2];
  cout<<x[3]<<" "<<y[3]<<" "<<x[4]<<" "<<y[4];
}

Measured memory_bytes: 256
package main
 
import (
  "fmt"
)
 
func main() {
  var a, b, c int
  fmt.Scanf("%d %d %d", &a, &b, &c)

  tens := a
  ans := tens * 10 + b + c
  if tens <= b {
    tens = b
  	ans = tens * 10 + a + c
  }
  if tens <= c {
    tens = c
  	ans = tens * 10 + a + b
  }  

  fmt.Printf("%d\n", ans)
}

Measured memory_bytes: 1832
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"
#define Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything 42

long long power(long long x, long long n){
	long long ans = 1;
	for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
		if(n&1)ans*=x;
	return ans%MOD;
}

signed main(){
	cout<<fixed<<setprecision(7);
	
	int m, n;
	
	cin>>m>>n;
	
	cout<<power(m,n)<<endl;
	
	
	return 0;
}


Measured memory_bytes: 3096
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn get_head_tail(x: usize) -> (usize, usize){
    let mut v = vec![];
    let mut x = x;

    while x > 0{
        v.push(x%10);
        x /= 10;
    }

    return (*v.first().unwrap(), *v.last().unwrap());
}

fn print_v(v: &Vec<Vec<usize>>){
    for row in v{
        println!("{:?}", row);
    }
}

fn main(){
    let n: usize = read_as_vec::<usize>()[0];

    let mut v: Vec<Vec<usize>> = vec![vec![0;10];10];

    for i in 1..n+1{
        let (head, tail) = get_head_tail(i as usize);
        v[tail][head] += 1;
    }

    //print_v(&v);
    let mut ans: usize = 0;

    for head in 0..10{
        for tail in 0..10{
            //println!("(h, t) = ({}, {}): {}", head, tail, v[head][tail] * v[tail][head]);
            ans += v[head][tail] * v[tail][head];
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var s=cin.Read;
            WriteLine(s.Count(x => x == '1'));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11348
from math import gcd
K = int(input())

ans = 0
h = {}
for i in range(1, K+1):
  for j in range(1, K+1):
    x = gcd(i, j)
    h[x] = h.get(x, 0)
    h[x] += 1

keys = list(h.keys())
n = len(keys)
for i in range(n):
  tmp = 0
  key = keys[i]
  for j in range(1, K+1):
    tmp += gcd(key, j)
  ans += tmp * h[key]

print(ans)

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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

int main() {
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    double ar = 360.0 / 12.0 * H + 30.0 / 60.0 * M;
    double br = 360.0 / 60.0 * M;
    double r;
    if(ar > br){
        r = ar - br;
    } else {
        r = br - ar;
    }
    double ans = A * A + B * B - 2 * A * B * cos(M_PI * r / 180);
    printf("%.20f\n",sqrt(ans));
}

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

int main(){
    int N, M; cin >> N >> M;
    vector<int> P, S;
    int ac = 0;
    int wa = 0;
    int AC[N+1]; for(int i = 0; i <= N+1; i++) AC[i] = 0;
    int WA[N+1]; for(int i = 0; i <= N+1; i++) WA[i] = 0;
    for(int i = 0; i < M; i++){
        int p; string s; cin >> p >> s;
        if(AC[p] == 1) continue;
        else if(s == "WA") WA[p]++;
        else if(s == "AC"){
            AC[p] = 1;
            ac++;
        }
    }
    for(int i = 0; i < N+1; i++){
        if(AC[i] == 1) wa += WA[i];
    }
    cout << ac << " " << wa << endl;
}

Measured memory_bytes: 1024
#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;
	vector<pair<int, int>> A(N);
	rep(i, N) {
		int a;
		cin >> A.at(i).first;
		A.at(i).second = i + 1;
	}
	sort(A.begin(), A.end());
	rep(i, N) {
		cout << A.at(i).second << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1536
// if (j - i === k - j) {
        //   continue
        // }
        // if (S[i] !== S[j] && S[j] !== S[k] && S[i] !== S[k]) {
        //   count++
        // }

function main(input) {
  const inputs = input.split('\n')
  const N = Number(inputs[0])
  const S = inputs[1]
  const R = [], G = [], B = []
  S.split('').forEach((e, i) => {
    if (e === 'R') {
      R.push(i)
    } 
    if (e === 'G') {
      G.push(i)
    } 
    if (e === 'B') {
      B.push(i)
    } 
  })
  // console.log(R, G, B)

  // 貪欲
  // {
  //   let count = 0
  //   for(let i = 0; i < N - 2; i++) {
  //     for(let j = i + 1; j < N - 1; j++) {
  //       if (S[i] === S[j]) continue
  //       const ji = j - i
  //       for (let k = j + 1; k < N; k++) {
  //         if (S[j] === S[k]) continue
  //         if (k - j === ji) continue
  //         if (S[i] === S[k]) continue
  //         console.log('rgb:', i, j, k)
  //         count++
  //       }
  //     }
  //   }
  //   console.log('greedy:', count)
  // }

  let count = R.length * B.length * G.length
  // console.log(count)
  let notCount = 0
  for(let i = 0; i < N; i++) {
    for(let j = i + 1; j < N-1; j++) {
      const k = j * 2 - i
      if (k < N) {
        // console.log(i, j, k, S[i], S[j], S[k])
        if (S[i] !== S[j] && S[j] !== S[k] && S[i] !== S[k]) {
          // console.log('not count')
          notCount++
        }
      }
    }
  }

  console.log(count - notCount)

}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N, M;
	cin >> N >> M;
	ll A[N];
	rep(i, 0, N) cin >> A[i];
	map<ll, ll> m;
	m[0]++;
	ll sum = 0;
	rep(i, 0, N) {
		sum += A[i];
		m[sum % M]++;
	}

	ll rsl = 0;
	for(map<ll, ll>:: iterator it = m.begin(); it != m.end(); it++) {
		rsl += (it->second) * (it->second - 1) / 2;
	}

	cout << rsl << endl;

}


Measured memory_bytes: 4992
import sys

A = []
for i in  range(3):
    A.extend( list(map(int,input().split() )) )
N = int(input())
b = []

for i in range(N):
    b.append(int(input()))

c = [0] * 9

for i in b:
    for index , j in enumerate(A):
        if i == j:
            c[index] = 1

# tate

if c[0] == 1 and c[1] == 1 and c[2] == 1:
    print("Yes")
    sys.exit()
elif c[3] == 1 and c[4] == 1 and c[5] == 1:
    print("Yes")
    sys.exit()
elif c[6] == 1 and c[7] == 1 and c[8] == 1:
    print("Yes")
    sys.exit()

# yo

if c[0] == 1 and c[3] == 1 and c[6] == 1:
    print("Yes")
    sys.exit()
elif c[1] == 1 and c[4] == 1 and c[7] == 1:
    print("Yes")
    sys.exit()
elif c[2] == 1 and c[5] == 1 and c[8] == 1:
    print("Yes")
    sys.exit()

if c[0] == 1 and c[4] == 1 and c[8] == 1:
    print("Yes")
    sys.exit()
elif c[2] == 1 and c[4] == 1 and c[6] == 1:
    print("Yes")
    sys.exit()

print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> L(N);

    int sum = 0;
    for(int i=0; i<N; i++){
        cin >> L[i];
        sum += L[i];
    }

    int res = 0;
    for(int i=0; i<N; i++){
        if(sum - L[i] <= L[i]) res = 1;
    }
    if(res == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  int n;
  cin >> n;

  vector<int> b(n-1);
  fillInt(b,n-1);
  
  int before = b[n-2];
  int res = before;

  for(int i = n-3; i >= 0; i--) {
    res += min(before, b[i]);
    before = b[i];
  }

  res += before;

  cout << res << endl;
}


Measured memory_bytes: 256
import sys
from itertools import combinations
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    for i in range(N):
        A[i] -= i + 1
    A.sort()
    ans = 0
    for a in A: ans += abs(a - A[N // 2])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 93996
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  ll n, k;
  cin >> n >> k;
  vll cnt(100001);
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    cnt[a] += b;
  }
  for (int ans = 1; ans <= 100000; ++ans) {
    if (k <= cnt[ans]) {
      cout << ans << endl;
      break;
    }
    k -= cnt[ans];
  }
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

struct Card {
	char suit;
	char value;
};

void trace(Card C[], int N) {
	for (int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout << C[i].suit << C[i].value;
	}
	cout << endl;
}

int selectionSort(Card C[], int N) {
	int minj;
	Card tmp;
	int count = 0;

	for (int i = 0; i < N; i++) {
		minj = i;
		for (int j = i; j < N; j++) {
			if (C[j].value < C[minj].value) {
				minj = j;	
			}
		}
		
		if (minj != i) {
			tmp = C[i];
			C[i] = C[minj];
			C[minj] = tmp;

			count++;
		}
	}

	return count;
}

int bubbleSort(Card C[], int N) {
	int flag = 1;
	int count = 0;
	Card tmp;

	while (flag) {
		flag = 0;

		for (int i = N - 1; i > 0; i--) {
			if (C[i].value < C[i - 1].value) {
				tmp = C[i];
				C[i] = C[i - 1];
				C[i - 1] = tmp;
				
				flag = 1;
				count++;
			}
		}

	}
	
	return count;
}

bool isStable (Card C1[], Card C2[], int N) {
	for (int i = 0; i < N; i++) {
		if (C1[i].suit != C2[i].suit) {
			return false;
		}
	}

	return true;
}

int main() {
	Card C1[36];
	Card C2[36];
	int N;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> C1[i].suit >> C1[i].value;
		C2[i] = C1[i];
	}

	bubbleSort(C1, N);
	selectionSort(C2, N);

	trace(C1, N);
	cout << "Stable" << endl;

	trace(C2, N);
	if (isStable(C1, C2, N)) {
		cout << "Stable" << endl;
	} else {
		cout << "Not stable" << endl;
	}
	
	return 0;
}

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

int main(){
	string s;
	cin >> s;
	int f = 0;
	int b = s.size() - 1;
	
	int ans = 0;
	while( f < b ){
	 	if( s[f] != s[b] ) {
	 		if( s[f] == 'x' || s[b] == 'x' ){
	 			ans ++;
	 			if( s[f] == 'x' ){
	 				f++;
	 			}else{
	 				b--;
	 			}
	 		}else{
	 			cout << -1 << endl;
	 			return 0;
	 		}
	 	}else{
	 		f++;
	 		b--;
 		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 310;
const ll mod = 1e9 + 7;

int x[N * N], y[N * N];
vector<int> c[N * N];

int main()
{
	int n, m, d;
	scanf("%d %d %d", &n, &m, &d);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1, p; j <= m; ++j) {
			scanf("%d", &p);
			x[p] = i, y[p] = j;
		}
	}
	for (int i = 0; i < d; ++i) {
		c[i].push_back(0);
		for (int j = i + d, k = 1; j <= n * m; j += d, ++k) {
			c[i].push_back(c[i][k - 1] + abs(x[j] - x[j - d]) + abs(y[j] - y[j - d]));
		}
	}
	int q;
	scanf("%d", &q);
	while (q--) {
		int l, r, z;
		scanf("%d %d", &l, &r);
		z = l % d;
		l = l / d, r = r / d;
		printf("%d\n", c[z][r] - c[z][l]);
	}
	return 0;
}

Measured memory_bytes: 6272
def count(n, s, i, arr, count_num)
  if arr.size == n
    count_num += 1 if s == arr.inject(:+)
    return count_num
  end

  i.upto(9) do |j|
    arr.push(j)
    count_num = count(n, s, j+1, arr, count_num)
    arr.pop
  end
  return count_num
end

while gets
  n,s = $_.split(' ').map(&:to_i)
  break if n == 0 && s == 0

  puts count(n, s, 0, [], 0)
end

Measured memory_bytes: 6108
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define MOD (int)1e9+(int)7
#define INF 2147483647
typedef long long ll;
typedef unsigned long long ull;

//dark power
//#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない
/*
vector<int> d(100000);
vector<int> b(100000);
class UnionFind{
	public:
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	signed find(signed x){
		if(d[x]==x){
			return x;
		}else{
			return d[x]=find(d[x]);
		}
	}
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	void unite(signed x,signed y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(b[x]<b[y]){
			d[x]=y;
		}else{
			d[y]=x;
			if(b[x]==b[y])b[x]++;
		}
	}
	bool same(signed x,signed y){return (find(x)==find(y));}
};
*/
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n=0;
	cin>>n;
	float sum=0.0;
	vector<float> a(n);
	vector<string> b(n);
	rep(i,n){
		cin>>a[i];
		cin>>b[i];
	}
	rep(i,n){
		if(b[i]=="JPY"){
			sum+=a[i];
		}else{
			sum+=a[i]*380000.0;
		}
	}
	cout<<fixed<<sum<<endl;
	
	
//	int m,n;
//	cin>>n>>m;
//	vector<string> a(n);
//	vector<string> b(m);
//
//	rep(i,n)cin>>a[i];
//	rep(i,m)cin>>b[i];
//
//	rep(i,n-m+1)rep(j,n-m+1){
//		rep(k,m)rep(l,m)if(a[i+k][j+l]!=b[k][l])goto BB;
//		cout<<"Yes"<<endl;
//		return 0;
//BB:
//		continue;
//	}
//	cout<<"No"<<endl;
//
//
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
#define int LL
string arr[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI","SAT"};
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);;
#endif
  int n,k;cin >> n >> k;
  vector<LL> v(n);
  for(int i=0;i<n;i++) cin >> v[i];
  v[0] %= k;
  for(int i=1;i<n;i++){
    v[i] += v[i-1];
    v[i] %= k;
  }
  map<LL,vector<int>> mm;
  mm[0].push_back(0);
  for(int i=0;i<n;i++){
    LL h = v[i] - i - 1;
    if(h<0){
      h += k*(abs(h)/k+1);
    }
    h %= k;
    mm[h].push_back(i+1);
  }
  LL f = 0;
  for(auto it:mm){
    for(int i=0;i<it.second.size();i++){
      f += lower_bound(ALL(it.second),it.second[i]) - upper_bound(ALL(it.second),it.second[i]-k);
    }
  }
  cout << f << endl;
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 23680
#include <stdio.h>

int main(void){
    int N=0, teika=0 , max_num=0, sum=0, ans=0;
    scanf("%d", &N);
    for(int i=0;i<N;i++){
        scanf("%d", &teika);
        
        if( max_num < teika ) max_num = teika;
        
        sum += teika;
    }
    max_num = max_num / 2;
    sum -= max_num;
    printf("%d\n", sum);
    
    return 0;
}


Measured memory_bytes: 128
<?php
  # 前もしくは後ろ3つを確認
  $s = str_split(trim(fgets(STDIN)));
  $pro1 = array_slice($s, 0, 3);
  $pro2 = array_slice($s, 1, 3);
  $pro1 = array_unique($pro1);
  $pro2 = array_unique($pro2);
  
  if(count($pro1) == 1 || count($pro2) == 1){
    echo "Yes" .  PHP_EOL;
  }else{
    echo "No" . PHP_EOL;
  }
?>

Measured memory_bytes: 3828
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int n;
string s;
LL dp[5050][5050];
const int MOD = 1e9 + 7;

int main() {
	cin >> n >> s;
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= 5010; j++) {
			if (j == 0) {
				dp[i][j] = (dp[i - 1][0] + dp[i - 1][1]) % MOD;
			}
			else {
				dp[i][j] = (2 * dp[i - 1][j - 1] + dp[i - 1][j + 1]) % MOD;
			}
		}
	}
	LL ans = dp[n][s.size()];
	for (int i = 0; i < s.size(); i++) {
		ans = (ans* MMOD)%MOD;
	}
	cout << ans << endl;
	//system("pause");
}

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

using namespace std;

const int N=2e5+5,OO=0x3f3f3f3f,M=1e9+7;
int t,n,m,k;
int arr[200];

int tr(int x){
    int ret=0;
    for(int i=0;i<n;++i){
        ret+=(arr[i]-x)*(arr[i]-x);
    }
    return ret;
}

int main() {
    scanf("%d",&n);
    for(int i=0;i<n;++i)
        scanf("%d",arr+i);
    int mn=OO;
    for(int i=-100;i<101;++i){
        mn=min(mn,tr(i));
    }
    cout<<mn;
    return 0;
}


Measured memory_bytes: 256
S=input()
T=input()
for i in range(len(S)-len(T),-1,-1):
    for j in range(len(T)):
        if S[i+j]!=T[j] and S[i+j]!="?":
            break
    else:
        s=""
        for j in range(i):
            if S[j]=="?":
                s+="a"
            else:
                s+=S[j]
        for j in range(len(T)):
            s+=T[j]
        for j in range(i+len(T),len(S)):
            if S[j]=="?":
                s+="a"
            else:
                s+=S[j]
        break
else:
    s="UNRESTORABLE"
print(s)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) begin(x)+(a), begin(x)+(n)
#define ADD(a, b) ((((a)%MOD+MOD)%MOD+((b)%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) ((((a)%MOD+MOD)%MOD-((b)%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) (((((a)%MOD+MOD)%MOD)*(((b)%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }


int N, T;
PII AB[3010];
int dp[3010][3010];


signed main(){
    cin >> N >> T;
    rep(i, 0, N) cin >> AB[i].first >> AB[i].second;

    sort(RNG(AB, 0, N));

    rep(i, 0, N){
        int A, B;
        tie(A, B) = AB[i];
        rep(j, 0, T) chmax(dp[i+1][j], dp[i][j]), chmax(dp[i+1][min(T, j+A)], dp[i][j]+B);
        chmax(dp[i+1][T], dp[i][T]);
    }

    cout << dp[N][T] << endl;

    return 0;
}

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


int n, A[100];

int solve(int i, int m){
    int res;
    if( m == 0 ) return true;
    if( i >= n ) return false;
    res = solve( i + 1, m ) || solve( i + 1, m - A[i] );
    return res;
}

int main(){
    //int n;
    cin >> n;
    //cout << n << endl;
    //int A[n];
    for( int i = 0; i < n; i++ ){
        cin >> A[i];
        //cout << A[i] << " " << endl;
    }
    
    int q;
    cin >> q;
    //cout << q;
    int m;
    for( int j = 0; j < q; j++){
        cin >> m;
        //cout << m << " " << endl;
        if( solve(0, m) ) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    
    return 0;
    
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define LL long long 
#define MAXN 300005
#define INF 0x3f3f3f3f
using namespace std;

int n;

int main()
{
	scanf("%d", &n);
	if(n>=1000) printf("ABD\n");
	else printf("ABC\n");
}
/*
3
)(
()
()
*/
/*
2
)()
()(
*/
 

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

int  BubbleSort(int *,int);

int main(){
  int swcut=0;
  int n,*a,i;
  
  scanf("%d",&n);
  a=(int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  swcut=BubbleSort(a,n);

  for(i=0;i<n;i++){
  printf("%d",a[i]);
  if(i!=n-1) printf(" ");
  }
  printf("\n%d\n",swcut);
  
  return 0;
}

int BubbleSort(int *a,int n){
  int i,j,stock,count=0;

  for(i=0;i<n;i++){
    for(j=n-1;j>0;j--){
      if(a[j]<a[j-1]){
        stock=a[j];
        a[j]=a[j-1];
        a[j-1]=stock;
        count++;
      }
    }
  }

  return count;
}



Measured memory_bytes: 2128
N = int(input())

A,B = [], []
for i in range(N):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

cnt = 0
if(N % 2 == 1):
    l = A[N//2]
    r = B[N//2]
    cnt = r - l + 1
else:
    l = A[N//2-1] + A[N//2]
    r = B[N//2-1] + B[N//2]
    cnt = r - l + 1
print(cnt)


Measured memory_bytes: 25472