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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

using P = pair<long, long>;

int main() {
    lint H, W;
    cin >> H >> W;
    lint sh, sw, gh, gw;
    cin >> sh >> sw >> gh >> gw;
    sh--, sw--, gh--, gw--;
    vector<string> G(H);
    rep(i, H) cin >> G[i];

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

    vector<vector<lint>> dist(H, vector<lint>(W, -1));
    dist[sh][sw] = 0;
    deque<P> q({{sh, sw}});

    while (!q.empty()) {
        int ch, cw;
        tie(ch, cw) = q.front(), q.pop_front();

        for (int i = 0; i < 4; i++) {
            int nh = ch + dx[i], nw = cw + dy[i];
            if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if (G[nh][nw] == '#') continue;

            if (dist[nh][nw] == -1 || (dist[nh][nw] > dist[ch][cw])) {
                dist[nh][nw] = dist[ch][cw];
                q.push_front({nh, nw});
            }
        }

        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                if (abs(i) + abs(j) == 1) continue;

                int nh = ch + i, nw = cw + j;
                if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
                if (G[nh][nw] == '#') continue;

                if (dist[nh][nw] == -1 || (dist[nh][nw] > dist[ch][cw] + 1)) {
                    dist[nh][nw] = dist[ch][cw] + 1;
                    q.push_back({nh, nw});
                }
            }
        }
    }

    cout << dist[gh][gw] << endl;
    // ddump(dist);
    return 0;
}

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

#define ll long long
#define pi 2*acos(0.0)

const int maxn = 1e5+7;

ll h[maxn], dp[maxn], n;

ll call(int pos)
{
    if(pos > n)
    {
        return INT_MAX;
    }
    if(pos == n)
    {
        return 0;
    }
    if(dp[pos] != -1)
    {
        return dp[pos];
    }

    dp[pos] = min((abs(h[pos] - h[pos+1]) + call(pos+1)), (abs(h[pos] - h[pos+2]) + call(pos+2)));
    return dp[pos];
}

int main()
{
    //int n;
    scanf("%lld", &n);

    memset(dp, -1, sizeof dp);

    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &h[i]);
    }

    cout << call(1) << endl;

    return 0;
}


Measured memory_bytes: 3328
package main
import . "fmt"
import "bytes"
func main() {
  var h,w int
  var s,t string
  var buf bytes.Buffer
  Scan(&h,&w)
  for i:=0;i<w+2;i++ { buf.WriteString("#") }
  t = buf.String()
  Println(t)
  for i:=0;i<h;i++ {
    Scan(&s)
    buf.Reset()
    buf.WriteString("#")
    buf.WriteString(s)
    buf.WriteString("#")
    Println(buf.String())
  }
  Println(t)
}

Measured memory_bytes: 640
import sys
#from collections import defaultdict, deque, Counter
#from bisect import bisect_left
#import heapq
#import math
#from itertools import groupby as gb
#from itertools import permutations as perm
#from itertools import combinations as comb
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
h,w = map(int, stdin.readline().rstrip().split())
s = [list(map(str, stdin.readline().rstrip().split())) for _ in range(h)]

dx = [-1,0,1,-1,1,-1,0,1]
dy = [-1,-1,-1,0,0,1,1,1]
ans = []
for i in range(h):
    an = []
    for j in range(w):
        if s[i][0][j] == ".":
            count = 0
            for d in range(8):
                if h > i + dy[d] >= 0 and w > j + dx[d] >= 0:
                    if s[i + dy[d]][0][j + dx[d]] == "#":
                        count += 1
                    else:
                        pass
                else:
                    pass
            a = str(count)
        else:
            a = "#"
        an += a
    ans.append(an)

for i in range(h):
    p = "".join(ans[i])
    print(str(p))


Measured memory_bytes: 3188
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main(){
    int n, ans = 0;
    string s;
    cin >> n >> s;
    for(int i = 0; i+2 < n; i++){
        if(s.substr(i, 3) == "ABC") ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] a) {


		Scanner sc = new Scanner(System.in);



		int fiveNum [] = new int [5];

		for(int i = 0; i < 5; i++) {
			int line = sc.nextInt();
			fiveNum[i] = line;
		}

		Arrays.sort(fiveNum);



		System.out.println(fiveNum[4] + " " + fiveNum[3] + " " + fiveNum[2] + " " + fiveNum[1] + " " + fiveNum[0]);

	}
}

Measured memory_bytes: 26268
def main2():
    S = input()
    idx = 0
    while idx < len(S):
        if S[idx:].startswith("dream"):
            e = S[idx+5:idx+5+3]

            if len(e) == 3:
                if e.startswith("d") or e == "era":
                    idx += 5

                elif e == "erd" or e == "ere":
                    idx += 7
                    
                else:
                    idx += 5

            elif len(e) == 2:
                if e == "er":
                    idx += 7
                else:
                    idx += 5

            elif len(e) == 1:
                idx += 5
            
            else:
                idx += 5

        elif S[idx:].startswith("eraser"):
            idx += 6

        elif S[idx:].startswith("erase"):
            idx += 5

        else:
            print("NO")
            exit()

    print("YES")

if __name__ == "__main__":
    main2()

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int A, B; cin >> A >> B;
  int ans = max(0, A - 2 * B);
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
struct status{
    int idx_node;
    vector<int> children;
    int finded = 0;
    int visited = 0;
};
 
int step = 0;
vector<status> graph;
 
void dfs(int now_node){
    ++step;
    graph[now_node-1].finded = step;
    for(auto&& next_node:graph[now_node-1].children){
        if(not graph[next_node-1].finded){
            dfs(next_node);
        }
    }
    ++step;
    graph[now_node-1].visited = step;
}
 
int main(void){cin.tie(0);ios::sync_with_stdio(false);
 
    //stdi
    int nb_nodes; cin >> nb_nodes;
    graph.resize(nb_nodes);
    for(auto& times:graph){
        int idx_node; cin >> idx_node; graph[idx_node-1].idx_node = idx_node;
        int nb_edges; cin >> nb_edges; graph[idx_node-1].children.resize(nb_edges);
        for(auto& a:graph[idx_node-1].children){
            cin >> a;
        }
        sort(graph[idx_node-1].children.begin(),graph[idx_node-1].children.end());
    }
     
    //dfs
    for(int i=1; i<=nb_nodes; ++i){
        if(not graph[i-1].finded) dfs(i);
    }
     
    //stdo
    for(auto& a:graph){
        cout<<a.idx_node<<" "
            <<a.finded<<" "
            <<a.visited<<"\n";
    }
}

Measured memory_bytes: 3220
lake_len, house_num = map(int, input().split())
house = list(map(int, input().split()))
diff = []

for i in range(house_num):
    if i != house_num - 1:
        diff.append(house[i+1] - house[i])
    else:
        diff.append(lake_len - house[i] + house[0])

diff_sort = sorted(diff, reverse=True)

print(sum(diff_sort) - diff_sort[0])

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

//Write From this Line

int main()
{
	int n ;
	cin >>  n ;
	vector<int> t(n) , x(n),y(n);
	rep(i,n){
		cin >> t[i] >>x[i] >>y[i];
	}
	int T = 0 , X = 0 , Y = 0;
	rep(i,n){
		int possible = t[i] - T ;
		T = t[i] ;
		int need = abs(x[i] - X) + abs(y[i] - Y);
		X = x[i] , Y = y[i];
		//到達可能で、もしpossibleのほうが大きいなら、その余った分が２の倍数ならok
		if( possible < need ){
			coN();
			return 0 ;
		}else{
			if((possible - need) % 2 == 1){
				coN();
				return 0 ;
			}
		}
	}
	coY();
}


Measured memory_bytes: 1408
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,mul4=0, odd=0
    integer(int32), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)
    do i=1,n
        if (btest(a(i),0))then
            odd=odd+1
        else if (mod(a(i),4) == 0) then
            mul4=mul4+1
        end if
    end do

    if (mul4 >= odd) then
        print'(a)', 'Yes'
    else
        if (mul4+1 == odd .and. mul4+odd == n) then
            print'(a)', 'Yes'
        else
            print'(a)', 'No'
        end if
    end if
end program name

Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

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

#define N 200004

ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0)return 1;
    else if(p==1)return mod(i);
    else if(p%2==0)return mod(po(mod(mod(i)*mod(i)),p/2));
    else  return mod(mod(i)*mod(po(i,p-1)));
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    for(int i=1;i<N;i++){
        kai[i]=mod(kai[i-1]*i);
        kai2[i]=mod(po(kai[i],i_5));
    }
}
ll comb(ll n,ll k){
    if(n==0){
        if(k==0)return 1;
        else return 0;
    }
    else if(n<k)return 0;
    else return mod(mod(mod(kai[n])*mod(kai2[n-k]))*mod(kai2[k]));
}

int main(){
    calc();
    ll n;cin>>n;ll a[n+1];ll c[n+1];for(ll i=1;i<=n;i++)c[i]=0;
    for(ll i=0;i<=n;i++){cin>>a[i];c[a[i]]++;}
    ll d=0;
    for(ll i=1;i<=n;i++){
        if(c[i]==2)d=i;
    }
    ll s[2];ll qqq=0;
    for(ll i=0;i<=n;i++){
        if(a[i]==d){s[qqq]=i;qqq++;}
    }
    ll l=s[0],r=n-s[1];
    for(ll q=1;q<=n+1;q++){
        cout<<mod(comb(n+1,q)-comb(l+r,q-1))<<endl;
    }
    return 0;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;

int main(void){
	int N ,M; cin>>N>>M;
	string a[N],b[M];
	rep(i ,N)cin>>a[i];
	rep(j ,M)cin>>b[j];
	bool jud = false;
	int cnt = 0;

	for(int t = 0; t < N - M + 1; t++){
		for(int k = 0; k < N - M + 1; k++){
			cnt = 0;
			for(int s = 0; s < M; s++){
				for(int q = 0; q < M; q++){
					if(a[t + s][k + q] == b[s][q])cnt++;
				}
			}
			if(cnt == M * M){
				jud = true;
			}
		}
	}

	cout<<(jud?"Yes":"No");

}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from itertools import groupby
from itertools import accumulate

def solve(N: int, K: int, S: str):
    group = groupby(S)

    one = []
    zero = []
    for key,value in group:
        if key == "1":
            one.append(len(list(value)))
        else:
            zero.append(len(list(value)))
    
    if len(zero) <= K:
        print(sum(one)+sum(zero))
        return
    
    # one がzeroより一つ多くなるように
    if len(one) == len(zero):
        if S[0] == "1":
            one.append(0)
        else:
            one = [0]+one
    elif len(zero) > len(one):
        one = [0]+one+[0]
    

    accum_zero = [0] + list(accumulate(zero))
    accum_one = [0] + list(accumulate(one))

    answer = 0
    for i in range(len(zero)-K+1):
        total = (accum_one[i+K+1]-accum_one[i]) + accum_zero[i+K]-accum_zero[i]
        answer = max(total,answer)
    
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = str(next(tokens))  # type: str
    solve(N, K, S)

if __name__ == '__main__':
    main()


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

#define show(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

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


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

struct Graph {
    Graph(int n)
    {
        edge.resize(n);
    }
    void addEdge(int from, int to)
    {
        edge[from].push_back(to);
    }
    vector<vector<int>> edge;
};

void dfs(int p, const Graph& g, vector<bool>& visited)
{
    visited[p] = true;
    for (const int to : g.edge[p]) {
        if (not visited[to]) {
            dfs(to, g, visited);
        }
    }
}

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

    Graph g(2 * H + 1);
    vector<int> dim(2 * H + 1, 0);
    for (ll i = 1; i <= N; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int l = 0;
        if (c == 0) {
            l = a;
        } else {
            l = -c;
        }

        int r = 0;
        if (d == 0) {
            r = b;
        } else {
            r = -d;
        }

        //        cout << l << "->" << -r << endl;
        dim[l + H]++;
        dim[-r + H]--;
        g.addEdge(l + H, -r + H);
    }

    int num1 = 0;
    int num2 = 0;
    vector<bool> visited(2 * H + 1, false);
    for (int i = 2 * H; i >= 0; i--) {
        //        cout << i - H << ": " << dim[i] << endl;
        if (i - H > 0) {
            if (dim[i] > 0) {
                dfs(i, g, visited);
                num1++;
            } else if (dim[i] < 0) {
                cout << "NO" << endl;
                return 0;
            }
        }
        if (i - H < 0) {
            if (dim[i] < 0) {
                num2++;
            } else if (dim[i] > 0) {
                cout << "NO" << endl;
                return 0;
            }
        }
    }

    // if (num1 == num2 and num1 > 0) {
    for (int i = 0; i < 2 * H + 1; i++) {
        if ((not g.edge[i].empty()) and (not visited[i])) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    // } else {
    //     cout << "NO" << endl;
    // }


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

char c[] = {'M','A','R','C','H'};

int main() {
  int n; cin >> n;
  string s;
  map<char,int> m;

  REP(i,n) { cin >> s; m[s[0]]++; }

  ll ans = 0;
  for (ll bit = 0; bit < (1<<5); bit++) {
    if (__builtin_popcount(bit) != 3) continue;
    ll sum = 1;
    REP (i,5) {
      if (bit >> i & 1) sum*=m[c[i]];
    }
    ans+=sum;
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
 
  int ans=0;
  if(c==-1||d==-1){
    if(a<b) ans=1;
    else if(a>b) ans=2;
  }else{
    if(c<d) ans=2;
    else if(c>d) ans=1;
  }

  if(ans==0) cout<<"Draw"<<endl;
  else if(ans==1) cout<<"Alice"<<endl;
  else cout<<"Bob"<<endl;

  return 0;
}



Measured memory_bytes: 3120
I=lambda:list(map(int,input().split()))
n,W=I()
g=[0]+[I()for _ in range(n)]
vm=n*1000+1
dp=[[0]+[10**18]*vm]+[[0]*vm for _ in range(n)]
for i in range(1,n+1):
    w,v=g[i]
    for j in range(vm):
        k=j-v
        if k<0:
            dp[i][j]=dp[i-1][j]
        else:
            dp[i][j]=min(dp[i-1][j],dp[i-1][k]+w)
for j in range(vm)[::-1]:
    if dp[n][j]<=W:
        print(j)
        break

Measured memory_bytes: 119012
num = input()
if int(num[:2]) > 12 or int(num[:2])==0:
    if int(num[2:]) > 12 or int(num[2:])== 0:
        print('NA')
    else:
        print('YYMM')
else:
    if int(num[2:]) > 12 or int(num[2:])== 0:
        print('MMYY')
    else:
        print('AMBIGUOUS')

Measured memory_bytes: 38256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

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

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

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vll C(N-1),S(N-1),F(N-1);
    for(ll i=0;i<N-1;i++)cin>>C[i]>>S[i]>>F[i];
    
    for(ll i=0;i<N;i++){
        ll time=0;
        for(ll j=i;j<N-1;j++){
            if(time<S[j]){
                time=S[j]+C[j];
            }else{
                time=(ll)ceil((double)time/(double)F[j])*F[j]+C[j];
            }
        }
        cout<<time<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ar[n]={0};
	for(int i=0;i<n;i++)
	{
		cin>>ar[i];
	}
	int count =0;
	sort(ar,ar+n);
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(ar[i]!=ar[j] && ar[j]!=ar[k] && ar[k]!=ar[i])
				{
					if(ar[i]+ar[j]>ar[k])
					{
						count++;
					}
				}
			}
		}
	}
	cout<<count<<endl;
}

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

char chess(int h,int w){
    if((h+w)%2==0){
        return '#';
    }
    return '.';
}

int main(void){
    int H,W;
    while(true){
        cin >>H>>W;
        if(H==0&&W==0)break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout <<chess(i,j);
            }
            cout <<endl;
        }
        cout <<endl;
    }
}



Measured memory_bytes: 3088
#include <stdio.h>
#include <stdlib.h>
int main(void) {
	int w,i=1,len_s=0;
	char s[1000];
	scanf("%s",s);
	scanf("%d",&w);
	while(i){
		if(s[len_s]!='\0') len_s++;
		else i=0;
	}
	for(i=0;i<len_s;i+=w){
		printf("%c",s[i]);
	}
	printf("\n");
	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
   int a,b,c,i,d=0;
   scanf("%d %d %d",&a,&b,&c);
   for (i=a;i<=b;i++){
    if (c%i==0) d++;

   }

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

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

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

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

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



int main()
{
  int a, b, c; cin >> a >> b >> c;
  map<int, int> mp;
  ++mp[a];
  ++mp[b];
  ++mp[c];

  if(mp[5] == 2 && mp[7] == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3632
N = gets.to_i
S = gets.strip

rn = S.count('R')
gn = S.count('G')
bn = N - rn - gn
s = [nil] + S.chars.map(&:ord)
rgb = %w(R G B).map(&:ord).sum
ans = rn*gn*bn
(1 .. (N - 1)/2).each do |d|
  (1 .. N - 2*d).each do |a|
    ans -= 1 if [s[a], s[a + d], s[a + 2*d]].sum == rgb
  end
end
puts ans

Measured memory_bytes: 14716
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n, q;
  while (cin >> n >> q, n || q)
  {
    int cnt[101] = {};
    for (int i = 0; i < n; ++i)
    {
      int m;
      cin >> m;
      for (int j = 0; j < m; ++j)
      {
        int d;
        cin >> d;
        cnt[d]++;
      }
    }
    int ans = 0, sum = 0;

    for (int i = 0; i <= 100; ++i)
    {
      if (cnt[i] >= q && sum < cnt[i])
      {
        ans = i;
        sum = cnt[i];
      }
    }
    cout << ans << endl;
  }

  return 0;
}



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

#define int long long

#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()

#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007


signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin>>n;
    if (n==2)
    {
    	cout<<"1";
    	return 0;
    }
    // if (n==5)
    // {
    // 	cout<<"3";
    // 	return 0;
    // }
    int ans = 2;
    for (int i=2;i*i<=n;++i)
    {
    	if (i*i==n)
    	{
    		// debug1(i);
    		ans++;
    	}
    	else
    	{
    		if (n%i==0)
    		{
    			int x = n;
    			while(x%i==0)
    				x/=i;
    			if (x%i==1){
    				// debug2(x, i);
    				ans++;
    			}
    		}
    		else if (n%i==1)
    		{
    			// debug1(i);
    			ans++;
    			int x = n/i;
    			if (n%x==1 && x!=i)
    				ans++;
    		}
    	}
    }
    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> dam(n), dam2(n), ans;
    for (int i = 0;i < n; ++i) {
        cin >> dam[i];
        dam2[i] = 2*dam[i];
    }
    ll temp=0;
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            temp += dam2[i];
        }
        else {
            temp -= dam2[i];
        }
    }
    ans.push_back(temp / 2);
    cout << ans[0];
    for (int i = 1; i < n; ++i) {
        ans.push_back(dam2[i-1] - ans[i - 1]);
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3828
def combination_modp(n, r, p): # nCr modpを求める
    r = min(n-r, r)
    result = 1
    for i in range(n, n-r, -1):
        result *= i
        result %=p
    for i in range(1, r+1):
        result *= pow(i,p-2,p)
        result %= p
    return result

x,y = map(int,input().split())
mod = 10**9 + 7

if (x+y)%3 != 0 or 2*y-x <0 or 2*x-y<0:
    print(0)
    exit()

a = (2*y-x)//3
b = (2*x-y)//3

ans = combination_modp(a+b,a,mod)
print(ans)

Measured memory_bytes: 38768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s;
		String tmp = sc.next();
		s = tmp.toCharArray();
		char current = s[0];
		int count = 1;
		for (int i = 1; i < n; i++) {
			if (current != s[i]) {
				count++;
			}
			current = s[i];
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 27220
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local N = read.n()
local ph = read.N(N)
local pt = {}
for i=1,N do pt[i] = 1 - ph[i] end

local tbl = array(2, 0)
tbl[0][0] = 1.

for i=1,N do
    tbl[i][0] = tbl[i-1][0] * pt[i]
    for j=1,i do
        tbl[i][j] = tbl[i-1][j] * pt[i] + tbl[i-1][j-1] * ph[i]
    end
end
local sum = 0
for c=math.ceil(N/2),N do
    sum = sum + tbl[N][c]
end

print(sum)

Measured memory_bytes: 105464
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


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

int main(){
  string S;
  cin >> S;
  int Y= S[1] - 96, X = S[0] - 96, Z = S[2] -96;
  if(Y*X*Z==6){
    cout << "Yes" << endl;
  }
  else{
	cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__;
const ll MOD = 1000000007;
const int MAX = 200000;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll a,b,c; cin >> a >> b >> c;
    ll x=c-a-b;
    ll y=4*a*b;
    if(x>0 && y<x*x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  string s;cin >> s;
  int n;cin >> n;
  for(int i=0;i<n;i++){
    string code;cin >> code;
    if(code=="replace"){
      int a,b;cin >> a >> b;
      string h;cin >> h;
      for(int i=0;i<h.size();i++){
        s[a+i]=h[i];
      }
    }
    if(code=="reverse"){
      int a,b;cin >> a >> b;
      for(int i=0;i<(b-a+1)/2;i++){
        char tmp = s[a+i];
        s[a+i] = s[b-i];
        s[b-i] = tmp;
      }
    }
    if(code=="print"){
      int a,b;cin >> a >> b;
      for(int i=a;i<=b;i++) cout << s[i];
      cout << endl;
    }
  }
}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define mpi map<int,int>
#define N 200005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
string s;
ll n,q,ans[N];
int main() {
	cin>>n>>q>>s;
	rep(i,0,n-1){
		ans[i+1]+=ans[i];
		if(s[i]=='A'&&s[i+1]=='C')ans[i+1]++;
	}
	rep(i,0,q){
		int a,b;
		cin>>a>>b;
		cout<<ans[b-1]-ans[a-1]<<"\n";
	}
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

    // SUB ID: UG02-53-20-001

int main()
{

    int A, B;
    scanf("%d%d",&A,&B);

    if(A+B>=A-B&&A+B>=A*B)
        printf("%d",A+B);
    else if(A+B>=A-B&&A+B>=A*B)
        printf("%d",A+B);
    else if(A-B>=A+B&&A-B>=A*B)
        printf("%d",A-B);
    else if(A*B>=A+B&&A*B>=A-B)
        printf("%d",A*B);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;
int sum(vector<int> vec){
  int s = 0;
  rep(i, vec.size()) s += vec.at(i);
  return s;
}

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> gates(a + 1);
  rep(i, b){
    int x;
    cin >> x;
    gates.at(x) = 1;
  }

  int ans = 0;
  int x = 0, y = 0;
  repm(i, c, a) x += gates.at(i);
  repr(i, c) y += gates.at(i);
  ans = min(x, y);

  cout << ans << endl;
}

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

template<int SZ> struct DSU {
    int parent[SZ], size[SZ], count[SZ];

    DSU() {
        F0R(i, SZ) parent[i] = i, size[i] = 0, count[i] = 1;
    }

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

    void unify(int x, int y) {
        x = get(x); y = get(y);
        if (x == y) return;
        if (size[x] < size[y]) swap(x, y);
        if (size[x] == size[y]) size[x]++;
        parent[y] = x;
        count[x] += count[y];

    }
};

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

    int N, M; cin >> N >> M;
    DSU<100010> data;
    F0R(i, M) {
        int X, Y, Z; cin >> X >> Y >> Z;
        data.unify(X, Y);
    }

    set<int> found;
    int ans = N;
    FOR(i, 1, N+1) {
        if (!found.count(data.get(i))) {
            found.insert(data.get(i));
            ans += 1 - data.count[data.get(i)];
        }
    }

    cout << ans << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

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

using namespace std;

int n,k;

void solve(){
    cin >> n;
    vector<int> dpa(n),dpb(n),dpc(n);
    vector<int> a(n),b(n),c(n);
    for(int i = 0;i < n;i++) cin >> a[i] >> b[i] >> c[i];
    dpa[0] = a[0];
    dpb[0] = b[0];
    dpc[0] = c[0];
    for(int i = 1;i < n;i++){
        dpa[i] = a[i] + max(dpb[i-1],dpc[i-1]);
        dpb[i] = b[i] + max(dpa[i-1],dpc[i-1]);
        dpc[i] = c[i] + max(dpa[i-1],dpb[i-1]);
    }
    cout << max(max(dpa[n-1],dpb[n-1]),dpc[n-1]) << endl;
}

int main(){
    solve();
}


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

struct dice{
  int s1[6];
  int s2[6];
  char c[101];
};

int main(){
  struct dice D;
  int i,j;

  for(i=0;i<6;i++)
    scanf("%d",&D.s1[i]);

  scanf("%s",D.c);

  for(i=0;i<strlen(D.c);i++){
    for(j=0;j<6;j++)
      D.s2[j] = D.s1[j];

    if(D.c[i] == 'S'){
      D.s1[0] = D.s2[4];
      D.s1[1] = D.s2[0];
      D.s1[4] = D.s2[5];
      D.s1[5] = D.s2[1];
    }
    else if(D.c[i] == 'E'){
      D.s1[0] = D.s2[3];
      D.s1[2] = D.s2[0];
      D.s1[3] = D.s2[5];
      D.s1[5] = D.s2[2];
    }
    else if(D.c[i] == 'N'){
      D.s1[0] = D.s2[1];
      D.s1[1] = D.s2[5];
      D.s1[4] = D.s2[0];
      D.s1[5] = D.s2[4];
    }
    else if(D.c[i] == 'W'){
      D.s1[0] = D.s2[2];
      D.s1[2] = D.s2[5];
      D.s1[3] = D.s2[0];
      D.s1[5] = D.s2[3];
    }
  }
  printf("%d\n",D.s1[0]);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

signed main() {
  fio();

  string s;
  cin >> s;
  int n = s.size() + 1;
  vi a(n);
  rep (i, n - 1) {
    if (s[i] == '>' and s[i + 1] == '>') {
      a[i + 1] = 0;
    }
  }
  //DEBUG_VEC(a);

  rep (i, n - 1) {
    if (s[i] == '<') {
      chmax(a[i + 1], a[i] + 1);
    }
  }

  rrep (i, n - 1) {
    if (s[i] == '>') {
      chmax(a[i], a[i + 1] + 1);
    }
  }

  //DEBUG_VEC(a);
  
  ll ans = 0;
  rep (i, n) ans += a[i];
  cout << ans << endl;
}


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

int main()
{
  ll h, w, a;
  cin >> h >> w;
  if (h >= 2 && w >= 2)
  {
    cout << (h * w + 1) / 2;
  }
  else
  {
    cout << 1 << endl;
  }
}

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

vector<P> a;
int n;
map<int,string> memo,memo2;


int partition(int p,int r){
    int x = a[r].first;
    int i = p-1;
    for(int j=p;j<=r-1;j++){
        if(a[j].first<=x){
            i++;
            swap(a[i],a[j]);
        }
    }
    swap(a[i+1],a[r]);
    return i+1;
}

void quicksort(int p, int r){
    if(p<r){
        int q = partition(p, r);
        quicksort(p, q-1);
        quicksort(q+1, r);
    }
}

void isStable(){
    rep(i,n) memo2[a[i+1].first] += a[i+1].second;
    bool ok = true;
    rep(i,n) if(memo[a[i+1].first] != memo2[a[i+1].first]) ok = false;
    cout << ( ok ? "Stable" : "Not stable") << endl;
}

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

    a.resize(n+1);
    rep(i,n){
        cin >> a[i+1].second >> a[i+1].first;
        memo[ a[i+1].first ] += a[i+1].second;
    }
    quicksort(1,n);
    isStable();
    rep(i,n){
        cout << a[i+1].second << " " << a[i+1].first << endl;
    }
    return 0;
}



Measured memory_bytes: 14432
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int a,b,c;

int main(void){
	scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",max(0,c-(a-b)));
	return 0;
}


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

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);

    int count = 0;
    rep(i, N) {      // 人
        rep(j, D) {  // 日
            if (j * A.at(i) + 1 <= D) {
                count++;
            }
        }
    }

    int ans = count + X;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=1e9;
    for(int i=-100;i<=100;i++){
        int sum=0;
        for(int j=0;j<n;j++){
            sum+=abs(a[j]-i)*abs(a[j]-i);
        }
        if(ans>sum)ans=sum;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;
    if (s.size() == 2) cout << s << endl;
    else {
        reverse(s.begin(), s.end());
        cout << s << endl;
    }

    return 0;
}


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

int main() {
  int64_t N;
  cin >> N;
  vector<int> list(N);
  vector<int> pen(N);
  int minimum = N + 1;
  int cnt = 0;
  for (int i = 0; i < N; i++){
    int a;
    cin >> a;
    if (minimum > a){
      cnt++;
      minimum = a;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1792
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

h,w,k = get_nums_l()
grid = [ input() for _ in range(h)]

ruiseki_white = [ [0] * (w+1) for _ in range(h) ]
for y in range(h):
    for x in range(w):
        ruiseki_white[y][x+1] = ruiseki_white[y][x] + (1 if grid[y][x] == "1" else 0)

# log(ruiseki_white)

def num_whites(l,r,t,b):
    ret = 0
    for y in range(t, b):
        ret += ruiseki_white[y][r] - ruiseki_white[y][l]
    # log(l,r,t,b,ret)
    return ret

ans = 999999999999999999

for bits in range(2**(h-1)):
    h_breaks=[0]
    for i in range(h-1):
        if bits &  2**i != 0:
            h_breaks.append(i+1)
    h_breaks.append(h)

    # log("h_breaks: ", h_breaks)

    w_break_count = 0
    prev_w_break = 0
    ok = True
    for x in range(1,w+1):
        for i in range(len(h_breaks) - 1):
            top = h_breaks[i]
            bottom = h_breaks[i+1]
            left = prev_w_break
            right = x
            if num_whites(left, right, top, bottom) > k:
                # ここの左で切る
                # log("CUT", left, right, top, bottom)
                if prev_w_break + 1 == x:
                    # この縦の切り方はだめ
                    ok = False
                prev_w_break = x-1
                w_break_count += 1
                break
        if not ok:
            break
    if ok:
        # log("ok. wbreak_count: ", w_break_count)
        ans = min(ans, len(h_breaks)-2 + w_break_count)

print(ans)

Measured memory_bytes: 45532