akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

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

int h, w;
string s[50];
int minCost[50][50];

signed main() {
	int i, j;
	
	cin >> h >> w;
	rep(i, h) cin >> s[i];
	
	rep(i, h) rep(j, w) minCost[i][j] = 114514;
	
	queue<int> que;
	minCost[0][0] = 0;
	que.push(0);
	que.push(0);
	while (!que.empty()) {
		int y = que.front(); que.pop();
		int x = que.front(); que.pop();
		rep(i, 4) {
			int ny = y + dy[i];
			int nx = x + dx[i];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w || s[ny][nx] == '#' || minCost[ny][nx] <= minCost[y][x] + 1) continue;
			minCost[ny][nx] = minCost[y][x] + 1;
			que.push(ny);
			que.push(nx);
		}
	}
	
	if (minCost[h - 1][w - 1] >= 114514) { cout << "-1" << endl; return 0; }
	
	int cnt = 0;
	rep(i, h) rep(j, w) cnt += (s[i][j] == '.');
	cout << cnt - minCost[h - 1][w - 1] - 1 << endl;
	return 0;
}

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

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int ans = 0;
    for (int a = 0; a <= A; a++) {
        for (int b = 0; b <= B; b++) {
            for (int c = 0; c <= C; c++) {
                if (500 * a + 100 * b + 50 * c == X) ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,x=1,b,i=0;

    scanf("%d",&a);

    int A[a];

    while(i<a){
        scanf("%d",&A[i]);
        i++;
    }

    b=A[0];
    i=1;

    while(i<a){

        if(A[i]<b)
        {
            b=A[i];
            x++;

        }

        i++;
    }

    printf("%d\n",x);

    return 0;
}


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

using namespace std;
int main(){
	string input;
	cin >> input;
	string  target;
	cin >> target;
	input+=input;
	if(input.find(target)==-1)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}
//find??¢??°???????????????????????????????????????????´¢????±?????????????????????????????????????????????????
//1????????????0??§???????????´??????-1????????????

Measured memory_bytes: 3160
q = int(input())
l = [list(map(int,input().split())) for _ in range(q)]

def prime_table(n):
    list = [True for _ in range(n+1)]
    for i in range(2,int(n**0.5)+1):
        if list[i]:
            j = i*2
            while j<=n:
                list[j] = False
                j += i
    table = [i for i in range(n+1) if list[i] and i>=2]
    return table

table = prime_table(10**5)
sim_sum = [0]*(10**5+1)

for i in range(len(table)):
    if table[i]*2-1 in table:
        sim_sum[table[i]*2-1] += 1
for i in range(1,10**5+1):
    sim_sum[i] += sim_sum[i-1]
for l_ in l:
    print(sim_sum[l_[1]]-sim_sum[max(l_[0]-2,0)])

Measured memory_bytes: 32048
N = int(input())
mlist = [[]] * N
for i in range(N):
  mlist[i]  = list(map(str, input().split()))
X = str(input())
for j in range(N):
  if mlist[j][0] == X:
    mNo = range(j+1, N)
print(sum(int(mlist[k][1]) for k in mNo ))

Measured memory_bytes: 3060
### subroutines

def get_link(page, x, y)
  for bt in page
    x1, y1, x2, y2, link = bt
    return link if x1 <= x && x <= x2 && y1 <= y && y <= y2
  end
  nil
end

### main

loop do
  n = gets.to_i
  break if n == 0

  w, h = gets.split.map(&:to_i)

  pages = {}
  buffer = []
  nbuf = pos = 0

  n.times do
    title, nb = gets.strip.split
    pages[title] = []
    nb.to_i.times do
      bts = gets.strip.split
      pages[title] << bts[0, 4].map(&:to_i) + [bts[4]]
    end

    if nbuf == 0
      buffer << title
      nbuf = 1
    end
  end
  #p pages

  m = gets.to_i

  m.times do
    ops = gets.split

    case ops[0]
    when 'click'
      x, y = ops[1, 2].map(&:to_i)
      link = get_link(pages[buffer[pos]], x, y)
      if ! link.nil?
        pos += 1
        buffer[pos] = link
        nbuf = pos + 1
      end
    when 'back'
      pos -= 1 if pos > 0
    when 'forward'
      pos += 1 if pos < nbuf - 1
    when 'show'
      puts buffer[pos]
    end
  end
end

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

int main()
{
    int n;
    cin>>n;
    int arr[n+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    int flag=0;
    for(int i=0;i<n;i++)
    {
        if(arr[i]%2==0)
        {
            if(arr[i]%3!=0&&arr[i]%5!=0)
            {
                flag++;
                break;
            }
        }
    }
    if(flag==0)cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s[i]=='1')ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())

l = list(map(int, input().split()))

count = 0

for i in range(len(l)-2):
  for j in range(i+1, len(l)-1):
    for k in range(j+1, len(l)):
      n1 = l[i]
      n2 = l[j]
      n3 = l[k]
      if n1 < n2 + n3 and n2 < n1 + n3 and n3 < n1 + n2:
        if n1 != n2 and n1 != n3 and n2 != n3:
          count = count + 1
      else:
        continue

print(count)

Measured memory_bytes: 9148
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{ 
 

ll a,b,k;
cin>>a>>b>>k;

if(a+b<=k)
cout<<0<<" "<<0<<endl;
else if(a>=k)
cout<<a-k<<" "<<b<<endl;
else 
cout<<0<<" "<<b-(k-a)<<endl;
  }

Measured memory_bytes: 256
/*input
4664
*/
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define pii pair<ll,ll>
#define list vector<ll>
#define mp make_pair
#define vp vector< pair<ll,ll> >
#define in insert
#define pb push_back
#define ft first
#define sd second
#define matrix vector< vector<ll> >
#define all(x) x.begin(),x.end()
#define line string
#define rall(x) x.rbegin(),x.rend()
#define f(i,n) for(ll i=1;i<=n;i++) 
ll mod=(ll)(1e9+7);
ll total[101];
ll N;
ll solve(ll pos,ll cnt,ll foo)
{
	if(cnt==0)return foo;
	ll ans=0;
	for(ll i=1;i<=N;i++)
		if(i!=pos)
			{
					ans+=solve(i,cnt-1,foo+total[pos]);
			}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll N;
	cin>>N;
	for(ll h=1;h<=3500;h++)
		for(ll n=1;n<=3500;n++)
		{
			ll num=h*N*n;
			ll deno=4*h*n-(n+h)*N;
			if(num>0&&deno>0&&num%deno==0)
			{
				cout<<h<<" "<<n<<" "<<(num/deno)<<endl;
				return 0 ;
			}
		}
	return 0 ;
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N;

  void init() {
    scanf("%lld", &N);
  }

  void solve() {
    ll n = 100, i = 1;
    while(1) {
      n = floor(n * 1.01);
      if(n >= N) break;
      i++;
    }
    cout << i << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <cmath>

using namespace std;


class B {
	int MOD{ 7 + (int)pow(10, 9) };
	int N;
	int64_t ans{ 1 };
public:
	void solve()
	{
		cin >> N;

		for (int i{ 1 }; i <= N; i++)
		{
			ans *= i;
			ans %= MOD;
		}

		cout << ans << endl;
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int upper = min(b,d);
    int lower = max(a,c);
    cout << max(0, upper - lower) << endl;
}

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

class tousen{
  public:
    char num[9];
    long money;
};

bool se(char *x,tousen y){
  for(int i=8;i>=0;i--){
    if (y.num[i]=='*')return true;
    else if(x[i]!=y.num[i])return false;
  }
  return true;
}

int main(){
  int n,m;
  long long getmon;
  tousen x[100];
  char have[9];
  while(1){
    scanf("%d %d",&n,&m);
    if(!n||!m)break;
    getmon = 0;
    for(int i=0;i<n;i++){
      scanf("%s %ld",x[i].num,&x[i].money);
    }
    for(int i=0;i<m;i++){
      scanf("%s",have);
      for(int j=0;j<n;j++){
        if(se(have,x[j]))getmon += x[j].money;
      }
    }
    printf("%lld\n",getmon);
  }
  return 0;
}

Measured memory_bytes: 1032
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N, D = MI()
    print((N+2*D)//(1+2*D))

if __name__ == '__main__':
    solve()



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

#define ARRAY_LENGTH (100010)

// Infinity value
const long long INF = 1LL << 60;

long long dp[110][ARRAY_LENGTH];
long long w[110];
long long v[110];

template<class T>
bool chmin(T& a, T b){
  if(a > b){
    a = b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool chmax(T& a, T b){
  if(a < b){
    a = b;
    return true;
  }else{
    return false;
  }
}

int main(void)
{
  int N, W;

  std::cin >> N >> W;

  // Input costs
  for(int i = 0;i < N;i++){
    std::cin >> w[i] >> v[i];
  }

  // Initialize DP
  for(int i = 0;i < N;i++){
    for(int j = 0;j < ARRAY_LENGTH;j++){
      dp[i][j] = 0;
    }
  }

  // Loop
  for(int i = 1;i <= N;i++){
    for(int sum_w = 0;sum_w <= W;sum_w++){
      dp[i][sum_w] = dp[i-1][sum_w];
    }

    for(int sum_w = 0;sum_w <= W;sum_w++){
      chmax(dp[i][sum_w+w[i-1]], dp[i-1][sum_w] + v[i-1]);
      //chmax(dp[i][sum_w], dp[i-1][sum_w]);
    }
  }

  std::cout << dp[N][W] << std::endl;

  return 0;
}


Measured memory_bytes: 80128
package main

import (
	"fmt"
	"sort"
)

func main() {
	var (
		s string
		k int
	)
	fmt.Scan(&s, &k)

	m := make(map[string]bool)
	xs := make([]string, 0, len(s)*(len(s)+1)/2)
	for i := 1; i <= k; i++ {
		for j := 0; j+i <= len(s); j++ {
			w := s[j : j+i]
			if m[w] {
				continue
			}
			m[w] = true
			xs = append(xs, w)
		}
	}

	sort.Strings(xs)
	fmt.Println(xs[k-1])
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int x,y;
    cin>>n;
    cout<<1000*(n/500)+(5*((n%500)/5));
}
 
 
signed main()
{

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        // if(t)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3540
#include <stdio.h>
#include <map>
using namespace std;
char txt[200001];
int dp[2][10001];
int ddp[10001];
int main(){
	int N,P;scanf("%d %d\n",&N,&P);
	scanf("%s",txt);
	long long sum = 0;
	if(P<400){
		for(int i=0;i<N;i++){
		int nxt = i%2;
		int cnt=1-i%2;
		int d = txt[i]-'0';
		for(int j=0;j<P;j++) dp[nxt][j]=0;
		for(int j=0;j<P;j++){
			dp[nxt][(10*j+d)%P]+=dp[cnt][j];
		}
		dp[nxt][d%P]++;
		sum += dp[nxt][0];
		}
		printf("%lld",sum);
	}
	else{
		int cnt=0,p=1;
		for(int i=N-1;i>=0;i--){
			cnt=((txt[i]-'0')*p)%P + cnt;
			cnt%=P;
			ddp[cnt]++;
			p=(p*10)%P;
		}
		sum=ddp[0];
		for(int i=0;i<P;i++) sum+=1LL*ddp[i]*(ddp[i]-1)/2;
		printf("%lld",sum);
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n; string s;
    cin >> n >> s;
    if(n%2==1) cout << "No" << endl;
    else{
        bool flag = false;
        for(int i=0;i<s.size()/2;i++){
            if(s[i]!=s[s.size()/2+i]){
                flag = true;
                break;
            }
        }
        if(flag)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int siz,time;
    string name;
    while(true){
        cin>>name;
        if(name[0]=='-')break;
        cin>>time;
        for(int abc=0;abc<time;abc++){
            cin>>siz;
            name=name.substr(siz)+name.substr(0,siz);
        }
        cout<<name<<endl;
    }
    
}



Measured memory_bytes: 3180
// AOJ 1148

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair <int, int> P;
int data[1500][1500];

int main(void)
{
	int N, M;
	while (cin >> N >> M, N && M){
		for (int i = 0; i < 1500; i++){
			for (int j = 0; j < 1500; j++){
				data[i][j] = 0;
			}
		}

		int r;
		int t, n, m, s;
		cin >> r;
		for (int i = 0; i < r; i++){
			cin >> t >> n >> m >> s;
			for (int j = t; j < 1500; j++){
				data[n][j] = (s == 1) ? m : 0;
			}
		}

		int q;
		int ts, te;
		cin >> q;
		for (int i = 0; i < q; i++){
			cin >> ts >> te >> m;
			int ret = 0;
			for (int j = ts; j < te; j++){
				for (int i = 0; i <= N; i++){
					if (data[i][j] == m){
						ret++;
						break;
					}
				}
			}
			cout << ret << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 9952
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s, p;
	cin >> s >> p;
	s = s + s;
	if (s.find(p) == string::npos)
	{
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}

	return 0;
}




Measured memory_bytes: 3220
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int N;
    cin >> N;
    int C[N];
    int V[N];

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

    vector<int> sub;
    for(int i = 0; i < N; i++){
        int xy = V[i] - C[i];
        if(xy > 0)
            sub.push_back(xy);
    }
    int sum = 0;
    for(auto v : sub){
        sum += v;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n, x = gsmi

pat = Array.new(n+1,0)
pat[0] = 1
prev = pat[0]
1.upto(n) do |i|
  pat[i] = prev*2+1
  prev = pat[i]
end
all = Array.new(n+1,0)
all[0] = 1
prev = all[0]
1.upto(n) do |i|
  all[i] = prev*2+3
  prev = all[i]
end
# debug 'p',pat.to_s
# debug 'all',all.to_s

# xがN,N-1...1バーガの中心より左,右にあるか判断する
i = n
pos = x
while 0<i do
  cen = all[i]/2+1
  if pos==cen
    cnt+=pat[i-1]+1
    break
  elsif pos>cen
    cnt+=pat[i-1]+1
    i-=1
    pos-=cen
  else
    i-=1
    pos-=1
  end

  # debug 'i',i
  # debug 'pos',pos
  if i==0&&pos>=1
    cnt+=1
  end
end

puts cnt


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>
#include<iomanip>
#include<tuple>
#include<bitset>


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define printfloat(x) cout << fixed << setprecision(7) << (x) << endl;
#define printbit(x) cout << bitset<15>(x) << endl;
using ll = long long int;



long double pi = 3.14159265359;

int n;

int main(){
    cin >> n;
    int ans = 1;
    if(n == 1){
        cout << ans << endl;
        return 0;
    }
    rep(i,3){
        ans *= n;
    }
    cout << ans << endl;



return 0;
}

Measured memory_bytes: 3628
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();
		for(int i = 0; i < n; i++){
		    int a = sc.nextInt();
		    hm.put(a, hm.getOrDefault(a, 0) + 1);
		}
		
		// 計算
		int result = 0;
		int one = 0;
		int two = 0;
		for(Integer v : hm.values()){
		    if(v%2 == 0){
		        two++;
		    }else{
		        one++;
		    }
		}
		one += (two-1)/2*2;
		if(two != 0 && two%2 == 0){
		    one += 2;
		}
		result = one;
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 43356
#include <bits/stdc++.h>
#define int long long
#define pb       push_back
#define io    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define all(a)      (a).begin(),(a).end()
#define endl        '\n'
#define F    first
#define S second
#define mod 1000000007 
#define N 1005
#define pii pair<int,int>
using namespace std;
int n,m;
int dp[N][N];
vector<string> v(N);
void solve()
{
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>v[i];
    for(int i=0;i<n;i++)
        if(v[i][0]!='#')
            dp[i][0]=1;
        else 
            break;
    for(int j=0;j<m;j++)
        if(v[0][j]!='#')
            dp[0][j]=1;
        else
            break;
 
    for(int i=1;i<n;i++)
        for(int j=1;j<m;j++)
        {
            if(v[i][j]=='#')
                dp[i][j]=0;
            else
            {
                if(dp[i-1][j]>0)
                    dp[i][j]+=dp[i-1][j];
                if(dp[i][j-1]>0)
                    dp[i][j]+=dp[i][j-1];
            }
            dp[i][j]%=mod;
        }
   
    cout<<dp[n-1][m-1];
   
  /*for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            cout<<dp[i][j]<<" ";
            cout<<endl;
    }*/
}

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

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

int main(int argc, char const *argv[])
{
	int h, w; cin >> h >> w;
	vector<vector<int>> a(h, vector<int>(w)); {
		rep(i, h)rep(j, w) cin >> a[i][j];
	}

	int y = 0, x = 0;
	vector<tuple<int, int, int, int>> ans;
	rep(i, h * w - 1) {
		int ny = y, nx = x;
		if (y % 2 == 0) {
			if (x == w - 1) ny++;
			else nx++;
		} else {
			if (x == 0) ny++;
			else nx--;
		}
		// cout << "t: " << y + 1 << " " << x + 1 << " " << ny + 1 << " " << nx + 1 << endl;
		if (a[y][x] & 1) {
			// cout << y + 1 << " " << x + 1 << " " << ny + 1 << " " << nx + 1 << endl;
			ans.push_back(make_tuple(y + 1, x + 1, ny + 1, nx + 1));
			a[y][x]--;
			a[ny][nx]++;
		}
		y = ny, x = nx;
	}

	cout << ans.size() << endl;
	for (auto u : ans) {
		int y, x, ny, nx; tie(y, x, ny, nx) = u;
		cout << y << " " << x << " " << ny << " " << nx << endl;
	}
	return 0;
}


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

int main()
{
  string s,t;
  cin >> s >> t;
  for(size_t i = 0; i < s.size(); ++i){
    if(s[i]!=t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

typedef std::multimap<string, string> mss;
typedef std::pair<string, string> pss;
vector<pss> calc(string r) {
  int n = r.length();
  int m = (1 << n);
  vector<pss> ret(m);;
  rep (i, m) {
    string s = "";
    string t = "";
    rep (j, n) {
      if (((i >> j) & 1) == 1) {
        s += r[j];
      } else {
        t += r[j];
      }
    }
    reverse(all(t));
    ret[i] = (pss){s, t};
  }
  sort(all(ret));
  return ret;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string t = s.substr(0, n);
  string u = s.substr(n, n);
  auto mapt = calc(t);
  auto mapu = calc(u);
  ll cnt = 0;
  for (auto p : mapt) {
    auto lb = lower_bound(all(mapu), (pss){p.second, p.first});
    auto ub = upper_bound(all(mapu), (pss){p.second, p.first});
    cnt += (ub - lb);
  }
  printf("%lld\n", cnt);

  return 0;
}


Measured memory_bytes: 25464
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    int ans;
    if (a + b >= c) ans = b + c;
    else ans = b + (a + b) + 1;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

string str;

int main ()
{
    cin >> str;

    for (int i = 0; i + 1 < str.size (); ++i)
    {
        if (str[i] == 'S' && str[i + 1] == 'T')
        {
            for (; i + 1 < str.size () && str[i] == 'S' && str[i + 1] == 'T'; )
                str.erase (i, 2);

            i = max (i - 2, -1);
        }
    }

    cout << str.size () << '\n';

    return 0;
}


Measured memory_bytes: 640
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   A : Integer;
   B : Integer;
   H : Integer;
begin
   Get (A);
   Get (B);
   Get (H);
   Put_Line (Integer'Image ((A+B)*H/2));
end Solve;

Measured memory_bytes: 3668
#include <cstdio>
#include <vector>

using namespace std;

int main() {
  int n; scanf("%d", &n);
  vector<int> height(n);
  for (int i = 0; i < n; i++) {
    int t; scanf("%d", &t);
    height[i] = t;
  }

  vector<bool> dp(n), dp_1(n);
  dp[n - 1] = dp_1[n - 1] = true;
  for (int i = n - 2; i >= 0; i--) {
    if (dp[i + 1]) {
      if (height[i] <= height[i + 1]) {
        dp[i] = dp_1[i] = true;
      }
      if (height[i] - 1 <= height[i + 1]) {
        dp_1[i] = true;
      }
    }
    if (dp_1[i + 1]) {
      if (height[i] <= height[i + 1] - 1) {
        dp[i] = dp_1[i] = true;
      }
      if (height[i] - 1 <= height[i + 1] - 1) {
        dp_1[i] = true;
      }
    }
  }
  if (dp[0] || dp_1[0]) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
  long long n,a,x,mn,mx,s;
  s=0;
  mn=1000000;
  mx=-1000000;
  scanf("%lld",&n);
  for(x=0;x<n;x++){
    scanf("%lld",&a);
    s=s+a;
    if(mn>a){mn=a;}
    if(mx<a){mx=a;}
  }
  printf("%lld %lld %lld\n",mn,mx,s);
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
typedef long long ll;
int main (void) {
    int N;

    cin >> N;
    ll A[N], B[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    ll ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        A[i] += ans;
        if (A[i] % B[i] != 0) {
            ans += (A[i] / B[i] + 1) * B[i] - A[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
a, b, c, x, y = map(int, input().split())
cos = 0
if x < y:
    flag = True
    f = y-x
else:
    flag = False
    f = x-y
if 2*c < a+b:
    cos += min(x, y)*2*c
else:
    cos += min(x, y)*(a+b)
if (2*c < a and flag == False) or (2*c < b and flag):
    cos += f*2*c
else:
    if flag:
        cos += f*b
    else:
        cos += f*a
print(cos)

Measured memory_bytes: 38256
# -*- coding: utf-8 -*-

import sys
import os
import datetime

d = {}
for s in sys.stdin:
    v = int(s)

    if v not in d:
        d[v] = 1
    else:
        d[v] += 1

max_value = max(d.values())

for key in d.keys():
    if d[key] == max_value:
        print(key)

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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define PI 3.1415926535

int main(void){

    string s;
    cin >> s;

    if(s == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;

    return 0;
}


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

int main() {
  int N;
  string s;
  cin >> N >> s;
  int red, blue;
  red = 0;
  blue = 0;
  
  for(int i = 0; i < N; i++){
    if(s.at(i)  == 'R'){
      red++;
    }
    else{
      blue++;
    }
  }
  if(red > blue){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
  int n,q;

  while(1){
    
    cin>>n>>q;
    if(n==0&&q==0)break;
    map<int,int>mp;

    for(int i=0;i<n;i++){
      int x;
      cin>>x;
      for(int j=0;j<x;j++){
	int a;
	cin>>a;
	mp[a]++;
      }
    }
    int ans=0,tmp=0;
    for(int i=0;i<103;i++){
      //cout<<i<<":"<<mp[i]<<endl;
      if(mp[i]>=q&&mp[i]>tmp){
	ans=i;
	tmp=mp[i];
      }
    }
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
int main()
{
         int k,n,i,mx=0;
         cin>>k>>n;
         int a[n+1];
         for(i=0;i<n;i++)cin>>a[i];
         a[n]=k+a[0];
         for(i=0;i<n;i++)
         {
                  mx=max(mx,a[i+1]-a[i]);
         }
         cout<<k-mx<<endl;
         return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[] ,int n ,int left ,int mid ,int right){
  int n1,n2,i,j=0,k;
  n1 = mid - left;
  n2 = right - mid;
  for(i=0 ; i<n1 ; i++) L[i]=A[left+i];
  for(i=0 ; i<n2 ; i++) R[i]=A[mid+i];
  L[n1] = R[n2] = SENTINEL;
  i=0;
  for(k=left ; k<right ; k++){
    cnt++;
    if(L[i] <= R[j]){
      A[k]=L[i++];
    }
    else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[],int n,int left,int right){
  int mid;
  if(left+1 < right){
    mid = (left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int main(){
  int A[MAX],n,i;
  cnt=0;
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%d" ,&A[i]);
  }
    mergeSort(A,n,0,n);
    for(i=0 ; i<n ; i++){
      if(i) printf(" ");
      printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n" ,cnt);
    return 0;
}



Measured memory_bytes: 5636
#include<bits/stdc++.h>
#define ret(x) return puts((x)?"Yes":"No"),0
const int N=100007;
int n,as[N][3],v0[N],r0[2],bit[N];
void inc(int w){
	for(;w;w-=w&-w)++bit[w];
}
int sum(int w){
	int s=0;
	for(;w<=n;w+=w&-w)s+=bit[w];
	return s;
}
int main(){
	scanf("%d",&n);
	for(int j=0;j<3;++j){
		for(int i=1;i<=n;++i)scanf("%d",as[i]+j);
	}
	for(int i=1;i<=n;++i){
		int a=as[i][0],b=as[i][1],c=as[i][2];
		if(a-b==1&&b-c==1&&a%3==0){
			v0[i]=a/3;
			r0[i&1]^=1;
		}else if(c-b==1&&b-a==1&&c%3==0){
			v0[i]=c/3;
		}else ret(0);
		if(v0[i]-i&1)ret(0);
	}
	for(int i=1;i<=n;i+=2){
		r0[0]^=1&sum(v0[i]);
		inc(v0[i]);
	}
	memset(bit,0,sizeof(bit));
	for(int i=2;i<=n;i+=2){
		r0[1]^=1&sum(v0[i]);
		inc(v0[i]);
	}
	ret(!(r0[0]|r0[1]));
}

Measured memory_bytes: 2176
t1,n1=map(int,input().split())
t2,n2=map(int,input().split())
t3,n3=map(int,input().split())
t4,n4=map(int,input().split())

if t1==1:
    A=6000*n1
elif t1==2:
    A=4000*n1
elif t1==3:
    A=3000*n1
else:
    A=2000*n1
    
if t2==1:
    B=6000*n2
elif t2==2:
    B=4000*n2
elif t2==3:
    B=3000*n2
else:
    B=2000*n2
    
if t3==1:
    C=6000*n3
elif t3==2:
    C=4000*n3
elif t3==3:
    C=3000*n3
else:
    C=2000*n3
    
if t4==1:
    D=6000*n4
elif t4==2:
    D=4000*n4
elif t4==3:
    D=3000*n4
else:
    D=2000*n4
    
print(A)
print(B)
print(C)
print(D)
    
    
    


Measured memory_bytes: 5608
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class A {
public:
	void solve(istream& in, ostream& out) {
        vector<int> a(3);
        rep(i,3) in >> a[i];
        sort(a.begin(),a.end());
        if(a[0] == 5 && a[1] == 5 && a[2] == 7) out << "YES" << endl;
        else out << "NO" << endl;
	}
};

int main() {
	A solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

const int mod = 1e9 + 7;

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n;
    cin >> n;
    vt<ll> a(n);
    for (ll &i : a) cin >> i;

    ll cur = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        ans = (ans + cur * a[i]) % mod;
        cur = (cur + a[i]) % mod;
    }

    cout << ans;
}


Measured memory_bytes: 4740
using System;
using System.Buffers;
using System.Collections.Generic;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        int H = ScanInt(), W = ScanInt();
        var a = new List<string>();
        for (int i = 0; i < H; i++) {
            var isAllWhite = true;
            var line = Scan();
            for (int j = 0; j < W; j++) {
                if (line[j] == '.') continue;
                isAllWhite = false;
                break;
            }
            if (!isAllWhite) a.Add(line);
        }
        for (int i = 0; i < W; i++) {
            var isAllWhite = true;
            foreach (var s in a) {
                if (s[i] == '.') continue;
                isAllWhite = false;
                break;
            }
            if (!isAllWhite) continue;
            for (int j = 0; j < a.Count; j++) {
                a[j] = new StringBuilder(a[j][..i]).Append(a[j][(i + 1)..]).ToString();
            }
            i--;
            W--;
        }
        foreach (var line in a) {
            Console.WriteLine(line);
        }
    }
}

public static class Scanner
{
    static readonly Stream stream = Console.OpenStandardInput();
    static readonly byte[] buffer = ArrayPool<byte>.Shared.Rent(1024);
    static int length, p;
    static bool isEof;
    private static byte ConsoleIn() {
        if (isEof) return 0;
        var buf = buffer.AsSpan();
        if (p < length) return buf[p++];
        p = 0;
        if ((length = stream.Read(buf)) > 0) return buf[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = ConsoleIn();
        while ((by < '!' || '~' < by) && !isEof) by = ConsoleIn();
        return (char) by;
    }
    public static string Scan() {
        var sb = new StringBuilder();
        for (var ch = GetChar(); '!' <= ch && ch <= '~'; ch = (char) ConsoleIn()) {
            sb.Append(ch);
        }
        return sb.ToString();
    }
    public static int ScanInt() {
        var temp = 0;
        for (var ch = GetChar(); '0' <= ch && ch <= '9'; ch = (char) ConsoleIn()) {
            temp = temp * 10 + ch - '0';
        }
        return temp;
    }
}

Measured memory_bytes: 25884
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    bool f=0;
    string s,t;
    cin>>s>>t;
    ll n = s.length();
    rep(i,0,n){
        if(s[i]!=t[i])  f=1;
    }
    if(f)   cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

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


int main(){
    int  i,j;
    int N;
    scanf("%d",&N);
    char s[N+1][11];
    int c = 1;

    for(i=0;i<N;i++){
        scanf("%s",&s[i]);
    }
    qsort(s,N,11,strcmp);

    for(i=1;i<N;i++){
        if(strcmp(s[i-1],s[i])<0){
            c += 1;
        }
    }

    printf("%d\n",c);

    return 0;
}



Measured memory_bytes: 5700
#include<stdio.h>
     
    int main(){
      int n,min=1000,max=0,a,i;
      scanf("%d",&n);
      for(i=0;i<n;i++){
        scanf("%d",&a);
        if(min>a)
          min=a;
        if(max<a)
          max=a;
      }
      printf("%d\n",max-min);
    }

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int Ans,n;
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; ++i) {
		int w=0,t=i;
		while(t)t/=10,++w;
		if(w&1)++Ans;
	}
	printf("%d",Ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,m,ans=0,i=0,g=1;
    cin >> n;
    m=n;
    while(1){
        if(i!=0) g*=10;
        i++;
        if(n<10){
            if(i%2==1) ans+=m-g+1;
            break;
        }
        n/=10;
        if(i%2==1) ans+=9*g;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
const ll INF_LL = 1000000000000;
#define fir first
#define sec second


std::vector<bool> a;
int n;

bool chack(bool A, bool b, std::string& t){
    std::vector<bool> set(n);
    set[0] = A, set[1] = b;
    for(int i = 1; i < n - 1; i++){
        if(set[i - 1] == set[i] && set[i - 1]){

            if(a[i])    set[i + 1] = true;
            else        set[i + 1] = false;
            
        }else if(set[i - 1] == false && set[i] == true){

            if(a[i])    set[i + 1] = false;
            else        set[i + 1] = true;

        }else if(set[i - 1] == true && set[i] == false){

            if(a[i])    set[i + 1] = false;
            else        set[i + 1] = true;

        }else if(set[i - 1] == false && set[i] == false){
            
            if(a[i])    set[i + 1] = true;
            else        set[i + 1] = false;
        }else{
            assert(0);
        }
    }
    bool res = true;
    if(set[n - 1]){
        if(a[n - 1] && set[n - 2] != set[0])res = false;
        if(!a[n - 1] && set[n - 2] == set[0])res = false;
    }
    if(!set[n - 1]){
        if(!a[n - 1] && set[n - 2] != set[0])res = false;
        if(a[n - 1] && set[n - 2] == set[0])res = false;
    }
    if(set[0]){
        if(a[0] && set[1] != set[n - 1])res = false;
        if(!a[0] && set[1] == set[n - 1])res = false;
    }
    if(!set[0]){
        if(!a[0] && set[1] != set[n - 1])res = false;
        if(a[0] && set[1] == set[n - 1])res = false;
    }


    
    t.resize(0);
    for(int i= 0; i < n; i++){
        t.push_back((set[i] ? 'S' : 'W'));
    }
    return res;
}

int main()
{
    std::cin >> n;
    a.resize(n);
    for(int i = 0; i < n; i++){
        char t; std::cin >> t; 
        a[i] = (t == 'o');
    }

    std::string t;
    if(chack(1,1,t)){
        std::cout << t << std::endl;
        return 0;
    }else if(chack(1,0,t)){
        std::cout << t << std::endl;
        return 0;
    }else if(chack(0,1,t)){
        std::cout << t << std::endl;
        return 0;
    }else if(chack(0,0,t)){
        std::cout << t << std::endl;
        return 0;
    }
    std::cout << -1 << std::endl;
    
    // 0 : wolf / 1 : wolf
}


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

int main(){

    string S;
    cin >> S;
    if(S[2]==S[3]&&S[4]==S[5])cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll k,A,B;
void solve(){
	string s,t,res="";
	ll n;
	cin>>n>>s>>t;
	rep(i,0,n){
		res+=s[i];
		res+=t[i];
	}
	cout<<res;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
//#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/
const int N=705;
bool vis[N];
bool edge[N][N];
int n,m;
bool col[N];
int cnt[2];
void dfs(int node,bool color)
{
	if(vis[node])
	{
		if(col[node]!=color)
		{
			cout<<"-1\n";
			exit(0);
		}
		return;
	}
	cnt[color]++;
	col[node]=color;
	vis[node]=1;
	for(int i=1;i<=n;i++)
	{
		if(i!=node && !edge[node][i])
		{
			dfs(i,color^1);
		}
	}
	
}
int dp[N][N];
vector<pair<int,int>> v;
int C2(int x)
{
	return (x*(x-1))/2;
}
int rec(int ind,int l,int r)
{
	if(ind==v.size())
	{
		return C2(l)+C2(r);
	}
	int &ans=dp[ind][l];
	if(ans>=0)
	{
		return ans;
	}
	ans=min(rec(ind+1,l+v[ind].first,r+v[ind].second),rec(ind+1,l+v[ind].second,r+v[ind].first));
	return ans;
}
int32_t main()
{
	fastio();	
	cin>>n>>m;
	MEMS(dp,-1);
	for(int i=1;i<=m;i++)
	{
		int u,v;
		cin>>u>>v;
		edge[u][v]=1;
		edge[v][u]=1;
	}
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			cnt[0]=cnt[1]=0;
			dfs(i,0);
			v.push_back({cnt[0],cnt[1]});
		}
	}
	cout<<rec(0,0,0)<<endl;
}


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

using namespace std;

int main(){
	int N, K;
	char str[51];
	
	scanf("%d %d", &N, &K);
	scanf("%s", str);
	string s = str;

	transform( s.begin() + K - 1, s.begin() + K, s.begin() + K - 1, ::tolower);

	printf("%s\n", s.c_str());
}

Measured memory_bytes: 256
#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 5e3 + 5;
const int M = 1e5 + 5;
const ll OO = 1e18;
const int mod = 1e9 + 7;


int n,ans,dp[N][N];
string s;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> s;

    for (int i = n-1; ~i; --i) {
        for (int j = n-1; ~j; --j) {
            if(s[i]==s[j]) ans = max(ans, dp[i][j] = min(dp[i+1][j+1]+1, j-i));
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 101408
import java.util.Scanner;

public class Main {

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

		int numberA=sc.nextInt();
		int numberB=sc.nextInt();
		int T=sc.nextInt();

		int sum=(T/numberA)*numberB;
		System.out.println(sum);
		sc.close();
	}

}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main()
{
    int h,w;
    
    for(int i=0; ;i++)
    {
        cin>>h>>w;
        if(h==0&&w==0)break;
        
        //上の辺
        for(int y=0;y<w;y++){cout<<"#";}
        cout<<endl;
        //中段
        for(int u=0;u<h-2;u++)
        {
             cout<<"#";
             for(int k=0;k<w-2;k++)
             {
                 cout<<".";
             }
             cout<<"#"<<endl;
        }
        //下段
        for(int v=0;v<w;v++){cout<<"#";}
        cout<<endl<<endl;
    }
    return 0;
}


Measured memory_bytes: 3044
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n;
vector< long long > arr( 3003 ), pref( 3003, 0 );
int ok[ 3003 ][ 3003 ];
long long dp[ 3003 ][ 3003 ];

long long solve( int l, int r )
{
	if( l == r )
	{
		return arr[ l ];
	}
	if( ok[ l ][ r ] != -1 )
	{
		return dp[ l ][ r ];
	}
	ok[ l ][ r ] = 1;
	dp[ l ][ r ] = max( arr[ l ] + pref[ r ] - pref[ l ] - solve( l + 1, r ), arr[ r ] + pref[ r - 1 ] - pref[ l - 1 ] - solve( l, r - 1 ) );
	return dp[ l ][ r ];
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	memset( dp, -1, sizeof( dp ) );
	memset( ok, -1, sizeof( ok ) );
	cin >> n;
	for( int i = 1; i <= n; ++i )
	{
		cin >> arr[ i ];
		pref[ i ] += pref[ i - 1 ] + arr[ i ];		
	}
	cout << 2 * solve( 1, n ) - pref[ n ] << "\n";
	return 0;
}

Measured memory_bytes: 106240