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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n;
    cin >> n;
    vector<int> A(n);

    for(auto &i: A)
        cin >> i;

    int cc=0;
    
    FOR(i,0,n){
        bool flag=true;
        FOR(j,0,i){
            if(A[j]>A[i]){
                flag=false;
                break;
            }
        }
        if(flag)
            cc++;
    }

    cout << cc << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;
typedef long long ll;

struct p_t{
  ll p;
  ll y;
  ll num;
  ll numn;
};

bool asc(p_t left,p_t right) {
    return left.p == right.p ? left.y < right.y : left.p < right.p;
}
bool asc2(p_t left,p_t right) {
    return left.num < right.num;
}

int main(){
  ll n,m;
  cin>>n>>m;
  vector<p_t> a;
  p_t aa;
  for(int i=0;i<m;i++){
    cin>>aa.p>>aa.y;
    aa.num=i;
    aa.numn=0;
    a.push_back(aa);
  }
  sort(a.begin(),a.end(),asc);
  ll pp=0;
  ll x=1;
  for(int i=0;i<m;i++){
    if(pp==a[i].p){
      x++;
    }
    else{
      x=1;
      pp=a[i].p;
    }
    a[i].numn=x;
  }
  sort(a.begin(),a.end(),asc2);
  for(int i=0;i<m;i++){
    cout<< setfill('0') << right << setw(6) <<a[i].p<<setfill('0') << right << setw(6)<<a[i].numn<<endl;
  }
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
#include <set>
#include <queue>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define reps(i, s, n) for (int i = s; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define repsl(i, s, n) for (ll i = s; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

#define lpair pair<ll, ll>

int main()
{
  ll n,m;
  cin >> n >> m;
  vector<ll> rits;
  vector<ll> outs;
  repl(i, m)
  {
    ll k;
    cin >> k;
    ll d = 0;
    repl(j, k)
    {
      ll tmp;
      cin >> tmp;
      d += 1 << (tmp-1);
    }
    rits.push_back(d);
  }
  
  repl(i, m)
  {
    ll t;
    cin >> t;
    outs.push_back(t);
  }

  ll ans = 0;
  repl(i, pow(2, n))
  {
    bool isError = false;
    repl(j, m)
    {
      ll tmp = rits[j] & i;
      if(__builtin_popcountll(tmp) % 2 != outs[j] )
      {
        isError = true;
        break;
      }
    }
    if(!isError) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4120
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
    n = ni()

    if n % 2 != 0:
        print(0)
        return
    
    n //= 10
    ans = n
    while n > 0:
        n //= 5
        ans += n
    print(ans)    

if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
n, T = map(int, input().split())
c, t = [0]*n, [0]*n
for i in range(n):
    c[i], t[i] = map(int, input().split())
ind_list = []
for i in t:
    if i <= T:
        ind_list.append(t.index(i))
if len(ind_list) == 0:
    print('TLE')
else:
    print(min(c[i] for i in ind_list))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

int cnt[14][14];

int calc(string s, string t) {
	int n = min(s.size(), t.size());
	int ret = 0;
	for(int i = 1; i <= n; i++) {
		if(s.substr(s.size() - i, i) == t.substr(0, i)) ret = i;
	}
	return ret;
}

const int INF = 1 << 28;
int dp[1 << 14][14];

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

	int n;
	while(cin >> n, n) {
		vector<string> city(n);
		for(int i = 0; i < n; i++) {
			cin >> city[i];
		}

		vector<string> temp;
		for(int i = 0; i < n; i++) {
			bool flag = true;
			for(int j = 0; j < n; j++) {
				if(i == j) continue;
				if(city[j].find(city[i]) != string::npos) {
					flag = false;
					break;
				}
			}
			if(flag) temp.push_back(city[i]);
		}

		city = temp;
		n = city.size();

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(i == j) continue;
				cnt[i][j] = calc(city[i], city[j]);
				//cout << city[i] + " " + city[j] + " " << cnt[i][j] << endl;
			}
		}

		fill((int*)begin(dp), (int*)end(dp), INF);
		for(int i = 0; i < n; i++) {
			dp[1 << i][i] = city[i].size();
		}

		for(int i = 0; i < 1 << n; i++) {
			for(int j = 0; j < n; j++) {
				if(dp[i][j] == INF) continue;
				for(int k = 0; k < n; k++) {
					if(i >> k & 1) continue;
					int ni = i | (1 << k);
					int len = dp[i][j] + city[k].size() - cnt[j][k];
					dp[ni][k] = min(dp[ni][k], len);
				}
			}
		}

		int ans = INF;
		for(int i = 0; i < n; i++) {
			ans = min(ans, dp[(1 << n) - 1][i]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 4032
package main

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

var sc = bufio.NewScanner(os.Stdin)

// NextLine reads a line text from stdin, and then returns its string.
func NextLine() string {
	sc.Scan()
	return sc.Text()
}

// NextIntsLine reads a line text, that consists of **ONLY INTEGERS DELIMITED BY SPACES**, from stdin.
// And then returns intergers slice.
func NextIntsLine() []int {
	ints := []int{}
	intsStr := NextLine()
	tmp := strings.Split(intsStr, " ")
	for _, s := range tmp {
		integer, _ := strconv.Atoi(s)
		ints = append(ints, integer)
	}
	return ints
}

// NextRunesLine reads a line text, that consists of **ONLY CHARACTERS ARRANGED CONTINUOUSLY**, from stdin.
// Ant then returns runes slice.
func NextRunesLine() []rune {
	return []rune(NextLine())
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// PowInt is integer version of math.Pow
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}
	fa := float64(a)
	fe := float64(e)
	fanswer := math.Pow(fa, fe)
	return int(fanswer)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	fa := float64(a)
	fanswer := math.Abs(fa)
	return int(fanswer)
}

// sort package (snippets)
//sort.Sort(sort.IntSlice(s))
//sort.Sort(sort.Reverse(sort.IntSlice(s)))
//sort.Sort(sort.Float64Slice(s))
//sort.Sort(sort.StringSlice(s))

/*******************************************************************/

var s, t []rune

func main() {
	s = NextRunesLine()
	t = NextRunesLine()
	for i := 0; i < len(s); i++ {
		rots := []rune{}
		before := s[len(s)-1-i : len(s)]
		after := s[0 : len(s)-1-i]
		rots = before
		rots = append(rots, after...)
		if string(t) == string(rots) {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    int n, m;
    int **a;
    int *b;
    int c;

    scanf ("%d %d", &n, &m);

    a = (int **) malloc (sizeof(int *)*n);
    for (int i=0; i<n; i++) {
        a[i] = (int *) malloc (sizeof(int)*m);
    }
    b = (int *) malloc (sizeof(int)*m);

    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            scanf ("%d", &a[i][j]);
        }
    }
    for (int i=0; i<m; i++) {
        scanf ("%d", &b[i]);
    }

    for (int i=0; i<n; i++) {
        c = 0;
        for (int j=0; j<m; j++) {
            c += a[i][j] * b[j];
        }
        printf ("%d\n", c);
    }

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

    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,m;
string s,a,aa;
string f(string s,string t){
    string ss;
    for(int i=0;i<m;i++){
        if(s[i]==t[i])ss+='0';
        else ss+='1';
    }
    return ss;
}
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(1){
    cin>>n>>m;
    if(n==0&&m==0)return 0;
    aa="";
    map<string ,int> mp;
    vector<pair<string,int>> k;
    vector<string> v;
    for(int i=0;i<m;i++)aa+='0';
    cin>>a;
    mp[a]++;
    v.push_back(a);
    for(int i=1;i<n;i++){
        cin>>a;
        if(mp[a]==0){mp[a]=1;}
        for(auto x:v){
            //cout<<*x<<i<<endl;
            s=f(a,x);
            //cout<<s<<" "<<" "<<mp[s]<<endl;
            if(mp[s]==0){
                mp[s]+=mp[x]+1;
            }
            else{
                //cout<<mp[*x]<<" "<<*x<<endl;
                if(mp[x]+1>mp[s])k.push_back({s,mp[x]+1});//if(mp[a]+1>mp[s])
            }
        }
        for(auto x:k){
           mp[x.first]=x.second;
       }
       v={};
       for(auto x:mp)v.push_back(x.first);
       k={};
    }
    //for(auto x:mp){cout<<x.first<<" "<<x.second<<endl;}
    cout<<mp[aa]<<endl;
    }
}



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

using namespace std;

int main() {
    char a, b, c;
    int cont = 0;

    a = getchar();

    while ((b = getchar()) != '\n') {
        c = b;
        cont++;
    }

    cout << a << cont-1 << c << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        int[] list = new int[N];
        int Max = 0;
        int all = 0;
        for(int i = 0; i < N; i++){
           list[i] = sc.nextInt();
           if(list[i] > Max){
             Max = list[i];
           }
           all += list[i];
        }
      
       all -= Max;
       if(Max < all){
         System.out.println("Yes");
       }else{
         System.out.println("No");
       }
      
	}

}

Measured memory_bytes: 35572
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;
ll c[200001]={};
ll cb[200001]={};
ll calc(ll p1,ll q1){
	ll r=(c[p1]*cb[q1])%1000000007;
	r=(r*cb[p1-q1])%1000000007;
	return r;
}
int main() {
	ll h,w,a,b;

	cin>>h>>w>>a>>b;
	ll t=0;
	c[0]=1;
	for(ll i=1;i<200001;i++){
		c[i]=c[i-1]*i;
		c[i]%=1000000007;
	}
	cb[0]=1;
	for(ll i=1;i<200001;i++){
		ll c1=c[i];
		int k=1000000005;
		cb[i]=1;
		while(k>0){
			if(k%2==1)cb[i]*=c1;
			cb[i]%=1000000007;
			c1=(c1*c1)%1000000007;
			k/=2;
		}
	}

	for(int i=1;i<h-a+1;++i){
		t+=calc(b-2+i,i-1)*calc(w-b+h-i-1,h-i);
		t%=1000000007;
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

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

using Field = vector<vector<char>>;


void debug(Field field) {
  for(int i = 0; i < field.size(); i++) {
    for(int j = 0; j < field[i].size(); j++) {
      cout << field[i][j] << " ";
    }cout << endl;
  }
}

void drop(int h, int w, Field& field) {
  bool update = true;
  while(update) {
    update = false;
    for(int j = 0; j < w; j++) {
      for(int i = h - 1; i > 0; i--) {
	if(field[i][j] == '.' && field[i - 1][j] != '.') {
	  update = true;
	  swap(field[i][j], field[i - 1][j]);
	}
      }
    }
  }
}

bool simulate(int h, int w, int n, Field field) {
  bool update = true;
  drop(h, w, field);
  while(update) {
    set<pair<int, int> > pos;
    update = false;

    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
	// 横
	int cnt = 1;
	for(int k = j; k < w - 1; k++) {
	  if(field[i][k] != '.' && field[i][k] == field[i][k + 1]) cnt++;
	  else break;
	}
	if(n <= cnt) {
	  update = true;
	  for(int k = j; k < j + cnt; k++) pos.insert({k, i});
	}
	// 縦
	cnt = 1;
	for(int k = i; k < h - 1; k++) {
	  if(field[k][j] != '.' && field[k][j] == field[k + 1][j]) cnt++;
	  else break;
	}
	if(n <= cnt) {
	  update = true;
	  for(int k = i; k < i + cnt; k++) pos.insert({j, k});
	}
      }
    }
    for(auto v : pos) { field[v.second][v.first] = '.'; }
    drop(h, w, field);
  }
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(field[i][j] != '.') return false;
    }
  }
  return true;
}

int main(){
  int h, w, n;
  cin >> h >> w >> n;
  Field field = Field(h + 1, vector<char>(w, '.'));
  for(int i = 1; i < h + 1; i++) {
    for(int j = 0; j < w; j++) {
      cin >> field[i][j];
    }
  }

  h++;
  bool isParticipate = false;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w - 1; j++) {
      if(isParticipate) continue;
      swap(field[i][j], field[i][j + 1]);
      isParticipate = simulate(h, w, n, field);
      swap(field[i][j], field[i][j + 1]);
    }
  }
  
  if(isParticipate) cout << "YES" << endl;
  else cout << "NO" << endl;
}



Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

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

	int initcount = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '.')initcount++;
	}
	int score = initcount;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '#')initcount++;
		else initcount--;
		if (score > initcount)score = initcount;
	}
	print(score);




	return 0;
}

Measured memory_bytes: 640
x,y,z,n = map(int, input().split())
a = sorted(list(map(int, input().split())),reverse = True)
b = sorted(list(map(int, input().split())),reverse = True)
c = sorted(list(map(int, input().split())),reverse = True)
d = []
for i,i1 in enumerate(a):
  for j,j1 in enumerate(b):
    for k,k1 in enumerate(c):
      if (i+1) * (j+1) * (k+1) <= n:
        d.append(i1 + j1 + k1)
      else:
        break
d.sort(reverse = True)
for i in d[:n]:
  print(i)


Measured memory_bytes: 8708
// AtCoder ABC129: D - Lamp
// 2019.9.4 bal4u

#include <stdio.h>
#include <string.h>

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

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void ins(char *s) { // 文字列の入力　スペース以下の文字で入力終了
	do *s = gc();
	while (*s++ > ' ');
	*(s-1) = 0;
}

int H, W;
int s[2005][2005];
char S[2005][2005];
inline static void chmax(int *a, int b) { if (*a < b) *a = b; }

int main()
{
	int r, c, x, a, ans;
	
	H = in(), W = in();
	for (r = 0; r < H; r++) ins(S[r]);
	for (c = 0; c < W; c++) {
		r = 0; while (r < H) {
			while (S[r][c] == '#') r++;
			x = r, a = 0;
			while (S[r][c] == '.') a++, r++;
			while (x < r) s[x++][c] = a;
		}
	}
	for (r = 0; r < H; r++) {
		c = 0; while (c < W) {
			while (S[r][c] == '#') c++;
			x = c, a = 0;
			while (S[r][c] == '.') a++, c++;
			while (x < c) chmax(&ans, s[r][x++] + a);
		}
	}
	printf("%d\n", ans-1);
	return 0;
}


Measured memory_bytes: 19712
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
   int n;
   cin>>n;
   VS s(n);
   string st;
   map<string,int> mp;

   ll ans=0;
   rep(i,n){
       cin>>st;
       sort(st.begin(),st.end());
       if(mp[st]!=0){
           ans+=mp[st];
       }
       mp[st]++;
   }
   cout<<ans<<endl;
   
}


Measured memory_bytes: 12032
p = int(input())


def div(a, b):
    n = len(a)
    m = len(b)
    res = [0] * (n - m + 1)
    tmp = pow(b[-1], p - 2, p)
    for i in range(n - m, -1, -1):
        t = a[i + m - 1] * tmp % p
        res[i] = t
        for j in range(m):
            a[i + j] = (a[i + j] - t * b[j]) % p
    return res


a = list(map(int, input().split()))
ans = [0] * p
f = [0] * (p + 1)
f[0] = 1
for i in range(p):
    for j in range(p, 0, -1):
        f[j] += f[j - 1]
        f[j - 1] = -f[j - 1] * i
        f[j] %= p
for i in range(p):
    if a[i] == 1:
        fm = div(f[:], [-i, 1])
        t = 1
        r = 0
        for v in fm:
            r += v * t
            t = t * i % p
        t = pow(r, p - 2, p)
        for j in range(len(fm)):
            ans[j] += fm[j] * t
for i in range(p):
    ans[i] %= p
print(' '.join(map(str, ans)))


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

int main(){
  int H,W;
  cin >> H >> W;
  string a[110];
  for(int i=0; i<H; i++){
      cin >> a[i];
      cout << a[i] << endl;
      cout << a[i] << endl;
  }
}

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;
using P = pair<int, int>;

int main() {

    int N;
    cin >> N;

    int ans = 1;
    while (ans*2 <= N) ans *= 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3576
while(True):
        a,op,b = input().split()
        a = int(a)
        b = int(b)
        if op == '+':
                print(a+b)
        elif op == '-':
                print(a-b)
        elif op == '*':
                print(a*b)
        elif op == '/':
                print(a//b)
        else :
                break

Measured memory_bytes: 7660
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n,m;
ll ans=0ll;
ll dp[1050][1050];
char a[1050][1050];
const ll mod=1e9+7;
int main()
{
    gg(n);
    gg(m);
    repd(i,1,n)
    {
        repd(j,1,m)
        {
            cin>>a[i][j];
        }
    }
    dp[0][1]=1;
    repd(i,1,n)
    {
        repd(j,1,m)
        {
            if(a[i][j]=='.')
            {
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                dp[i][j]=(dp[i][j]+mod)%mod;
            }
        }
    }
    cout<<dp[n][m];
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 9472
#include<stdio.h>
int t[100000];
int main()
{
    int a,b,c,d,e=0,i,j,f,n,m,p,x,u,y,r;

    scanf("%d",&n);
    for(i=0;i<n;i++){
    scanf("%d",&t[i]);
    e=e+t[i];}

    scanf("%d",&m);
    for(j=1;j<=m;j++){
        scanf("%d %d",&p,&x);
        d=p-1;
        u=e+x-t[d];




        printf("%d\n",u);
    }
    return 0;


}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    int a=0,z=0;
    for(int i=0;i<s.length();i++){
        if('A'==s[i]){
            a=i;
            break;
        }
    }
    for(int i=s.length()-1;i>=0;i--){
        if('Z'==s[i]){
            z=i;
            break;
        }
    }
    cout<<z-a+1;
    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

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

  if (M == 0) {
    if (K == 0) {
      cout << "0 0" << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }

  if (M == 1) {
    if (K == 0) {
      cout << "0 0 1 1" << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }

  if (K >= (1 << M)) {
    cout << -1 << endl;
    return 0;
  }

  vector<int> X;
  for (int i = 0; i < (1 << M); i++) {
    if (i != K) X.push_back(i);
  }

  vector<int> Y(X);
  reverse(Y.begin(), Y.end());

  vector<int> ans(X);
  ans.push_back(K);
  for (auto i: Y) ans.push_back(i);

  ans.push_back(K);

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
    if (i == ans.size() - 1) cout << endl;
    else cout << ' ';
  }
}


Measured memory_bytes: 3952
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<decltype(x)::value_type>())
#define RSORT2(x, T) sort(ALL(x), greater<T>())
#define REVERSE(x) reverce(ALL(x))
#define ACM(x, y) accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)
#define FCT(x) [](int a) -> int {int r = 1; REP(i, a){r *= i;} return r;}(x)

// デバッグ用
#define PUT_LIST(x, y) std::copy(ALL(x), ostream_iterator<decltype(x)::value_type>(cout, y))

const int kMod = 1e9 + 7;

struct edge {
	int to;
	int cost;
	bool visit = false;
};

itn main() {
	ios::sync_with_stdio(false);

	int x;

	cin >> x;

	int res = (x / 11) * 2;

	x %= 11;

	if (x != 0 && x <= 6) {
		++res;
	}
	else if (x != 0 && x >= 7) {
		res += 2;
	}

	cout << res;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  int x = 1;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    if(x * 2 >= x + K){x += K;}
    else{x *= 2;}
  }
  cout << x << endl;
}
                       
    

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9

int main() {
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>
#include <map>
#include <list>

int main()
{
    std::string s;
    int q{};
    int t{};
    int f{};
    char c{};
    bool inv = false;

    std::cin >> s;
    std::list<char> result(s.begin(), s.end());
    std::cin >> q;

    for (int i = 0; i < q; i++) {
        std::cin >> t;
        if (t == 1) {
            inv = !inv;
        } else {
            std::cin >> f >> c;
            if ((f == 1 && !inv) || (f == 2 && inv)) {
                result.emplace_front(c);
            } else {
                result.emplace_back(c);
            }
        }
    }
    
    if (inv) {
        std::for_each(result.rbegin(), result.rend(), [](auto ch) { std::cout << ch; });
    } else {
        std::for_each(result.begin(), result.end(), [](auto ch) { std::cout << ch; });
    }
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 9984
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c; cin >> a >> b >> c;
    int ans = 3;
    if(a == b) ans--;
    if(a == c) ans--;
    if(a != b && b == c) ans--;
    cout << ans;
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (a>b) swap(a, b);
    if (b % a == 0)
        return a;
    else
        return gcd(a, b%a);
}

ll power_mod(ll n, ll m)
{
    ll res = 1;
    ll base = n;
    while (m)
    {
        if (m&1)
        {
            res *= base;
            res %= MOD;
        }
        base *= base;
        base %= MOD;
        m >>= 1;
    }
    return res;
}

ll inv_mod(ll n)
{
    return power_mod(n, MOD-2);
}

vector<ll> primes;
int maxn = 10000;
void init_prime()
{
    vector<bool> is_prime(maxn, true);
    is_prime[0] = is_prime[1] = false;
    for (ll i=0; i<maxn; ++i)
    if (is_prime[i])
    {
        primes.emplace_back(i);
        for (ll j=i*i; j<maxn; j+=i)
            is_prime[j] = false;
    }
}


int main()
{
    init_prime();

    int N;
    cin >> N;
    vector<ll> values(N);
    rep(i, 0, N) cin >> values[i];

    // calc LCM
    unordered_map<ll, ll> prime_map;
    rep(i, 0, N)
    {
        ll now = values[i];
        unordered_map<ll, ll> cnt_map;
        for (auto prime: primes)
        {
            while (now%prime== 0)
            {
                ++cnt_map[prime];
                now /= prime;
            }
        }
        ++cnt_map[now];

        for (auto elem: cnt_map)
            prime_map[elem.first] = max(prime_map[elem.first], elem.second);
    }

    ll LCM = 1;
    for (auto elem: prime_map)
    {
        LCM *= power_mod(elem.first, elem.second);
        LCM %= MOD;
    }

    // sum up B
    ll res = 0;
    rep(i, 0, N)
    {
        // cout << now << endl;
        res += LCM * inv_mod(values[i]);
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}

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


int is_prime(int n) {
    int max = (int)sqrt(n);

    if (n <= 1) {
        return 0;
    }
    if (n == 2) {
        return 1;
    }
    if (n % 2 == 0) {
        return 0;
    }

    for (int i = 3; i <= max; i+=2) {
        if (n % i == 0) {
            return 0;
        }
    }

    return 1;
}

int main() {
    int n, num, cnt = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> num;
        cnt += is_prime(num);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>

#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n, m;
  ll res = 0;
  cin >> n >> m;
  vector<ll> a(n);
  REP(i, n)
  {
    cin >> a[i];
  }
  sort(ALL(a));
  vector<pair<ll, ll>> p(m);
  REP(i, m)
  {
    ll b, c;
    cin >> b >> c;
    p[i] = make_pair(c, b);
  }
  sort(ALL(p), greater<pair<ll,ll>>());

  decltype(a)::iterator start = a.begin();
  REP(i, m)
  {
    ll c = p[i].first;
    ll b = p[i].second;

    decltype(a)::iterator it = lower_bound(start, a.end(), c);
    if (distance(start, it) == 0)
      break;
    if (distance(start, it) <= b)
    {
      res += c * distance(start, it);
      start += distance(start, it);
    }
    else
    {
      res += c * b;
      start += b;
    }
  }
  ll maxc = p[m - 1].first;
  decltype(a)::iterator it = lower_bound(start, a.end(), maxc + 1);
  for (auto itr = start; itr != a.end(); ++itr)
  {
    res += *itr;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

ll dp[50];

int main(){
    dp[0] = dp[1] = 1;
    for(int i = 2; i <= 44 ; i++) dp[i] = dp[i-1] + dp[i-2];
    int n;
    cin >> n;
    cout << dp[n] << endl;
}


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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, deque<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


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

    map<long long, int> ma;
    deque<long long> rireki, syu;
    long long sum = 0;
    for (long long n = 0; n < N; ++n) {
        if (ma.count(X)) {
            int p = ma[X];
            for (long long i = p; i < n; ++i) syu.push_back(rireki[i]);
            break;
        }
        ma[X] = n;
        rireki.push_back(X);
        sum += X;

        X = (X * X) % M;
    }
/*
    COUT(rireki);
    COUT(syu);
    COUT(sum);
*/
    N -= rireki.size();
    if (syu.empty()) cout << sum << endl;
    else {
    deque<long long> ruiseki(syu.size() + 1, 0);
    for (int i = 0; i < syu.size(); ++i) ruiseki[i+1] = ruiseki[i] + syu[i];
    long long q = N / syu.size();
    long long r = N % syu.size();
    sum += ruiseki[syu.size()] * q + ruiseki[r];
    cout << sum << endl;
    }
}

















Measured memory_bytes: 7948
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

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

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

///////////////////////////




int main() {

	ll A, B, K;
	cin >> A >> B >> K;

	ll ans = 101;

	while (K > 0) {

		ans--;

		if (A%ans == 0 && B%ans == 0) { K--; }
		
	}

	cout << ans;

	system("PAUSE");
}

Measured memory_bytes: 504
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            Dictionary<string, string> table = new Dictionary<string, string>()
            {
                {"A", "T"},
                {"C", "G"},
                {"G", "C"},
                {"T", "A"},
            };

            var b = Console.ReadLine();
            var answer = table[b];
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 11104
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var res = Console.ReadLine().Split().Distinct().Count();
        Console.WriteLine(res == 3 ? "Three" : "Four");
    }
}


Measured memory_bytes: 28180
#include <iostream>
#include <algorithm>
#include <cassert>
#include <deque>
#include <fstream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
#include <bitset>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr if(true) cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;
typedef pair<int,int> pp;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }

int cost[2010][2010];
std::vector<int> E[2010];
std::vector<int> ans,O;
bool is[2010] = {};

void rec(int pos,int d, int c){
	if(ans[pos] == -1)ans[pos] = c;

	if(d <= O[pos])return;
	O[pos] = d;

	if(d == 0)return;
	for(int to:E[pos]){
		rec(to,d-1,c);
	}
}

void BFS(int pos,int d, int c){
	vi q;
	q.push_back(pos);
	is[pos] = true;
	ans[pos] = c;


	REP(dd,d){
		vi ne;
		for(int from:q){
			for(int to:E[from]) if(!is[to]){
				ne.push_back(to);
				is[to] = true;
				ans[to] = c;
			}
		}
		q = ne;
		ne.clear();
	}
}

void solve(long long N, long long M, vector<long long> a, vector<long long> b, long long Q, vector<long long> v, vector<long long> d, vector<long long> c){
	ans.resize(N,-1);
	O.resize(N,0);

	REP(i,M){
		E[a[i]].push_back(b[i]);
		E[b[i]].push_back(a[i]);
	}

	reverse(ALL(v));
	reverse(ALL(d));
	reverse(ALL(c));

	REP(i,Q){
		fill(is,is+2010,false);
		rec(v[i],d[i],c[i]);
		// BFS(v[i],d[i],c[i]);
	}


	REP(i,N)
		cout << (ans[i] < 0?0:ans[i]) << endl;
	// REP(i,N){
	// 	cout << "1->" << (i+1) << " " <<cost[0][i]<< endl;
	// }
}



int main(){
	ios::sync_with_stdio(false);
	long long N;
	long long M;
	long long Q;
	cin >> N;
	cin >> M;
	vector<long long> a(M-1+1);
	vector<long long> b(M-1+1);
	for(int i = 0 ; i <= M-1 ; i++){
		cin >> a[i];a[i]--;
		cin >> b[i];b[i]--;
	}
	cin >> Q;
	vector<long long> v(Q-1+1);
	vector<long long> d(Q-1+1);
	vector<long long> c(Q-1+1);
	for(int i = 0 ; i <= Q-1 ; i++){
		cin >> v[i];v[i]--;
		cin >> d[i];
		cin >> c[i];
	}
	solve(N, M, a, b, Q, v, d, c);
	return 0;
}


Measured memory_bytes: 16888
let rec remove value lst =
	let rec remove_sub rel value lst =
		match lst with
		| []      -> []
		| x :: xs ->
			if rel value x then remove_sub rel x xs
			else x :: xs
	in
	match lst with
	| []      -> []
	| x :: xs ->
		if value < x then remove_sub (<=) x xs
		else if value > x then remove_sub (>=) x xs
		else remove x xs

let rec solve count lst =
	match lst with
	| []      -> count
	| x :: xs -> solve (count + 1) (remove x xs)

let () =
	let n = read_int () in
	let a =
		read_line ()
		|> Str.split (Str.regexp " ")
		|> List.map int_of_string
	in
	solve 0 a
	|> print_int
	|> print_newline


Measured memory_bytes: 16000
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod=1e9+7;

struct p{
  int up=0, down=0, right=0, left=0;
};

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  rep(i,h) cin >> grid[i];
  vector<vector<p>> sq(h, vector<p>(w));
  rep(j,w){
    rep(i,h){
      if(grid[i][j]=='.'){
        if(i==0 || sq[i-1][j].down==0){
        	int n=1;
        	while(i+n<h && grid[i+n][j]=='.')
        		n++;
        	sq[i][j].down = n;
        }else
	      	sq[i][j].down = sq[i-1][j].down-1;
	  	}else
	  		sq[i][j].down = 0;
    }
  }
  rep(j,w){
    for(int i=h-1; i>=0; i--){
      if(grid[i][j]=='.'){
        if(i==h-1 || sq[i+1][j].up==0){
        	int n=1;
        	while(i-n>=0 && grid[i-n][j]=='.')
        		n++;
        	sq[i][j].up = n;
        }else
	      	sq[i][j].up = sq[i+1][j].up-1;
	  	}else
	  		sq[i][j].up = 0;
    }
  }
  rep(i,h){
    rep(j,w){
      if(grid[i][j]=='.'){
        if(j==0 || sq[i][j-1].right==0){
        	int n=1;
        	while(j+n<w && grid[i][j+n]=='.')
        		n++;
        	sq[i][j].right = n;
        }else
	      	sq[i][j].right = sq[i][j-1].right-1;
	  	}else
	  		sq[i][j].right = 0;
    }
  }
  rep(i,h){
    for(int j=w-1; j>=0; j--){
      if(grid[i][j]=='.'){
        if(j==w-1 || sq[i][j+1].left==0){
        	int n=1;
        	while(j-n>=0 && grid[i][j-n]=='.')
        		n++;
        	sq[i][j].left = n;
        }else
	      	sq[i][j].left = sq[i][j+1].left-1;
	  	}else
	  		sq[i][j].left = 0;
    }
  }
  int ans=0;
  rep(i,h){
    rep(j,w){
      ans = max(ans, sq[i][j].up+sq[i][j].down+sq[i][j].right+sq[i][j].left-3);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 68992
#include <cstdio>
#include <utility>
#include <vector>
#include <cmath>
# define M_PI		3.14159265358979323846	/* pi */
using namespace std;
int depth;
const double cos_60 = cos(M_PI / 3.0);
const double sin_60 = sin(M_PI / 3.0);
vector<pair<double, double>> endpoints;

inline pair<double, double> midpoint(pair<double, double> origin, pair<double, double> object)
{
	pair<double, double> tmp_pair;
	tmp_pair.first = object.first - origin.first;
	tmp_pair.second = object.second - origin.second;
	return make_pair(origin.first + tmp_pair.first * cos_60 - tmp_pair.second * sin_60, origin.second + tmp_pair.first * sin_60 + tmp_pair.second * cos_60);
}

void koch(pair<double, double> start, pair<double, double> end, int n) //从左往右
{
	if (n == 0){
        endpoints.push_back(start);
        return;
    }
    pair<double, double> p1, p2, p3;
	p1 = make_pair(start.first + (end.first - start.first) / 3.0, start.second + (end.second - start.second) / 3.0);
	p3 = make_pair(start.first + (end.first - start.first) / 3.0 * 2.0, start.second + (end.second - start.second) / 3.0 * 2.0);
	p2 = midpoint(p1, p3);
	if (n == 1)
	{
		endpoints.push_back(start);
		endpoints.push_back(p1);
		endpoints.push_back(p2);
		endpoints.push_back(p3);
		return;
	}
	koch(start, p1, n - 1);
	koch(p1, p2, n - 1);
	koch(p2, p3, n - 1);
	koch(p3, end, n - 1);
	return;
}

int main()
{
	scanf("%d", &depth);
	koch(make_pair(0.0, 0.0), make_pair(100.0, 0.0), depth);
	endpoints.push_back(make_pair(100.0, 0.0));
	for (auto pair : endpoints)
	{
		printf("%lf %lf\n", pair.first, pair.second);
	}
}


Measured memory_bytes: 2768
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
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 main(){
    int H,W,N;
    cin>>H>>W>>N;
    pair<int,int> A[N];
    rep(i,N){
        int a;
        cin>>a;
        A[i]=mp(a,i+1);
    }
    sort(A,A+N,greater<pair<int,int>>());
    vector<vector<int>> ans(H,vector<int>(W));
    int ai=0;
    for(int i=0; i<H; i++){
        if(i%2){
            for(int j=W-1; j>=0; j--){
                if(A[ai].F==0) ai++;
                ans[i][j]=A[ai].S;
                A[ai].F--;
            }
        }else{
            for(int j=0; j<W; j++){
                if(A[ai].F==0) ai++;
                ans[i][j]=A[ai].S;
                A[ai].F--;
            }
        }
    }
    rep(i,H){
        rep(j,W){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
 //Compiler version g++ 6.3.0
int main(){
    int H,W,cnti=0,cntj=0;
    cin>>H>>W;
    char c[H*W];
    int a[H],b[W];
    for(int i=0;i<H*W;i++){
        cin>>c[i];
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(c[W*i+j]=='#'){
                a[cnti]=i;
                cnti++;
                break;
            }
        }
    }
    cout<<"\n";
    for(int j=0;j<W;j++){
        for(int i=0;i<H;i++){
            if(c[W*i+j]=='#'){
                b[cntj]=j;
                cntj++;
                break;
            }
        }
    }
    for(int i=0;i<cnti;i++){
        for(int j=0;j<cntj;j++){
            cout<<c[W*a[i]+b[j]];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<int> a(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);

	std::vector<i64> cnt(2e5 + 1, 0);
	for(auto v: a) cnt[v]++;

	i64 now = 0;
	for(auto v: cnt) now += v * (v - 1) / 2;
	for(auto v: a) {
		now -= cnt[v] * (cnt[v] - 1) / 2;
		cnt[v]--;
		now += cnt[v] * (cnt[v] - 1) / 2;

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

		now -= cnt[v] * (cnt[v] - 1) / 2;
		cnt[v]++;
		now += cnt[v] * (cnt[v] - 1) / 2;
	}
	
	return 0;
}


Measured memory_bytes: 4864
import sys
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
import collections
from collections import deque 

input = sys.stdin.readline

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

s = input()
t = input()
_debug(s)
dp = [[0] * (len(t) + 1) for i in range(len(s) + 1)]

for i in range(1, len(s)+1):
    ch = s[i-1]
    for j in range(1, len(t)+1):
        if ch == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

# 文字列作成
length = dp[len(s)][len(t)]
_debug(length)

i = len(s) - 1
j = len(t) - 1
ans = [""] * length
_debug(ans)
while length > 0:
    if s[i] == t[j]:
        ans[length-1] = s[i]
        i -= 1
        j -= 1
        length -= 1
    elif dp[i+1][j+1] == dp[i+1][j]:
        j -= 1
    else:
        i -= 1
print("".join(ans))



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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n; cin >> n;
	if(n==1){
		cout << "Hello World" << endl;
		return 0;
	}
	if(n==2){
		int a, b;cin >> a >> b;
		cout << a+b << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<pair<int,int>,null_type, less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e8+1, mod=1e9+7;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	string s,t;
	cin>>s>>t;
	int n=s.length(), m=t.length();
	int dp[n+1][m+1];
	memset(dp,0,sizeof dp);
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if( s[i-1]==t[j-1] ) dp[i][j]= dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int cur=dp[n][m], x=n,y=m;
	string res="";
	for(int i=n;i>0;i--){
		for(int j=m;j>0;j--){
			if( i<=x && j<=y && dp[i][j] ==cur && max(dp[i-1][j],dp[i][j-1])!=dp[i][j] ){
				cur--;
				res.pb(s[i-1]);
				x=i-1; y=j-1;
			}
		}
	}
	reverse(res.begin(),res.end());
	cout<<res;
}
// check for any potential overflow before submitting



Measured memory_bytes: 35456