akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
using namespace std;
 
const char dir[5]="NESW";
int dx[4]={0, 1, 0, -1};
int dy[4]={-1, 0, 1, 0};
 
int main(){
    while(1){
        int h,w;
        long long int l;
        cin >> h >> w >> l;
        if(w==0) break;
         
        vector<vector<char> > c(h+2, vector<char>(w+2, '#'));
        int sy, sx, ndir;
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                cin >> c[i][j];
                if(c[i][j]!='.' && c[i][j]!='#'){
                    sy = i;
                    sx = j;
                    for(int k=0; k<4; k++){
                        if(c[i][j] == dir[k]){
                            ndir = k;
                            break;
                        }
                    }
                }
            }
        }
         
        map<pair<int, pair<int,int> >, int> used;
        int y=sy, x=sx;
        bool flag=false;
        for(long long int i=0; i<l; i++){
            pair<int, pair<int,int> > key = make_pair(ndir, make_pair(y, x));
            if(used.count(key) != 0){
                long long int rem = i-used[key];
                long long int rnum = (l-i)%rem;
                used.clear();
                i = l-rnum-1;
                continue;
            }else{
                used[key] = i;
            }
            while(c[y+dy[ndir]][x+dx[ndir]] == '#') ndir = (ndir+1)%4;
            y += dy[ndir];
            x += dx[ndir];
        }
         
        if(!flag){
            cout << y << " " << x << " " << dir[ndir] << endl;
        }
         
    }
    return 0;
}

Measured memory_bytes: 3388
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
LL read(){
    LL f=1,x=0;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 100
#define INF 0x3f3f3f3f
int main(){
LL a=read(),k=read();
printf("%lld\n",min(a%k,1ll));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int a, b, c, d, e;

bool check(int m) {
  if (m * c > b) return false;
  return m + (b - m * c) / d >= a;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> a >> b >> c >> d >> e, a) {
    int ok = 0, ng = min(e, b / c) + 1;
    while (ng - ok > 1) {
      int m = (ok + ng) / 2;
      if (check(m)) ok = m;
      else ng = m;
    }
    if (ok == 0) cout << "NA" << endl;
    else cout << ok << " " << (b - ok * c) / d << endl;
  }

  return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define eb emplace_back
#define mp make_pair
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.length()/2;i++){
        ans+=(s[i]!=s[s.length()-1-i]);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    int s[m];
    int c[m];
    int ans = -1;
    string snum;
    for(int i=0;i<m;i++) cin >> s[i] >> c[i];
    for(int j=1000;j>=0;j--){
        bool ok = true;               
        snum = to_string(j);
        if(snum.size() != n) ok = false;
        for(int t=0;t<m;t++){
            if(snum[s[t]-1] != (char)('0' + c[t])) ok = false;
        }
        if(ok) ans = j;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]= new int[n+1];
        for (int i=1;i<=n;i++){
            a[i]=sc.nextInt();
        }
        for (int i=k+1;i<=n;i++){
            if (a[i]>a[i-k]){
                System.out.println("Yes");
            }
            else System.out.println("No");
        }
    }
}

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





int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！
    int A,B;
    cin>>A>>B;
    if(A%2==0||B%2==0){
        cout << "No"<< endl;
    }else{
        cout << "Yes"<< endl;
    }
    


    


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>

#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int num[1005];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1,a2,a3,a4;
    //float f,g,h;
    char c;
    string s,s1;
    //priority_queue<int> pq;
    //map<string,int> mp;
    //map<string,int>::iterator iter;
    cin>>n;
    num[0]=0;num[1]=1;
    for(i=1;i<=sqrt(n);i++)
    {
        a=a1=i;
        while(i!=1)
        {
            a*=a1;
            if(a>n)
            {
                a/=a1;
                k=max(k,a);
                break;
            }
        }
    }
    cout<<k;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll n,ans=0;
    scanf("%lld",&n);
    ll a[n];
    rep(i,0,n){
        scanf("%lld",&a[i]);
    }
    sortup(a,n);
    ll sum=0;
    rep(i,0,n-1){
        if((sum+a[i])*2 >=a[i+1] ){
            ans++;
            sum+=a[i];
        }else{
            ans=0;
            sum+=a[i];
        }
    }
    ans++;
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

typedef long long ll;

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

ll n, a, w, t, r;

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    while(n--){

        string s;
        cin >> s;
        if(s == "AC")a++;
        else if(s == "WA")w++;
        else if(s == "TLE")t++;
        else if(s == "RE")r++;
    }
    cout << "AC x " << a << "\n";
    cout << "WA x " << w << "\n";
    cout << "TLE x " << t << "\n";
    cout << "RE x " << r << "\n";
    return 0;
}


Measured memory_bytes: 3664
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int count = -1;
        int N;
        String line;
        List<Restaurant> rList = new ArrayList<Restaurant>();
        while (sc.hasNextLine()) {
            line = sc.nextLine();
            if (line.equals("")) break;
            if (++count == 0) {
                N = Integer.parseInt(line);
            } else {
                String[] lineArr = line.split(" ");
                rList.add(restaurantFactory(count, lineArr[0], Integer.parseInt(lineArr[1])));
            }
        }

        Collections.sort(rList, new Comparator<Restaurant>() {
            @Override
            public int compare(Restaurant o1, Restaurant o2) {
                if (!o1.city.equals(o2.city)) return o1.city.compareTo(o2.city);

                return (-1) * o1.score.compareTo(o2.score);
            }
        });

        for (Restaurant r: rList) {
            System.out.println(r.index);
        }
    }

    private static Restaurant restaurantFactory(Integer index, String city, Integer score) {
        Restaurant r = new Restaurant();
        r.index = index;
        r.city = city;
        r.score = score;
        return r;
    }

    private static class Restaurant {
        Integer index;
        String city;
        Integer score;
    }
}


Measured memory_bytes: 23892
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include<string.h>
#include<iostream>
#include<queue>
using namespace std;
struct node{
    int data;
    node *lchild;
    node *rchild;
};
int pre[1000],in[1000];
node *create(int prel,int prer,int inl,int inr)
{
        if(prel>prer)
            return NULL;
        node *root =new node;
        root->data=pre[prel];
        int k;
        for(k=inl;k<=inr;k++)
        {
            if(in[k]==pre[prel])
            {
                break;
            }
        }
        int numl=k-inl;
        root->lchild=create(prel+1,prel+numl,inl,k-1);
        root->rchild=create(prel+numl+1,prer,k+1,inr);
        return root;
}
void ceng(node *root)
{
    queue<node*> q;
    q.push(root);
    while(!q.empty())
    {
        node *now =q.front();
        q.pop();
        cout<<now->data;
        if(now->lchild!=NULL)
            q.push(now->lchild);
        if(now->rchild!=NULL)q.push(now->rchild);
    }
}
long long GCD(long long a)
{
    for(int i=sqrt(a)+1;i>=0;i--)
    {
        if(a%i==0)
        {
            return i;
        }
    }
}
int main()
{
   long long k;
    cin>>k;
    long long  x=GCD(k);
    cout<<x+k/x-2;
	return 0;

}




Measured memory_bytes: 256
#include <stdio.h>

#define MAX_N 200000

void printCompare(int n, int as[], int len);


int main()
{
    int n, k;
    int as[MAX_N];
    
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++)
    {
	scanf("%d", &as[i]);
    }
    printCompare(n, as, k);

    return 0;
}


void printCompare(int n, int as[], int len)
{   
    for (int i = 0; i < n - len; i++)
    {
        int former = as[i];
        int latter = as[i + len];

        if (former < latter)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
}


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

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define all(a) (a).begin(),(a).end()

using vd = vector<double>;
using vvd = vector<vd>;

void add(vvd &sections, const vd &e){
  sections.push_back({e[2],0}); // 始点イベント
  sections.push_back({e[3],1}); // 終点イベント
}

void del(vvd &sections, const vd &e){
  vd tmp = {e[2],0};
  auto itr = find(all(sections),tmp);
  sections.erase(itr);
  tmp = {e[3],1};
  itr = find(all(sections),tmp);
  sections.erase(itr);
}

double sum(vvd &sections){
  double res = 0;
  sort(all(sections));
  double l = sections[0][0];
  int cnt = 1;
  FOR(i,1,sections.size())
    if(sections[i][1] == 0){
      cnt++;
      if(cnt == 1) l = sections[i][0];
    }else{
      cnt--;
      if(cnt == 0) res += sections[i][0] - l;
    }

  return res;
}

signed main(){
  int n, cnt = 1;
  while(cin >> n, n){
    vvd es;
    rep(i,n){
      double x,y,r;
      cin >> x >> y >> r;
      es.push_back({x-r,0,y-r,y+r}); // 追加イベント
      es.push_back({x+r,1,y-r,y+r}); // 削除イベント
    }
    sort(all(es));

    double ans = 0;
    vvd sections;
    add(sections, es[0]);
    FOR(i,1,es.size()){
      if(es[i][0] != es[i-1][0])
	ans += (es[i][0] - es[i-1][0]) * sum(sections);

      if(es[i][1] == 0)
	add(sections,es[i]);
      else
	del(sections,es[i]);
    }
    printf("%d %.2lf\n",cnt,ans);
    cnt++;
  }
}


Measured memory_bytes: 3200
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		if (a + b < k) System.out.println(0 + " " + 0);
		else if (a - k <= 0) {
			System.out.println(0 + " " + (b + a - k));
		} else {
			System.out.println((a - k) + " " + b);
		}
		
		sc.close();
	}

}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	llong N, Q;
	vector<vector<llong> > edges;
	vector<llong> cnt;

	cin >> N >> Q;
	edges.resize(N+1);
	cnt.resize(N+1, 0);

	llong a, b;
	for (int i = 0; i < N-1; ++i) {
		cin >> a >> b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}

	llong p, x;
	for (int i = 0; i < Q; ++i) {
		cin >> p >> x;
		cnt[p] += x;
	}

	queue<lpair> que;
	vector<llong> used(N+1, 0);
	que.push(lpair(0, 1));
	used[1] = 1;
	while (que.size()) {
		llong now = que.front().second;
		llong before = que.front().first;
		que.pop();

		cnt[now] += cnt[before];
		for (auto edge: edges[now]) {
			if (used[edge] == 1) continue;
			used[edge] = 1;
			que.push(lpair(now, edge));
		}
	}

	for (int i = 1; i <= N; ++i)
		cout << cnt[i] << " ";
	cout << endl;

	return 0;
}

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

int main()
{
    long long N, A, B;
    cin >> N >> A >> B;

    vector<long long> X(N);
    for (long long &x : X)
    {
        cin >> x;
    }

    long long ans = 0;
    for (int to = 1; to < N; to++)
    {
        int from = to - 1;
        ans += min(A * (X[to] - X[from]), B);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define speed                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define oprecision                                                             \
  cout.precision(30);                                                          \
  cerr.precision(7);
#define bb bool
#define ii int
#define ll long long
#define ff float
#define dd double
#define cc char
#define ss string
#define forn(sz) for (int i = 1; i <= sz; i++)
#define forni(i, sz) for (int i = 1; i <= sz; i++)
#define fornid(i, m, sz) for (int i = m; i <= sz; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vii vector<ii>
#define vii64 vector<ll>
#define vb vector<bb>
using namespace std;
int sz, a[100005], b[100005], c[100005], dp[100005][5];
int main() {
  speed;
  oprecision;
  /*#ifndef ONLINE_JUDGE
freopen("outd.txt", "rt", stdin);
#endif*/
  // code
  cin >> sz;
  forn(sz) cin >> a[i] >> b[i] >> c[i];
  forn(sz) {
    dp[i][1] = max(dp[i - 1][2] + b[i], dp[i - 1][3] + c[i]);
    dp[i][2] = max(dp[i - 1][1] + a[i], dp[i - 1][3] + c[i]);
    dp[i][3] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + b[i]);
  }
  cout << max({dp[sz][1], dp[sz][2], dp[sz][3]});
// endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


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

void Cont(){
    int N,L;
    cin >> N >>L;
    vector<string> Si(N);
    for(auto& v:Si)
        cin >> v;
    sort(Si.begin(),Si.end());
    
    for(const auto& v:Si)
        cout << v;
    cout << "\n";
    
}

int main()
{
	std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Cont();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF 1000000001
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
int main(){
      int n,m;
      string b;
      string io="OI";
      while(cin>>n&&n){
            string a="I";
            REP(i,n)a+=io;
            cin>>m;
            cin>>b;
            int al=a.length(),bl=b.length();
            ull ah=0,bh=0,t=1;
            REP(i,al)t*=B;
            REP(i,al)ah=ah*B+a[i];
            REP(i,al)bh=bh*B+b[i];
            int cnt=0;
            for(int i=0;i+al<=bl;i++){
                  if(ah==bh)cnt++;
                  if(i+al<bl)bh=bh*B+b[i+al]-b[i]*t;
            }
            cout<<cnt<<endl;
      }
}

Measured memory_bytes: 2156
n,x,m=map(int,input().split())
l,s=[0]*m,[0]*m
t=p=0
while l[x]<1:
  t+=1
  l[x]=t
  s[x]=s[p]+x
  p=x
  x=p*p%m
k=l[x]
d,m=divmod(n-k,t+1-k)
print((s[p]+x-s[x])*d+s[l.index(k+m)])

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> l(n);
  rep(i, n) cin >> l[i];
  sort(ALL(l));
  int ans = 0;
  for(int i = 0; i < n; ++i) {
    for(int j = i+1; j < n; ++j) {
      for(int k = j+1; k < n; ++k) {
        if(l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
        if(l[k] < l[i]+l[j]) ++ans;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

int main() {
    int64_t A, B, C, K;
    cin >> A >> B >> C >> K;
    if (A >= K){
        cout << K << endl;
    }
    else if (A + B >= K){
        cout << A << endl;
    }
    else {
        cout << A - (K - A - B) << endl;
    }
}

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

using namespace std;

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

    vector<long long> a(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int idx = 0;
    long long sum = 0;
    for (int i = 1; i <= n; ++i) {
        if (a[i] > sum * 2) idx = i;
        sum += a[i];
    }

    cout << n - idx + 1 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>

typedef long long ll;
#define INF 1e9

using namespace std;
const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int n, bool visited[nmax]){
    bool all_visited = true;

    for (int i = 0; i < n; i++){
        if(visited[i] == false)
        all_visited = false;
    }

    //辺を全部通ったら1を返す
    if(all_visited == true) return 1;

    int ret = 0;//回数
    for (int i = 0; i < n; i++){
        if(graph[v][i] == false) continue;//辺訪問済み
        if(visited[i]) continue; //点訪問済み

        visited[i] = true;
        ret += dfs(i, n, visited);
        visited[i] = false;//訪問前に再設定
    }
    return ret;
}

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

    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
    }

    bool visited[nmax];
    for (int i = 0; i < n; i++){
        visited[i] = false;
    }

    visited[0] = true; //出発点

    cout << dfs(0, n, visited) << endl;
    return 0;
}

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

int main( int argc, char *argv[] )
{
int i;
int N;
int K;
int L;
int iAns;

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

	cin >> N;
	cin >> K;

	L = K - 1;
	iAns = K;
	for( i = 1; i < N; i++ ) iAns *= L;

	cout << iAns << endl;

	return 0;
}


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

	int main() {
		int N;
		cin >> N;
		vector < int>t;
		int suma = 0;
		for (int i = 0; i < N; i++) {
			int a;
			cin >> a;
			suma += a;
			if (a % 10 != 0) {
				t.push_back(a);
			}
		}
		int minElement = *std::min_element(t.begin(), t.end());

		
		if (suma % 10 == 0 && !t.empty()) {
			suma -= minElement;
			cout << suma << endl;

		}
		else if (t.empty()) {
			cout << 0 << endl;
		}
		else cout << suma << endl;
		
		return 0;
	}	

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

int main(void) {
	char s[11];
	int cout = 0, max = 0;
	scanf("%s", s);

	for (int i = 0; i < strlen(s);++i) {
		if (s[i] == 'A' || s[i] == 'C' ||
			s[i] == 'G' || s[i] == 'T') {
			++cout;
			max = cout > max ? cout : max;
		}else{
			cout = 0;
		}
	}
	printf("%d", max);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ld long double
typedef pair<ll,ll> P;
#define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
int main()
{
    ll n,i,j;
    cin>>n;
    ld DP[n+1];
    ld p_head;
    memset(DP,0,sizeof(DP));
    DP[0]=1;
    for(i=0;i<n;i++){
        cin>>p_head;
        for(j=i+1;j>=0;j--){
            DP[j]= (j==0?0:DP[j-1]*p_head)+DP[j]*(1-p_head);
        }
    }
    ld ans=0;
    for(ll Head=0;Head<=n;Head++){
        ll Tail=n-Head;
        if(Head>Tail)
        {ans=ans+DP[Head];}
    }
    cout<<setprecision(10)<<ans<<endl;
}


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

int main(){
int N;
cin >> N;
int ans;
if (N <= 9) {
    ans = N;
} else if (N >= 10 && N <= 99) {
    ans = 9;
} else if (N >= 100 && N <= 999) {
    ans = 9 - 99 + N;    
} else if (N >= 1000 && N <= 9999) {
    ans = 9 - 99 + 999;
} else if (N >= 10000 && N <= 99999) {
    ans = 9 - 99 + 999 - 9999 + N;
} else if (N == 100000) {
    ans = 9 - 99 + 999 - 9999 + 99999;
}
cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s1,s2;
    cin>>s1>>s2;
    std::deque<char> deq1;
    std::deque<char> deq2;
    for (int i=0;i<s1.size();i++) {
        deq1.emplace_back(s1.at(i));
    }
    for (int j=0;j<s2.size();j++) {
        deq2.emplace_back(s2.at(j));
    }
    if (deq1.size()-deq2.size()==0) {
        for (int k=0;k<deq1.size();k++) {
            cout<<deq1[k]<<deq2[k];
        }
        cout<<endl;
    } else {
        for (int l=0;l<deq1.size();l++) {
            if (l!=deq1.size()-1) {
                cout<<deq1[l]<<deq2[l];
            } else {
                cout<<deq1[l];
            }
        }
        cout<<endl;
    }
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var whn = Console.ReadLine().Split();
        var w = int.Parse(whn[0]);
        var h = int.Parse(whn[1]);
        var n = int.Parse(whn[2]);

        var x = new int[n];
        var y = new int[n];
        var a = new int[n];
        for (int i = 0; i < n; i++)
        {
            var xya = Console.ReadLine().Split();
            x[i] = int.Parse(xya[0]);
            y[i] = int.Parse(xya[1]);
            a[i] = int.Parse(xya[2]);
        }

        var x1 = 0;
        var y1 = 0;
        var x2 = w;
        var y2 = h;
        for (int i = 0; i < n; i++)
        {
            if (a[i] == 1)
            {
                x1 = Math.Min(x2, Math.Max(x1, x[i]));
            }
            else if (a[i] == 2)
            {
                x2 = Math.Max(x1, Math.Min(x2, x[i]));
            }
            else if (a[i] == 3)
            {
                y1 = Math.Min(y2, Math.Max(y1, y[i]));
            }
            else
            {
                y2 = Math.Max(y1, Math.Min(y2, y[i]));
            }
        }

        Console.WriteLine((x2 - x1) * (y2 - y1));
    }
}


Measured memory_bytes: 13140
n,m = map(int,input().split())
A = []
ans = 0
for _ in range(m):
    A.append(list(map(int,input().split())))
P = list(map(int,input().split()))
for bit in range(1<<n):
    flag = True
    for i in range(m):
        cnt = 0
        k,S = A[i][0],A[i][1:]
        for s in S:
            if ((bit>>(s-1))&1) and flag == True:
                cnt += 1
        if cnt %2==P[i]:
            continue
        else:
            flag = False
    if flag:
        ans += 1
print(ans)



Measured memory_bytes: 9184
import sys

def read():
	return int(sys.stdin.readline().rstrip())
def reads():
	return list(map(int, sys.stdin.readline().rstrip().split()))
def read_s(n: int):
	return list(map(int, [read() for _ in range(n)]))

N, K, Q = reads()
A = read_s(Q)

S = [0 for _ in range(N)]

for a in A:
  S[a-1] += 1
  
for s in S:
  if K - Q + s > 0:
    print("Yes")
  else:
    print("No")


Measured memory_bytes: 8616
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
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; }
#define int long long

void solve() {
	int n; cin >> n;
    int res = n - 1;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            int m = n / i;
            int tmp = (i - 1) + (m - 1);
            chmin(res, tmp);
        }
    }
    cout << res << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
/*
2020-05-05
atcoder ABC
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N;
    cin >> N;
    N %= 10;
    switch(N){
        case 2:
        case 4:
        case 5:
        case 7:
      	case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
        default: 
            break;
    }
    
    return 0;
}


Measured memory_bytes: 3636
namespace VainZero.Procon.FSharp

open System
open System.Collections.Generic

[<AutoOpen>]
module Operators =
  let read f = Console.ReadLine().Split([|' '|]) |> Array.map f

module Program =
  [<EntryPoint>]
  let main _ =
    let [|n|] = read int
    let xs = read int
    let calc () =
      let xs = xs |> Array.sort
      (xs |> Array.last) - xs.[0]
    printfn "%d" (calc ())
    0


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

typedef long long ll;

const int N = 1001;

struct cake {
	ll x, y, z;
	ll xi, yi, zi;
	cake(ll _x = 0, ll _y = 0, ll _z = 0): x(_x), y(_y), z(_z) {}
} cakes[N];

int main () {
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++) {
		ll x, y, z; cin >> x >> y >> z;
		cakes[i] = cake(x,y,z);
	}
	ll ans = -10000000000*m-1;
	for (int i = 0; i < 8; i++) {
		ll xi = (i&1 ? -1 : 1);
		ll yi = (i&(1<<1) ? -1 : 1);
		ll zi = (i&(1<<2) ? -1 : 1);
		sort(cakes, cakes+n, [=](const cake& a, const cake& b){
			return (a.x*xi+a.y*yi+a.z*zi) < (b.x*xi+b.y*yi+b.z*zi);
		});
		ll temp = 0;
		for (int j = n-1; j > n-1-m; j--)
			temp += cakes[j].x*xi+cakes[j].y*yi+cakes[j].z*zi;
		ans = max(ans, temp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

int main(void){
  long n;
  std::cin >> n;

  if(n==0){
    std::cout << "0" << std::endl;
    return 0;
  }

  std::vector<long> lower;
  std::vector<long> upper;

  long minus = 0;
  long plus = 0;
  int dec = 1;
  lower.push_back(0);
  upper.push_back(1);
  while(true){
    if(dec%2){
      lower.push_back(lower[dec-1] + std::pow(-2, dec));
      upper.push_back(upper[dec-1]);
    }else{
      lower.push_back(lower[dec-1]);
      upper.push_back(upper[dec-1] + std::pow(-2, dec));
    }
    //std::cout << lower[dec] << " " << upper[dec] << std::endl;
    if(n<0){
      if(lower[dec] < n) break;
    }else{
      if(upper[dec] > n) break;
    }

    dec++;
  }

  for(int i=dec; i>=1; i--){
    if(i%2){
      if(lower[i-1] > n){
        std::cout << "1";
        n -= std::pow(-2, i);
      }else{
        std::cout << "0";
      }
    }else{
      if(upper[i-1] < n){
        std::cout << "1";
        n -= std::pow(-2, i);
      }else{
        std::cout << "0";
      }
    }
    //std::cout << std::endl << "a" << n << std::endl;                                                                 
  }
  std::cout << (n?"1":"0");
  std::cout << std::endl;




  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
 public static void main(String args[]){;
  Scanner scan = new Scanner(System.in);

  int a = Integer.parseInt(scan.next());
  int b = Integer.parseInt(scan.next());
  int c = Integer.parseInt(scan.next());
  
  if(a < b && b < c) {
    System.out.println("Yes");
  } else {
    System.out.println("No");
  }
 }
}

Measured memory_bytes: 17280
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> V;
typedef pair<ll,ll> P;
typedef map<ll,ll> M;

#define REP(i, n) for(ll (i) = 0; (i) < (n); ++(i))
#define FOR(i, j, n) for(ll (i) = (j); (i) < (n); ++(i))
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; --(i))

signed main(){

    int n;
    cin >> n;
    V r(n);
    V t(n);
    REP(i,n)cin >> r[i] >> t[i];

    REP(i,n){
        int kyo = r[i];
        int kak = t[i];
        V pos;
        pos.push_back(5 * (kak / 30) + kyo / 100);
        if(kyo % 100 != 0){
            pos.push_back(5 * (kak / 30) + kyo / 100 + 1);
        }
        if(kak % 30 != 0){
            pos.push_back(5 * (kak / 30) + kyo / 100 + 5);
            if(kyo % 100 != 0){
                pos.push_back(5 * (kak / 30) + kyo / 100 + 6);
            }
        }
        REP(i,pos.size() - 1)cout << pos[i] << " ";
        cout << pos.back() << endl;
    }

}



Measured memory_bytes: 3168
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    A, B = map(int, input().split())
    print('Possible' if any([A % 3 == 0,
                             B % 3 == 0,
                             (A + B) % 3 == 0]) else 'Impossible')


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int MAXN=500005;
typedef pair<int,int> kD;
typedef pair<kD,int> kDT;
vector<kDT> S, T;
vector<int> ans;

int main() {
  int n;
  cin >> n;
  for (int i=0; i<n; i++) {
    int x, y;
    cin >> x >> y;
    S.push_back(kDT(kD(x,y),i));
    T.push_back(kDT(kD(y,x),i));
  }
  sort(S.begin(),S.end());
  sort(T.begin(),T.end());
  int q;
  cin >> q;
  for (int i=0; i<q; i++) {
    int sx, tx, sy, ty;
    cin >> sx >> tx >> sy >> ty;
    int lx=lower_bound(S.begin(),S.end(),kDT(kD(sx,sy),0))-S.begin();
    int hx=upper_bound(S.begin(),S.end(),kDT(kD(tx,ty),n))-S.begin();
    int ly=lower_bound(T.begin(),T.end(),kDT(kD(sy,sx),0))-T.begin();
    int hy=upper_bound(T.begin(),T.end(),kDT(kD(ty,tx),n))-T.begin();
    int wx=hx-lx;
    int wy=hy-ly;
    if (wx<wy) {
      for (int i=lx; i<hx; i++) {
        int y=S[i].first.second;
        if (sy<=y && y<=ty) {
          ans.push_back(S[i].second);
        }
      }
    } else {
      for (int i=ly; i<hy; i++) {
        int x=T[i].first.second;
        if (sx<=x && x<=tx) {
          ans.push_back(T[i].second);
        }
      }
    }
    sort(ans.begin(),ans.end());
    for (int i=0; i<ans.size(); i++) {
      printf("%d\n",ans[i]);
    }
    printf("\n");
    ans.clear();
  }
  return 0;
}

Measured memory_bytes: 14564
#include<iostream>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
ll N,M,K;
main()
{
    cin>>N>>M>>K;
    ll A=1,B=1,C=1;
    for(int i=1;i<=M*N-2;i++)A=A*i%mod;
    for(int i=1;i<=M*N-K;i++)B=B*i%mod;
    for(int i=1;i<=K-2;i++)C=C*i%mod;
	cout<<A*power(B*C%mod,mod-2)%mod*((mod+1)/2)%mod*(N*N%mod*M%mod*(M+1)%mod*(M-1)%mod+M*M%mod*N%mod*(N+1)%mod*(N-1)%mod)%mod*power(3,mod-2)%mod<<endl;
    return 0;
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	string s = to_string(n);
	if ((s[0] == s[1] && s[0] == s[2]) || (s[1] == s[2] && s[1] == s[3])) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <algorithm>

int main()
{
    std::map<std::string, int> ItemData;
    int Item_num;
    
    while (std::cin >> Item_num) {
        if (Item_num == 0) break;
        
        
        for (int i = 0; i < Item_num; ++i) {
            std::string ItemName;
            int ItemPrice;
            
            std::cin >> ItemName >> ItemPrice;
            ItemData[ItemName] = ItemPrice;
        }
        
        int mix_num;
        
        std::cin >> mix_num;
        
        for (int i = 0; i < mix_num; ++i) {
            std::string ItemName;
            int Material_num;
            
            std::cin >> ItemName >> Material_num;
            
            int temp = 0;
            std::string MaterialName;

            for (int j = 0; j < Material_num; ++j) {
                std::cin >> MaterialName;
                temp += ItemData[MaterialName];
            }
                
            ItemData[ItemName] = std::min(ItemData[ItemName], temp);
        }
        
        std::string Material;
        
        std::cin >> Material;
        
        std::cout << ItemData[Material] << std::endl;
    }
    
    return 0;
}

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

using namespace std;
const int N = 200010;
int _w;

int n;
char str[N];

bool check( int l1, int r1, int l2, int r2 ) {
	if( (r1-l1) != (r2-l2) ) return true;
	if( l2 < 0 ) return false;
	for( int i = 0; i <= (r1-l1); ++i )
		if( str[l1+i] != str[l2+i] )
			return true;
	return false;
}

int f[N][3];

void dp() {
	f[0][0] = 0;
	for( int i = 1; i <= n; ++i )
		for( int j = 0; j < 3 && j < i; ++j ) {
			if( check(i-j, i, i-j-1, i-j-1) )
				f[i][j] = max( f[i][j], f[i-j-1][0] + 1 );
			if( check(i-j, i, i-j-2, i-j-1) )
				f[i][j] = max( f[i][j], f[i-j-1][1] + 1 );
			if( check(i-j, i, i-j-3, i-j-1) )
				f[i][j] = max( f[i][j], f[i-j-1][2] + 1 );
		}
	cout << *max_element(f[n], f[n]+3) << endl;
}

int main() {
	cin >> (str+1);
	n = (int)strlen(str+1);
	dp();
	return 0;
}


Measured memory_bytes: 6108
// once more
#include <bits/stdc++.h>
using namespace std;
typedef long long llong;

static const int INF = 1e9;

int main(void) {
  int N, M;
  cin >> N >> M;
  
  int a[M], b[M], c[M][N];

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

  int dp[(1<<N)];
  for(int i=0;i<(1<<N);i++) {
    dp[i] = INF;
  }

  dp[0] = 0;

  for(int i=0;i<M;i++) {
    int open = 0;
    for(int j=0;j<b[i];j++) {
      open |= (1<<(c[i][j]-1));
    } 
    for(int boxes=0;boxes<(1<<N);boxes++) {
      dp[boxes|open] = min(dp[boxes|open], dp[boxes]+a[i]);
    }
  }
  if(dp[((1<<N)-1)]==INF) dp[((1<<N)-1)] = -1;
  cout << dp[((1<<N)-1)] << endl;

  return (0);
}

//keyword:bitDP


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int n,m,x,y,a;
int Max_x,Min_y;
int main()
{
	scanf("%d%d%d%d",&n,&m,&x,&y);
	Max_x=x;
	Min_y=y;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(a>Max_x)
			Max_x=a;
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&a);
		if(a<Min_y)
			Min_y=a;
	}
	if(Max_x<Min_y&&x<y)
		printf("No War\n");
	else
		printf("War\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double db;
typedef vector<ll> VI;
typedef vector<pair<ll,ll> > VII;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
//
#define M 1000000007
#define INF (ll)0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define itr iterator
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}

void error_out() { cerr << endl; }
template <typename Head, typename... Tail>
void error_out(Head H, Tail... T) {
  cerr << " " << H;
  error_out(T...);
}
void time_elapsed(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}
#ifndef ONLINE_JUDGE
#define error(...) cerr << "[" << #__VA_ARGS__ << "]:", error_out(__VA_ARGS__)
#define fioe() fileioe()
#define time() time_elapsed()
#else
#define error(...) 1
#define fioe() 1
#define time() 1
#endif


//
int main()
{
	GO
	//fioe();
	ll h,w;
	cin>>h>>w;
	string s[h+3];
	for(ll i=0;i<h;i++){
		cin>>s[i];
	}
	ll arr[h+3][w+3];
	memset(arr,0,sizeof(arr));
	ll i=0;
	while(s[i][0]=='.'){
		arr[i++][0]=1;
	}
	ll j=0;
	while(s[0][j]=='.'){
		arr[0][j++]=1;
	}
	for(ll i=1;i<h;i++){
		for(ll j=1;j<w;j++){
			if(s[i][j]=='.'){
				arr[i][j]=arr[i-1][j]+arr[i][j-1];
				arr[i][j]%=M;
			}
		}
	}
	cout<<arr[h-1][w-1]<<endl;
	time();
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int digits = log10(n) + 1;
    int count = 0;
    
    int check = n % (int)pow(10,digits-1);
    if(digits==1){
         count = n;
    }else if(check == 0){
         count = 10;
    }else{
        while(digits != 0){
            count = count + n / pow(10,digits-1);
            n = n % (int)pow(10,digits-1);
            digits--;
        }         
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(int argc, char** argv){
    int H, W, N, sr, sc;
    cin >> H >> W >> N >> sr >> sc;
    string S, T;
    cin >> S >> T;

    int cur = sc - 1;
    for (int i=0; i<N; i++){
        if (S[i] == 'R') cur++;
        if (cur == W){
            cout << "NO\n";
            return 0;
        }
        if (T[i] == 'L') cur = max(cur-1, 0);
    }

    cur = sc - 1;
    for (int i=0; i<N; i++){
        if (S[i] == 'L') cur--;
        if (cur == -1){
            cout << "NO\n";
            return 0;
        }
        if (T[i] == 'R') cur = min(cur+1, W-1);
    }

    cur = sr - 1;
    for (int i=0; i<N; i++){
        if (S[i] == 'D') cur++;
        if (cur == H){
            cout << "NO\n";
            return 0;
        }
        if (T[i] == 'U') cur = max(cur-1, 0);
    }

    cur = sr - 1;
    for (int i=0; i<N; i++){
        if (S[i] == 'U') cur--;
        if (cur == -1){
            cout << "NO\n";
            return 0;
        }
        if (T[i] == 'D') cur = min(cur+1, H-1);
    }

    cout << "YES\n";

    return 0;
}


Measured memory_bytes: 776
#include<iostream>
#include<cstdio>

using namespace std;

#define maxn 100000
char str[maxn];

inline int readin(){
    int x=0,s=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')s=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*s;
}

int main(){
    int n;
    scanf("%s",str);
    n=readin();
    for(int i=0,j=n;str[i]!='\0';++i,++j)
	if(j==n)printf("%c",str[i]),j=0;
    puts("");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> a(n+1,0);
    for(int i=0;i<m;i++){
        int ai;
        cin >> ai;
        a[ai]++;
    }

    int l=0;
    for(int i=x;i>0;i--){
        l+=a[i];
    }

    int r=0;
    for(int i=x;i<n;i++){
        r+=a[i];
    }

    cout << std::min(l,r) << endl;
    return 0;
}



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

int main(int argc, const char * argv[]) {



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

    /////////////////////
    // Write code below /
    /////////////////////
    
    int S,W;

    cin >>S >>W;

    if(S>W)
        cout <<"safe"<<endl;
    else
    {
        cout <<"unsafe"<<endl;
    }
    


    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define float long double
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define g(t, n) get<n>(t)
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)2e5+5;
const int mod = (int)1e9+7;

void solve()
{
    int n;
    cin>>n;
    int a[n], ans = 0;
    f(i, 0, n) cin>>a[i];
    f(i, 0, n)
    {
    	f(j, i+1, n)
    	{
    		f(k, j+1, n)
    		{
    			if(a[i]+a[j] > a[k] && a[i]+a[k] > a[j] && a[j]+a[k] > a[i] && a[i] != a[j] && a[i] != a[k] && a[j] != a[k]) ans++;
    		}
    	}
    }
    cout<<ans<<endl;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        // cout<<"Case #"<<tno<<": ";
        solve();
    }
    return 0;
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        cin >> v[i];
    vector<vector<int>> dp(n, vector<int>(n));

    for(int l=n-1;l>=0;l--)
    {
        for(int r=l;r<n;r++)
        {
            if(l == r) dp[l][r] = v[l];
            else
                dp[l][r] = max(v[l] - dp[l+1][r], v[r] - dp[l][r-1]);
        }
    }
    cout << dp[0][n-1] << "\n";

    return 0;
}



Measured memory_bytes: 70784