akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[100100];
li b[100100];

inline li calc(li base, li now) {
    li res = base - (now % base);
    if (res == base)return 0;
    return res;
}

int main() {
    li n;
    cin >> n;
    rin{cin >> a[i] >> b[i];}

    li cnt = 0;
    for (li i = n - 1; i >= 0; i--) {
        cnt += calc(b[i], a[i] + cnt);
        //cout << cnt << endl;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define ll long long
using namespace std;
map<string,bool>mm;
vector<string>v;
int ans[200005];
int main()
{
    string a,b,h;
    cin>>a;
    int aa,bb;
    //scanf("%d%d",&aa,&bb);
    int n=a.length();
    for(int i=0;i<n;i++)cout<<'x';
    printf("\n");

}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  rep(i, n) cin >> s[i] >> t[i];
  string x;
  cin >> x;
  
  int flag = 0;
  int ans = 0;
  rep(i, n) {
    if (flag == 1) {
      ans += t[i];
    }
    if (s[i] == x) {
      flag = 1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
K = min(K, N)
h = list(map(int, input().split()))
cost = [abs(h[i] - h[0]) for i in range(K)]

for i in range(K, N):
#  print(i, cost)
  cost = cost[1:] + [min([cost[j] + abs(h[i]-h[i-K+j]) for j in range(K)])]

print(cost[-1])

Measured memory_bytes: 52592
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
using namespace std;
//整形Shift + alt + f　2回
//int x[101],y[101],h[101];
//int koya[100001][];
/*
//ユークリッドの互除法
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
*/

/*
//桁数取得
unsigned GetDigit(unsigned num)
{
    unsigned digit = 0;
    while (num != 0)
    {
        num /= 10;
        digit++;
    }
    return digit;
}
*/

/*
//素数の真偽
vector<bool> IsPrime;
//素数のリスト
vector<int> PrimeList;
//素数の出現回数
map<int, int> CountPrime;

void sieve(int max)
{
    IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
    IsPrime[0] = false;
    IsPrime[1] = false;

    for (int i = 2; i * i <= max; i++)         // 0からsqrt(max)まで調べる
        if (IsPrime[i])                        // iが素数ならば
            for (int j = 2; i * j <= max; j++) // (max以下の)iの倍数は
                IsPrime[i * j] = false;        // 素数ではない
}

void mkPrimeList()
{
    for (int i = 2; i <= IsPrime.size() - 1; i++)
    {
        if (IsPrime[i])
        {
            PrimeList.push_back(i);
        }
    }
}

void factor(int n)
{

    for (auto e : PrimeList)
    {
        int ct = 0;
        int tmp = n;
        while (tmp % e == 0)
        {
            tmp = tmp / e;
            ct++;
        }
        CountPrime.insert(make_pair(e, ct));
    }
}
*/

/*
// index が条件を満たすかどうか
bool isOK(int index)
{
    long double tmp = pow((double)index, n);
    //i^n が pを超えるか
    if (p < tmp)
        return true;
    else
        return false;
}

//二分探索
int binary_search()
{
    int left = 1;
    int right = p;

    while (right - left > 1)
    {
        long long int mid = left + (right - left) / 2;
        if (isOK(mid))
            right = mid;
        else
            left = mid;
    }

    //left は条件を満たさない最大の値、right は条件を満たす最小の値になっている
    return right;
}
*/

long long int n, sum = 0, ct = 0;
vector<long long int> a, b, d;
long long int fusoku = 0;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        b.push_back(tmp);
        d.push_back(a[i] - b[i]);
        if (d[i] < 0)
        {
            fusoku -= d[i];
            ct++;
        }
        sum += d[i];
    }

    if (sum < 0)
    {
        //cout << sum;
        cout << -1;
        return 0;
    }

    if (fusoku == 0)
    {
        cout << 0;
        return 0;
    }

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

    int i = 0;
    while (fusoku > 0)
    {
        fusoku -= d[i];
        i++;
    }

    cout << i + ct;
    return 0;
}


Measured memory_bytes: 3444
import java.util.Scanner;
public class Main{
  public static void main(String... args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int R = sc.nextInt();

    if(N >= 10){
      System.out.println(R);
    }else{
      System.out.println(R + 100*(10-N));
    }
  }
}

Measured memory_bytes: 21844
using System;
using System.Linq;
 
public class Test
{
	public static void Main()
	{
		// your code goes here
		int[] count = new int[26];
		string character = "abcdefghijklmnopqrstuvwxyz";
		string line = Console.ReadLine();
		for(int i=0;i<line.Length;i++)
		{
			count[character.IndexOf(line[i])] = 1;
		}
		//Console.WriteLine(count.Sum());
		if(count.Sum()==26)
		{
			int i;
			for(i=25;i>=0;i--)
			{
				int j;
				string s = line.Substring(i);
				char a = line[i], c = s.Max();
				//Console.WriteLine(s);
				//Console.WriteLine("{0} {1}", a, c);
				for(j=0;j<s.Length;j++)
				{
					if(a<s[j]&&s[j]<c) c = s[j];
				}
				if(a<c)
				{
					Console.WriteLine(line.Substring(0, i) + c);
					return;
				}
			}
			Console.WriteLine("-1");
		}
		else
		{
			for(int i=0;i<26;i++)
			{
				if(count[i]==0)
				{
					line += character[i];
					Console.WriteLine(line);
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  int n;
  cin >> n;
  vint x(n);
  rep(i,n) cin >> x[i];
  vint y = x;
  sort(y.begin(),y.end());
  rep(i,n){
    if(x[i] <= y[n/2-1]){
      cout << y[n/2] << endl;
    }
    else{
      cout << y[n/2-1] << endl;
    }
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long N;cin>>N;
    vector<long long>A(N);
    for(long long i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    long long ans=0;
    for(long long i=1;i<N;i++){
        ans+=A[A.size()-(i/2)-1];
    }
    cout<<ans;
}


Measured memory_bytes: 4840
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
  for j in range(1, n):
    if i-j >= 0 and a[i-j] > a[i-j+1]:
      a[i-j], a[i-j+1] = a[i-j+1], a[i-j]
    else:
      break
  print(" ".join([str(i) for i in a]))


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

using ll = long long;

int main()
{
    int W, H; cin >> W >> H;

    struct Line { int cost, type; };
    auto lines = vector<Line>();
    for (auto i = 0; i < W; i++)
    {
        int x; cin >> x;
        lines.push_back({x, 0});
    }

    for (auto i = 0; i < H; i++)
    {
        int x; cin >> x;
        lines.push_back({x, 1});
    }

    sort(begin(lines), end(lines), [](const Line a, const Line b) { return a.cost < b.cost; });

    auto verticals = 0, horizontals = 0;
    auto total = 0LL;
    for (const auto line : lines)
    {
        if (line.type == 0)
        {
            verticals++;
            total += ll(line.cost)*(H+1-horizontals);
        }
        else
        {
            horizontals++;
            total += ll(line.cost)*(W+1-verticals);
        }
    }

    cout << total << endl;
}


Measured memory_bytes: 2420
k,s = gets.split.map(&:to_i)
count = 0
l = []

0.upto(k) do |x|
  unless (x*3 > s or 2*k < s-x)
    x.upto(k) do |y|
      unless (x+y*2 > s or k < s-x-y)
        l << [x,y,(s-x-y)].uniq
      end
    end
  end
end

l.each do |a|
  count += (0..a.size).inject(:+)
end

puts count

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()

const ll MAXN = 2e3 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;

ll n , m , ans;
string s[MAXN];
vector<ll> x[MAXN] , y[MAXN];

int main() {
    cin >> n >> m;
    s[0] = string(m + 2 , '#');
    s[n + 1] = s[0];
    for(ll i = 1 ; i <= n ; i++){
        cin >> s[i];
        s[i] = '#' + s[i] + "#";
    }

    for(ll i = 0 ; i <= n + 1 ; i++){
        for(ll j = 0 ; j <= m + 1 ; j++){
            if(s[i][j] == '#'){
                x[i].push_back(j);
                y[j].push_back(i);
            }
        }
    }

    for(ll i = 1 ; i <= n ; i++){
        for(ll j = 1 ; j <= m ; j++){
            if(s[i][j] == '#')  continue;
            ll indx = lower_bound(all(x[i]) , j) - x[i].begin();
            ll indy = lower_bound(all(y[j]) , i) - y[j].begin();
            ans = max(ans , (x[i][indx] - x[i][indx - 1]) - 1 + (y[j][indy] - y[j][indy - 1]) - 1 - 1); //'-1' means remove Duplication
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 75136
function seach(x){
   var flag=true;
   var cnt=0;
   var sum=0;
   for(var i=0;i<ary.length;i++){
      if(x<ary[i]){
         flag=false;
         break;
      }else if(sum+ary[i]==x){
         sum=0;
         if(i!=ary.length-1)cnt++;
      }else if(sum+ary[i]>x){
         sum=ary[i];
         cnt++;
      }else if(sum+ary[i]<x){
         sum+=ary[i];
      }
      if(cnt==m){
         flag=false;
         break;
      }
   }
   return flag;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var mn=arr.shift();
   if(mn=="0 0")break;
   mn=mn.split(" ").map(Number);
   var m=mn[0];
   var n=mn[1];
   var ary=[];
   while(n--)ary.push(arr.shift()-0);
   var L=0;
   var R=1500000
   while(true){
      var middle=Math.floor((L+R)/2);
      var flag=seach(middle);
      if(flag){
         R=middle-1;
      }else{
         L=middle+1;
      }
      if(L>R)break;
   }
   console.log(R+1);
}

Measured memory_bytes: 16140
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(S: str):
    return sum([int('{}1'.format(s)) for s in S])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    result = solve(S)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
//Power Of Ninja Go
#include <bits/stdc++.h>
//#ifdef atom #else #endif
using namespace std;
typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector< ii > vii;
#define X first
#define Y second
#define pb push_back
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int x, y;
    cin >> x >> y;
    int bestsum = min(a+b, 2*c);
    cout << min(1LL*bestsum*max(x, y), 1LL*bestsum*min(x, y)+(x> y?1LL*(x-min(x, y))*a:1LL*(y-min(x, y))*b)) << endl;
}


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

signed main(){
	int N, i;
	scanf("%lld", &N);
	vector<int> A(N);
	int sum = 0;
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
		sum += A[i];
	}
	sum /= 2;
	for(i = 1; i < N; i += 2){
		sum -= A[i];
	}
	vector<int> x(N);
	x[0] = sum;
	for(i = 1; i < N; i++){
		x[i] = A[i - 1] - x[i - 1];
	}
	for(i = 0; i < N; i++){
		printf("%lld ", 2 * x[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2816
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    vector <int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (x >= a[i])
        {
            x -= a[i];
            if (i != n - 1 || x == 0)
                ans++;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 892
#include<stdio.h>
 
int n;
int a[20];
int flg[10000000];
 
void dfs(int x,int sum){
  if(x==n){
    flg[sum]=1;
    return;
  }
  dfs(x+1,sum);
  dfs(x+1,sum+a[x]);
}
 
int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  dfs(0,0);
  int q,key;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if( flg[key]==1 ){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }
  return 0;
}


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

int main() {
    map<string, int> m;
    int n;
    cin >> n;
    cin.ignore();
    string s;
    for(int i = 0; i < n; i++) {
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}

Measured memory_bytes: 3612
while 1:
    n=input()
    if n=='-':
        break
    m=[i for i in range(len(n))]
    count=int(input())
    for i in range(count):
        l=int(input())
        for j in range(len(n)):
            m[j]=n[(l+j)%len(n)]
        n=m.copy()
    for i in range(len(n)):
        print(n[i],end="")
    print()     

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

#define int long long
#define uint unsigned int
#define pii pair<int, int>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin()), ((c).end())

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

int X, Y, Z, K;
int A[1010];
int B[1010];
int C[1010];
int pos[1010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> X >> Y >> Z >> K;
  REP(i, X) cin >> A[i];
  REP(i, Y) cin >> B[i];
  REP(i, Z) cin >> C[i];
  vector<int> v;
  REP(i, X) REP(j, Y) {
    v.EMPB(A[i]+B[j]);
  }
  SORT(v);
  REV(v);
  priority_queue<pii> que;
  REP(i, Z) que.EMP(v[0]+C[i], i);
  REP(i, K) {
    pii p = que.top(); que.pop();
    cout << p.first << endl;
    if (pos[p.second]+1 < X*Y) {
      que.EMP(p.first-v[pos[p.second]]+v[pos[p.second]+1], p.second);
      pos[p.second]++;
    }
  }

  return 0;
}

Measured memory_bytes: 10604
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
   int n;
   cin >> n;
   vector<int> a(n);
   for(int i = 0;i < n;i++){
      cin >> a[i];
   }
   sort(a.begin(),a.end());
   int flag = 0;
   for(int i = 0;i < n-1;i++){
      if(a[i] == a[i+1])
         flag = 1;
   }
   if(flag == 1)
      cout << "NO" << endl;
   else
   {
      cout << "YES" << endl;
   }
   
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;
ll mod_pow(ll x, ll n, ll m = mod){
    if(n == 0)return 1;
    ll res = mod_pow(x*x%m,n/2,m);
    if(n&1) res = res * x % m;
    return res;
}
int main(){
  int n;
  cin >> n;
  vector<ll> c(n);
  rep(i,n) cin >> c[i];
  sort(c.begin(), c.end(), greater<ll>());
  ll d = mod_pow(4, n - 1);
  ll res = 0;
  for (int i = 0; i < n; i++) {
    res += (c[i] * (i + 2)) % mod;
    res %= mod;
  }
  res *= d;
  res %= mod;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for(int i = be; i <= en; i++) 
ll mod = LLONG_MAX;
ll power(ll a, ll b)
{
	if(b == 0) return 1;
	ll ans = power(a, b/2);
	ans = (ans*ans)%mod;
	if(b%2) ans*=a;
	return ans%mod;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(NULL);
	int n;
	string s;
	set<string> a;
	cin >> n;
	fr(1, n)
	{
		cin >> s;
		a.insert(s);
	}
	cout << a.size();
}

Measured memory_bytes: 19248
import collections
n=int(input())
s=[input() for i in range(n)]
c=collections.Counter(s)
l=(c.most_common())
x=l[0][1]
ans=[]
for i in range(len(l)):
  if l[i][1]==x:
    ans.append(l[i][0])
  else:
    break
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Measured memory_bytes: 121424
#include<stdio.h>
int main()
{
int a,b,c,d=0;
scanf("%d %d %d",&a,&b,&c);
if(a<b)
{
if(b<c)
{
printf("Yes\n");
d=1;
}
}
if(d==0)
{
printf("No\n");
}
return 0;
}

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

int main(){
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if(x+r<=w&&x-r>=0&&y+r<=h&&y-r>=0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3076
#include <iostream>
#include <string.h>
using namespace std;

int main () {
  string s;
  cin >> s;
  string h = "2019/04/30";
  if (h.compare(s) >= 0) {
    cout << "Heisei" << endl;  
  }  
  else {
    cout << "TBD" << endl;  
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <utility>

using namespace std;

#define HOUR_CYCLE 12 * 60
#define MIN_CYCLE 60

double PI = 3.14159265358979;

int main() {
  int a, b, h, m;

  cin >> a >> b >> h >> m;

  // 経過分を求める
  int min = (h % 12) * 60 + m;

  // それぞれの角度を求める（単位は度）
  double h_deg = (double)min / 2;
  double m_deg = (double)m * 6;

  // 針の間の角度を求める
  double theta = abs(h_deg - m_deg);
  if (theta > 180) {
    theta = 360 - theta;
  }
  theta = theta / 180 * PI;

  // 求めたい長さを求める
  double res_square = pow(a, 2) + pow(b, 2) - 2 * a * b * cos(theta);
  double res = sqrt(res_square);

  cout << fixed << setprecision(11) << res << endl;

  return 0;
}

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

int h,w;
char grid[1003][1003];
int ans[1003][1003];
const int MOD = 1e9+7;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ans[1][0] = 1;
	cin>>h>>w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>grid[i][j];
			if(grid[i][j] == '.'){
				ans[i][j] = ans[i][j-1] + ans[i-1][j];
				if(ans[i][j] >= MOD) ans[i][j] -= MOD;
			}
		}
	}
	
	cout<<ans[h][w];
	
	//for(int i=1;i<=h;i++){
	
	return 0;
}


Measured memory_bytes: 5120
#include<stdio.h>
int main(void){
	char ope[20]={0},x;
	int num[20]={0},ltr=0,i=0,j=0,mode=0,bob,cnt=0,ans=0;
	while(1){
		scanf("%c",&x);
		if(x=='\n'){
			break;
		}
		cnt++;
		if(mode==0&&x!='*'&&x!='+'){
			ltr+=x-48;
		}
		else if(x!='*'&&x!='+'){
			ltr=ltr*(x-48);
		}
		if(x=='*'||x=='+'){
			ope[i]=x;
			if(x=='*'){
				mode=1;
			}
			else{
				mode=0;
			}
			i++;
		}
		else{
			num[j]=x-48;
			j++;
		}
	}
	i=0;
	while(i<j){
		if(ope[i]=='*'){
			num[i+1]=num[i+1]*num[i];
			num[i]=0;
		}
		i++;
	}
	for(i=0;i<=cnt;i++){
		ans+=num[i];
	}
	scanf("%d",&bob);
	if(bob==ans&&bob==ltr){
		printf("U\n");
	}
	else if(bob==ans){
		printf("M\n");
	}
	else if(bob==ltr){
		printf("L\n");
	}
	else{
		printf("I\n");
	}
	return 0;
}

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

int main() {
	int n,a[5000],i,j,max,sum;
	
	while(cin>>n,n){
		
		for(i=0;i<n;++i)cin>>a[i];
		
		max=-100000;
		
		for(i=0;i<n;++i){
			sum=0;
			for(j=i;j<n;++j){
				sum+=a[j];
				if(sum>max)max=sum;
			}
		}
		
		cout << max << endl;
	}
}

Measured memory_bytes: 1172
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := newIo()
	defer io.flush()

	n := io.nextInt()
	var fmHf, ltHf []int

	for i := range make([]struct{}, n) {
		a := io.nextInt()
		if n%2 != i%2 {
			fmHf = append(fmHf, a)
		} else {
			ltHf = append(ltHf, a)
		}
	}

	for i := len(fmHf) - 1; i >= 0; i-- {
		io.print(fmHf[i], " ")
	}
	for i, v := range ltHf {
		if i != 0 {
			io.print(" ")
		}
		io.print(v)
	}
	io.println()
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) flush() {
	_ = io.writer.Flush()
}

func (io *io) nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) nextString() string {
	for io.nextToken >= len(io.tokens) {
		line := io.nextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) nextInt() int {
	i, _ := strconv.Atoi(io.nextString())
	return i
}

func (io *io) print(a ...interface{}) {
	fmt.Fprint(io.writer, a...)
}

func (io *io) println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}


Measured memory_bytes: 15744
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

int func(char ch) {
	switch (ch) {
	case 'I':
		return 1;
	case 'V':
		return 5;
	case 'X':
		return 10;
	case 'L':
		return 50;
	case 'C':
		return 100;
	case 'D':
		return 500;
	case 'M':
		return 1000;
	}
}

int main() {
	string s;
	while (cin >> s) {
		int sum = func(s.at(s.size() - 1));
		for (int i = s.size() - 1; i > 0; i--) {
			int a = func(s.at(i - 1)),
				b = func(s.at(i));

			if (a < b) {
				sum -= a;
			}
			else {
				sum += a;
			}
		}

		cout << sum << endl;
	}
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
int gcd(int a,int b){//最大公約数
int c=a%b;
while(true){
if(c==0) break;
a=b;
b=c;
c=a%b;
}
return b;
}
bool IsPrime(int num){
if (num < 2) return false;
else if (num == 2) return true;
else if (num % 2 == 0) return false;
double sqrtNum = sqrt(num);
for(int i=3;i<=sqrtNum;i+=2){
if(num%i==0){
return false;
}
}
}
int lcm(int a,int b){//最小公倍数
return (a*b)/gcd(a,b);
}	
signed main(){
// __builtin_ctz(N); Nを２で何回割り切れるかを返す
//(n+1)*n/2; １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    a-=c;
    if(a<0){
	b+=a;
	if(b<0) b=0;
	a=0;
    }
    cout<<a<<" "<<b<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <queue>
using namespace std;
stack<int > d;

int tag[50005];
int popo(stack<int> &x)
{
    int y=x.top();x.pop();
    return y;
}
int main()
{
    char a[100];
    int x,y;
    while(cin>>a)
    {
        if(a[0]=='-')
        {
            x=popo(d);
            y=popo(d);
            d.push(y-x);
        }
        else if(a[0]=='+')
        {
            x=popo(d);
            y=popo(d);
            d.push(x+y);
        }
        else if(a[0]=='*')
        {
            x=popo(d);
            y=popo(d);
            d.push(x*y);
        }
        else if(a[0]=='/')
        {
            x=popo(d);
            y=popo(d);
            d.push(x/y);
        }
        else d.push(atoi(a));
    }cout<<d.top()<<endl;

}

Measured memory_bytes: 3112
O=input()
E=input()
for i in range(len(O)):
    if i!=len(O)-1:
        print(O[i],end="")
        print(E[i],end="")
    else:
        print(O[i],end="")
        if len(O)-len(E)==0:
            print(E[i],end="")
        else:
            continue


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

int main(){
  string S;
  cin >> S;
  int minA=100000000,maxZ=-100000000;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A'){
      minA=min(minA,i);
    }
    else if(S.at(i)=='Z'){
      maxZ=max(maxZ,i);
    }
  }
  cout << maxZ-minA+1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
 
const string boin = "aiueo";
const string shiin = "kstnhmyrwgzdbp";
const string cho = "aiu";
const string museiinshi = "ksthp";
 
bool isBoin(char c) {
  return boin.find(c) != string::npos;
}
 
bool isShiin(char c) {
  return shiin.find(c) != string::npos;
}
 
bool isCho(char c) {
  return cho.find(c) != string::npos;
}
 
bool isMuseiinshi(char c) {
  return museiinshi.find(c) != string::npos;
}
 
vector<pair<string,int> > parse(const string &s) {
  vector<pair<string,int> > v;
  string t = "";
  for(int i = 0; i < s.size(); ++i) {
    t += s[i];
    if(isBoin(s[i])) {
      int type = 0;
      if(t.size() == 1) {
        if(i >= 1 && isBoin(s[i-1]) && isCho(s[i])) {
          type = 6;
        } else {
          type = 1;
        }
      } else if(t.size() == 2) {
        type = 2;
      } else if(t.size() == 3) {
        type = 3;
      }
      v.push_back(make_pair(t, type));
      t = "";
    } else if(i+1 < s.size() && isShiin(s[i]) && s[i+1] == s[i] &&
              s[i] != 'n' && s[i] != 'y' && s[i] != 'w') {
      v.push_back(make_pair(t, 4));
      t = "";
    } else if(s[i] == 'n' &&
              (i+1 == s.size() || (i+1 < s.size() && isShiin(s[i+1]))) ) {
      v.push_back(make_pair(t, 5));
      t = "";
    } else if(s[i] == '\'') {
      v.push_back(make_pair(t, 5));
      t = "";
    }
  }
  return v;
}
 
char getBoin(const string &s) {
  return *s.rbegin();
}
 
int main() {
  string s;
  while(cin >> s && s != "#") {
    vector<pair<string, int> > v = parse(s);
    int n = v.size();
    bool isMusei[n];
    fill(isMusei, isMusei+n, false);
 
    // i or u
    for(int i = 0; i < n; ++i) {
      if((v[i].second == 2 || v[i].second == 3) &&
         isMuseiinshi(v[i].first[0]) &&
         (getBoin(v[i].first) == 'i' || getBoin(v[i].first) == 'u') &&
         (i+1 == n || isMuseiinshi(v[i+1].first[0]))) {
        isMusei[i] = true;
      }
    }
     
    // a or o
    for(int i = 0, cnt = 0; i+1 < n; ++i) {
      if((getBoin(v[i].first) == 'a' || getBoin(v[i].first) == 'o') &&
         getBoin(v[i].first) == getBoin(v[i+1].first)); else continue;
      bool flag = true;
      for(int j = 0; j < 2; ++j) {
        const string &t = v[i+j].first;
        const int &type = v[i+j].second;
        if((type == 2 || type == 3) &&
           isMuseiinshi(t[0])) ; else {
          flag = false;
          break;
        }
      }
      if(flag) {
        isMusei[i] = true;
      }
    }
 
    for(int i = 0, pre = 0; i < n; ++i) {
      if(isBoin(getBoin(v[i].first))) {
        bool musei = !pre && isMusei[i];
        cout << v[i].first.substr(0, v[i].first.size()-1);
        if(musei) cout << "(";
        cout << getBoin(v[i].first);
        if(musei) cout << ")";
        pre = musei;
      } else {
        cout << v[i].first;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    S = list(input())
    N = len(S)
    check = [0] * 2019
    ten = 1
    mod = 1
    check[mod] += 1
    for i in range(N):
        mod = (mod + int(S[N - i - 1]) * ten) % 2019
        ten = (ten * 10) % 2019
        check[mod] += 1
    answer = 0
    for i in range(2019):
        answer += ((check[i] - 1) * check[i]) // 2
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    vector<int>cnt(a[n-1]+10,0);
    for(int i=0;i<n;i++){
        cnt[a[i]]++;
    }
    int ans=0;
    for(int i=0;i<=a[n-1];i++){
        ans = max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4036
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  Scanner sc;

  Main() {
    sc = new Scanner(System.in);
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  String ans;
  ArrayList<String> list;
  int count;

  void dfs(String str) {
    //check
    char[] rep = str.toCharArray();
    for (int i = 'b'; i <= 'z'; ++i) {
//      rep = rep.replaceFirst((char) i + "", (char) (i - 1) + "");
      for (int j = 0; j < str.length(); ++j) {
        if (str.charAt(j) == i) {
          rep[j] = (char) (i - 1);
          break;
        }
      }
    }
    boolean flag = true;
    for (int i = 0; i < str.length(); ++i) {
      flag &= rep[i] == ans.charAt(i);
    }
    if (!flag) {
      return;
    }
    if (str.length() == ans.length()) {
      if (list.size() < 10) {
        list.add(str);
      } else {
        list.remove(5);
        list.add(str);
      }
      ++count;
    } else {
      char c = ans.charAt(str.length());
      dfs(str + c);
      if (c != 'z') {
        dfs(str + (char) (c + 1));
      }
    }
  }

  void run() {
    for (; ; ) {
      ans = sc.next();
      if (ans.equals("#")) {
        break;
      }
      list = new ArrayList<>();
      count = 0;

      dfs("");

//      debug(list);

      System.out.println(count);
      for (int i = 0; i < Math.min(count, 10); ++i) {
        System.out.println(list.get(i));
      }
    }
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

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

int main() {
    long long N; cin >> N;
    string S; cin >> S;
    vector<long long>West(N, 0), East(N, 0);
    if (S.at(0) == 'W') West.at(0) = 1;
    for (long long i = 1; i < N; i++) {
        if (S.at(i) == 'W') {
            West.at(i) = West.at(i - 1) + 1;
        }
        else {
            West.at(i) = West.at(i - 1);
        }
    }
    if (S.at(N - 1) == 'E') East.at(N - 1) = 1;
    for (long long i = N - 2; i >= 0; i--) {

        if (S.at(i) == 'E') {
            East.at(i) = East.at(i + 1) + 1;
        }
        else{
            East.at(i) = East.at(i + 1);
        }
    }
    long long ans = min(East.at(0), West.at(N - 1));
    for (long long i = 1; i < N - 1; i++) {
        ans = min(ans, West.at(i - 1) + East.at(i + 1));
    }
    cout << ans << endl;
}

Measured memory_bytes: 8224
#include<iostream>
#include<cstring>
using namespace std;
int main() 
{
    int k;
    char S[110];
    cin>>k>>S;
    int l=strlen(S);
    if(l>k) 
    {
        S[k]='.';
        S[k+1]='.';
        S[k+2]='.';
        S[k+3]='\0';
    }
    cout<<S<<endl;
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
        ios_base::sync_with_stdio(false);
        int N, H, W, ans=0;

        cin >> N >> H >> W;

        ans = (N-H+1) * (N-W+1);

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String[] array = br.readLine().split(" ");
			int N = Integer.parseInt(array[0]);
			int C = Integer.parseInt(array[1]);

			List<TVData> list = new ArrayList<>(N);
			for (int i = 0; i < N; i++) {
				list.add(new TVData(br.readLine()));
			}
			final int[] table = new int[2 * 100_001];
			final boolean[] tmp = new boolean[2 * 100_001];
			for (int channel = 1; channel <= C; channel++, init(tmp)) {
				final int c = channel;
				list.parallelStream().filter(data -> data.channel == c).forEach(data -> {
					for (int i = data.start * 2 - 1; i <= data.end * 2; i++) {
						tmp[i] = true;
					}
				});
				for (int i = 0; i < table.length; i++) {
					if (tmp[i]) {
						table[i]++;
					}
				}
			}

			System.out.println(Arrays.stream(table).max().getAsInt());
		}
	}

	private static void init(boolean[] tmp) {
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = false;
		}
	}

	public static class TVData {
		private final int channel;
		private final int start;
		private final int end;

		public TVData(String line) {
			int[] tmp = Arrays.stream(line.split(" ")).mapToInt(Integer::parseInt).toArray();
			start = tmp[0];
			end = tmp[1];
			channel = tmp[2];
		}
	}

}


Measured memory_bytes: 63052
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
typedef long long ll;
typedef long double ld;

int N;
int dp[10][10] = { 0 };
ll res = 0;

void digit_array(int n){
    int x;
    for(int i = 0; i <= n; i++){
        x = i;
        while(x >= 10) x /= 10;
        ++dp[x][i%10];
    }
}

int main(){
    cin >> N;
    digit_array(N);

    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++) res += dp[i][j] * dp[j][i];
    }

    cout << res << endl;
    return 0;

}

Measured memory_bytes: 3588
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
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=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int max_ab = max(x, y);
    ll min_yen = INF;
    REP(i, max_ab+1) {
        int ra, rb;
        ra = max(0, (int)(x-i));
        rb = max(0, (int)(y-i));
        min_yen = min(min_yen, ra*a+rb*b+i*2*c);
    }
    cout << min_yen << endl;
    return 0;
}

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

int main() {
    double n; cin >> n;
    double ans = 2. * sqrt(n * n / 2.);
    if (n >= 1.) ans = max(ans, floor(n) + 1.);

    printf("%.12f\n", ans);

    return 0;
}

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

using namespace std;

const int maxn = 101;
short f[maxn][maxn][maxn][maxn],sum1[maxn][maxn],sum2[maxn][maxn];
char s[maxn][maxn];
int n,m,sx,sy;

short Max(short a,short b)
{
    if (a > b)
        return a;
    return b;
}

void solve()
{
    int l1 = sx - 1,r1 = n - sx,l2 = sy - 1,r2 = m - sy; //上下左右
    for (int i = 0; i <= l1; i++)
        for (int j = 0; j <= r1; j++)
            for (int p = 0; p <= l2; p++)
                for (int q = 0; q <= r2; q++)
                {
                    int L = max(q + 1,sy - p),R = min(m - p,sy + q);
                    if (L <= R)
                    {
                        f[i + 1][j][p][q] = Max(f[i + 1][j][p][q],f[i][j][p][q] + (sx - i - 1 >= j + 1 ? sum1[sx - i - 1][R] - sum1[sx - i - 1][L - 1] : 0));
                        f[i][j + 1][p][q] = Max(f[i][j + 1][p][q],f[i][j][p][q] + (sx + j + 1 <= n - i ? sum1[sx + j + 1][R] - sum1[sx + j + 1][L - 1] : 0));
                    }
                    L = max(j + 1,sx - i),R = min(n - i,sx + j);
                    if (L <= R)
                    {
                        f[i][j][p + 1][q] = Max(f[i][j][p + 1][q],f[i][j][p][q] + (sy - p - 1 >= q + 1 ? sum2[R][sy - p - 1] - sum2[L - 1][sy - p - 1] : 0));
                        f[i][j][p][q + 1] = Max(f[i][j][p][q + 1],f[i][j][p][q] + (sy + q + 1 <= m - p ? sum2[R][sy + q + 1] - sum2[L - 1][sy + q + 1] : 0));
                    }
                }
    /*
    for (int i = 0; i <= l1; i++)
        for (int j = 0; j <= r1; j++)
            for (int p = 0; p <= l2; p++)
                for (int q = 0; q <= r2; q++)
                    cout << i << " " << j << " " << p << " " << q << " " << f[i][j][p][q] << endl;
                */
    cout << f[l1][r1][l2][r2] << endl;
}

int main()
{
    scanf("%d%d",&n,&m);
    for (int i = 1; i <= n; i++)
    {
        scanf("%s",s[i] + 1);
        for (int j = 1; j <= m; j++)
            if (s[i][j] == 'E')
            {
                sx = i;
                sy = j;
            }
    }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
        {
            sum1[i][j] = sum1[i][j - 1];
            sum2[i][j] = sum2[i - 1][j];
            if (s[i][j] == 'o')
                sum1[i][j]++,sum2[i][j]++;
        }
    solve();

    return 0;
}


Measured memory_bytes: 145792
#pragma comment(linker, "/STACK:640000000")
#include <bits/stdc++.h>

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);

const int maxn = 2222;
const int mod = (int)1e9 + 7;

int a[maxn], b[maxn], c[maxn];
int o[maxn];
int s[maxn], p[maxn];
ll pw[maxn];
ll sum[maxn];

bool cmp(int i, int j) {
	return c[i] < c[j];
}

int get(int x) {
	if (p[x] == x) return x;
	return p[x] = get(p[x]);
}

bool unite(int x, int y) {
	x = get(x);
	y = get(y);
	if (x == y) return false;
	if (s[x] < s[y]) swap(x, y);
	s[x] += s[y];
	p[y] = x;
	return true;
}

int main() {
	#ifdef LOCAL
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
	#endif

	int n, m; cin >> n >> m;
	ll w; cin >> w;

	pw[0] = 1;
	for (int i = 1; i <= m; i++) {
		pw[i] = 2 * pw[i - 1];
		pw[i] %= mod;
	}

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

	sort(o, o + m, cmp);
	
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			s[j] = 1;
			p[j] = j;
		}
		unite(a[i], b[i]);
		ll ss = c[i];
		for (int j = 0; j < m; j++) {
			int id = o[j];
			if (unite(a[id], b[id])) {
				ss += c[id];
			}
		}
		sum[i] = ss;
	}

	ll mi = *min_element(sum, sum + m);

	//cout << mi << " " << w << endl;

	if (mi > w) {
		cout << 0 << endl;
		return 0;
	}

	if (mi < w) {
		int lo = 0;
		int cnt = 0;
		for (int i = 0; i < m; i++) {
			if (sum[i] == w) cnt++;
			if (sum[i] < w) lo++;
		}
		cout << 2LL * ((pw[cnt] - 1 + mod) % mod) * pw[m - cnt - lo] % mod << endl;
		return 0;
	}

	int cnt = -(n - 1);
	for (int i = 0; i < m; i++) if (sum[i] == w) cnt++;

	cout << (((pw[n - 1] - 2 + mod) % mod) * 1LL * pw[m - (n - 1)] + 2LL * (pw[cnt] - 1 + mod) * pw[m - cnt - (n - 1)]) % mod << endl;

	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
    int n, a;
    cin >> n >> a;

    if (n % 500 == 0 || n % 500 <= a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

map<ll, int> prime_factor(ll n)
{
    map<ll, int> ret;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();
    ll n,m; cin >> n >> m;
    auto mp = prime_factor(m);
    ll ans = 1;
    for(auto p:mp){
        (ans *= COM(p.second+n-1,p.second))%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 23680
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a < 10 && b < 10) cout << a * b << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    string N;
    io.read(N);
    string ans = "No";
    if(N[0] == '9' || N[1] == '9'){
        ans = "Yes";
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin>>n;
  set<char>s;
  REP(i,0,n){
    char c;
    cin>>c;
    s.insert(c);
  }
  cout<<(s.size()==3?"Three":"Four")<<endl;

  return 0;
}


Measured memory_bytes: 256