akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <bitset>
#include <functional>

using namespace std;

#define FOR(i,n) 		for(int(i)=0;(i)<(int)(n);(i)++)
#define FORN(i,a,b,c) 	for(int(i)=a;i<(int)(b);i+=(c))
#define RES(x,nilai)	memset(x,nilai,sizeof(x));
#define pb              push_back
#define mp              make_pair
#define INF				1000000000

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

inline string IS(int a){
    char x[100];
    sprintf(x,"%d",a); string s = x;
    return s;
}

inline int SI(string a){
    char x[100]; int res;
    strcpy(x,a.c_str()); sscanf(x,"%d",&res);
    return res;
}

//==============================================

bool cmp(int x,int y) {return x>y;}

int n,arr[200];

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("13.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	while (cin >> n) {
		for(int i =0 ;i < n ;i++) {
			cin >> arr[i];
		}
		sort(arr,arr+n);
		
		int penalty = 0, time = 0;
		for(int i =0; i< n;i++) {
			time += arr[i];
			penalty += time;
		}
		cout << penalty << endl;
	}
	
	
 
	
    return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
const int M=5001;
int n,m,P,a,b,c;
struct node{
	int to,val,id;
};
vector<node>d[M];
vector<int>p[M];
int dis[M];
queue<int>Q;
bool mark[M],mem[M],fl;
int cf[2501][2501],rd[M];
void spfa(){
	dis[1]=0;
	Q.push(1);
	mark[1]=1;
	while(!Q.empty()){
		int x=Q.front();
		Q.pop();
		mark[x]=0;
		for(int i=0;i<(int)d[x].size();i++){
			node y=d[x][i];
			if(!mem[y.to])continue;
			int t=dis[x]+y.val;
			if(t>dis[y.to]){
				if(cf[x][y.to]>m){
					fl=1;
					return;
				}
				cf[x][y.to]++;
				dis[y.to]=t;
				if(!mark[y.to]){
					Q.push(y.to);
					mark[y.to]=1;
				}
			}
		}
	}
}
int main(){
	memset(dis,-63,sizeof(dis));
	scanf("%d%d%d",&n,&m,&P);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&a,&b,&c);
		c-=P;
		rd[b]++;
		d[a].push_back((node)<%b,c,i%>);
		p[b].push_back(a);
	}
	mem[n]=1;
	Q.push(n);
	while(!Q.empty()){
		int x=Q.front();
		Q.pop();
		for(int i=0;i<(int)p[x].size();i++){
			int y=p[x][i];
			if(mem[y])continue;
			mem[y]=1;
			Q.push(y);
		}
	}
	spfa();
	if(fl){
		puts("-1");
		return 0;
	}
	printf("%d\n",max(dis[n],0));
}

Measured memory_bytes: 24448
/* 5月17日正午はIPA基本情処試験の合格発表ですね。 */
#include <stdio.h>
int isRight(int x,int y,int z){
  if(x*x==(y*y+z*z))return -1;
  return 0;
} 
int main(){
  int a,b,c,d,e;
  scanf("%d",&a);
  for(b=1;b<=a;b++){
    scanf("%d %d %d",&c,&d,&e);
    if(isRight(c,d,e) || isRight(d,c,e) || isRight(e,c,d)) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 0
def f(x, y, z)
  x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
end

N = gets.to_i

fn = Hash.new
max = Math.sqrt(N).to_i - 1
aaa = (1..max).to_a

aaa.repeated_combination(3).to_a.each do |x, y, z|
  n = f(x, y, z)
  if x == y && y == z
    fn[n] = fn[n].to_i + 1
  elsif x == y || y == z
    fn[n] = fn[n].to_i + 3
  else
    fn[n] = fn[n].to_i + 6
  end
end

(1..N).each do |i|
  p fn[i].to_i
end

Measured memory_bytes: 27036
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    ll h1,h2,m1,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    ll total = (h2 - h1)*60;
    total += m2 - m1 - k; 
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>

#define WHITE 0
#define BLACK 1
#define INF 1000000000

int main(){

  int d[100],p[100],color[100],min,n,u,k,c,i,j;
  int m[100][100];
 
  scanf("%d",&n);

  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      m[i][j]=-1;
 
  for(i=0;i<n;i++){
    scanf("%d%d",&c,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      scanf("%d",&m[i][c]);
    }
  }
 
  for(i=0;i<n;i++){
    d[i]=INF;
    p[i]=-1;
  }
  d[0]=0;

  while(1){
    min=INF;
    for(i=0;i<n;i++)
      if(color[i]!=BLACK && d[i]<min){
	min=d[i];
	u=i;
      }
    if(min==INF)break;

    color[u]=BLACK;

    for(i=0;i<n;i++)
      if(color[i]!=BLACK && m[u][i]!=-1 && d[u]+m[u][i]<d[i]){
	p[i]=u;
	d[i] = d[u]+m[u][i];
      }
  }
  for(i=0;i<n;i++)printf("%d %d\n",i,d[i]);


}



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

using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> l(26, 0), r(26, 0);
    for (int i=0; i<n; i++) {
        r[s[i]-'a']++;
    }

    int ans = 0;
    for (int i=0; i<n; i++) {
        l[s[i]-'a']++;
        r[s[i]-'a']--;
        int cnt = 0;
        for (int j=0; j<26; j++) {
            if (l[j]>0 && r[j]>0)
                cnt++;
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n;
string str="yuiophjklnm";

main(){
	string s;
	while(cin >> s, s!="#"){
		vector<int> ans;
		REP(i, s.size()) ans.push_back(find(ALL(str), s[i])!=str.end());
		UNIQUE(ans);
		cout << (int)ans.size()-1 << endl;
	}
	return 0;
}

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

using namespace std;

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

typedef long long ll;

int k;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> k;
    ll sum = 0;
    for(int i = 1; i <= k; i++)
        for(int j = 1; j <= k; j++)
            for(int x = 1; x <= k; x++)
                sum += gcd(gcd(i, j), x);
    cout << sum << "\n";
    return 0;
}


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

int main() {
    string foo; cin >> foo;
    int n = 0, w = 0, s = 0, e = 0;
    for (int i = 0; i < (int) foo.size(); ++i) {
        if (foo[i] == 'N') ++n;
        if (foo[i] == 'W') ++w;
        if (foo[i] == 'S') ++s;
        if (foo[i] == 'E') ++e;
    }
    cout <<  ((n == 0) != (s == 0) || (w == 0) != (e == 0) ? "No" : "Yes")  << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

int main(){
	int i,j,k,l,a,b,c,d;
	scanf("%d",&a);	
    set<string> mp;
    while(a--){
        string x;
        cin >> x;
        mp.insert(x);
    }
    printf("%d",SZ(mp));
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


Measured memory_bytes: 19276
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define maxn 5010
using namespace std;
typedef long long ll;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m;
ll a[maxn];
int b[maxn][204];
int s[maxn],top;
int nxt[maxn],las[maxn];
ll res[maxn][maxn];
int main()
{
    n=read();m=read();
    for(int i=1;i<n;i++)  a[i]=read();
    for(int i=1;i<n;i++)  a[i]+=a[i-1];
    for(int i=1;i<=n;i++)
      for(int j=1;j<=m;j++)  b[i][j]=read();
    for(int i=1;i<=m;i++)
    {
        top=0;
        s[0]=0;
        for(int j=1;j<=n;j++)
        {
            while(top&&b[s[top]][i]<=b[j][i])  top--;
            las[j]=s[top];
            s[++top]=j;
        }
        top=0;
        s[0]=n+1;
        for(int j=n;j>=1;j--)
        {
            while(top&&b[s[top]][i]<b[j][i])  top--;
            nxt[j]=s[top];
            s[++top]=j;
        }
        for(int j=1;j<=n;j++)
        {
            res[las[j]+1][j]+=b[j][i];
            res[las[j]+1][nxt[j]]-=b[j][i];
            res[j+1][j]-=b[j][i];
            res[j+1][nxt[j]]+=b[j][i];
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            res[i][j]+=res[i-1][j]+res[i][j-1]-res[i-1][j-1];
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j<=n;j++)
        {
            ans=max(ans,res[i][j]-(a[j-1]-a[i-1]));
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 200448
import sys
sys.setrecursionlimit(10000000)
n=int(input())
s=[[]for i in range(n+1)]
g=[0]*(n+1)
h=[True]*(n+1)
for i in range(n-1):
    a,b,c=map(int,input().split())
    s[a].append([b,c])
    s[b].append([a,c])
def dfs(x):
    h[x]=False
    for i in s[x]:
        if h[i[0]]:
            g[i[0]]=g[x]+i[1]
            dfs(i[0])
dfs(1)
for i in range(1,n+1):
    if g[i]%2==0:
        print(0)
    else:
        print(1)

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  string S,T;
  cin>>N>>S>>T;
  for(int i=0;i<N;i++){
    cout<<S[i]<<T[i];
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  ll a, b, c, d;
  cin >> a >> b >> c;
  d = c - a - b;
  if(d > 0 && 4 * a * b < d * d) {
    cout << "Yes\n";
  }
  else {
    cout << "No\n";
  }
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  string s;
  cin>>n;
  if(n%2!=0)
    return cout<<"No", 0;
  cin>>s;
  for(int i=0;i<n/2;i++)
  {
    if(s[i]!=s[i+n/2])
      return cout<<"No", 0;
  }
  return cout<<"Yes",0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <queue>

using namespace std;

#define MAX 100

#define WHITE 0
#define GRAY 1
#define BLACK 2

int T;
int N;

int M[MAX][MAX];
int C[MAX],D[MAX];

void bfs(int s)
{
    queue<int> *q = new queue<int>;

    q->push(s);
    D[s] = 0;
    C[s] = GRAY;

    while(!q->empty())
    {
        int u = q->front();
        q->pop();

        for (int v = 0; v < N; v++)
        {
            if (M[u][v] && C[v] == WHITE)
            {
                C[v] = GRAY;
                D[v] = D[u] + 1;
                q->push(v);
            }
        }

        C[u] = BLACK;
    }
}

int main ()
{
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        C[i] = WHITE;
        D[i] = -1;

        for (int j = 0; j < N; j++)
        {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < N; i++)
    {
        int u, k;
        cin >> u >> k;
        u--;

        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

/*
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (j > 0)
                cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
*/
    bfs(0);

    for (int i = 0; i < N; i++)
    {
        cout << i+1 << " " << D[i] << endl;
    }

    return 0;
}





Measured memory_bytes: 3144
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int [][]arr=new int[n][3];
		for(int i=0;i<n;i++){
		    for(int j=0;j<3;j++)
		        arr[i][j]=s.nextInt();
		}
		int dp[][]=new int[n][3];
		dp[0][0]=arr[0][0];
		dp[0][1]=arr[0][1];
		dp[0][2]=arr[0][2];
		for(int i=1;i<n;i++){
		    dp[i][0]=arr[i][0]+Math.max(dp[i-1][1],dp[i-1][2]);
		    dp[i][1]=arr[i][1]+Math.max(dp[i-1][0],dp[i-1][2]);
		    dp[i][2]=arr[i][2]+Math.max(dp[i-1][1],dp[i-1][0]);
		}
		System.out.println(Math.max(dp[n-1][0],Math.max(dp[n-1][1],dp[n-1][2])));
	}
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> V(N);
  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }
  int res = 0;
  for (int l = 0; l < K + 1; l++) {
    for (int r = 0; r < K + 1; r++) {
      if (l + r > min(N, K)) continue;

      priority_queue<int, vector<int>, greater<int>> que;
      for (int i = 0; i < l; i++) {
        que.push(V[i]);
      }
      for (int i = N - 1; i > N - r - 1; i--) {
        que.push(V[i]);
      }

      for (int i = 0; i < K - (l + r) && !que.empty(); i++) {
        if (que.top() > 0) break;
        que.pop();
      }

      int value = 0;
      while (!que.empty()) {
        value += que.top();
        que.pop();
      }
      res = max(res, value);
    }
  }
  cout << res << '\n';
  return 0;
}


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

int main() {
  int n, s = 0;
  cin >> n;
  vector<int> a(n), c(n-1);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  for(int i = 0; i < n; i++){
    int b;
    cin >> b;
    s += b;
  }
  for(int i = 0; i < n-1; i++)
    cin >> c.at(i);
  for(int i = 0; i < n-1; i++){
    if(a.at(i+1) == a.at(i)+1)
      s += c.at(a.at(i)-1);
  }
  cout << s << endl;
}


Measured memory_bytes: 256
//14:07:00 

#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int h,w; cin>>h>>w;
	if(h%3==0 || w%3==0) cout<<"0\n";
	else
	{
		int mn=1e12;
		For(i,1,w-1)
		{
			int a=h*i;
			int b=h/2*(w-i);
			int c=h*w-a-b;
			mn=min(mn,max(max(a,b),c)-min(min(a,b),c));
		}
		swap(h,w);
		For(i,1,w-1)
		{
			int a=h*i;
			int b=h/2*(w-i);
			int c=h*w-a-b;
			mn=min(mn,max(max(a,b),c)-min(min(a,b),c));
		}
		if(h<mn || w<mn) mn=min(h,w);
		cout<<mn<<"\n";
	}
	return 0;
}











Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 10L^^15;
enum mod = 10L ^^ 9 + 7;

void main() {
    int h, w;
    scan(h, w);
    auto ban = iota(h).map!(i => readln.chomp).array;
    auto dp = new long[][](h, w);
    dp[0][0] = 1;
    foreach (i ; 0 .. h) {
        foreach (j ; 0 .. w) {
            if (ban[i][j] == '#') {
                continue;
            }
            if (i > 0) {
                dp[i][j] += dp[i-1][j];
                dp[i][j] %= mod;
            }
            if (j > 0) {
                dp[i][j] += dp[i][j-1];
                dp[i][j] %= mod;
            }
        }
    }
    writeln(dp[h-1][w-1]);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 11260
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

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

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

int main()
{
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
//Fabonacci Number
//Ebitani Akira

#include <stdio.h>
#include <stdlib.h>

#define N 44

int array[N];

int main(){
  int i, n;

  scanf("%d", &n);
  if(n < 0 || n > N){
    printf("入力が正しくありません。\n");
    exit(1);
  }

  array[0] = 1;
  array[1] = 1;
  for(i = 2 ; i <= n ; i++)
    array[i] = array[i-1] + array[i-2];

  printf("%d\n", array[n]);

  return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>
int main(void)
{
    int N, ans = 0;
    scanf("%d", &N);
    if (N / 10 == 0) {
        ans += N;
        printf("%d", ans);
        return 0;
    }
    else {
        ans += 9;
    }
    if (N < 100) {
        printf("%d", ans);
        return 0;
    }
    if (N / 1000 == 0) {
        ans += N - 99;
        printf("%d", ans);
        return 0;
    }
    else {
        ans += 900;
    }
    if (N < 10000) {
        printf("%d", ans);
        return 0;
    }
    if (N / 100000 == 0) {
        ans += N - 9999;
        printf("%d", ans);
        return 0;
    }
    printf("90909");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
  int X,A,B;
  
  scanf("%d",&X);
  scanf("%d",&A);
  scanf("%d",&B);
  
  X = X - A;
  
  while(X>0){
    X = X - B;
   
  }
  
  if(X<0)
  printf("%d",X+B);
  
  if(X==0)
  printf("%d",X);
  
  
	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

  int K;
  std::cin >> K;

  ll sum = 0;

  for(int a=1;a<=K;++a){
      for(int b=1;b<=K;++b){
          for(int c=1;c<=K;++c){
              sum += std::gcd(a, std::gcd(b, c));
          }
      }
  }

  std::cout << sum << std::endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
	int N; 
	int a[100010] = {};
	int b[100010] = {}; 
	int c[100010] = {}; 
	int A[100010] = {};//最終日がaのときのmax
	int B[100010] = {}; 
	int C[100010] = {}; 
	cin >> N; 
	for(int i = 1; i <= N; i++){
		cin >> a[i] >> b[i] >> c[i]; 
		A[i] = a[i] + max(B[i-1], C[i-1]);
		B[i] = b[i] + max(C[i-1], A[i-1]); 
		C[i] = c[i] + max(A[i-1], B[i-1]); 
	}
	cout << max({A[N], B[N], C[N]}) << endl; 
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;typedef long long ll;
#define r(i,n) for(int i=0;i<n;i++)
const ll MN=2005;ll md=1e9+7;ll n,sz[MN],p[MN];vector<ll>g[MN];ll d[MN][MN][2];ll f[MN];ll a[MN][3],x[MN][3];
int main(){f[0]=1;for(ll i=1;i<MN;i++)f[i]=f[i-1]*i%md;cin>>n;for(ll i=2;i<=n;i++){cin>>p[i];g[p[i]].push_back(i);}for(ll i=n;i;i--){memset(a,0,sizeof(a));a[0][0]=1;for(auto &j:g[i]){memset(x,0,sizeof(x)); r(k,sz[j]+1)r(l,sz[i]+1)r(m,3){x[k+l][m]+=d[j][k][0]*a[l][m]%md;if(m<2) x[k+l+1][m+1]+=d[j][k][1]*a[l][m]%md;}sz[i]+=sz[j];r(j,sz[i]+1)r(k,3){a[j][k]=x[j][k]%md;}}r(j,sz[i]+1){d[i][j][0]=a[j][0]+a[j][1]*2+a[j][2]*2;d[i][j][1]=a[j][0]+a[j][1];d[i][j][0]%=md;d[i][j][1]%=md;}sz[i]++;}ll rt=0;r(i,n+1){ll cr=d[1][i][0]*f[n-i]%md;if(i & 1) cr=md-cr;rt+=cr;}cout<<rt%md<<endl;}

Measured memory_bytes: 42584
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve(n):
    s = [input() for _ in range(n)]
    key = [[i[0]] for i in s]
    for i in range(n):
        for j in range(len(s[i])-1):
            if s[i][j] in "aiueo":
                key[i].append(s[i][j+1])
    k = 0
    for i in range(n):
        for j in range(i):
            nk = 0
            m = min(len(key[i]),len(key[j]))
            while nk < m and key[i][nk] == key[j][nk]:
                nk += 1
            nk += 1
            if nk == len(key[i])+1 == len(key[j])+1:
                print(-1)
                return
            if nk > k:
                k = nk
    print(k)
    return

#Solve
if __name__ == "__main__":
    while 1:
        n = I()
        if n == 0:
            break
        solve(n)



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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    // A, B バラ買いパターン
    int n = a * x + b * y;

    // A, B のどちらか必要な量を超えるパターン
    int m = 2 * c * max(x, y);

    // 必要最小限の Cセットを買い、足りない分はバラ買いパターン
    int p = x < y ? b : a;
    int l = 2 * c * min(x, y) + p * abs(x - y);

    // 上記のうちで1番安いの
    int ans = min(n, min(m, l));
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))

    # cs = sum(a[:i]) % m
    cs = 0
    # dic[i] = len({j | sum[:j] % m == i})
    dic = {0:1}

    ans = 0
    for i, x in enumerate(a):
        cs += x
        cs %= m
        if cs in dic:
            ans += dic[cs]
            dic[cs] += 1
        else:
            dic[cs] = 1
    
    print(ans)

main()

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int h1, h2, m1, m2, k;
	cin>>h1>>m1>>h2>>m2>>k;
	int a = h1*60 + m1;
	int b = h2*60 + m2;
	cout<<(b - a - k)<<endl;

	return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
int main(void){
  int i,fi=0,se=0,th=0;
  int mt[10];
  for(i=0;i<10;i++){
    scanf("%d",&mt[i]);
    if(fi<mt[i]){
      th=se;
      se=fi;
      fi=mt[i];
    }
    else
      if(se<mt[i]){
	th=se;
        se=mt[i];
      }
    else
      if(th<mt[i]){
        th=mt[i];
      }
  }
  printf("%d\n%d\n%d\n",fi,se,th);
	return(0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define SZ(i) int(i.size())
#define eb emplace_back
#define ALL(i) i.begin(),i.end()
#define X first
#define Y second
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"#%d: %s = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
template<typename It> ostream& _printRng(ostream &os,It bg,It ed)
{
    os<<"{";
    for(It it=bg;it!=ed;it++) {
        os<<(it==bg?"":",")<<*it;
    }
    os<<"}";
    return os;
}
template<typename T> ostream &operator << (ostream &os,vector<T> &v){return _printRng(os,v.begin(), v.end());}
template<typename T> void pary(T bg, T ed){_printRng(cerr,bg,ed);cerr<<endl;}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#define pary(...)
#endif

const int MAXN = 200005;
const ll MOD = 1000000007;

int n;
vector<int> edge[MAXN];

int ans[MAXN];
vector<int> x[MAXN];
void dfs (int nd, int par, bool c) {
    x[c].eb(nd);

    for (auto v : edge[nd]) {
        if (v != par) {
            dfs(v, nd, !c);
        }
    }
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n;
    for (int i=0; i<n-1; i++) {
        int u, v;
        cin >> u >> v;
        edge[u].eb(v);
        edge[v].eb(u);
    }

    dfs(1, -1, 0);
    if (x[0].size() >= x[1].size()) {
        swap(x[0], x[1]);
    }

    int oc = n / 3;
    debug(oc, x[0].size(), x[1].size());
    if (x[0].size() <= oc) {
        int c = 3;
        for (auto v : x[0]) {
            ans[v] = c;
            c += 3;
        }
    } else {
        for (int i=0; i*3+1<=n; i++) {
            ans[x[0][i]] = i*3+1;
        }
        for (int j=0; j*3+2<=n; j++) {
            ans[x[1][j]] = j*3+2;
        }
    }

    set<int> x;
    for (int i=1;i<=n;i++) {
        x.insert(i);
    }
    for (int i=1; i<=n; i++) {
        if (ans[i]) {
            x.erase(ans[i]);
        }
    }
    for (int i=1; i<=n; i++) {
        if (ans[i] == 0) {
            ans[i] = *x.begin();
            x.erase(x.begin());
        }
    }

    REP1 (i, n) {
        cout << ans[i] << " \n"[i==n];
    }
}


Measured memory_bytes: 33524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll chmin(ll a,ll b){
    if(a > b){
        return b;
    }
    else{
        return a;
    }
}

ll chmax(ll a,ll b){
    if(a > b){
        return a;
    }
    else{
        return b;
    }
}

int main() {
    int n,k;
    cin >> n >> k;
    vector<ll> line (n);
    for(int i=0; i<n; i++){
        cin >> line.at(i);
    }
    ll ans = 300000010;
    for(int i=0; i<n-k+1; i++){
        if(line.at(i) >= 0){
            ans = chmin(ans,line.at(i+k-1));
        }
        else if(line.at(i+k-1) <= 0){
            ans = chmin(ans,-line.at(i));
        }
        else{
            ans = chmin(chmin(-line.at(i),line.at(i+k-1))*2 + chmax(-line.at(i),line.at(i+k-1)),ans);
        }
    }
    if(n == 1){
        ans = 300000010;
        for(int i : line){
            if(i < 0) i = -i;
            ans = chmin(ans,i);
        }
    }
    if(k == 1){
        ans = 300000010;
        for(int i : line){
            if(i < 0) i = -i;
            ans = chmin(ans,i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
 
typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void)
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool a = false, b = false, c = false;
    for (int i = 0; i < 3;i++){
        if(s[i]=='a')
            a = true;
            if(s[i]=='b')
                b = true;
                if(s[i]=='c')
                    c = true;
    }
    if(a==true&&b==true&&c==true)
        cout << "Yes" << endl;
        else
            cout << "No" << endl;
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
using namespace std;
int main() {
	long long a, b;
	cin >> a >> b;
	int c = b - a;
	if (a > 0 && b > 0) {
		cout << "Positive" << endl;
	}
	else if (a < 0 && b < 0 && c % 2 == 0) {
		cout << "Negative" << endl;
	}
	else if (a <= 0 && 0 <= b)
		cout << "Zero" << endl;
	else
		cout << "Positive" << endl;

}
	

Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
l=[int(i+1) for i in range(n)]
cnt=0
for i in range(n):
    if p[i]!=l[i]:
        cnt+=1
    else:
        continue
if cnt<=2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
#ifdef local
#define dbg(a) cout << #a": " << a << endl;
#else
#define dbg(a)
#endif // loacl


using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const ll inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-6;
const int mod=998244353;
const int maxn=1e6+10;
const int N=2e5+10;
const int M=N<<1;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll MOD)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=(ans*a)%MOD;
        b>>=1;
        a=(a*a)%MOD;
    }
    return ans;
}

ll sum[N];
int head[N],tot;
struct edge{
    int to,nex;
}e[N<<2];
void add(int x,int y)
{
    e[++tot].to=y;e[tot].nex=head[x];head[x]=tot;
}
void dfs(int u,int fa)
{
    for(int i=head[u];i;i=e[i].nex)
    {
        int v=e[i].to;
        if(v==fa) continue;
        sum[v]+=sum[u];
        dfs(v,u);
    }
}
int main()
{
#ifdef local
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    IOS;
    int n,q;
    cin>>n>>q;
    rep1(i,n-1)
    {
        int u,v;cin>>u>>v;
        add(u,v);add(v,u);
    }
    rep1(i,q)
    {
        int x,y;cin>>x>>y;
        sum[x]+=y;
    }
    dfs(1,-1);
    rep1(i,n) cout<<sum[i]<<" ";
    return 0;
}


Measured memory_bytes: 18304
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	int x; cin >> x;

	vector<Int> L;
	L.push_back(2);
	L.push_back(1);
	int luca = 0;

	for (int i = 0; i < x-1; i++) {
		L.push_back(L[i] + L[i + 1]);
	}

	cout << L.back();

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Fennec" << '\n'; exit(0); }
inline void no() { cout << "Snuke" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  vector<vi32> edges(n);
  rep(i, n - 1) {
    int a, b; cin >> a >> b;
    a--, b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }

  vector<bool> seen(n);

  vi32 cnt(2, 0);
  queue<int> q[2];
  q[0].push(0), q[1].push(n - 1);

  auto bfs = [&](queue<int> &q, int t) {
    if (q.size() == 0) return;

    int c = q.size();
    rep(_, c) {
      int v = q.front(); q.pop();
      if (seen[v]) return;
      seen[v] = true;
      cnt[t]++;

      each(u, edges[v]) {
        if (seen[u]) continue;
        q.push(u);
      }
    }
  };

  while (!q[0].empty() || !q[1].empty()) {
    bfs(q[0], 0), bfs(q[1], 1);
  }

  if (cnt[0] > cnt[1]) yes(); no();
}


Measured memory_bytes: 5760
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		String st = sc.next();
		int count[] = new int[26];
		for(int i = 0; i < num; i ++) {
			count[st.charAt(i) - 'a'] ++;
		}
		long ans = 1;
		for(int i = 0; i < 26; i ++) {
			ans = mod(ans * (count[i] + 1));
		}
		ans = mod(ans - 1);
		System.out.println(ans);
	}

	static long divisor = (long)Math.pow(10, 9) + 7;
	public static long mod(long i) {
		return i % divisor + ((i % divisor) < 0 ? divisor : 0);
	}
}

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

int main() {
  int N;
  cin >> N;
  
  for (int i=0; i<N; i++){
    string S;
    cin >> S;
    
    if (S == "Y"){
      cout << "Four" <<endl;
      break;
    }
    else if (S != "Y" && i==(N-1))
      cout << "Three" << endl;
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<string>

//#define MAX 1001

using namespace std;

static const int N = 1001;

int Lcs(string X, string Y) {
	int c[N][N];
	int m = X.size();
	int n = Y.size();
	int len = 0;

	X = ' ' + X;
	Y = ' ' + Y;

	for (int j = 0; j<m; j++) {
		c[j][0] = 0;
	}
	for (int k = 0; k<n; k++) {
		c[0][k] = 0;
	}

	for (int j = 1; j<=m; j++) {
		for (int k = 1; k<=n; k++) {

			if (X[j] == Y[k]) {
				c[j][k] = c[j - 1][k - 1] + 1;
			}
			else if (c[j - 1][k] >= c[j][k - 1]) {
				c[j][k] = c[j - 1][k];
			}
			else {
				c[j][k] = max(c[j-1][k], c[j][k-1]);
				
			}
			len = max(len, c[j][k]);
		}
	}
	return len;
	//cout << lon << endl;
}

int main() {
	int q;//データセットの数
	string Xi, Yi;

	cin >> q;
	for (int i = 0;i < q; i++) {
		cin >> Xi >> Yi;

		cout << Lcs(Xi, Yi) << endl;
	}


	return 0;
}


Measured memory_bytes: 6916
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll X, Y;
    cin>>X>>Y;
    ll count=0;
    while(true){
        if(X>Y) break;
        count++;
        X*=2;
    }
    cout<<count<<endl;
    return 0;
}


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

int main()
{
	ll n, m; scanf("%lld", &n);
	int len = 1; m = n;
	for (ll tmp = 26, sum = 0; sum <= n; len++) {
		if (sum + tmp >= n) break;
		sum += tmp; m -= tmp; tmp *= 26;
	}
	string ans = ""; m--;
	for (int i = 0; i < len; i++) {
		ans += (m % 26 + 'a');
		m /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

    int N, ans = 0;
    cin >> N;

    vector <ull> a(N);

    for (int i = 0; i < N; i++) {
        cin >> a[i];
        while (a[i]%2 == 0) {
            a[i]/=2;
            ans++;
        }
        putchar('\n');
    }
    cout << ans << endl;
    
    return 0;
}

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

#define ll long long
using namespace std;

int k, N, ans, ara[200000+3], hi;

int main()
{
  cin >> k >> N >> ara[ 0 ];
  
  for (int i=1; i<N; i++){
    cin >> ara[ i ];
    hi = max( hi, abs( ara[ i ] - ara[ i - 1 ] ) );
  }
  
  hi = max( hi, k - ara[ N - 1 ] + ara[ 0 ] );
 
  cout << k - hi << "\n";
  
  return 0;
}


Measured memory_bytes: 1024
///****In the name of ALLAH, most Gracious, most Compassionate****//

#include <bits/stdc++.h>
using namespace std;

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

#define ALL(a) a.begin(), a.end()
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

#define DBG(a) cerr<< "line "<<__LINE__ <<" : "<< #a <<" --> "<<(a)<<endl
#define NL cout<<endl

template < class T1,class T2>
ostream &operator <<(ostream &os,const pair < T1,T2 > &p)
{
    os<<"{"<<p.first<<","<<p.second<<"}";
    return os;
}

const int N=3e5+5;
const int oo=1e9+7;

pii a[N];

int32_t main()
{
    FastIO;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].first;
        a[i].second = i;
    }
    sort(a+1 , a+ n+1);
    int ans =0;
    for(int i=1;i<=n;i++)
        ans+=(i%2) ^ (a[i].second %2);
    ans= (ans+1)/2;
    cout<<ans<<"\n";

}


Measured memory_bytes: 1024
import collections as c
ip = lambda : map(int, input().split())
mod = 10**9+7
# ##############
N = int(input())
l = list(ip())
l.sort()

ans = 0
f = 1
for i in range(N):
    ans = (ans + l[i]*(1+N-i)%mod)%mod
    if i>0:
        f=f*4%mod
ans = ans*f%mod
print(ans)

Measured memory_bytes: 27660
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (c - b == b - a) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
void no(){cout<<"No"<<endl;exit(0);}
signed main(){
  Int a,b;
  string s;
  cin>>a>>b>>s;
  if(s[a]!='-') no();
  for(Int i=0;i<a+b+1;i++){
    if(i==a) continue;
    if(!isdigit(s[i])) no();
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = rl()
cnt = 0
for lis in list(itertools.combinations(li, 3)):
    a, b, c = sorted(lis)
    if a+b > c and a!=b!=c and c!=a:
        cnt += 1
print(cnt)
        













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


int main(){   
    int n; cin >> n;
    vector<int> A(n); 
    rep(i, n) cin >> A[i];
    int Q; cin >> Q;
    vector<int> memo(100001);
    ll sum = 0;
    
    for(int a : A){
      sum += a;
      memo.at(a)++;
  }
    rep(i, Q){
      ll a,b; cin >> a >> b;
      sum -= a*memo[a];
      sum += b*memo[a];
      memo[b] += memo[a];
      memo[a] = 0;
      cout << sum << endl;
    }
}


Measured memory_bytes: 4028
use proconio::input;

fn main() {
    input!(q: usize, ab: [(u64, u64); q]);
    for (a, b) in ab {
        let d = ((a * b) as f64).sqrt() as u64;
        let e = if d * (d + 1) <= a * b { d + 1 } else { d };
        let f = if d == e {
            if a == b {
                2
            } else {
                if a * b == d * e {
                    3
                } else {
                    2
                }
            }
        } else {
            if a == b + 1 || a + 1 == b {
                3
            } else {
                if a * b == d * e {
                    3
                } else {
                    2
                }
            }
        };
        let ans = d + e - f;
        println!("{}", ans);
    }
}


Measured memory_bytes: 2096
#include<stdio.h>
#include<string.h>

int main()
{
   char ch[5];
   int i,j,k,p=1;
   scanf("%s",ch);
   for(i=0;i<4-1;i++)
   {
       if(ch[i]==ch[i+1])
       {
           p++;
       }
       else
       {
           if(p<3)
          {

           p=1;}
       }
   }

   if(p>=3)
   {
       printf("Yes\n");
   }
   else
   {
       printf("No\n");
   }

    return 0;
}


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

using namespace std;

typedef long long ll;

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

    while (true)
    {
        ll n, q;
        cin >> n >> q;
        if (n == 0 && q == 0)
            break;
        std::vector<string> ename;
        std::vector<ll> eyear, wyear;
        for (int i = 0; i < n; i++)
        {
            string s;
            ll a, b;
            cin >> s >> a >> b;
            ename.push_back(s);
            eyear.push_back(a);
            wyear.push_back(b);
        }
        for (int i = 0; i < q; i++)
        {
            ll y;
            cin >> y;
            bool flag = false;
            for (int j = 0; j < n; j++)
            {
                int st = wyear[j] - eyear[j] + 1;
                if (st <= y && y <= wyear[j])
                {
                    cout << ename[j] << " " << y - st + 1 << endl;
                    flag = true;
                    break;
                }
            }
            if (!flag)
                cout << "Unknown" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3280