akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 1e6+5;
char s[maxn];
int a[maxn],f[maxn],c0,c1,c2;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n>>s+1;
    for(int i=1;i<=n;i++)
    {
        a[i]=s[i]-'1';
        if(a[i]==0) c0=1;
        if(a[i]==1) c1=1;
        if(a[i]==2) c2=1;
    }
    for(int i=2;i<=n;i++)
    {
        f[i] = f[i-1];
        int ii=i;
        while(!(ii&1)) {f[i]++;ii>>=1;}
    }
    int t=1,ans=0;
    if(c0 && c1 && c2)
    {
        for(int i=1;i<=n;i++) a[i]=a[i]==2?0:a[i];
    }
    else if(c0 && c2) t=2;
    else if(c1 && c2)
    {
        for(int i=1;i<=n;i++) a[i]--;
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]) ans ^= (f[n-1]-f[i-1]-f[n-i]==0);
    }
    cout<<ans*t<<endl;
    return 0;
}


Measured memory_bytes: 9216
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define each(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

int n, w, ans;
int cnt[100010];

int main(){
	cin >> n >> w;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j * j <= i; j++) if(i % j == 0){
			if(++cnt[j] == 2) ans++;
			if(j * j < i && ++cnt[i / j] == 2) ans++;
		}
		if(++cnt[i] == 2) ans++;
		
		if(i >= w) cout << ans << (i == n ? "\n" : " ");
		if(i < w) continue;
		
		int a = i - w + 1;
		for(int j = 1; j * j <= a; j++) if(a % j == 0){
			if(cnt[j]-- == 2) ans--;
			if(j * j < a && cnt[a / j]-- == 2) ans--;
		}
		if(cnt[a]-- == 2) ans--;
	}
	return 0;
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

ll a[4];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>a[0]>>a[1]>>a[2]>>a[3];
	ll n; cin>>n;
	ll mx = min(n*4*a[0], min((n*2)*a[1], (n)*a[2]));
	ll cost = 0;
	cost += (n/2)*a[3];
	if(n&1)
	{
		cost += min(4*a[0], min(2*a[1], a[2]));
	}
	cout<<min(cost,mx)<<'\n';
}


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

public class ABC
{
    //          long[] sp = Console.ReadLine().Split().Select(long .Parse).ToArray();
    //          int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        int r = int.Parse(Console.ReadLine());
        Console.WriteLine(3*r*r);


    }




}





Measured memory_bytes: 13140
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let m: usize = it.next().unwrap().parse().unwrap();
    let w: Vec<u32> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let mut g = vec![vec![]; n];
    let mut d = vec![0; n];
    for _ in 0..m {
        let a = it.next().unwrap().parse::<usize>().unwrap() - 1;
        let b = it.next().unwrap().parse::<usize>().unwrap() - 1;
        g[a].push(b);
        g[b].push(a);
        d[a] += 1;
        d[b] += 1;
    }
    d[0] = 1_000_000;
    let mut dp = vec![0; n];
    let mut q = std::collections::VecDeque::new();
    for i in 0..n {
        if d[i] == 1 {
            d[i] = 1_000_000;
            q.push_back(i);
        }
    }
    let mut used = vec![false; n];
    while let Some(v) = q.pop_front() {
        used[v] = true;
        for &u in &g[v] {
            d[u] -= 1;
            dp[u] = std::cmp::max(dp[u], dp[v] + w[v]);
            if d[u] == 1 {
                d[u] = 1_000_000;
                q.push_back(u);
            }
        }
    }
    let mut ans = 0;
    for i in 0..n {
        if !used[i] {
            ans += w[i];
        }
    }
    ans += *dp.iter().max().unwrap();
    println!("{}", ans);
}

fn main() {
    run();
}



Measured memory_bytes: 17204
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	string N;
	cin >> N;

	if (N[1] == N[2] && (N[0] == N[1] || N[2] == N[3])) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

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

int main (){
  int N,M;
  int count=0;
  cin>>N>>M;
  rep(i,M){
    int x;
    cin>>x;
    count+=x;
  }
  if(N<count) cout<<-1;
  else cout<<N-count;
}

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

int main() {
	int	N;
	cin >> N;
	int	M;
	cin >> M;
	int C;
	C = 0;
	rep(j, M)
	{
		int	a;
		cin >> a;
		C += (1 << a);
	}
	rep(i, 1 << N)
	{
		if (i & ~C)
			continue;
		cout << i << ':';
		rep(j, N)
		{
			if (i & (1 << j))	
				cout << ' ' << j;
		}
		cout << endl;
	}
}



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

#define PI 3.14159265359

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	int A, B, H, M;
	cin >> A >> B >> H >> M;

	double rad = abs(((2 * PI / 720.0) * (H * 60.0 + M) - (2 * PI / 60.0) * M));
	double ans = A * A + B * B - 2 * A * B * cos(rad);
	ans = sqrt(ans);

	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}


Measured memory_bytes: 4184
N = int(input())
A = list(map(int, input().split()))

A = sorted(A, reverse=True)
#print(A)

if A[-1] == 0:
  print(0)
  exit()
  
ans = 1

for i in A:
  ans = ans * i
  if ans > 10 ** 18:
    print(-1)
    exit()

print(ans)

Measured memory_bytes: 21628
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
using namespace std;
#define N 100010
vector<int> p[N];
map<int,int> q[N];
typedef struct
{
    int x,y;
}Node;
Node e[N];
int main()
{
    int i,j,k,n,m;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++)
    {
        scanf("%d%d",&e[i].x,&e[i].y);
        p[e[i].x].push_back(e[i].y);
    }
    for(i=1;i<=n;i++)
    {
        k=p[i].size();
        if(k==0)
            continue;
        sort(p[i].begin(),p[i].end());
        for(j=0;j<k;j++)
            q[i][p[i][j]]=j+1;
    }
    for(i=0;i<m;i++)
        printf("%06d%06d\n",e[i].x,q[e[i].x][e[i].y]);
    return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);


    LL x,y,ans=1;
    cin >> x >> y;
    LL gcd=__gcd(x,y);
    for(LL i=2;i*i<=gcd;i++)
    {
        if(gcd%i == 0)
        {
            ++ans;
            while(gcd%i == 0)gcd/=i;
        }
    }
    if(gcd > 1)++ans;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while (cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while (1) {
    if (cur == nil) break;
    if (isf++ > 0) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if (t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

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

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

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  x->prev = nil;
  nil->next->prev = x;
  nil->next = x;
}

int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for (i = 0; i < n; i++) {
    scanf("%s%d", com, &key);
    if (com[0] == 'i') {
      insert(key);
      np++;
      size++;
    }
    else if (com[0] == 'd') {
      if (strlen(com) > 6) {
        if (com[6] == 'F') deleteFirst();
        else if (com[6] == 'L') deleteLast();
      } else {
        deleteKey(key);;
        nd++;
      }
      size--;
    }
  }

  printList();
  
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

ll solve(string S, vector<int> work){
    vector<ll> ls;
    int l = 0, num_char = 1;
    rep(i, work.size()){
        if(work[i]){
            string res = S.substr(l, num_char);
            ls.push_back(stoll(res));
            l += num_char;
            num_char = 1;
        }
        else{
            num_char++;
        }
    }
    ls.push_back(stoll(S.substr(l)));
    //rep(i, ls.size()) cout << ls[i] << " "; cout << endl;
    ll acc = 0;
    rep(i, ls.size()) acc += ls[i];
    return acc;
}

int main(void){
    ll ans = 0;
    string S; cin >> S;
    int lenS = S.length();
    int loop = pow(2, lenS-1);
    rep(i, loop){
        int val = i;
        vector<int> work;
        rep(j, lenS-1){
            work.push_back(val % 2);
            val /= 2;
        }
        ans += solve(S, work);
    }
    cout << ans << endl;
    return 0;
}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()

int main() {
    int N;
    cin >> N;
    if(N < 1000) {
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (i * m + n * j - 2 * i * j == K) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


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

int main() {
  long N;
   cin >> N ;
  int i;
  int j;
  vector<int> X(N);
 
  for (i=0;i<N;i++){
  cin >>X.at(i);
   //cout << i << endl; 
   //  cout << X.at(i) << endl; 
  }
  int P;
  P =0;
  int answer;
  answer =0;
  int plus;
  plus =0;
   for (i=0;i<N;i++) {
    // cout << i << endl; 
   plus = X.at(i)*X.at(i);
     //cout << plus << endl; 
     answer = answer + plus;
  }
  plus = 0;
  for(j=1;j<100;j++){
  for (i=0;i<N;i++) {
    plus =plus+(X.at(i)-j)*(X.at(i)-j);
  }
    answer=min(answer,plus);
    plus =0;
  }
  
  P =answer;
  cout << P << endl; 
}

Measured memory_bytes: 3632
#include <stdio.h>
 
int main()
{
    int a[3000], b[3000], i;

    for (i = 0; i < 3000; i++) {
        scanf("%d %d", &a[i], &b[i]);
        if (a[i] == 0 && b[i] == 0) 
            break;
    }
   
    for (i = 0; i < 3000; i++) {
        if (a[i] == 0 && b[i] == 0) 
            break;
        if (a[i] > b[i]) {
            printf("%d %d\n", b[i], a[i]);
        } else {
            printf("%d %d\n", a[i], b[i]);
        }
    }
    
    return 0;
}

Measured memory_bytes: 624
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;

int main() {
    cout << fixed << setprecision(8);
    int n; cin >> n;
    double odd = n / 2 + n % 2;
    cout << odd / n << endl; 
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,i=-1,j,mc,max,p[10],y,d[5][20],t;
  char s[5][20],c[20]={"A23456789TJQK"};
  char w[5]={"SCHD"};
  while(~scanf("%d",&n)){
    if(i+1)printf("\n");
    for(i=p[0]=0;i<4;i++){
      for(j=0;j<13;j++)scanf("%d",&d[i][j]);
    }
    for(i=1;i<10;i++)scanf("%d",&p[i]);
    while(n--){
    int b[20]={0};
      for(i=t=max=mc=0;i<5;i++){
	scanf("%s",s[i]);//printf("%s\n",s[i]);
	for(j=0;s[i][0]-c[j];j++);
	for(m=0;s[i][1]-w[m];m++);
	b[j]++;//printf("b\n");
	t+=d[m][j];
	if(b[j]==1)mc++;
	if(max<b[j])max=b[j];
      }//printf("%d %d\n",max,mc);
      if(max==4)y=7;
      if(max==3)y=mc-2?3:6;
      if(max==2)y=mc-3?1:2;
      if(max==1){
	for(i=0;b[i]==0;i++);
	for(j=0;j<5;j++)mc-=b[i+j];
	y=(mc==0||b[0]*b[9]*b[10]*b[11]*b[12])?4:0;
      //printf("%d ",y);
	for(i=0;i<5&&s[4][1]==s[i][1];i++);
	if(i==5){
	  y+=5;
	  if(y==9&&b[0]*b[9]==0)y--;
	}
      }//printf("%d:",y);
      printf("%d\n",p[y]*t);
    }
  }
  return 0;
}
    

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define poly vector<ll>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
inline ll read(){
	ll x=0;char ch=getchar();bool d=1;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') d=0;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return d?x:-x;
}
inline void write(ll x){
	if(x<0) x=-x,putchar('-');
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=10005,mo=998244353;
char a[N],b[N];
int fac[N],inv[N],f[N][N];
int ksm(int x,int p){
	int res=1;
	for(;p;p>>=1,x=(ll)x*x%mo){
		if(p&1) res=(ll)res*x%mo;
	}
	return res;
}
void init(int n){
	For(i,fac[0]=1,n) fac[i]=(ll)i*fac[i-1]%mo;
	inv[n]=ksm(fac[n],mo-2);
	Rep(i,n-1,0) inv[i]=(ll)(i+1)*inv[i+1]%mo;
}
int C(int n,int m){
	if(n<m||n<0||m<0) return 0;
	return (ll)fac[n]*inv[m]%mo*inv[n-m]%mo;
}
int main(){
	init(N-1);
	scanf("%s%s",a+1,b+1);
	int n=strlen(a+1),cnt1=0,cnt2=0;
	For(i,1,n){
		if(a[i]=='1'){
			if(b[i]=='0') cnt2++;
			else cnt1++;
		}
	}
	For(i,0,cnt2) f[0][i]=(ll)fac[i]*fac[i]%mo;
	For(i,1,cnt1) For(j,1,cnt2){
		f[i][j]=((ll)f[i-1][j]*i%mo*j%mo+(ll)f[i][j-1]*j%mo*j)%mo;
	}
	int ans=0;
	For(i,0,cnt1){
		ans=(ans+(ll)f[cnt1-i][cnt2]*fac[i]%mo*fac[i]%mo*C(cnt1,i)%mo*C(cnt1+cnt2,i))%mo;
	}
	cout<<ans;
}

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

int main(){
    int A,B;

    cin >> A >> B;

    if(A >= 1 && A <= 9 && B >= 1 && B <= 9){
        cout << A*B << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#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 < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> s(n);
    rep(i,n)cin>>s[i];
    sort(all(s));
    int sum = 0;
    for(auto a : s) sum+=a;
    if(sum%10!=0) {
        cout<<sum<<endl;
        return 0;
    }else{
        for(auto t : s){
            if(t%10!=0){
                cout<<sum-t<<endl;
                return 0;
            }
        }
        cout<<0<<endl;
    }
}

Measured memory_bytes: 256
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val n = readLine.trim.toInt
  val target = readLine.trim.toList
  for (_ ← 0 until n){
    println(
      if (target < readLine.trim.toList) '+'
      else '-'
    )
  }

  def <(a: List[Char], b:List[Char]): Boolean = {
    (a, b) match {
      case (Nil, _) ⇒ true
      case (_, Nil) ⇒ false
      case (an Numbers at, bn Numbers bt) ⇒ if (an == bn) at < bt else an < bn
      case (ah::_, _) if ah.isDigit ⇒ true
      case (_, bh::_) if bh.isDigit ⇒ false
      case (ah::at, bh::bt) if ah == bh ⇒ at < bt
      case (ah::_, bh::_) ⇒ ah < bh
    }
  }
  implicit class ListExtend(val value: List[Char]){
    def <(b: List[Char]): Boolean = Main.<(value, b)
  }
  object Numbers{
    def unapply(express: List[Char]): Option[(Int, List[Char])] = {
      express match {
        case h::t if h.isDigit ⇒ Some(subUnapply(express))
        case _ ⇒ None
      }
    }
    private def subUnapply(express: List[Char], number: Int = 0): (Int, List[Char]) = {
      express match {
        case h::t if h.isDigit ⇒ subUnapply(t, number * 10 + h.asDigit)
        case _ ⇒ (number, express)
      }
    }
  }
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 45328
N,A,B,C = map(int,input().split())
IN = []
for i in range(N):
  temp = str(input())
  IN.append(temp)

ans = []
for i in range(N):
  if IN[i] == "AB":
    if A== 0 and B == 0:
      print("No")
      exit()
    elif A == 1 and B ==1:
      if i == N-1: #最後ならどちらでもよい
        ans.append("A")
      else:
        if IN[i+1] == "AC": #次に来るのがACならAを補完
          A += 1; B -=1
          ans.append("A")
        elif IN[i+1] == "BC":#次に来るのがBCならBを補完
          A -=1; B += 1
          ans.append("B")
        else: #次がABならどっちでもよい
          A += 1; B-=1
          ans.append("A")
    else:
      if A>=B:
        A-=1;B+=1
        ans.append("B")
      else:
        A+=1;B-=1
        ans.append("A")
  
  elif IN[i] == "AC":
    if A== 0 and C == 0:
      print("No")
      exit()
    elif A == 1 and C ==1:
      if i == N-1: #最後ならどちらでもよい
        ans.append("A")
      else:
        if IN[i+1] == "AB": #次に来るのがABならAを補完
          A += 1; C -=1
          ans.append("A")
        elif IN[i+1] == "BC":#次に来るのがBCならCを補完
          A -=1; C += 1
          ans.append("C")
        else: #次がACならどっちでもよい
          A += 1; C-=1
          ans.append("A")
    else:
      if A>=C:
        A-=1;C+=1
        ans.append("C")
      else:
        A+=1;C-=1
        ans.append("A")
        
  else: #IN[i] == "BC":
    if B == 0 and C == 0:
      print("No")
      exit()
    elif B == 1 and C ==1:
      if i == N-1: #最後ならどちらでもよい
        ans.append("B")
      else:
        if IN[i+1] == "AB": #次に来るのがABならBを補完
          B += 1; C -=1
          ans.append("B")
        elif IN[i+1] == "AC":#次に来るのがACならCを補完
          B -=1; C += 1
          ans.append("C")
        else: #次がBCならどっちでもよい
          B += 1; C-=1
          ans.append("B")
    else:
      if B>=C:
        B-=1;C+=1
        ans.append("C")
      else:
        B+=1;C-=1
        ans.append("B")
print("Yes")
print(*ans,sep="\n")

Measured memory_bytes: 95192
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if(b == 1) {
    cout << 0 << endl;
    return 0;
  }
  int p = 1;
  for(int i=1; ; i++) {
    p -= 1;
    p += a;
    if(b <= p) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define MAX 100001
int main()
{
    int n,k;
    cin>>n>>k;
    int input[MAX];
    int dp[MAX];
    for(int i = 0; i < n; i++) cin>>input[i];
    dp[0] = 0;
    for(int i = 1; i < n; i++)
    {
        int temp = INT_MAX;
        for(int j = i-1; j >= max(0,i-k); j--)
        {
            if(temp > abs(input[i] - input[j]) + dp[j]) temp = abs(input[i] - input[j]) + dp[j];
        }
        dp[i] = temp;
    }
    cout<<dp[n-1];
    return 0;
}

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

int main() {
	long N, M; cin >> N >> M;
	if(N>M) swap(N, M);
	if(N==1) cout << abs(M-2) << endl;
	else{
	    long ans=(N-2)*(M-2);
	    cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int A=0,B=0;

int main()
{
	int n;
	while(true)
	{
		A=0,B=0;
	scanf("%d",&n);
	if(n==0)break;
	for(int i=0;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		if(a>b)A+=a+b;
		else if(a==b)
		{
			A+=a;
			B+=b;
		}
		else B+=a+b;
	}
	printf("%d %d\n",A,B);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int n,k;
int h[100000];
int dp[100001];
int rec(int i){
  int res;
  if(dp[i]>=0) return dp[i];
  if(i==n-1) res=0;
  else if(i==n-2) res=rec(i+1)+abs(h[i]-h[i+1]);
  else{
    res=rec(i+1)+abs(h[i]-h[i+1]);
    for(int j=2;j<=k&&i+j<=n-1;j++){
      res=min(res,rec(i+j)+abs(h[i]-h[i+j]));
    }
  }
  return dp[i]=res;
}
int main(){
  cin >> n >> k;
  for(int i=0;i<n;i++) cin >> h[i];
  memset(dp,-1,sizeof(dp));
  cout << rec(0) << "\n";
  return 0;
}
  


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n,m;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>m;
		a[m]=i;
	}
	for(int i=1;i<=n-1;i++)
	{
		cout<<a[i]<<" ";
	}
	cout<<a[n];
}

Measured memory_bytes: 1152
#include<stdio.h>
int main()
{
int a[105],b,c,d,i,n;
int sum=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(d=1;d<=n-1;d++)
for(b=1+d;b<=n;b++)
{c=a[d]*a[b];
sum=sum+c;}
printf("%d",sum);
return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	cnt, n := 0, nextInt(sc)

	S := make([]int, n)
	for i := range S {
		S[i] = nextInt(sc)
	}
	q := nextInt(sc)
	for i := 0; i < q; i++ {
		key := nextInt(sc)
		if binarySearch(S, key) {
			cnt++
		}
	}
	fmt.Println(cnt)
}

func nextInt(s *bufio.Scanner) int {
	s.Scan()
	n, err := strconv.Atoi(s.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func binarySearch(x []int, key int) bool {
	left, mid, right := 0, 0, len(x)
	for left < right {
		mid = (left + right) / 2
		if x[mid] == key {
			return true
		} else if key > x[mid] {
			left = mid + 1
			continue
		}
		right = mid
	}
	return false
}



Measured memory_bytes: 2716
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,s; cin >> n >> s;
    if(n == 1 && s == 1){
        cout << 2 << endl;
        return 0;
    }
    auto f = [&](ll n, ll k){
        ll ans = 0;
        while(n){
            ans += n % k;
            n /= k;
        }
        return ans;
    };
    for(int i = 2; i * i <= n; i++){
        if(f(n, i) == s){
            cout << i << endl;
            return 0;
        }
    }
    bool ok = false;
    ll ans = INF;
    for(int i = 1; i * i <= n; i++){
        ll r = s - i;
        if((n - r) % i != 0)continue;
        ll p = (n - r) / i;
        if(p > r && p > i && r >= 0 && p > 1){
            ok = true;
            chmin(ans, p);
        }
        debug(p, i, r);
    }

    if(s == 1){
        ok = true;
        chmin(ans, n);
    }
    if(s == n){
        ok = true;
        chmin(ans, n+1);
    }
    cout << (ok ? ans : -1) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Keyence_2020
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int h = ReadInt();
            int w = ReadInt();
            int n = ReadInt();
            int row = n / w;
            if (n % w > 0) row++;
            int col = n / h;
            if (n % h > 0) col++;
            WriteLine(Min(row, col));
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int sum = 0;
    for(int i=0;i<s.length();i++)
    {
        sum += s[i] - '0';
    }
    if(sum%9==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    cout<<endl;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    if(n >= m) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> x(m);
    rep(i, m) cin >> x[i];
    sort(x.begin(), x.end());
    int ans = x[m - 1] - x[0];
    vector<int> dx(m - 1);
    rep(i, m - 1) {
        dx[i] = x[i + 1] - x[i];
    }
    sort(dx.begin(), dx.end());
    for(int i = m - 2; i >= m - n; i--) {
        ans -= dx[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4052
n, m, x = map(int, input().split())
c = []
a = []
INF = 1001001001

for i in range(n):
    l = list(map(int, input().split()))
    c.append(l[0])
    a.append(l[1:])

ans = INF

for s in range(2 ** n):
    cost = 0
    d = [0 for i in range(m)]
    for i in range(n):
        if (s >> i) & 1:
            cost += c[i]
            for j in range(m):
                d[j] += a[i][j]
    ok = True
    for j in range(m):
        if d[j] < x: ok = False
    if ok: ans = min(ans, cost)

if ans == INF: print(-1)
else: print(ans)

Measured memory_bytes: 9244
import java.util.*;

/**
 * @author mix
 */
public class Main {

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner s1 = new Scanner(System.in);
        int N = s1.nextInt();
        int K = s1.nextInt();
        Integer[] arr = new Integer[K];

        for (int i = 0; i < K; i++) {
            arr[i] = s1.nextInt();
        }

        String numberInString = N + "";
        boolean obstacle = false;

        int res = N;
        while (true) {

            for (Integer hate : arr) {
                if (numberInString.contains(hate + "")) {
                    obstacle = true;
                    break;
                }
            }
            if (!obstacle) {
                System.out.println(numberInString);
                return;
            } else {
                res++;
                numberInString = res + "";
                obstacle = false;
            }
        }


    }

}


Measured memory_bytes: 36628
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

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

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

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

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

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n = int(input())
  clist = []
  for i in range(n):
    s = ''.join(sorted(input()))
    clist.append(s)
  d = {}
  for v in clist:
    if v in d:
      d[v] += 1
    else:
      d[v] = 1
  ans = 0
  for v, count in d.items():
    if count >= 2:
      ans += combinations_count(count, 2)
  print(ans)
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Measured memory_bytes: 93908
l,r=map(int,input().split())
l0=l%2019
r0=r%2019
if r-l>=2019 or l0==0 or r0==0:
    print(0)
elif l-l%2019+2019<=r:
    print(0)
else:
    ans=2019
    for i in range(l0,r0):
        for j in range(i+1,r0+1):
            if (i*j)%2019<ans:
                ans=(i*j)%2019
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;


int main() {

	int s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}
	
	
	return 0;
	
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vl;
typedef vector<vector<ll>> vll;
typedef vector<bool> vb;
typedef set<int> si; 
typedef queue<int> qi;
typedef stack<int> sti;
typedef priority_queue<int> pqi;
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
//#define __builtin_popcountll bitCountLL
//#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//std::uniform_int_distribution<long long> rg(1,1e18);
#define maxn 100005
#define Mod 1000000007
const int INF = 2e9;
const ll ML = 4e18;
    
void solve() {
    int n, x, t;
     cin >> n >> x >> t;
     cout << (n + x - 1) / x * t << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
//	freopen("D:\\data_in.txt", "r", stdin);
   
    solve();
   
    /*
    clock_t start,finish;
    start = clock();
    
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 3660
N = int(input())

cons = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for _ in range(N):
    tmp = input()
    cons[tmp] += 1
    
print('AC x {}'.format(cons['AC']))
print('WA x {}'.format(cons['WA']))
print('TLE x {}'.format(cons['TLE']))
print('RE x {}'.format(cons['RE']))

Measured memory_bytes: 9208
#include <iostream>
#include <cstring>
#include <string>
int main()
{
    long long x,y;
    std::cin>>x>>y;
    if(x==1||y==1)
    {
        x=std::max(x,y);
        if(x==1)std::cout<<x<<std::endl;
        else {x-=2;
            std::cout<<x<<std::endl;}
        return 0;
    }
    std::cout<<x*y-(x*2+y*2)+4<<std::endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

int main(){
	int n;

	while(~scanf("%d",&n)){
		if(n==0) break;

		int S = 0;
		for(int i=1;i*i<=n;i++){
			if(n % i == 0 && i != n){
				S+=i;
				if(n/i != i && n/i != n) S+=n/i;
			}
		}
		
		if(S < n){
			printf("deficient number\n");
		}
		else if(S==n){
			printf("perfect number\n");
		}
		else{
			printf("abundant number\n");
		}
	}
}

Measured memory_bytes: 1168
function f(N,R,G,B)
	ans=0
	for r=N:-R:0,g=r:-G:0
		ans+=g%B==0
	end
	ans
end
function main()
	R,G,B,N=map(x->parse(Int,x),split(readline()))
	println(f(N,R,G,B))
end
main()

Measured memory_bytes: 110892
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int n;
   std::cin >> n;
   std::vector<Int> xs(n);
   rep(i,n) std::cin >> xs[i];
   std::sort(xs.begin(), xs.end());
   Int ys[2] = {};
   rep(i,n)
      ys[i%2] += xs[i];
   printf("%ld\n", std::abs(ys[0]-ys[1]));
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];

    deque<ll> d;
    rep(i, N){
        int p = lower_bound(all(d), a[i]) - d.begin();
        if(p == 0){
            d.push_front(a[i]);
        }else{
            d[p-1] = a[i];
        }
    }
    cout << d.size() << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 6016
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
#include <fstream>

using namespace std;

#define A first
#define B second
#define all(x) (x).begin(), (x).end

typedef long long ll;
constexpr int MOD = 1000000007;

inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}

void solve() {
  int H, W;
  cin >> H >> W;
  vector<string> A(H);
  for(int i = 0; i < H; i++){
    cin >> A[i];
  }
  vector<vector<int>> dp(H, vector<int>(W));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(i == 0 && j == 0){
        if(A[i][j] == '.') dp[i][j] = 1;
        else dp[i][j] = 0;
      }
      else if(i == 0){
        dp[i][j] = (A[i][j] == '.') ? dp[i][j - 1] : 0;
      }
      else if(j == 0){
        dp[i][j] = (A[i][j] == '.') ? dp[i - 1][j] : 0;
      }
      else {
        dp[i][j] = (A[i][j] == '.') ? addmd(dp[i - 1][j], dp[i][j - 1]) : 0;
      }
    }
  }
  cout << dp[H - 1][W - 1];

}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  T = 1;
  //cin >> T;
  while(T--){
    solve();
  }
}

Measured memory_bytes: 8208
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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



int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;

    h *= 30;
    h += 30.0/60*m;
    m *= 6;
 
    double r = abs(h-m);
    if(r > 180)r = 360-r;
   
    printf("%.20f\n",sqrt(a*a + b*b -(2*a*b*cos(pi / 180 *r))));
    return  0;
}


Measured memory_bytes: 4252
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif

typedef std::array<unsigned, 26> CharArray;

CharArray string2array(const std::string &S)
{
  CharArray array;
  std::fill(array.begin(), array.end(), 0);
  
  for (unsigned i = 0; i < S.size(); ++i) {
    ++array[S[i] - 'a'];
  }
  
  return array;
}

CharArray merge(const CharArray &A, const CharArray &B)
{
  CharArray array;
  std::fill(array.begin(), array.end(), 0);
  
  for (unsigned i = 0; i < 26; ++i) {
    array[i] = std::min(A[i], B[i]);
  }
  
  return array;
}

std::string array2string(const CharArray &A)
{
  std::string S;
  
  for (unsigned i = 0; i < 26; ++i) {
    for (unsigned j = 0; j < A[i]; ++j) {
      S.push_back('a' + i);
    }
  }
  
  return S;
}

int main()
{
  unsigned N;
  std::cin >> N;
  
  CharArray array;
  for (unsigned n = 0; n < N; ++n) {
    std::string S;
    std::cin >> S;
    
    CharArray a = string2array(S);
    
    if (n == 0) array = a;
    else {
      array = merge(array, a);
    }
  }
  
  std::cout << array2string(array) << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args:Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val a, b = sc.nextInt()

    if (a == 1 && b != 1) {
      println("Alice")
    } else if (a != 1 && b == 1) {
      println("Bob")
    } else if (a == b) {
      println("Draw")
    } else if (a < b) {
      println("Bob")
    } else if (a > b) {
      println("Alice")
    }
  }
}

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

using namespace std;

using u128 = __uint128_t;

#define int long long
#define MOD 1000000007

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int h, n;
    cin>>h>>n;
    int *a = new int[n];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    sort(a  + 0 , a+ n);
    for(int i = n-1 ; i >= 0; i--){
        h -= a[i];
    }
    if(h > 0) {
        cout<<"No"<<endl;
    } else cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

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

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if(a<c&&c<b)
        cout << "Yes" << endl;
        else if(c<a&&b<c)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
}

Measured memory_bytes: 892