akhauriyash/Code-Regression huggingface dataset:
/*In the name of ALLAH, Most Gracious, Most Merciful*/
#include<bits/stdc++.h>

#define ll                      long long int
#define ull                     unsigned long long int
#define PI                      2*acos(0.0)
#define sqr(x)                  (x)*(x)
#define EPS                     10E-10
#define MOD                     1000000007
#define longlimit               92233720368547758
#define infinity                (1<<28)
#define setbits                 __builtin_popcount
#define zerobits                __builtin_ctzll
#define parity(n)               __builtin_parity(n)
#define pb(a)                   emplace_back(a)
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define gcd(a, b)               __gcd(a,b)
#define lcm(a, b)               ((a)*(b))/gcd(a,b)
#define watch(x)                cout << (#x) << " is " << (x) << endl
#define FOR(x,n)                for (ll i=x,j=x,k=x;i<n,j<n,k<n;i++,j++,k++)
#define FORR(n,x)               for (ll i=n-1,j=n-1,k=n-1;i>=x,j>=x,k>=x;i--,j--,k--)
#define TEST_CASES()            ll t;cin>>t;while (t--)
#define PRECISION(a,x)          fixed<<setprecision(x)<<a<<endl;
#define endl                    "\n"
#define all(a)                  (a.begin()),(a.end())
#define UNIQUE(X)               (X).erase(unique(all(X)),(X).end())
#define DELETE(X)               (X).erase (remove (all(X)),(X).end())
#define SORT_UNIQUE(c)          (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define FAST_IO()               ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FILE_IO()               freopen("output.txt", "w", stdout);freopen("input.txt", "r", stdin)
using namespace std;

int F(int x)
{

    int ans = 0;
    for(int i = 1;; i++)
    {
        if(i > x) return ans;
        ans++;
        x -= i;
    }
}
void solve()
{
    ll n;
    cin >> n;
    int ans = 0;
    for(ll i = 2; i * i <= n; i++) 
    {
        if(n % i == 0) 
        {
            int cnt = 0;
            while(n % i == 0) 
            {
                cnt++;
                n /= i;
            }
            ans += F(cnt);
        }
    }

    if(n > 1) ans++;
    cout << ans << endl;
}

int32_t main()
{
    FAST_IO();
    //TEST_CASES()
        solve();
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define inf (1ll << 62)
using namespace std;
const int maxn = 1e5+5;
typedef long long ll;
int N,W,w[maxn],v[maxn];
ll dp[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> W;
    for (int i = 1; i <= N; i++){
        cin >> w[i] >> v[i];
    }

    for (int j = 1; j <maxn;j++)
            dp[j] = (inf);

    for (int i = 1; i <= N;i++){
        for (int j =maxn -1; j >= v[i];j--){
            dp[j] = min(dp[j],(ll)dp[j-v[i]]+w[i]);
        }
    }
    int sol = 0;
    for (int i = 0; i < maxn;i++){
        if (dp[i] <= W && dp[i] != inf){
            sol = i;
        }
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 1024
// AtCoder Regular Contest 074
// D - 3N Numbers

#include <cstdio>
#include <queue>
#define MAX_N 100000
using namespace std;
typedef long long int ll;
typedef pair<ll, int> PLI;


int N;
ll a[3 * MAX_N];
priority_queue<ll, vector<ll>, greater<ll>> ql;
priority_queue<ll> qr;
ll suml[MAX_N + 1], sumr[MAX_N + 1];
ll ans;

int main() {

  scanf("%d", &N);
  for (int i = 0; i < 3 * N; i++) {
    scanf("%lld", &a[i]);
  }

  suml[0] = 0;
  sumr[N] = 0;
  for (int i = 0; i < N; i++) {
    suml[0] += a[i];
    ql.push(a[i]);

    sumr[N] += a[3 * N - i - 1];
    qr.push(a[3 * N - i - 1]);
  }

  for (int i = 1; i <= N; i++) {
    suml[i] = suml[i - 1];
    suml[i] += a[N - 1 + i];
    ql.push(a[N - 1 + i]);
    suml[i] -= ql.top();
    ql.pop();

    sumr[N - i] = sumr[N - i + 1];
    sumr[N - i] += a[2 * N - i];
    qr.push(a[2 * N - i]);
    sumr[N - i] -= qr.top();
    qr.pop();
  }

  ans = suml[0] - sumr[0];
  for (int i = 1; i <= N; i++) {
    ans = max(ans, suml[i] - sumr[i]);
  }

  printf("%lld\n", ans);

  return 0;

}




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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld PI = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n, m; cin >> n >> m;
    vec<string> s(112345, "WA");
    map<int, ll> p;
    ll wa = 0, ac = 0;
    rep(i,m) {
        int x; string ss;
        cin >> x >> ss;
        if(s[x]=="AC") continue;

        if(p.find(x)==p.end()) p.insert(make_pair(x,0));
        if(ss=="WA") {
            p[x]++;
        }
        else {
            s[x] = "AC";
        }
    }
    for(auto pp : p) {
        if(s[pp.first]=="WA") continue;
        ac++;
        wa += pp.second;
    }
    cout << ac <<' '<<wa << endl;
}

Measured memory_bytes: 12032
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e9
typedef long long ll;
typedef pair<ll,ll> P;
unsigned long long popCount64bitB(unsigned long long x) 
{ 
    x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) 
      +  (x & 0x5555555555555555UL); 
    x = ((x & 0xccccccccccccccccUL) >> 2) 
      +  (x & 0x3333333333333333UL); 
    x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) 
      +  (x & 0x0f0f0f0f0f0f0f0fUL); 
    x = ((x & 0xff00ff00ff00ff00UL) >> 8) 
      +  (x & 0x00ff00ff00ff00ffUL); 
    x = ((x & 0xffff0000ffff0000UL) >> 16) 
      +  (x & 0x0000ffff0000ffffUL); 
    x = ((x & 0xffffffff00000000UL) >> 32) 
      +  (x & 0x00000000ffffffffUL); 
    return x; 
} 

int n,m;
bool g[53][53];
bool visited[53];
int a[53],b[53];

void dfs(int v){
    visited[v]=true;
    for(int i=0;i<n;i++){
        if(!g[v][i])continue;
        if(visited[i])continue;
        dfs(i);
    }
}

int main(void){
    cin>>n>>m;
    int ans=0;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        g[a[i]][b[i]]=true;
        g[b[i]][a[i]]=true;
    }
    for(int i=0;i<m;i++){
        g[a[i]][b[i]]=false;
        g[b[i]][a[i]]=false;
        for(int i=0;i<n;i++)visited[i]=false;
        dfs(0);
        bool judge=true;
        for(int i=0;i<n;i++)if(!visited[i])judge=false;
        if(judge)ans++;
        g[a[i]][b[i]]=true;
        g[b[i]][a[i]]=true;
    }
    cout<<m-ans<<endl;
}

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

#define MAX 99999999

int main()
{
  int w,h;
  for(;cin>>w>>h,w;)
    {
      int maps[h][w];
      for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
          maps[i][j]=MAX;
      bool tate[h][w-1];
      bool yoko[h-1][w];
      for(int i=0;i<h;i++)
        {
          for(int j=0;j<w-1;j++)
            {
              cin>>tate[i][j];
            }
          if(i!=h-1)
            {
              for(int j=0;j<w;j++)
                {
                  cin>>yoko[i][j];
                }
            }
        }
      maps[0][0]=1;
      queue<pair<int,int> > qu;
      int ans=0;
      qu.push(make_pair(0,0));
      const int dx[]={0,0,-1,1};
      const int dy[]={-1,1,0,0};

      while(!qu.empty())
        {
          int x=qu.front().first;
          int y=qu.front().second;
          qu.pop();
          //cerr<<"[queue]:"<<x<<","<<y<<endl;
          if(x==h-1 && y==w-1)
            {
              ans=maps[x][y];
              break;
            }
          for(int i=0;i<4;i++)
            {
              //cerr<<"i:"<<i<<endl;

              if(x+dx[i]>=0 && y+dy[i]>=0 &&
                 x+dx[i]<h && y+dy[i]<w &&
                 maps[x][y]+1<maps[x+dx[i]][y+dy[i]])
                {
                  //cerr<<tate[x][y-1]<<" "<<tate[x][y]<<" "<<yoko[x-1][y]<<" "<<yoko[x][y]<<endl;

                  if(i==0 && tate[x][y-1]==0)
                    {
                      qu.push(make_pair(x+dx[i], y+dy[i]));
                      maps[x+dx[i]][y+dy[i]] = maps[x][y]+1;
                    }
                  if(i==1 && tate[x][y]==0)
                    {
                      //cerr<<"[1]"<<endl;

                      qu.push(make_pair(x+dx[i], y+dy[i]));
                      maps[x+dx[i]][y+dy[i]]= maps[x][y]+1;
                    }
                  if(i==2 && yoko[x-1][y]==0)
                    {
                      qu.push(make_pair(x+dx[i], y+dy[i]));
                      maps[x+dx[i]][y+dy[i]]= maps[x][y]+1;
                    }
                  if(i==3 && yoko[x][y]==0)
                    {
                      qu.push(make_pair(x+dx[i], y+dy[i]));
                      maps[x+dx[i]][y+dy[i]]= maps[x][y]+1;
                    }
                }

            }

        }
      cout<<ans<<endl;

    }


}

Measured memory_bytes: 1220
#include <stdio.h>
int main(){
  int n,i;
  scanf("%d",&n);
  float a[n],gyaku=0;
  for(i=0;i<n;i++){
    scanf("%f",&a[i]);
    gyaku=gyaku+1/a[i];
  }
  printf("%f",1/gyaku);
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 x,y;
  cin >> x >> y;
  REP(i,x+1){
    if(2*i+4*(x-i)==y){
      Yes(true);
      return 0;
    }
  }
  Yes(false);
  return 0;
}

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

#define rep(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace(x) cout << #x << ": " << x << endl
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define INF 1LL<<62

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;

const ll MAX =1e7 +10;
vi arr;

int main(){
  ll n, x, y;
  cin >> n >> x >> y;
  for(int i = n-1; i>0;i--) arr.pb(i);
  
  ll d;
  for(int i = 1; i < y; i++){
    if(y - i <= i - x + 1) break;
    d = (x>i)?(x-i):(i-x);
    rep(i,0,n-y+1)
      arr[d+i]++;
    d = y-i-1;
    rep(i,0,n-y+1)
      arr[d+i]--;
  }
  for(int i = y-1; i > x; i--){
    if(i - x <= y - i + 1) break;
    
    d = y-i;
    rep(i,0,x)
      arr[d+i]++;
    d = i-x-1;
    rep(i,0,x)
      arr[d+i]--;
  }
  ll dx, dy;
  for(int i = x+1; i < y ; i++){
    dx = i - x;
    for(int j = y-1; j > i ;j--){
      dy = y - j;
      if( j - i <= dx+1+dy) break;
      d = dx+dy;
      arr[d]++;
      d = j-i-1;
      arr[d]--;
    }
  }
  rep(i,0,arr.size()){
    cout << arr[i] << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int n,k;
int dp[105][5][5]={};
//dp[a][b][c] .. a日目に、今日はb、昨日はcのパスタを食べた場合の通り数
int dat[105]={};
 
int main(void){
	scanf("%d%d",&n,&k);
	int d,i,j,p;
	for(i=1;i<=k;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		dat[a] = b;
	}
 
	for(i=1;i<=3;i++){
		for(j=1;j<=3;j++){
			if(dat[1]!=0 && dat[1]!=j){
				continue;
			}
			if(dat[2]!=0 && dat[2]!=i){
				continue;
			}
			dp[2][i][j]=1;
		}
	}
	//カレンダーに合わない食べ方なら、0
	//そうでなければ、1
	for(d=3;d<=n;d++){
		for(i=1;i<=3;i++){
			for(j=1;j<=3;j++){
				//dp[d][i][j]について
				if(dat[d-1]!=0 && dat[d-1]!=j){
					dp[d][i][j]=0;
				}
				else if(dat[d]!=0 && dat[d]!=i){
					dp[d][i][j]=0;
				}
				//カレンダーに合わないなら、飛ばす(0)
				else{
					for(p=1;p<=3;p++){
						if(i==j && j==p)continue;
						//三日連続で同じのなら、飛ばす（足さない）
						dp[d][i][j] += dp[d-1][j][p];
					}
					dp[d][i][j]%=10000;
				}
				//printf("%d ",dp[d][i][j]);
			}
		}
		//printf("\n");
	}
 
	int ans=0;
	for(i=1;i<=3;i++){
		for(j=1;j<=3;j++){
			//総和
			ans += dp[n][i][j];
		}
	}
	ans %= 10000;
 
	printf("%d\n",ans);
	return 0;
}
 

Measured memory_bytes: 1032
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	bool operator<(const struct Info &arg) const{
		return cost < arg.cost;
	};
	int from,to,cost;
};

int* parent,*height;
int N,M;

int getParent(int id){
	if(parent[id] == id)return id;
	else{
		return parent[id] = getParent(parent[id]);
	}
}

bool isSame(int a, int b){
	return getParent(a) == getParent(b);
}

void unite(int a,int b){
	int a_parent = getParent(a);
	int b_parent = getParent(b);

	if(a_parent == b_parent)return;

	if(height[a_parent] > height[b_parent]){
		parent[b_parent] = a_parent;
	}else{
		if(height[a_parent] == height[b_parent])height[b_parent]++;
		parent[a_parent] = b_parent;
	}
}

void init_array(){
	for(int i = 0; i < N; i++){
		parent[i] = i;
		height[i] = 0;
	}
}


int main(){

	scanf("%d %d",&N,&M);

	parent = new int[N];
	height = new int[N];

	init_array();

	Info* info = (Info*)malloc(sizeof(Info)*M);

	for(int i = 0; i < M; i++){
		scanf("%d %d %d",&info[i].from,&info[i].to,&info[i].cost);
		info[i].from--;
		info[i].to--;
	}

	int minimum = 0;

	sort(info,info+M);

	vector<int> V;

	for(int i = 0; i < M; i++){
		if(!isSame(info[i].from,info[i].to)){
			unite(info[i].from,info[i].to);
			V.push_back(i);
			minimum += info[i].cost;
		}
	}

	int tmp_cost,group_num,check_id,ans = 0,num = 0;

	for(int loop = 0; loop < V.size();loop++){
		check_id = V[loop];

		init_array();

		tmp_cost = 0;

		for(int i = 0; i < M; i++){
			if(isSame(info[i].from,info[i].to) == false && i != check_id){
				unite(info[i].from,info[i].to);
				tmp_cost += info[i].cost;
			}
		}

		if(tmp_cost > minimum){
			ans += info[check_id].cost;
			num++;
			continue;
		}

		group_num = 0;
		for(int i = 0; i < N; i++){
			if(parent[i] == i)group_num++;
		}

		if(group_num > 1){
			ans += info[check_id].cost;
			num++;
			continue;
		}

	}

	printf("%d %d\n",num,ans);

	return 0;
}

Measured memory_bytes: 3392
a =int(input())
resultList=[]
for i in range(a):
  resultList.append(input())
print('AC x '+str(resultList.count('AC')))
print('WA x '+str(resultList.count('WA')))
print('TLE x '+str(resultList.count('TLE')))
print('RE x '+str(resultList.count('RE')))

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<pair<int,int>> AB(N);
  for (int i=0; i<N; i++) {
    cin >> AB[i].first >> AB[i].second;
  }
  sort(AB.begin(),AB.end());
  int now = 0;
  long long ans = 0;
  multiset<int> st;
  int num = 0;
  for (int i=1; i<=M; i++) {
    while (now < N) {
      if (AB[now].first == i) {
        st.insert(AB[now].second);
        num++;
      }
      else {
        break;
      }
      now++;
    }
    if (num != 0) {
      auto itr = st.end();
      --itr;
      ans += *itr;
      st.erase(itr);
      num--;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define REP(i,n) for(int i =0; i <n; ++i)

#define REPR(i,n) for(int i =n; i >=0; --i)

#define REP_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

//const ll MOD = 1000000007;

//const  long double PI=(acos(-1));

//const  long double EPS=0.0000000001;

int main(){
    int n,m;cin >> n >> m;
    vector<int> x(m);
    REP(i,m)cin >> x[i];


    if(n >= m)cout << 0 << endl;
    else{

        sort(x.begin(),x.end());
        priority_queue<int> q;

        REP(i,m-1)q.push((x[i+1]- x[i]));

        REP(i,n-1)q.pop();

        ll res = 0;
        while(!q.empty()){
            res += q.top();
            q.pop();
        }

        cout << res << endl;
    }




    return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

vector<int> nxt[26];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    S += S;
    rep(i, 26) {
        rep(j, S.length()) {
            if(S[j] == 'a' + i) nxt[i].push_back(j);
        }
    }
    ll ans = 0;
    int x = -1;
    rep(i, T.length()) {
        int prev = x;
        int k = T[i] - 'a';
        auto itr = lower_bound(nxt[k].begin(), nxt[k].end(), x + 1);
        if(itr == nxt[k].end()) {
            cout << -1 << endl;
            return 0;
        }
        ans += *itr - prev;
        x = *itr % (S.length() / 2);
        //cout << prev << " "<< x <<" " << ans << endl;
    }
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 1896
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str1,str2;
  int count=0;
  cin>>str1;
  cin>>str2;
  for(int i=0;i<str1.length();i++){
    if(str1[i]!=str2[i])count++;
  }
  printf("%d\n",count);
return 0;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mx5 100005
#define mx6 1000005
#define mod 1000000007
#define nfs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main() {
    nfs
    int i, j, n, fa, fb, fc, a, b, c;
    fa = fb = fc = 0;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> a >> b >> c;
        tie(fa, fb, fc) = make_tuple(a + max(fb, fc), b + max(fa, fc), c + max(fa, fb));
    }
    cout << max({fa, fb, fc});
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  string s;
  int k;
  cin >> s >> k;
  for(int i=0; i<s.size()&&k>0; i++) {
    if(s[i]!='a') {
      int d='z'-s[i]+1;
      if(k>=d) {
        s[i]='a';
        k-=d;
      }
    }
  }
  s[s.size()-1]='a'+(s[s.size()-1]-'a'+k)%26;
  cout << s << endl;
}

Measured memory_bytes: 512
N = gets.to_i
A = gets.split.map(&:to_i) # N+1
B = gets.split.map(&:to_i) # N

Decrease = lambda{|iA, iB|
	A[iA], B[iB] = (A[iA] < B[iB]) ? [0, B[iB]-A[iA]] : [A[iA]-B[iB], 0]
}

A0 = A.inject(&:+)
(0..(N/2)).each{|i|
	Decrease[i  , i]
	Decrease[i+1, i]
	Decrease[N-i  , N-i-1]
	Decrease[N-i-1, N-i-1]
}
A1 = A.inject(&:+)

p A0-A1


Measured memory_bytes: 21288
#!usr/bin/env python
#-*- coding: utf-8 -*-

while True:
    (m, nmin, nmax) = map(int, raw_input().split())
    if m == 0:
        break

    scores = []
    for i in range(m):
        scores.append(int(raw_input()))
    
    submax = 0
    for i in range(nmin, nmax+1):
        subtmp = scores[i-1] - scores[i]
        if subtmp >= submax:
            ans = i
            submax = subtmp

    print ans

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

using namespace std;

int n,m,a[300000],ans;

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n*2;++i) scanf("%d",a+i);
	sort(a+1,a+n*2+1);
	int l=0,r=n;
	while (l<=r){
		int mid=(l+r)>>1;
		bool fl=1; int tmp=0;
		for (int i=1;i<=mid;++i){
			fl&=a[i]+a[mid*2-i+1]<m;
			tmp=max(tmp,a[i]+a[mid*2-i+1]);
		}
		if (!fl){r=mid-1; continue;}
		for (int i=1;i<=n-mid;++i){
			fl&=a[mid*2+i]+a[n*2-i+1]>=m;
			tmp=max(tmp,a[mid*2+i]+a[n*2-i+1]-m);
		}
		if (!fl){l=mid+1; continue;}
		ans=tmp; r=mid-1;
	}
	printf("%d\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

const int N = 1e6 + 5;
const int MOD = 1e9 + 7;

void solve() {
    int n, ans = 0;
    cin >> n;
    for (int i=1;i<=n;++i) {
        int x; cin >> x;
        if (i & 1) {
            if (x & 1) ++ans;
        }
    }
    cout << ans << '\n';
} 

int main() {
    FASTIO;
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    int K;
    cin >> K;

    if(S.length() < K){
        cout << 0 << endl;
        return 0;
    }

    int dp[S.length()+1][S.length()+1][2];
    for(int i=0; i<=S.length(); i++){
        for(int j=0; j<=S.length(); j++){
            dp[i][j][0] = 0;
            dp[i][j][1] = 0;
        }
    }
    dp[0][0][0] = 1;

    for(int i=0; i<S.length(); i++){
        for(int j=0; j<S.length(); j++){
            int d = S[i] - '0'-1;
            if(S[i]=='0'){
                dp[i+1][j][0] += dp[i][j][0];
            }else{
                dp[i+1][j+1][0] += dp[i][j][0];
                dp[i+1][j+1][1] += dp[i][j][0]*d;
                dp[i+1][j][1] += dp[i][j][0];
            }
            dp[i+1][j][1] += dp[i][j][1];
            dp[i+1][j+1][1] += dp[i][j][1]*9;
        }
    }

    cout << dp[S.length()][K][0]+dp[S.length()][K][1] << endl;


    return 0;
}


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

using namespace std;
#define ll long long int

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

  int count = 0;
  int max = 0;

  for (int i = 0 ; i <=2 ; i++)
  {
      if (S[i]=='R')count++;
      if (max<count)max=count;      
      else count = 0;
  }
 
 cout << max;

 return 0;
}





Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main() {
	vector<int> num(3);
	int ans = 0,max=-1,tmp;
	for (int i = 0; i < 3; i++) {
		cin >> num[i];
		if (max < num[i]) {
			max = num[i];
		}
	}
	for (int i = 0; i < 3; i++) {
		num[i] = max-num[i];
	}
	sort(num.begin(),num.end());
	ans += num[1];
	tmp = num[2] - num[1];
	if(tmp%2){
		ans += 2;
	}
	ans += tmp / 2;
	cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  int count=0;
  int curr=1;
  
  rep(i, N) {
    count++;
    curr=a[curr-1];
    if (curr==2) {
      cout << count << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a+b)%24 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=998244353;
const ll inf=1e18+5;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
  ll n,k;
  cin >> n >> k;
  vll a(n);
  rep(i,0,n) cin >> a[i];
  sort(all(a));
  
  ll l=-inf,r=inf;
  while(r-l>1){
    ll x=(l+r)/2;
   bool ok = [&]{
      ll tot = 0;
      rep(i,0,n) {
        if (a[i] < 0) {
          int l = -1, r = n;
          while (l+1<r) {
            int c = (l+r)/2;
            if (a[c]*a[i] < x) r = c; else l = c;
          }
          tot += n-r;
        } else {
          int l = -1, r = n;
          while (l+1<r) {
            int c = (l+r)/2;
            if (a[c]*a[i] < x) l = c; else r = c;
          }
          tot += r;
        }
        if (a[i]*a[i] < x) tot--;
      }
      tot /= 2;
      return tot < k;
    }();
    
    
    
    
    
   if(ok) l=x;
   else r=x; 
    
    
  }
  
 cout << l << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  


Measured memory_bytes: 4776
// AOJ ALDS1_3_D Areas on the Cross-Section Diagram
// 2018.5.9 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

#define MAX  40002
#define BASE 20000

int a[MAX];
int sum[MAX]; int sz;
int left[MAX];

int main()
{
	int i, j, k, x, h, s, ans;
	int c;

	h = BASE, ans = s = 0;
	for (x = 1; ; x++) {
		c = gc();
		if (c <= ' ') break;
		if (c == '\\') {
			if (s > 0) ans += s, sum[sz++] = s, s = 0;
			a[--h] = x;
		} else if (c == '/') {
			if (a[h] > 0) left[sz] = a[h], s += x-a[h];
			else if (s > 0) ans += s, sum[sz++] = s, s = 0;
			h++;
		}
	}
	if (s > 0) ans += s, sum[sz++] = s;

	printf("%d\n", ans);
	k = sz;
	i = sz-1; while (i > 0) {
		j = i-1; while (j >= 0 && left[j] > left[i]) {
			sum[i] += sum[j], sum[j] = 0, j--, k--;
		}
		i = j;
	}

	printf("%d", k);
	for (i = 0; i < sz; i++) if (sum[i] > 0) printf(" %d", sum[i]);
	putchar('\n');
	return 0;
}



Measured memory_bytes: 2104
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC170D
int compare_int(const void *a, const void *b) { //sort
  return *(int*) a-*(int*) b;
}
int main(void) {
  int n, k, i, cou=0, tmp;
  scanf("%d", &n);
  int a[n];
  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
  }
  qsort(a, n, sizeof(int), compare_int); //sort

  if(n==1){
    printf("1");
    return 0;
  }

  if(a[0]==1){
    if(a[1]==1){
      printf("0");
      return 0;
    }else{
      printf("1");
      return 0;
    }
  }

  int map[a[n-1]+1];

  for(i=0; i<a[n-1]; i++)
    map[i]=0;

  for(i=0; i<n; i++){
    if(i==0){
      if(a[i]==a[i+1]) cou--;
    }else if(a[i]==a[i-1]){
      continue;
    }else if(i!=n-1){
      if(a[i]==a[i+1]&&map[a[i]-1]==0) cou--;
    }
    if(map[a[i]-1]==0){
      cou++;
      tmp=a[i];
      while(tmp<=a[n-1]){
        map[tmp-1]=1;
        tmp+=a[i];
      }
    }
    /*
     for(k=0; k<a[n-1]; k++){
     printf("%d ", map[k]);
     }
     printf(" map cou=%d i=%d\n", cou, i);
     */
  }
  printf("%d", cou);
  return 0;
}

Measured memory_bytes: 6424
#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
//#define mp make_pair
#define pb push_back
#define tp make_tuple
#define srt(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr(a) printf("%lld\n",a)
#define r0 return 0
using namespace std;

ll ax[10005];

void fun()
{

    ll f=0;

    for(ll i=1; i<=10000; i++)
    {
        if(i*i>10000)break;

        for(ll j=1; j<=10000; j++)
        {
            if(i*i+j*j+i*j>10000)break;

            for(ll l=1; l<=10000; l++)
            {

                ll d=i*i+j*j+l*l+i*j+i*l+j*l;

                if(d>10000)
                {
                    f=1;
                    break;
                }

                ax[d]++;

            }

        }

    }
}

int main()
{
    ll n,m,i,j,k,t,x,y,d;

    cin>>n;

    fun();

    for(i=1; i<=n; i++)
    {

        cout<<ax[i]<<endl;
    }

}



Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main(){
    string s; cin >> s;
    if(s.find('a')!=string::npos && s.find('b')!=string::npos && s.find('c')!=string::npos){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		int num, max, min;
		long sum = 0;
		Scanner scan = new Scanner(System.in);
		num = scan.nextInt();
		int[] arr = new int[num];

		for(int i=0; i<num; i++) {
			arr[i] = scan.nextInt();
			sum += arr[i];
		}

		Arrays.sort(arr);
		min = arr[0];
		max = arr[num-1];

		System.out.printf("%d %d %d\n", min, max, sum);
	}
}

Measured memory_bytes: 42112
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
	public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();	//?????£?????????????????????????????°
        while( !(str.equals("-")) ) {
			String repStr = br.readLine();	//??°??????????????°
			int rep = Integer.parseInt(repStr);
			for(int i = 0 ; i < rep ; i++ ) {
				String posStr = br.readLine();	//?????£???????????????
				int pos = Integer.parseInt(posStr);
				String left = str.substring(0, pos);
				String right = str.substring(pos);
				str = right + left;
//				System.out.println(str);	//????????????(???????????°)
			}
			System.out.println(str);	//???????????????
			str = br.readLine();
		}
	}
}

Measured memory_bytes: 24348
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll n, m;
vvl G;
vl visited;
ll ans = 0;

void check() {
    ll ok = 1;
    rep(i, n) {
        if(visited[i] == 0) {
            ok = 0;
        }
    }
    if(ok) {
        ans++;
    }
}

void dfs(ll v) {
    check();
    for(auto u : G[v]) { 
        if(visited[u]) {
            continue;
        }
        visited[u] = 1;
        dfs(u);
        visited[u] = 0;
    }
}

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

    G.resize(n);
    visited.resize(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    visited[0] = 1;
    dfs(0);

    out(ans);
    re0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char a[100000],b[100000],c[100000];
  int la,lb;
  scanf("%s %s %s",a,b,c);
  la=strlen(a);
  lb=strlen(b);
  if(a[la-1]==b[0] && b[lb-1]==c[0])
    puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func solve() {
	var N int
	fmt.Scan(&N)

	po := 1
	for po <= N {
		po *= 2
	}
	fmt.Println(po / 2)
}

func main() {
	solve()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 512
S = input()
N = len(S)
A = [0]*(N+1)
B = [0]*(N+1)

for i in range(N):
    if S[i] == '<':
        A[i+1] = A[i]+1
    else:
        A[i+1] = 0

for i in range(N):
    if S[N-i-1] == '>':
        B[N-i-1] = B[N-i]+1
    else:
        B[N-i-1] = 0

ans = 0
for i in range(N+1):
    ans += max(A[i], B[i])
print(ans)


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

const int INF = (int) 1e9;

int main() {
	int n, k;
	cin>>n>>k;
	
	vector<int> h(n);
	for(auto &it: h) cin>>it;
	
	vector<int> dp(n, INF);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	
	for(int i=2; i<n; i++) {
		for(int j=1; j<=k; j++)
			if(i-j>=0)
				dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1024
<?php
  ini_set('error_reporting', E_ALL & ~E_NOTICE);

  $task = [];
  fscanf(STDIN, "%d", $N);
  for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d %d", $A, $B);
    $task[$B] += $A;
  }
  ksort($task);

  $ans = "Yes";
  $past = 0;
  foreach ($task as $lim => $amount) {
    $past += $amount;
    if ($past > $lim) {
      $ans = "No";
      break;
    }
  }

  echo $ans;


Measured memory_bytes: 17400
#include<stdio.h>
int main()
{
  int n;
  long long int ans;
  ans=1;
  scanf("%d",&n);
  long long int a[100005];
  for(int i=0;i<n;i++)
  {
      scanf("%lld",&a[i]);
      if(!a[i])
      {
          printf("0");
          return 0;
      }
  }
 for(int i=0;i<n;i++)
  {
    long long int temp;
    temp=ans*a[i];
    if(ans>temp||temp>1000000000000000000)
    {  printf("-1"); return 0;}
    ans=temp;
  }
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 2508
// garnab27
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ll int64_t
#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
ll modex(ll a,ll b,ll p){ll res=1;a%=p;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b>>=1;}return res;}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};

int a[100005],b[100005],c[100005];
int n;

ll dp[100005][4];

ll maximum(int i,int p){
	if(i==n)
		return 0;

	if(dp[i][p]!=-1) return dp[i][p];

	ll w=0;
	if(i==0){
		w=max(w,maximum(1,1)+a[0]);
		w=max(w,maximum(1,2)+b[0]);
		w=max(w,maximum(1,3)+c[0]);
	}
	else{
		if(p==1){
			w=max(w,maximum(i+1,2)+b[i]);
			w=max(w,maximum(i+1,3)+c[i]);
		}
		else if(p==2){
			w=max(w,maximum(i+1,1)+a[i]);
			w=max(w,maximum(i+1,3)+c[i]);
		}
		else{
			w=max(w,maximum(i+1,1)+a[i]);
			w=max(w,maximum(i+1,2)+b[i]);
		}
	}

	return dp[i][p]=w;
}

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

	memset(dp,-1,sizeof dp);

	cin>>n;

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

	ll ans=maximum(0,0);


	cout<<ans;

	return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
long long int n,c=0,m=1000000000,ans;
std::vector<long long int> v;
int main(){
  cin >> n;
  v.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> v[i];
    if(v[i] < 0) c++;
    m = min(m,abs(v[i]));
    ans += abs(v[i]);
  }
  if(c%2 == 1)ans -= m*2;
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3],w=0,x=0,y=0,z=0,b=0;
  while(b==0){
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[2]<a[0]+a[1]&&b==0){
      w++;
      if(a[2]*a[2]==a[0]*a[0]+a[1]*a[1])x++;
      if(a[2]*a[2]>a[0]*a[0]+a[1]*a[1])z++;
      if(a[2]*a[2]<a[0]*a[0]+a[1]*a[1])y++;
    }else b++;
  }
  cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define re register
#define rep(i,a,b) for(re int i=a,i##end=b; i<=i##end; i++)
#define drep(i,a,b) for(re int i=a,i##end=b; i>=i##end; i--)
#define repp(i,a,b) for(re int i=a,i##end=b; i<i##end; i++)
#define drepp(i,a,b) for(re int i=a,i##end=b; i>i##end; i--)
#define Erep(i,x) for(int i=head[x]; ~i; i=Edge[i].nxt)
#define ll long long
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define lowbit(x) (x&-x)
#define ms(x,a) memset(x,a,sizeof x)
using namespace std;
template <class T> inline bool Max(T &x, T y){
	return x<y?x=y,1:0;
}
template <class T> inline bool Min(T &x, T y){
	return x>y?x=y,1:0;
}
template <class T> inline T rd() {
	static char ch;static bool neg;
	static T x=0;
	for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
	for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
	return x=(neg?-x:x);
}
const int mod=1e9+7,oo=1e9,M=505;
int A[M],B[M],sum[M];
int n,k;
bool check(int x){
	int tot=0,p=0;
	rep(i,1,n){
		B[i]=A[i]%x;
		tot+=B[i];
	}
	sort(B+1,B+n+1);
	rep(i,1,n){
		p+=B[i];
		if(p==1ll*(n-i)*x-(tot-p)) return p<=k;
	}
	return 0;
}

int main(){
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	n=rd<int>(),k=rd<int>();
	int mx=0,tot=0,mn=oo;
	rep(i,1,n){
		A[i]=rd<int>();
		tot+=A[i]; Max(mx,A[i]); Min(mn,A[i]);
	}
	if(tot-mx<=k){
		printf("%d\n",tot); return 0;
	}
	sort(A+1,A+n+1);
	int ans=0;
	rep(i,1,sqrt(tot)+1){
		if(tot%i==0){
			int res=check(i);
			if(res) Max(ans,i);
			res=check(tot/i);
			if(res) Max(ans,tot/i);
		}
	}
	printf("%d\n",ans);
	return 0;
}



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

#define ll long long int

ll f(vector<ll> s, int i, vector<ll> t, int j) {
    if(i >= s.size() && j >= t.size())
        return 1;
    if(i >= s.size() || j >= t.size())
        return 0;
    ll ans = f(s, i + 1, t, j) + f(s, i, t, j + 1);    
    if(i < s.size() && j < t.size() && s[i] == t[j])
        ans += f(s, i + 1, t, j + 1);
    return ans;    
}

int main() {
  ll n, m, MOD = 1e9 + 7;
  cin >> n >> m;
  vector<ll> s(n), t(m);
  for(int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for(int i = 0; i < m; i++) {
    cin >> t[i];
  }
  
  ll sum[2001][2001], dp[2001][2001], ans = 0;
  memset(sum, 0, sizeof sum);
  memset(dp, 0, sizeof dp);
  for(int i = 1; i <= n; i++) {
      for(int j = 1; j <= m; j++) {
        if(s[i - 1] == t[j - 1]){
            dp[i][j] = sum[i - 1][j - 1] + 1;
        }
        else {
            dp[i][j] = 0;
        }
        sum[i][j] = ((sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + MOD) % MOD
            + dp[i][j] % MOD) % MOD;
        ans = (ans + dp[i][j]) % MOD;
      }
  }
  cout << (ans + 1) % MOD << endl;
}

Measured memory_bytes: 62976
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    H, W, M = map(int, input().split())
    cnt_h = [0] * (H+1)
    cnt_w = [0] * (W+1)
    B = set()
    for _ in range(M):
        h, w = map(int, input().split())
        cnt_h[h] += 1
        cnt_w[w] += 1
        B.add(h * (W+1) + w)

    hmax = max(cnt_h)
    wmax = max(cnt_w)
    h_list = []
    w_list = []
    for h in range(1, H+1):
        if cnt_h[h] == hmax:
            h_list.append(h)
    for w in range(1, W+1):
        if cnt_w[w] == wmax:
            w_list.append(w)
    if len(h_list) * len(w_list) > M:
        print(hmax + wmax)
    else:
        flg = 1
        for h in h_list:
            for w in w_list:
                if h * (W+1) + w not in B:
                    flg = 0
                    break
        print(hmax + wmax - flg)


if __name__ == '__main__':
    main()


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

int main(){
    
    size_t n;
    std::cin >> n;

    std::vector<size_t> d(n);

    for(auto&& e : d){
        std::cin >> e;
    }
    
    size_t ans = 0;

    for(size_t i = 0; i < n - 1; i++){
        for(size_t j = i + 1; j < n; j++){
            ans += d[i] * d[j];
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define It set<node>::iterator
#define endl '\n'
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=2e5+10;
const int inf=0x3f3f3f3f;

int n,m;
double ans=(double)-inf;
int arr[maxn],pre[maxn];

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i) cin>>arr[i];
	for(int i=1;i<=n;++i) pre[i]=pre[i-1]+arr[i];
	for(int i=m;i<=n;++i) ans=max(ans,((double)pre[i]-(double)pre[i-m]+(double)m)/2.0);
	printf("%.12lf\n",ans);
	return 0;
} 

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

int main(int argc, char *argv[]) {
	int age = 0;
	int A = 0;
	int B = 0;

	std::cin >> age;

	if (age == 1) {
		std::cout << "Hello World" << std::endl;
	} else {
		std::cin >> A;
		std::cin >> B;
		std::cout << A + B << std::endl;
	}
	return 0;
}


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

int main(){
  int num=0;
  int answer=0;
  cin >>num ;

  vector<string> name(num);
  vector<int> time(num,0);
    
  for(int i=0; i<num;i++){
      cin >> name.at(i) >> time.at(i);
  }
  
  string asleep_name;
  
  cin >> asleep_name;
  
  bool flag = false;
 
  for(int i=0; i<num;i++){
   if(flag == false){
    if(name.at(i) == asleep_name){
      flag = true;
     continue; 
    }else{
      continue;
    }
   }else{
    answer += time.at(i);
   }
  }
 
  cout << answer <<  endl;
}


Measured memory_bytes: 256
#include <iostream>

long long gcd(const long long x, const long long y)
{
    long long a = x;
    long long b = y;
    long long r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

long long lcm(const long long x, const long long y)
{
    long long d = gcd(x, y);
    return x / d * y;
}

long long count(long long A, long long C, long long D)
{
    long long L = lcm(C, D);
    return A - (A/C + A/D - A/L);
}

int main()
{
    long long A, B, C, D;
    std::cin >> A >> B >> C >> D;
    long long L = lcm(C, D);
    std::cout << count(B, C, D) - count(A-1, C, D) << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int mod=1e9+7;

void solve(){
	int w,a,b,d=0;
	cin>>w>>a>>b;
	if(b+w<=a){
		d=a-b-w;
	}
	else if(b>=a+w){
		d=b-a-w;
	}
	cout<<d;

}

int main(){
int test=1;
// cin>>test;
while(test--){
	solve();
	cout<<endl;
}

return 0;
}


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  int x,y,s;
  while(scanf("%d%d%d",&x,&y,&s) && x+y+s){
    int res = 0;
    map<int,int>m;
    for(int i=1;i*(100+x)/100 <= s;i++){
      int v = i*(100+x)/100;
      if(m.find(v) == m.end()) m[v] = i;
    }
    
    for(int i=1;i<s;i++){
      int j = s-i;
      res = max(res, m[i]*(100+y)/100 + m[j]*(100+y)/100);
    }
    cout << res << endl;
  }

  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;

  int temp_N = 0;
  for (int i = N; i > 0; i--) {
    temp_N += i - 1;
  }

  int temp_M = 0;
  for (int i = M; i > 0; i--) {
    temp_M += i - 1;
  }

  cout << temp_N + temp_M << endl;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
ll mat[MAX_INT][MAX_INT];

int main() {
	scanf("%lld %lld %lld", &N, &M, &A);
	fi(i, 0, N, 1) {
		fi(j, 0, M + 1, 1) {
			scanf("%lld", &mat[i][j]);
		}
	}	
	ll minMoney = 1e15;
	fi(i, 1, (1 << N), 1) {
		ll spent = 0;
		memset(arr1, 0, sizeof(arr1));
		fei(j, 0, N, 1) {
			if((1 << j) & i) {
				// cout << i << " " << (1 << j)<< " \n"; 
				spent += mat[j][0];
				// cout << spent << " \n";
				fei(k, 1, M, 1) {
					arr1[k] += mat[j][k];
				}
				ll ok = 1;
				fei(k, 1, M, 1) {
					if(arr1[k] < A) {
						ok = 0;
						break;
					}
				}
				if(ok) {
					minMoney = min(minMoney, spent);
					break;
				}
			}
		}
	}
	if(minMoney == 1e15) {
		minMoney = -1;
	}
	printf("%lld\n", minMoney);
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3800
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int R, G;

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

  cin >> R >> G;

  int b = 2 * G - R;
  cout << b << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <string>
#include <list>
#include <limits>
#include <type_traits>
#include <vector>

using namespace std;

int main(void) {

    int a,b,c,d;

    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    bool tWin = false;
    bool aWin = false;
    
    while ( tWin == false && aWin == false ) {
        
        c -= b;
        if( c <= 0 ){
            tWin = true;
            break;
        }

        a -= d;
        if (a <= 0) {
            aWin = true;
        }
    }

    if ( tWin == true ) {
        cout << "Yes";
    }
    else {
        cout << "No";

    }

    
}

Measured memory_bytes: 3568