akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool ok[9][9];
int m[9][9];

void reset(int *r){
	for(int i = 0; i < 10; ++i)
		*(r + i) = 0;
}

void func(int x, int y){
	int cn[10] = {};
	for(int i = x; i < x + 3; ++i)
		for(int j = y; j < y + 3; ++j)
			cn[m[i][j]]++;
			
	for(int i = x; i < x + 3; ++i){
		for(int j = y; j < y + 3; ++j){
			if(cn[m[i][j]] >= 2)
				ok[i][j] = true;
		}
	}
}
int main() {
	int n;
	cin >> n;
	for(int c = 0; c < n; ++c){
		for(int i = 0; i < 9; ++i)
			for(int j = 0; j < 9; ++j)
				ok[i][j] = false;
			
		for(int i = 0; i < 9; ++i)
			for(int j = 0; j < 9; ++j)
				cin >> m[i][j];
		
		int cnt[10] = {0};
		for(int i = 0; i < 9; ++i){
			for(int j = 0; j < 9; ++j)
				cnt[m[j][i]]++;
				
			for(int j = 0; j < 9; ++j){
			if(cnt[m[j][i]] >= 2)
				ok[j][i] = true;
			}
			reset(cnt);
		}
	
		for(int i = 0; i < 9; ++i){
			for(int j = 0; j < 9; ++j)
				cnt[m[i][j]]++;
				
			for(int j = 0; j < 9; ++j){
				if(cnt[m[i][j]] >= 2)
					ok[i][j] = true;
			}
			reset(cnt);
		}
		
		for(int i = 0; i < 9; i += 3)
			for(int j = 0; j < 9; j += 3)
				func(i, j);
				
		for(int i = 0; i < 9; ++i){
			for(int j = 0; j < 9; ++j){
				if(ok[i][j])
					cout << "*";
				else
					cout << " ";
				cout << m[i][j];
			}
			cout << endl;
		}
		if(c != n - 1)
			cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main()

{

     int a,b;

    scanf("%d %d",&a,&b);

    if(a<b){

       printf("a < b\n");

    }

    if(a>b){

       printf("a > b\n");

    }

    if(a==b){

       printf("a == b\n");

    }

    return 0;

}

Measured memory_bytes: 1008
import fractions
from functools import reduce

N=int(input())
T = [int(input()) for i in range(N)]

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(T))

Measured memory_bytes: 5048
let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then (
                if flag then cur :: acc else acc
            ) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) 0 false (cur :: acc)
                | false, ' ' -> loop (i + 1) 0 false acc
                | true,  v   -> loop (i + 1) (cur * 10 + int_of_char v - 48) true acc
                | false, v   -> loop (i + 1) (cur * 10 + int_of_char v - 48) true acc
            )
        in
        List.rev (loop 0 0 false [])
    in
    let main () =
        let n = int_of_string (read_line ()) in
        let a = Array.of_list (split (read_line ())) in
        let buf = Array.make n 0 in
        let ans = Array.make n 0 in
        for i = n downto 1 do
            let f = buf.(i - 1) lxor a.(i - 1) in
            let () = ans.(i - 1) <- f in
            let rec loop j =
                if i >= j * j then (
                    if i mod j = 0 then (
                     (*   if f <> 0 then Printf.printf "buf %d %d to %d\n" j buf.(j - 1) (buf.(j - 1) lxor f); *)
                        buf.(j - 1) <- buf.(j - 1) lxor f;
                        let l = i / j in
                        if l <> j then (
                     (*   if f <> 0 then Printf.printf "buf %d %d to %d\n" l buf.(l - 1) (buf.(l - 1) lxor f); *)
                        buf.(l - 1) <- buf.(l - 1) lxor f;
                        )
                    );
                    loop (j + 1)
                )
            in
            loop 1
        done;
        Printf.printf "%d\n" (Array.fold_left (+) 0 ans);
        for i = 1 to n do
            if ans.(i - 1) > 0 then Printf.printf "%d  " i
        done;
        print_newline ()
    in
    main ()

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(m);
  rep(i, m) cin >> a[i];

  ll sum = 0;

  rep(i, m) sum += a[i];

  ll ans = n - sum;

  if (ans >= 0) cout << ans << endl;
  else cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 3712
import java.util.Scanner;

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

	    while(true){
	        Hcount = sc.nextInt();
	        Wcount = sc.nextInt();

	        if(Hcount ==0 && Wcount ==0) {
	        	break;
	        }
	        for(int i =0; i<Hcount;i++) {
	        	for(int x =0; x<Wcount;x++) {
		        	System.out.print("#");
		        }
		        System.out.println();
	        }
	        System.out.println();
	    }


	}
}


Measured memory_bytes: 35024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <utility>
#include <cstring>
using namespace std;

#define INF 1000
#define TEST 0
#if TEST
FILE* in = freopen("./B.txt", "r", stdin);
FILE* out = freopen("./ans.txt", "w", stdout);
#endif

int w, h;
int barrier[2][40][40];
int cost[40][40];

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

inline bool isRegion(int x, int y){
    return x >= 0 && x < w && y >= 0 && y < h;
}

void bfs(){
    bool isChecked[40][40] = {false};
    queue<pair<int,int> > q;
    q.push(make_pair(0,0));
    isChecked[0][0] = true;
    
    while(!q.empty()){
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        cost[x][y] = INF;
        if(!x && !y) cost[x][y] = 1;
        
        for(int i = 0; i < 4; i++){
            int nx = x + dx[i], ny = y + dy[i];
            
            int isV = (i+1) & 1;
            int minX = min(x, nx), minY = min(y, ny);
            if(isRegion(nx, ny) && !barrier[isV][minX][minY]){
                if(cost[nx][ny]){
                    cost[x][y] = min(cost[x][y], cost[nx][ny] + 1);
                } else if(!isChecked[nx][ny]){
                    q.push(make_pair(nx, ny));
                    isChecked[nx][ny] = true;
                }
            }
        }
    }
}

int main(int argc, const char * argv[]) {
    
    int cnt = 0;
    while(1){
        scanf("%d %d", &w, &h);
        if(!w && !h) break;
        cnt++;
        
        // ?????????
        memset(cost, 0, sizeof(cost));

        // ??\???
        for(int y = 0; y < h; y++){
            for(int x = 0; x < w - 1; x++){
                scanf("%d", &barrier[0][x][y]);
            }
            if(y != h-1){
                for(int x = 0; x < w; x++){
                    scanf("%d", &barrier[1][x][y]);
                }
            }
        }
        
        // ???????????¢?´¢
        bfs();
        //cout << cnt << "(w=" << w << ",h=" << h << "): ";
        cout << cost[w-1][h-1] << endl;
    }
#if TEST
    fclose(in);
    fclose(out);
#endif
}

Measured memory_bytes: 1244
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		sc.close();
		int cost1=0;
		int cost2=0;
		int anumber = N/A;
		int bnumber = N/C;
		int cost;
		if(N%A==0) {
			cost1+=B*anumber;
		}
		else {
			cost1+=B*(anumber+1);
		}
		if(N%C==0) {
			cost2+=D*bnumber;
		}
		else {
			cost2+=D*(bnumber+1);
		}
		if(cost1>cost2) {
			cost=cost2;
		}
		else {
			cost=cost1;
		}
		System.out.println(cost);
		

	}
}



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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    lld n, m;
    scanf("%lld %lld", &n, &m);
    n -= 2; m -= 2;
    if(n < 0){
        n = 1;
    }
    if(m < 0){
        m = 1;
    }
    printf("%lld", n*m);

    return 0;
}

Measured memory_bytes: 128
import math

class Circle:
    def __init__(self,x,y,r):
        self.x = x
        self.y = y
        self.r = r

def getCircle(x1, y1, x2, y2, x3, y3):
    d = 2 * (x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
    px = ((x1**2 + y1**2) * (y2 - y3) + (x2**2 + y2**2) * (y3 - y1) + (x3**2 + y3**2) * (y1 - y2) ) / d
    py = ((x1**2 + y1**2) * (x3 - x2) + (x2**2 + y2**2) * (x1 - x3) + (x3**2 + y3**2) * (x2 - x1) ) / d
    a = math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
    b = math.sqrt((x1 - x3)**2 + (y1 - y3)**2)
    c = math.sqrt((x2 - x3)**2 + (y2 - y3)**2)
    s = (a + b + c) / 2
    A = math.sqrt(s * (s - a) * (s - b) * (s - c))
    r = a * b * c / (4 * A)
    return Circle(px,py,r)

          
n = int(input())
for k in range(n):
    x1, y1, x2, y2, x3, y3 = [float(x) for x in input().split()]
    circle = getCircle(x1, y1, x2, y2, x3, y3)
    print("%.3f %.3f %.3f" % (circle.x, circle.y, circle.r))


Measured memory_bytes: 5692
from math import log2, ceil
n, k = map(int, input().split())
dic = {}
for i in range(1, n + 1):
  x = max(0, ceil(log2(k / i)))
  dic.setdefault(x, 0)
  dic[x] += 1
res = 0
for i in dic:
  res += (dic[i] * (2 ** -i))
print(res / n)

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

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    queue<int> w;
    stack<int> r;
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        if (c == 'W') {
            w.push(i);
        } else {
            r.push(i);
        }
    }
    int cnt = 0;
    while (w.size() > 0 && r.size() > 0) {
        int wi = w.front();
        w.pop();
        int ri = r.top();
        r.pop();
        if (wi >= ri) {
            break;
        }
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int i = 1; i <= N; i++){
            a[sc.nextInt() - 1] = i;
        }
        Arrays.stream(a).forEach(i -> System.out.print(i + " "));

    }

}


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

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;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const int INF=1e9;
const double eps=0.0000000001;



int main(){
  ll n;
  cin >> n;
  ll a[1000000];
  ll mini=10000000000;
  ll v=0,x=0;
  FOR(i,n){
    cin >> a[i];
    chmin(mini,abs(a[i]));
    v+=abs(a[i]);
    if(a[i]<0)x++;
  }

  if(x%2==0){
    cout <<v << endl;
  }else{
    cout << v-mini*2 << endl;
  }

  

  
  
}

Measured memory_bytes: 3072
while line = gets do
  n = line.to_i
  counter = 0
  10.times do |i|
    10.times do |j|
      10.times do |k|
        10.times do |m|
          if i + j + k + m == n then counter += 1 end
        end
      end
    end
  end
  puts counter
end

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



int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0;i<N;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  bool same = false;
  for (int i=0;i<N-1;i++){
    if(a.at(i) == a.at(i+1)){
      same = true;
      break;
    }
  }
  
  if(same){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define N 1200

int main(){
  int i;
  char s[N];
  scanf("%[^\n]", s);

  for(i = 0; i < strlen(s); i++){
    if(isupper(s[i]) != 0)
      s[i] = tolower(s[i]);
    else if(islower(s[i]) != 0)
      s[i] = toupper(s[i]);
    printf("%c", s[i]);
  }

  printf("\n");
  return 0;
}



Measured memory_bytes: 2048
// atcoder/abc088/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> a(n);
    cin >> a;
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int sum[2] = {0, 0};
    sum[0] = sum[1] = 0;
    for (int i = 0; i < n; ++i) {
      sum[i % 2] += a[i];
    }
    cout << sum[0] - sum[1] << endl;
  }

  return 0;
}


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

using namespace std;

typedef int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

const li N=1e3+5;

vector<vi> vis(N, vi(N,0));
char a[N][N];

vi dx={-1,1,0,0};
vi dy={0,0,1,-1};

vi dd={-2,-1,0,1,2};

li n,m;

bool ok(li x,li y)
{
    if(x<0 || x>=n || y>=m || y<0)
        return false;

    if(a[x][y]=='#')
        return false;

    if(vis[x][y])
        return false;

    return true;
}

void solve()
{
    cin>>n>>m;

    li x1,y1,x2,y2;

    cin>>x1>>y1>>x2>>y2;
    --x1;--x2;--y1;--y2;

    f(i,0,n-1)
    {
        f(j,0,m-1)
        {
            cin>>a[i][j];
        }
    }

    priority_queue<pair<li,pi>,vector<pair<li,pi>>,greater<pair<li,pi>>> pq;

    pq.push({0,{x1,y1}});

    while(!pq.empty())
    {
        pair<li,pi> tp=pq.top();
        pq.pop();

        li val=tp.F,x=tp.S.F,y=tp.S.S;

        if(x==x2 && y==y2)
        {
            cout<<val;
            return;
        }

        if(vis[x][y])
            continue;

        vis[x][y]=1;

        f(i,0,3)
        {
            li xx=x+dx[i];
            li yy=y+dy[i];

            if(ok(xx,yy))
            {
                pq.push({val,{xx,yy}});
            }
        }

        f(i,0,4)
        {
            f(j,0,4)
            {
                li xx=x+dd[i];
                li yy=y+dd[j];

                if(ok(xx,yy))
                {
                    pq.push({val+1,{xx,yy}});
                }   
            }
        }
    }

    cout<<-1;

}

int main()
{    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

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

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 9812
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] prefix = new int[n];
		int[] postfix = new int[n];
		int[] nums = new int[n];
		
		for (int i = 0; i < n; i++) {
			int w = sc.nextInt();
			nums[i] = w;
		}
		
		prefix[0] = nums[0];
		
		for (int i = 1; i < nums.length; i++) {
			prefix[i] = nums[i] + prefix[i-1];
		}

		postfix[n-1] = nums[n-1];
		
		for (int i = n - 2; i >= 0; i--) {
			postfix[i] = postfix[i+1] + nums[i];
		}

		int res = Integer.MAX_VALUE;
		
		for (int i = 1; i < n; i++) {
			res = Math.min(res, Math.abs(postfix[i] - prefix[i-1]));
		}
		
		System.out.println(res);
	}

}

Measured memory_bytes: 23764
#include <stdio.h>

#define NUM_MAX (45)

int dp[NUM_MAX];

int
fibonacci(int num)
{
        if (num <= 1)
                return dp[num] = 1;

        if (dp[num] != -1)
                return dp[num];

        return dp[num] = fibonacci(num - 1) + fibonacci(num - 2);
}

int
main(void)
{
        int num;
        int i;

        for (i = 0; i < NUM_MAX; i++)
                dp[i] = -1;

        scanf("%d", &num);
        printf("%d\n", fibonacci(num));

        return 0;
}



Measured memory_bytes: 2032
#include "stdlib.h"
#include "stdio.h"
#include "string.h"

struct NODE{
    int key;
    struct NODE *prev, *next;
};

struct NODE *head;

void init(){
    head = (struct NODE*)malloc(sizeof(struct NODE));
    head->next = head;
    head->prev = head;
}

void insert(int x){
    struct NODE *temp = (struct NODE*)malloc(sizeof(struct NODE));
    temp->key = x;
    temp->next = head->next;
    head->next->prev = temp;
    head->next = temp;
    temp->prev = head; 
}

struct NODE* listSearch(int x){
    struct NODE *cur = head->next;
    while(cur != head && cur->key != x){
        cur = cur->next;
    }
    return cur;
}

void deleteNode(struct NODE *deleNode){
    if(deleNode == head){
        return;
    }
    deleNode->prev->next = deleNode->next;
    deleNode->next->prev = deleNode->prev;
}

void delete(int x){
    deleteNode(listSearch(x));
}

void deleteFirst(void){
    deleteNode(head->next);
}

void deleteLast(void){
    deleteNode(head->prev);
}

int N;
char ins[10];
int opNum;


int main(){
    //freopen("DoublyLinkedList.txt", "r", stdin);
    init();
    scanf("%d", &N);
    for(int i=0; i<N; i++){
        scanf("%s", ins);
        if(strcmp(ins, "insert") == 0)
        {
            scanf("%d", &opNum);
            insert(opNum);
        }
        else if(strcmp(ins, "delete") == 0){
            scanf("%d", &opNum);
            delete(opNum);
        }
        else if(strcmp(ins, "deleteFirst") == 0){
            deleteFirst();
        }
        else{
            deleteLast();
        }
    }
    struct NODE *cur = head->next;
    while(cur != head->prev){
        printf("%d ", cur->key);
        cur = cur->next;
    }
    printf("%d\n", cur->key);
}


Measured memory_bytes: 36108
#include<bits/stdc++.h>
using namespace std;
int main() {
	int city[4] = {};
	for (int i = 0; i < 3; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		city[a]++;
		city[b]++;
	}
	int cnt_1 = 0, cnt_2 = 0;
	for (int i =0 ; i < 4; i++) {
		if (city[i] == 1) cnt_1++;
		else if (city[i] == 2) cnt_2++;
	}
	if (cnt_1 == 2 && cnt_2 == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<ctime>
#include<cstdlib>
#define INF long long int(1e18+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main() {
	long long int n = 7, k;
	long long int ans = 1;
	long long int x;
	cin >> k;
	if (k == 1) {
		cout << 1 << endl;
		return 0;
	}
	while (1) {
		if (n % k==0) {
			cout << ans << endl;
			return 0;
		}
		x = n % k;
		n = x * 10 % k; 
		n += 7;
		n = n % k;
		ans++;
		if (ans > 2000000)break;
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3652
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if (a > 10 || b > 10 && c >10) && (a<1 && b < 1 && c < 1){
		return
	}

	if (a == b && b != c) || (a == c && c != b) || (b == c && a != b){
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}

Measured memory_bytes: 1768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))

const int maxn = 5e5 + 10;
const int inf = 0x7ffffff;

void solve()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (1)
    {
        c -= b;
        if(c<=0)
        {
            cout << "Yes\n";
            return;
        }
        a -= d;
        if(a<=0)
        {
            cout << "No\n";
            return;
        }
    }
    


}

int main()
{
    //freopen("out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while(T-- > 0)
        solve();

}

Measured memory_bytes: 3636
using System;
using System.IO;
using System.Collections.Generic;
namespace aoj{
    class program{
     
	    static void Main() {
			RPN rpn = new RPN(Console.ReadLine());
			rpn.analyze();
	    }
	}
	class Stack{
		List<int> stk;
		public Stack(){
			stk = new List<int>();
		}
		public void push(int val){
			stk.Add(val);
		//	Console.WriteLine("push:{0}",val);
		}
		public int pop(){
			int tmp=stk[stk.Count-1];
			stk.RemoveAt(stk.Count-1);
		//	Console.WriteLine("pop:{0}",tmp);
			return tmp;
		}
		public int ans(){
			return stk[0];
		}
	}
	class RPN{
		string[] exp;
		Stack stack;
		public RPN(string e){
			exp = e.Split(' ');
			stack = new Stack();
			
		}
		public void analyze(){
			int num;
			foreach(string str in exp){
				if(Int32.TryParse(str,out num))
					stack.push(num);
				else{
				//	int tmp=0;
					stack.push(calc(stack.pop(),stack.pop(),str[0]));
				//	Console.WriteLine("calc:{0}",tmp);
				}
			}
			Console.WriteLine(stack.ans());
		}
		int calc(int b, int a, char op){
			if(op=='+')
				return a+b;
			if(op=='*')
				return a*b;
			if(op=='-')
				return a-b;
			Console.WriteLine("error");
			return 0;
		}
	}

}

Measured memory_bytes: 7692
import sys
from collections import Counter
input = sys.stdin.readline

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]


s = Counter(s)
t = Counter(t)
s.subtract(t)

print(max(0, s.most_common(1)[0][1]))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

int x, a;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> x >> a;
  if (x < a) cout << 0;
  else cout << 10;
  cout << endl;
  return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S):
    ans = 0
    pre_b = set()
    post_a = set()
    for i, s in enumerate(S):
        if s[0] == 'B':
            pre_b.add(i)
        if s[-1] == 'A':
            post_a.add(i)
        ans += s.count('AB')
    # error_print(ans)
    both = pre_b & post_a
    if both:
        ans += len(pre_b & post_a) - 1
    pre_b -= both
    post_a -= both
    # print(pre_b, post_a)
    pbl = len(pre_b)
    pal = len(post_a)
    if both:
        if pbl == 0 and pal == 0:
            pass
        elif pbl == 0:
            # print(min(max(pbl, 1), max(pal, 1),))
            ans += min(1, pal)
        elif pal == 0:
            ans += min(1, pbl)
        else:
            ans += min(pbl+1, pal+1)
    else:
        ans += min(pbl, pal)
    return ans


def slv2(N, S):
    ans = 0
    for i in permutations(range(N), N):
        ans = max(ans, ''.join([S[j] for j in i]).count('AB'))
    return ans


def main():
    N = read_int()
    S = [read_str() for _ in range(N)]
    print(slv(N, S))
    # print(slv2(N, S))

    # for _ in range(1000):
    #     N = 5
    #     S = [''.join(random.choices('ABC', k=5)) for _ in range(N)]
    #     if slv2(N, S) != slv(N, S):
    #         print(S)
    #         break


if __name__ == '__main__':
    main()


Measured memory_bytes: 8648
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=998244353
    N,S=MI()
    A=LI()
    
    dp=[[0]*(S+1)for _ in range(N+1)]
    #dp[i][j]はi番目まで見た時に和がjになる組み合わせを何通り作れるか．
    #ただし，iを増やすたびにj=0が1つ増える（Lがひとつずれたものと対応）
    
    for i in range(N):
        a=A[i]
        dp[i][0]+=1
        for j in range(S+1):
            dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod
            if j+a<=S:
                dp[i+1][j+a]=(dp[i+1][j+a]+dp[i][j])%mod
                
    ans=0
    for i in range(N+1):
        ans=(ans+dp[i][-1])%mod
        
    print(ans)
                
            
    
            
        

main()


Measured memory_bytes: 111708
#include<iostream>
#include<time.h>
#include<random>
using namespace std;
const int INFTY =2147483647;

struct work{
    int a,b;
};

work L[200005],R[200005];

void merge(work A[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;i++) L[i]=A[left+i];
    for(int i=0;i<n2;i++) R[i]=A[mid+i];
    L[n1].b =R[n2].b=INFTY;
    int i=0,j=0;
    for(int p=left;p<right;p++){
        if(L[i].b<=R[j].b) A[p]=L[i++];
        else A[p]=R[j++];
    }
}

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

int main(){
    int n;
    cin>>n;
    work A[200005];
    for(int i=0;i<n;i++)cin>>A[i].a>>A[i].b;
    sort(A,0,n);

    bool ans=true;
    long long sum=0;
    for(int i=0;i<n;i++){
        sum+=A[i].a;
        if(sum>A[i].b){
            ans=false;
            break;
        }
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#include<complex>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef complex<double> P;
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
P pin(){
	double x,y;
	cin>>x>>y;
	P p(x,y);
	return p;
}
void PIN(P* a,int n){
	rep(i,n)a[i]=pin();
}
double dot(P a,P b){
	return real(conj(a)*b);
}
double cross(P a,P b){
	return imag(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
} 
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		P p[4];
		PIN(p,4);
		P a=p[1]-p[0];
		P b=p[3]-p[2];
		double t1=abs(cross(a,p[2]-p[0]));
		double t2=abs(cross(a,p[3]-p[0]));
		P ans=p[2]+b*t1/(t1+t2);
		printf("%.9f %.9f\n",ans.real(),ans.imag());
	}
}

Measured memory_bytes: 1252
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());

using ll = long long int;

int main(){
    int n;
    cin >> n;
    for(int i = 0; i <= n; ++i) {
        if(i * 108 / 100 == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a, b, c, i;
	int counter = 0;
	scanf("%d %d %d", &a, &b, &c);
	for(i = a; i <= b; i++){
		if( c%i == 0){
			counter++;
		}
		else{
			continue;
		}
	}
	printf("%d\n", counter);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,N,A=0;
vl a;

int main(){
	cin>>n;
	N=n/2;
	a=vl(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());
	if(n%2==0){
		for(int i=0;i<N;i++) A-=2*a[i];
		for(int i=N;i<n;i++) A+=2*a[i];
		cout<<A+a[N-1]-a[N]<<endl;
	}
	else{
		for(int i=0;i<N;i++) A-=2*a[i];
		for(int i=N+1;i<n;i++) A+=2*a[i];
		cout<<max(A+a[N-1]-a[N],A+a[N]-a[N+1])<<endl;
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

const int M = 2;
const int N = 10;
vector<vector<int>> bit_w;
vector<vector<int>> bit_h;
void dfs(vector<int> &A, int size)
{
    if (A.size() == size)
    {
        bit_w.push_back(A);
        return;
    }

    for (int v = 0; v < M; ++v)
    {
        A.push_back(v);
        dfs(A, size);
        A.pop_back();
    }
}

void dfs2(vector<int> &A, int size)
{
    if (A.size() == size)
    {
        bit_h.push_back(A);
        return;
    }

    for (int v = 0; v < M; ++v)
    {
        A.push_back(v);
        dfs2(A, size);
        A.pop_back();
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(k));
    vector<vector<char>> store(h, vector<char>(k));
    vector<vector<char>> check(h, vector<char>(k));
    int b_cnt = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> c[i][j];
            store[i][j] = c[i][j];
            if (c[i][j] == '#')
                b_cnt++;
        }
    }
    if (b_cnt < k)
    {
        cout << 0 << endl;
        return 0;
    }

    vector<int> A;
    vector<int> B;
    dfs(A, w);
    dfs2(B, h);
    int ans = 0;
    for (int i = 0; i < bit_w.size(); i++)
    {
        // 初期化
        for (int index_i = 0; index_i < h; index_i++)
        {
            for (int index_j = 0; index_j < w; index_j++)
            {
                store[index_i][index_j] = c[index_i][index_j];
                check[index_i][index_j] = c[index_i][index_j];
            }
        }
        int s_cnt = b_cnt;
        int c_cnt = b_cnt;
        for (int j = 0; j < w; j++)
        {
            if (bit_w[i][j] == 1)
            {
                for (int k = 0; k < h; k++)
                {
                    if (store[k][j] == '#')
                    {
                        s_cnt--;
                        store[k][j] = '.';
                    }
                }
            }
        }
        for (int l = 0; l < bit_h.size(); l++)
        {
            // 初期化
            for (int index_i = 0; index_i < h; index_i++)
            {
                for (int index_j = 0; index_j < w; index_j++)
                {
                    check[index_i][index_j] = store[index_i][index_j];
                }
            }
            int c_cnt = s_cnt;
            for (int f = 0; f < h; f++)
            {
                if (bit_h[l][f] == 1)
                {
                    for (int q = 0; q < w; q++)
                    {
                        if (check[f][q] == '#')
                        {
                            c_cnt--;
                            check[f][q] = '.';
                        }
                    }
                }
            }
            if (c_cnt == k)
                ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main()
{ int N;
 scanf("%d",&N);
 if(N%10==3)
 { 
   printf("bon");
   return 0;
 }
 else if((N%10==0)||(N%10==1)||(N%10==6)||(N%10==8))
 {
   printf("pon");
   return 0;
 }
 else printf("hon");
 return 0;
}


Measured memory_bytes: 1696
#include <iostream>
 
using namespace std;
 
int main()
{
    int z=0;
char  x[3],y[3];
 for(int i=0;i<3;i++){
 cin>>x[i];
 }
  for(int i=0;i<3;i++){
 cin>>y[i];
 }
 for(int i=0;i<3;i++){
 if(x[i]==y[i])
     z++;
 }
 cout<<z;
 
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int Y = scanner.nextInt();
        int Z = scanner.nextInt();
        System.out.print(Z);
        System.out.print(" ");
        System.out.print(X);
        System.out.print(" ");
        System.out.print(Y);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	string ans = "Good";
	rep(i, sz(s) - 1)
	{
		if (s[i] == s[i + 1])	ans = "Bad";
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections

def solve(N,K,P):
    P.sort()
    ans = 0
    for i in range(K):
        ans += P.pop(0)
    return ans
def main():
    N,K = map(int,input().split())
    P = list(map(int,input().split()))
    # solve()
    print(solve(N,K,P))

if __name__ == "__main__":
    main()


Measured memory_bytes: 9460
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if (a > b) swap(a, b);
  for (int i=0; i<b; i++) {
    cout << a;
  }
  cout << endl;
}

Measured memory_bytes: 256
from collections import deque
h,w = map(int,input().split())
d = [input() for i in range(h)]
count = 0
for i in range(h):
    for j in range(w):
        if d[i][j] == '#':
            count+=1
visited = [[0 for i in range(w)] for i in range(h)]
def bfs(sy,sx,gy,gx):
    que = deque()
    que.append((sy,sx))
    visited[sy][sx] = 0
    while que:
        y,x = que.popleft()
        if y == gy and x == gx:
            return visited[y][x]
        for dy,dx in [(-1,0),(1,0),(0,-1),(0,1)]:
            ny,nx = y+dy, x+dx
            if ny < 0 or nx < 0 or ny >= h or nx >= w:
                continue
            elif d[ny][nx] == '#':
                continue
            elif visited[ny][nx] != 0:
                continue
            else:
                visited[ny][nx] = visited[y][x] + 1
                que.append((ny,nx))
    return visited[gy][gx]
ans = bfs(0,0,h-1,w-1)
if ans == 0:
    print(-1)
    exit()
print(h*w - ans - count - 1)

Measured memory_bytes: 39920
#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>

using namespace std;
typedef long long int ll;

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

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

    cout << r*r << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;

int main(void){
    int N; cin >> N;
    vector<int> a(N*2);
    int i=0;

    while(N > i){
        long long tmp = 0;
        cin >> tmp;
        a.push_back(tmp);
        a.push_back(tmp);
        i++;
    }
    sort(a.begin(), a.end(), greater<int>());
    int count = 0;
    long long sum = 0;
    a[0] = 0;
    while (N > count) {
        sum += a[count];
        count++;
    }
    cout << sum << endl;
}

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

int main(){
    int a,b,c,d,e;
    cin>>a;
    b=a/3600;
    c=a%3600;
    d=c/60;
    e=c%60;
    cout<<b<<":"<<d<<":"<<e<<endl;
    
}


Measured memory_bytes: 3120
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderCs
{

    class Program
    {

        const int Mod = 1000000007;

        static void Main()
        {

            var arg = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var useDays = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).Sum();

            Console.WriteLine(arg[0] < useDays ? -1 : arg[0] - useDays);

        }


    }
}


Measured memory_bytes: 29072
function Main(input) {
	var lines = input.split("\n");
    var words = lines[0].split(" ");
    var ans1 = [5, 5, 7]
    var ans2 = [5, 7, 5]
    var ans3 = [7, 5, 5]
	console.log(words.join('') === ans1.join('') || words.join('') === ans2.join('') || words.join('') === ans3.join('') ? 'YES' : 'NO')
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7372
#define _CRT_SECURE_NO_WARNINGS

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

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define SREP(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;
int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
int prime[50000] = { 0 };
int prime3[50000] = { 0 };
int idx;
int n;

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}
void getPrime(int num) {
	if (num < 2) {
		idx = -1;
		return;
	}
	prime[0] = 2;
	if (num < 3) {
		idx = 0;
		return;
	}
	idx = 1;
	prime[0] = 2;
	prime[1] = 3;
	int i, j;
	int start;
	int flag;
	for (i = prime[idx] + 2; i <= num; i += 2) {
		flag = 1;
		for (j = 0; prime[j] <= (int)sqrt(i); j++) {
			if (i%prime[j] == 0) {
				flag = 0;
				break;
			}
		}
		if (flag)prime[++idx] = i;
	}
}
void get3Prime() {
	prime3[0] = 2;
	idx = 1;
	REPS(i, 10000) {
		if (prime[i] == 0)break;
		if (prime[i] % 10 == 3) {
			prime3[idx++] = prime[i];
		}
		if (idx == 55)break;
	}
}

int main() {
	scanf("%d", &n);
	getPrime(10000);
	get3Prime();
	REP(i, n) {
		printf("%d", prime3[i]);
		if (i != n - 1)printf(" ");
	}
	puts("");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[1000+200][1000+200];
long long int dp[1000+200][1000+200];

int main(int argc, char const *argv[])
{
	int H, W;
	while(cin >> H >> W) {
		memset(a, 0, sizeof(a));
		memset(dp, 0, sizeof(dp));
		for(int i=1; i<=H; i++){
			for(int j=1; j<=W; j++){
				char temp;
				cin >> temp;
				if(temp == '.'){
					a[i][j] = 0;
				} else {
					a[i][j] = 1;
				}
			}
		}
		dp[1][1] = 1;
		const unsigned int M = 1000000007;
		for(int i=1; i<=H; i++) {
			for(int j=1; j<=W; j++) {
				if(i == 1 && j == 1) continue;
				if(!a[i][j]){
					dp[i][j] = dp[i-1][j] + dp[i][j-1];
				    dp[i][j] %= M;
				}
			}
		}
		cout << dp[H][W] << endl;
	}
	return 0;
}

Measured memory_bytes: 20464
#include <iostream>
#include <vector>
#include <complex>

using namespace std;

typedef complex<double> P;
typedef pair<P,double> circle;
struct L { P p, q; L(P p, P q) : p(p), q(q) {} };

template <class T>
inline const T& abs(const T& a)
{
	return a > 0 ? a : -a;
}

const double EPS = 1e-8;

double dot(P a, P b) { return real(conj(a)*b); }
double cross(P a, P b) { return imag(conj(a)*b); }

P footPerp(L l, P p) {
	return l.p + (l.q-l.p)*(dot(l.q-l.p, p-l.p) / (abs(l.q-l.p)*abs(l.q-l.p)));
}

double lenPerp(L l, P p){
	return abs(footPerp(l, p)-p);
}

P ssCrosspoint(L a, L b){
	double A = cross(a.q-a.p, b.q-b.p);
	double B = cross(a.q-a.p, a.q-b.p);
	return b.p + B/A * (b.q-b.p);
}

bool crossCircle(circle c1, circle c2){
	double r1 = c1.second;
	double r2 = c2.second;
	double d = abs(c1.first-c2.first);
	if(d<r1||d<r2)
		return d-abs(r1-r2)>EPS;
	return r1+r2-d>-EPS;
}

vector<P> crossPoint(circle c1, circle c2){
	vector<P> res;
	double r1 = c1.second;
	double r2 = c2.second;
	double r3 = abs(c1.first-c2.first);
	double rc = (r3*r3+r1*r1-r2*r2)/(2*r3);
	double rs = sqrt(r1*r1-rc*rc);
	P dif = (c2.first-c1.first)/r3;
	res.push_back(c1.first+dif*P(rc,rs));
	if(abs(rs) > EPS) res.push_back(c1.first+dif*P(rc,-rs));
	return res;
}

int main(){
	int x1, y1, x2, y2, x3, y3;
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3, x1|y1|x2|y2|x3|y3){
		x1 += 100, y1 += 100;
		x2 += 100, y2 += 100;
		x3 += 100, y3 += 100;
		while(x1-x2>0){
			int tmp = x1; x1 = x2; x2 = x3; x3 = tmp;
			    tmp = y1; y1 = y2; y2 = y3; y3 = tmp;
		}
		P p1 = P(x1, y1), p2 = P(x2, y2), p3 = P(x3, y3);
		double res = 1e12;
		int cnt = 0;
		for(int xa=0;xa<=200;xa++){
			for(int ya=0;ya<=200;ya++){
				if(cross(p2-p1, P(xa,ya)-p1) > -EPS) break;
				double len = abs(P(xa,ya)-p2);
				int r1 = int(len+EPS);
				for(int xb=max(0,x2-r1);xb<=min(200,x2+r1);xb++){
					if(len < abs(x2-xb)) continue;
					double dsq = sqrt(len*len-(x2-xb)*(x2-xb));
					int sqt = int(dsq+EPS);
					if(abs(dsq-sqt) > EPS) continue;
					for(int sgn=-1;sgn<=1;sgn+=2){
						int yb = sgn*sqt + y2;
						if(yb < 0 || 200 < yb) continue;
						if(abs(abs(p2-P(xb,yb)) - len) > EPS || abs(P(xb,yb)-P(xa,ya)) < EPS) continue;
						if(cross(p3-p2, P(xb,yb)-p2) > -EPS) continue;
						circle ca = make_pair(p1, abs(p1-P(xa,ya)));
						circle cb = make_pair(p3, abs(p3-P(xb,yb)));

						P pt = ssCrosspoint(L(P(xa,ya), P(xa,ya)+P(0,1)*(p2-p1)), L(P(xb,yb), P(xb,yb)+P(0,1)*(p3-p2)));
						double la = lenPerp(L(p1,p2), P(xa,ya));
						double lb = lenPerp(L(p1,p2), pt);
						if(la*la-lb*lb < EPS) continue;
						if(sqrt(la*la-lb*lb) > res) continue;

						if(!crossCircle(ca, cb)) continue;
						vector<P> cp = crossPoint(ca, cb);
						for(int i=0;i<cp.size();i++){
							int xc = cp[i].real()+0.5;
							int yc = cp[i].imag()+0.5;
							if(xc < 0 || 200 < xc || yc < 0 || 200 < yc) continue;
							if(cross(p1-p3, P(xc,yc)-p3) > -EPS) continue;
							if(abs(P(xc,yc)-cp[i]) > EPS) continue;
							res = min(res, sqrt(la*la-lb*lb));
						}
					}
				}
			}
		}
		if(res < 1e10) printf("%.7lf\n", res);
		else           puts("-1");
	}
}

Measured memory_bytes: 984
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };


int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

signed main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  reverse(all(s));
  int n = s.size();
  vector<vector<ll>> dp(n+1, vector<ll>(13));
  dp[0][0] = 1;
  ll d = 1;
  REP(i, n) {
    if(s[i] == '?') {
      REP(j, 10) { //char
        REP(k, 13) {
          dp[i+1][(j*d+k)%13] += dp[i][k];
        }
      }
    }
    else {
      ll a = s[i] - '0';
      REP(j, 13) {
        dp[i+1][(j+a*d)%13] = dp[i][j];
      }
    }
    REP(j, 13) {
      dp[i+1][j] %= mod;
    }
    d *= 10;
    d %= 13;
  }
  cout << dp[n][5] << endl;
  return 0; 
}


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

int main(){
  int a,b;
  cin >> a >> b;
  int r;
  r = b - a;
  int sum = 0,e1,e2,e3,e4,e5,a1;
  for(int i = 0;r>=i;i++){
    a1 = a; a++;
    e1 = a1%10; a1 /= 10;
    e2 = a1%10; a1 /= 10;
    e3 = a1%10; a1 /= 10;
    e4 = a1%10; a1 /= 10;
    e5 = a1;
    if ( e1 == e5 && e2 == e4 ){
      sum++;
    }
    
    
  }
  
 cout << sum << endl;
}

Measured memory_bytes: 256
using System;
using System.CodeDom;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PaperMario
{
    class Program
    {
        public static void Main(string[] args)
        {
            Console.ReadLine();
            var str = Console.ReadLine();
            var redCount = str.Count(c => c == 'R');
            var changeCount = str.Take(redCount).Count(c => c == 'W');
            Console.WriteLine(changeCount);
        }
    }
}


Measured memory_bytes: 27448