akhauriyash/Code-Regression huggingface dataset:
def gcd(a,b):
	while b>0:
		a,b = b,a%b
	return a 
N,X = input().split(" ")
N,X = int(N),int(X)

A = input().split(" ")

diff = []
for x in A:
	diff.append(abs(int(x)-X))
# print(diff)
ans = diff[0]
for i in diff[1:]:
	ans = gcd(ans,int(i))
print(ans)


Measured memory_bytes: 14992
#include<stdio.h>
#include<string.h>
int main(void)
{
    int n,a=0, b=0, c=0, d=0;
    scanf("%d",&n);
    char s[5];
    char s1[4]="AC";
    char s2[4]="WA";
    char s3[4]="TLE";
    char s4[4]="RE";
    for(int i=0;i<n;i++)
    {
        scanf("%s",&s);
        if(strcmp(s,s1)==0)
        {a++;}
       else if(strcmp(s,s2)==0)
        {b++;}
        else if(strcmp(s,s3)==0)
        {c++;}
       else if(strcmp(s,s4)==0)
        {d++;}
            }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,b,c,d);
    return 0;
}

Measured memory_bytes: 1728
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdint>

int main() {
  constexpr int kMaxItemsInRow = 3;
  int R, C, K;
  std::cin >> R >> C >> K;
  std::vector<std::vector<std::int64_t>> items(R + 1, std::vector<std::int64_t>(C + 1));
  for (int i = 0; i < K; ++i) {
    int r, c, v;
    std::cin >> r >> c >> v;
    items[r][c] = v;
  }
  std::vector<std::vector<std::vector<std::int64_t>>> mem(kMaxItemsInRow + 1, std::vector<std::vector<std::int64_t>>(R + 1, std::vector<std::int64_t>(C + 1)));
  for (int r = 1; r <= R; ++r) {
    for (int i = 0; i <= kMaxItemsInRow; ++i) {
      for (int c = 1; c <= C; ++c) {
        auto& m = mem[i][r][c];
        m = std::max(m, mem[i][r][c - 1]);
        if (i == 0) {
          m = std::max(m, mem[kMaxItemsInRow][r - 1][c]);
        } else {
          m = std::max(m, mem[i - 1][r][c]);
          if (i == 1) {
            m = std::max(m, mem[kMaxItemsInRow][r - 1][c] + items[r][c]);
          } else {
            m = std::max(m, mem[i - 1][r][c - 1] + items[r][c]);
          }
        }
      }
    }
  }
  std::cout << mem.back().back().back() << std::endl;
  return 0;
}


Measured memory_bytes: 425364
/*
___ is a raging sadist.
*/
//Destroy all WA at test 2
// Stay cool
// Pass the 4th wall..

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define siz(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define pi 3.14159265
const ll mod = 1000 * 1000 * 1000 + 7;
const ll mod1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 



ll p[5010]; ll c[5010];
ll pre[5005][5005];
ll fin[5005];
bool vis[5005];
ll sum,cnt;

void seno(ll idx, ll cur)
{
    if (vis[idx]==true)
    {   
        sum+=c[idx];
        pre[cur][cnt]=sum;
        return;
    }

    sum+=c[idx];
    pre[cur][cnt]=sum;
    vis[idx]=true;
    cnt+=1;

    seno(p[idx],cur);
    //cout<<cnt<<endl;
    return;
}


int main()
{

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

fastio();

    ll n,k; ll ans=-3*INF;
    cin>>n>>k;

    

    For(i,1,n+1)
    cin>>p[i];


    For(i,1,n+1)
    cin>>c[i];

    for(int i=1;i<=n;i++)
    {
        cnt=1;
        sum=0;
        seno(p[i],i);
        fin[i]=cnt-1;

        for(int i=1;i<=n;i++)
            vis[i]=false;
    }

    //cout<<fin[1]<<endl;


    for(int i=1;i<=n;i++)
    {
        if (pre[i][fin[i]]<=0)
        {
            for(int j=1;j<=min(k,fin[i]);j++)
            {
                ans=max(ans,pre[i][j]);
            }
            //cout<<ans<<endl;
        } else {

            if (k<=fin[i])
            {
                for(int j=1;j<=min(k,fin[i]);j++)
                {
                    ans=max(ans,pre[i][j]);
                }
            } else {

                ll q1=k/fin[i];
                ll q2=q1-1;
                ll rem=k%fin[i];

                ll sum1=q1*pre[i][fin[i]]; ll sum2=q2*pre[i][fin[i]];
                //cout<<sum1<<' '<<sum2<<endl;
                ll temp=0;

                for(int j=1;j<=rem;j++)
                temp=max(temp,pre[i][j]);

                sum1+=temp;
                temp=0;

                for(int j=1;j<=fin[i];j++)
                temp=max(temp,pre[i][j]);
                sum2+=temp;

                ans=max(ans,sum1);
                ans=max(ans,sum2);

            }
        }

        //cout<<ans<<endl;
    }

    cout<<ans;

return 0;
}

Measured memory_bytes: 199196
import os
import sys
from decimal import Decimal

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

a, b, c = list(map(int, sys.stdin.buffer.readline().split()))
a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
ok = Decimal.sqrt(a) + Decimal.sqrt(b) < Decimal.sqrt(c)
if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5712
import java.util.*;
import java.lang.Object;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] num = new int[n+1];
        num[0] = 0;
        int cnt = 0;

        for(int i = 1;i<n+1;i++){
            int l = sc.nextInt();
            num[i]+=num[i-1]+l;
          //  System.out.println(num[i]);
        }

        for(int i = 0;i<n+1;i++){
            if(num[i]<=x){
                cnt++;
            }
        }
        System.out.println(cnt);

        


    }
}


Measured memory_bytes: 23892
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	char s[110], t[110];
	cin >> s >> t;
	int tmp = 0;
	for (int i = n;i < 2 * n;i++) {
		for (int j = i - n;j <= i&&j < n;j++) {
			if (s[j] != t[j - i + n]) {
				tmp = 1;
				break;
			}
		}
		if (tmp == 0) {
			cout << i << endl;
			return 0;
		}
		tmp = 0;
	}
	cout << 2 * n << endl;
	return 0;
}


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

int main(void){
	long long n;
	cin>>n;
	if(n <= 6){
		cout<<1<<endl;
	} else if(n % 11 == 0) {
		cout<<(n/11)*2<<endl;
	} else if(n % 11 <= 6) {
		cout<<(n/11)*2 + 1<<endl;
	} else {
		cout<<(n/11)*2 + 2<<endl;
	}
}

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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;

    int ans = min(n * a, b);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	ll a, b, x;
	cin >> a >> b >> x;
	if (b == 1) {
		cout << 0 << endl;
		return 0;
	}
	ll X = min(b - 1, x);
	cout << (a * X) / b - a * (X / b) << endl;;
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
 
using namespace std;
 
int main(){
 
    string ban;

	cin>>ban;

	if(ban[0]=='o'&&ban[ban.size()-1]=='o') cout<<"o"<<endl;
	else if(ban[0]=='x'&&ban[ban.size()-1]=='o') cout<<"o"<<endl;
	else if(ban[0]=='o'&&ban[ban.size()-1]=='x') cout<<"o"<<endl;
	else if(ban[0]=='x'&&ban[ban.size()-1]=='x') cout<<"x"<<endl;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<string>
#include<vector>
using namespace std;
int main(){
    int N;
    cin>>N;
    for(int i=111;i<=999;i+=111){
        if(N<=i){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, K;
  cin >> N >> K;
  vector<double> data(N);
  double a;
  double sub = 0, ans = 0;
  for(int i = 0; i < N; i++){
    cin >> a;
    data.at(i) = (a + 1) / 2;
    if(i < K)sub += data.at(i);
  }
  ans = sub;
  for(int i = K; i < N; i++){
    sub -= data.at(i - K);
    sub += data.at(i);
    ans = max(ans, sub);
  }
  
  cout << setprecision(100) << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>

const int MAXN = 310, MOD = 1e9 + 7;
inline int mul(int x, int y) { return 1LL * x * y % MOD; }
inline void Add(int &x, int y) { (x += y) >= MOD && (x -= MOD); }
inline void Mul(int &x, int y) { x = 1LL * x * y % MOD; }

int n, m, tot, QAQ;
int a[MAXN * 2], b[MAXN * 2], c[MAXN * 2], dp[MAXN * 2][MAXN][MAXN];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n * 2; ++i) scanf("%d", a + i);
	for (int i = 1; i <= n * 2; i += 2)
		if (a[i] == -1 || a[i + 1] == -1) {
			++m;
			if (~a[i]) b[a[i]] = 1;
			else if (~a[i + 1]) b[a[i + 1]] = 1;
			else ++QAQ;
		} else b[a[i]] = b[a[i + 1]] = -1;
	for (int i = 1; i <= n * 2; ++i) if (~b[i]) c[++tot] = b[i];
	dp[m * 2 + 1][0][0] = 1;
	for (int i = 1; i <= QAQ; ++i) Mul(dp[m * 2 + 1][0][0], i);
	for (int i = m * 2; i; --i)
		for (int j = 0; j <= m; ++j)
			for (int k = 0; j + k <= m; ++k) if (c[i]) {
				if (j + k < m) Add(dp[i][j + 1][k], dp[i + 1][j][k]);
				if (k) Add(dp[i][j][k - 1], dp[i + 1][j][k]);
			} else {
				if (j + k < m) Add(dp[i][j][k + 1], dp[i + 1][j][k]);
				if (j) Add(dp[i][j - 1][k], mul(dp[i + 1][j][k], j));
				if (k) Add(dp[i][j][k - 1], dp[i + 1][j][k]);
			}
	printf("%d\n", dp[1][0][0]);
	return 0;
}

Measured memory_bytes: 227072
# include <iostream>
#include<vector>
#include<string>
#include <sstream>
using namespace std;

int main() {
	string s;
	cin>>s;
	int one=0, zeo=0;
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == '0')zeo++;
		else one++;
	}
	int ans;
	
	if (one < zeo)ans = 2*one;
	else ans = 2*zeo;
	cout <<  ans;
	
	
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }


int a, b;
int main() {
	while (cin >> a >> b) {
		if (a == 0 && b == 0) break;
		int res = a+b, ind = 0;
		for (int id = 1; id < 5; ++id) {
			cin >> a >> b;
			if (chmax(res, a+b)) ind = id;
		}
		cout << (char)('A'+ind) << " " << res << endl;
	}
    return 0;
}


Measured memory_bytes: 1160
class SegmentTree
    def initialize(n)
      @size=n
      @realsize=1
      while @realsize<@size do
        @realsize*=2
      end
      # default
      @tree=Array.new(2*@realsize,0)
    end
  
    def change(i,x)
      i+=@realsize
      @tree[i]=x
      while i>1 do
        parent=i/2
        brother=i^1
        # update rule
        @tree[parent]=@tree[i].gcd(@tree[brother])
        i=parent
      end
    end
  
    def get_gcd(a,b)
      return _get_gcd(a,b,1,0,@realsize)
    end
  
    def _get_gcd(a,b,k,l,r) # [a,b)
      return 0 if r<=a || b<=l
      return @tree[k] if a<=l && r<=b
      vl=_get_gcd(a,b,2*k,l,(l+r)/2)
      vr=_get_gcd(a,b,2*k+1,(l+r)/2,r)
      return vl.gcd(vr)
    end
end

N=gets.to_i
A=gets.split.map(&:to_i)
st=SegmentTree.new(N)
A.each_with_index do |a,i|
    st.change(i,a)
end
max=0
N.times do |i|
    st.change(i,0)
    g=st.get_gcd(0,N)
    max=g if max<g
    st.change(i,A[i])
end
puts max


Measured memory_bytes: 10628
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int main() {
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int64 n, x, m;
  cin >> n >> x >> m;
  vector<int64> A(2 * m), vis(2 * m, -1);
  A[1] = x;
  vis[A[1]] = 1;
  int fx = -1;
  for (int i = 2; i <= n; ++i) {
    A[i] = A[i - 1] * A[i - 1] % m;
    if (vis[A[i]] != -1) {
      fx = i;
      break;
    } else {
      vis[A[i]] = i;
    }
  }
  int64 res = 0;
  if (fx == -1) {
    for (int i = 1; i <= n; ++i) res += A[i];
  } else {
    for (int i = 1; i < vis[A[fx]]; ++i) res += A[i];
    int64 y = 0;
    for (int i = vis[A[fx]]; i < fx; ++i) y += A[i];
    n -= vis[A[fx]] - 1;
    res += n / (fx - vis[A[fx]]) * y;
    n %= fx - vis[A[fx]];
    for (int i = 0; i < n; ++i) res += A[vis[A[fx]] + i];
  }
  cout << res;

  return 0;
}
//2020.09.19 20:16:28


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


using namespace std;

int main()
{string S;
cin>>S;
long long int A=0,B=0,C=0,D=0;
for(int x=0;x<S.length();x++){
    if(S[x]=='N'){
        A++;
    }if(S[x]=='S'){
        B++;
    }if(S[x]=='E'){
        C++;
    }if(S[x]=='W'){
        D++;
    }
}
long long int E = 0;
if(A!=0&&C!=0&&B!=0&&D!=0&&E==0){
    cout<<"Yes"<<"\n";
    E=1;
}if(A!=0&&C==0&&B!=0&&D==0&&E==0){
    cout<<"Yes"<<"\n";
    E=1;
}if(A==0&&C!=0&&B==0&&D!=0&&E==0){
    cout<<"Yes"<<"\n";
    E=1;
}if(E==0){
    cout<<"No"<<"\n";
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    ll current = 0;
    ll plusNum = 1;
    for (int i = 0; i < K; i++)
    {
        ll test1 = current + plusNum;
        ll temp1 = test1;
        ll sum1 = 0;
        while (temp1)
        {
            sum1 += temp1 % 10;
            temp1 /= 10;
        }
        double testS1 = (double)test1 / (double)sum1;
        ll test2 = current + plusNum * 10;
        ll temp2 = test2;
        ll sum2 = 0;
        while (temp2)
        {
            sum2 += temp2 % 10;
            temp2 /= 10;
        }
        double testS2 = (double)test2 / (double)sum2;
        if (testS1 <= testS2)
        {
            current = test1;
        }
        else
        {
            current = test2;
            plusNum *= 10;
        }
        cout << current << "\n";
    }
    cout.flush();
    return 0;
}


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

int main(){
  
  int A, B, C;
  cin >> A >> B >> C;
  
  if ((A == B && B != C) || (A != B &&  B == C) || (A == C &&  B != C)) {
    
    cout << "Yes" << endl;
  } else {
    
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
MOD = 10**9+7

ans = 1
p3 = 1
for i in range(-1, -n-1, -1):
    if s[i] == '1':
        ans = ((ans * 2) % MOD + p3) % MOD
    p3 = (p3 * 3) % MOD
print(ans)

Measured memory_bytes: 65192
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N = int(input())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

X, A = map(int, input().split())
print(0 if X < A else 10)



# def main():

# if __name__ == '__main__':
#     main()


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

using namespace std;

int main(void){
    int h,w;
    int i,j;

    while(1){
        cin>>h>>w;
        if(h==0&&w==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if((i+j)%2==0)printf("#");
                else printf(".");
                }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>
#include <math.h>
#include <list>

using namespace std;

bool divide[1000005] = {};
vector<int> a;
int n;

int main(void) {

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

	cin >> n;
	for (int i = 0; i < n; i++) {
		int in;
		cin >> in;
		a.push_back(in);
	}
	
	sort(a.begin(), a.end());

	int count = 0;

	for (int i = 0; i < n; i++) {
		if (divide[a[i]] == false) {
			count++;
			for (int j = 1; j * a[i] <= a[n - 1]; j++) {
				divide[j * a[i]] = true;
			}
			if ((i != n - 1) && a[i + 1] == a[i]) count--;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 4908
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string p;
   cin>>p;
   int mx=0;
   for(int i=0;i<3;i++){
        if(p[i]=='R')
        {
            int cnt=0;
            while(p[i]=='R'){
                cnt++;
                i++;
            }
            mx=max(mx,cnt);
        }
   }
        cout<<mx<<endl;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

ll f(ll A, ll B) {
    ll lim = A*B;
    ll ok = 0, ng = B;
    // x > A, y < B
    while (ng - ok > 1) {
        ll mid = (ok + ng) / 2;
        // (A+mid, mid)
        // 1, 2, 3, 4, 5, ..., mid
        // A+mid, A+1, ..., A+1
        // A+mid+1 = x + y
        // 1<=x<=mid
        bool f = true;
        if (mid * (A + 1) >= lim)f = false;
        ll x = (A + mid + 1) / 2;
        for (ll xx = x - 2; xx < x + 3; ++xx) {
            if (xx >= 1 && xx <= mid) {
                ll y = xx * (A + 1 + mid - xx);
                if (y >= lim)f = false;
            }
        }
        (f ? ok : ng) = mid;
    }
    RT ok;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int Q;
    cin >> Q;
    while (Q--) {
        ll A, B;
        cin >> A >> B;

        ll bb = f(A, B);
        ll aa = f(B, A);
        ll ans = aa + bb;
        ll x = B - bb - 1, y = A - aa - 1;
        ans += max(0ll, min(x, y));
        cout << ans << endl;
    }
}

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

int main(){
    long double l;
    cin >> l;
    long double v = l/3; 
    cout << fixed << setprecision(15) << pow(v,3) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int a[7] = {1,3,5,7,8,10,12};
int b[4] = {4,6,9,11};
int c = 2;
int x,y;
int ax,ay;
int main() {
  cin >> x >> y;

  for(int i = 0; i < 7; i++) {
    if(x == a[i]) ax = 1;
    if(y == a[i]) ay = 1;
  }

  for(int i = 0; i < 4; i++) {
    if(x == b[i]) ax = 2;
    if(y == b[i]) ay = 2;
  }

  if(x == c) ax = 3;
  if(y == c) ay = 3;

  if(ax == ay) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}
    
      
  


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    static long [] a;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt(); long k = sc.nextLong();
        a = new long[n]; long sum = 0; long div = n + k;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            sum += a[i];
        }
        long [] denom = new long[n]; long temp = 0;
        PriorityQueue<Rat> pq = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            denom[i] = (long) Math.floor(((double) a[i] * div) / sum);
            temp += denom[i];
            pq.add(new Rat(denom[i], i));
        }
        while (temp < div) {
            Rat r = pq.poll();
            temp++;
            pq.add(new Rat(r.d + 1, r.i));
        }
        Rat max = pq.poll();
        long ans = (long) Math.ceil((double) a[max.i] / max.d);
        out.println(ans);
        out.close();
    }

    static class Rat implements Comparable<Rat> {
        long d; int i;
        Rat(long d, int i) {
            this.d = d; this.i = i;
        }

        @Override
        public int compareTo(Rat o) {
            double ratio = (double) a[i] / d;
            double other = (double) a[o.i] / o.d;
            return Double.compare(other, ratio);
        }
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 56940
import java.util.Scanner;
public class Main{ 
  public static void main(String[] args) { 
    Scanner sc = new Scanner(System.in);
    while(true){
      int m = sc.nextInt(); 
      int f = sc.nextInt();
      int r = sc.nextInt();
      if (m == -1 && f == -1 && r == -1){ 
        break; 
      } 
      if(m==-1 || f==-1){
        System.out.println("F");
      } 
      else{
        int S = m + f;
        if(S>=80){
          System.out.println("A");
        }
        else if(S<80 && S>=65){
          System.out.println("B");
        }
        else if(S<65 && S>=50){
          System.out.println("C");
        }
        else if(S<50 && S>=30){
          if(r>=50){
            System.out.println("C");
          }
          else if(r<50){
            System.out.println("D");
          }
        }
        else if(S<30){
          System.out.println("F");
        }
      }
    }
  }
}

Measured memory_bytes: 26140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    int N, K;
    cin >> N >> K;
    vector<ull> A(N);
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }
    for (int i=K; i<N; i++) {
        if (A[i] > A[i-K]) {
            cout << "Yes" << endl;
        }
        else if (A[i] <= A[i-K]) {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4840
/*input
7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1
*/
#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;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn],dp[3];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	fill(dp,dp+3,0);
	REP(i,n){
		int a,b,c;
		cin>>a>>b>>c;
		int x,y,z;
		x=max(dp[1],dp[2])+a;
		y=max(dp[0],dp[2])+b;
		z=max(dp[0],dp[1])+c;
		dp[0]=x;
		dp[1]=y;
		dp[2]=z;
	}
	cout<<max(dp[0],max(dp[1],dp[2]))<<'\n';
}

Measured memory_bytes: 384
import java.io.PrintStream;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int N = sc.nextInt();
		final int[] A = new int[N];
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}
		TreeMap<Integer, Integer> map = new TreeMap<>();
		for(int i=0;i<N;i++) {
			map.put(A[i], i+1);
		}
		StringBuilder sb = new StringBuilder();
		for(Integer i : map.values()) {
			sb.append(i).append(" ");
		}
		sb.setLength(sb.length()-1);
		out.println(sb.toString());
	}

}


Measured memory_bytes: 66324
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

bool pre[3][9000];

int main(void){
	int n[3],i,j,k,l,r,ans=INF;
	string a[3];
	for(i=0; i<3; ++i){
		cin >> a[i];
		n[i] = a[i].l_ength();
	}
	for(j=0; j<=8888; ++j){
		for(k=0; k<2; ++k){
			l = min(j,4444); r = max(j+n[k],4444+n[2]);
			pre[k][j] = true;
			if(j+n[k]<=4444||4444+n[2]<=j){
				continue;
			}
			for(i=l; i<r; ++i){
				if(!(0<=i-4444 && i-4444<n[2] && 0<=i-j && i-j <n[k])){
					continue;
				}
				if(!(a[2][i-4444]=='?' || a[k][i-j]=='?' || a[2][i-4444]==a[k][i-j])){
					pre[k][j] = false;
					break;
				}
			}
		}
	}
	for(j=0; j<=4444; ++j){
		l = min(j,2222); r = max(j+n[1],2222+n[0]);
		pre[2][j] = true;
		for(i=l; i<r; ++i){
			if(!(0<=i-2222 && i-2222<n[0] && 0<=i-j && i-j<n[1])){
				continue;
			}
			if(!(a[0][i-2222]=='?' || a[1][i-j]=='?' || a[0][i-2222]==a[1][i-j])){
				pre[2][j] = false;
				break;
			}
		}
	}

	for(i=0; i<=8888; ++i){
		for(j=0; j<=8888; ++j){
			if(!(pre[0][i]&&pre[1][j])){
				continue;
			}
			l = min({4444,i,j});
			r = max({4444+n[2],i+n[0],j+n[1]});
			if(abs(i-j)<=2222 && (!pre[2][2222+j-i])){
				continue;
			}
			ans = min(ans,r-l);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let s: Vec<char> = it.next().unwrap().chars().collect();
    let mut cur = 0;
    let mut ret = 0;
    for &si in &s {
        if si == 'R' {
            cur += 1;
        } else {
            ret = max(ret, cur);
            cur = 0;
        }
    }
    ret = max(ret, cur);
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2108
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

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

def main():
    ana = defaultdict(int)
    n = int(input())
    for i in range(n):
        s = "".join(sorted(input()))

        ana[s] += 1
    ans = 0
    for k,v in ana.items():
        ans += v*(v-1)//2
    print(ans)
if __name__ == '__main__':
  main()


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

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  for(int i = 0; i < n - 1; ++i) {
    if(h[i + 1] > h[i]) --h[i + 1];
  }
  bool ans = true;
  for(int i = 1; i < n; ++i) {
    if(h[i] < h[i - 1]) ans = false;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_V = 20000+5;
typedef int CAP;
const CAP INF = (int)1e9;

struct Edge{ int dst; CAP cap; int rev; };
vector<Edge> adj[MAX_V];
int level[MAX_V];
int done[MAX_V];
void clearedge() { REP(i, MAX_V) adj[i].clear(); }
void addedge(int u, int v, CAP c1, CAP c2) {
  adj[u].push_back( (Edge){v, c1, (int)adj[v].size() + (u == v)} );
  adj[v].push_back( (Edge){u, c2, (int)adj[u].size() - 1} );
}

CAP dinic_dfs(int v, CAP flow, int t) {
  if (v == t || flow == 0) return flow;
  for ( ; done[v] < (int)adj[v].size(); done[v]++) {
    Edge &e = adj[v][done[v]];
    if (level[v] >= level[e.dst]) continue;
    CAP f = dinic_dfs(e.dst, min(flow, e.cap), t);
    if (f > 0) {
      e.cap -= f;
      adj[e.dst][e.rev].cap += f;
      return f;
    }
  }
  return 0;
}

bool dinic_bfs(int s, int t) {
  memset(level, -1, sizeof(level));
  queue<int> q; q.push(s); level[s] = 0;
  while (!q.empty()) {
    int here = q.front(); q.pop();
    for (const Edge &e : adj[here]) {
      if (e.cap > 0 && level[e.dst] == -1) {
        level[e.dst] = level[here] + 1;
        q.push(e.dst);
      }
    }
  }
  return level[t] >= 0;
}

CAP dinic(int s, int t) {
  CAP res = 0;
  while (dinic_bfs(s,t)) {
    memset(done, 0, sizeof(done));
    for (CAP f; (f = dinic_dfs(s, INF, t)) > 0; ) res += f;
  }
  return res;
}

int main2() {
  clearedge();
  int H = nextInt();
  int W = nextInt();
  string m[H];
  REP(i, H) cin >> m[i];

  int s = 2*H*W+1;
  int t = 2*H*W+2;

  REP(i, H) REP(j, W) {
    if (m[i][j] == 'o') {
      int v_in = i * W + j;
      int v_out = i * W + j + H*W;
      addedge(v_in, v_out, 1, 0);
    }
    if (m[i][j] == 'S') {
      int v_in = i * W + j;
      int v_out = i * W + j + H*W;
      addedge(v_in, v_out, INF, 0);
      addedge(s, v_in, INF, 0);     
    }
    if (m[i][j] == 'T') {
      int v_in = i * W + j;
      int v_out = i * W + j + H*W;
      addedge(v_in, v_out, INF, 0);
      addedge(v_out, t, INF, 0);
    }
  }

  REP(i, H) REP(j, W) {
    int v1 = i*W+j + H*W;
    REP(k, W) { if(k != j && m[i][k] != '.')  addedge(v1, i*W+k, INF, 0); }
    REP(k, H) { if(k != i && m[k][j] != '.') addedge(v1, k*W+j, INF, 0); }
  }

  ll ans = dinic(s, t);
  if (ans >= INF/2) ans = -1;
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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


int main() {
    int n,ans=0;
    cin >> n;
    vector<int> v(n),c(n);

    for(int i =0; i < n;i ++){
        cin >> v.at(i);
    } 
    for(int i =0; i < n;i ++){
        cin >> c.at(i);
    } 

    for(int i = 0;i < n;i ++){
        if(v.at(i) > c.at(i)){
            ans += v.at(i) - c.at(i);
        }
    }

    cout << ans << endl;

}


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

N, K = map(int, input().split())
A = list(map(int, input().split()))

P = []
p = 0
for a in A:
    if a > 0:
        p += a
    P.append(p)

S = [0]
s = 0
for a in A:
    s += a
    S.append(s)

ans = 0
for i in range(N-K+1):
    others = 0
    if i != 0:
        others += P[i-1]
    others += P[-1] - P[i+K-1]
    ans = max(ans, others)
    ans = max(ans, others+(S[i+K]-S[i]))

print(ans)

Measured memory_bytes: 16612
#include <bits/stdc++.h>
#include <bitset>
#include <chrono>
#include <iomanip>
using namespace std;

/////------------------------TYPEDEF--------------------------/////
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
#define prq priority_queue<ll>;

/////------------------------CONSTANTS--------------------------/////
ll MOD=1000000007;
#define PI 3.1415926535897932384626433832795

/////------------------------GENERAL--------------------------/////
#define forx(i,j,n) for(int i=j;i<n;i++)
#define fory(i,j,n) for(int i=j;i>=n;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false)
#define testcase int t; cin>>t
#define MEM(xx,yy) memset(xx,yy,sizeof(xx))
#define vbs(xx,x) binary_search(all(xx),x)
#define vlb(xx,x) lower_bound(all(xx),x)
#define vub(xx,x) upper_bound(all(xx),x)

/////------------------------IO--------------------------/////
#define inpi(xx) scanf("%d",&xx)
#define inpl(xx) scanf("%lld",&xx)
#define inpc(xx) scanf("%c",&xx)
#define inps(xx) scanf("%s",&xx)
#define pri(xx) printf("%d",xx)
#define prl(xx) printf("%lld",xx)
#define prls(xx) printf("%lld ",xx)
#define prle(xx) printf("%lld\n",xx)
#define prc(xx) printf("%c",xx)
#define prs printf(" ");
#define pre printf("\n")
ll n,W;
//ll w[100005],v[100005];
ll ans[3005][3005];
char v[3005][3005];
int fun(int n,int m) 
{ 
   // cout<<n<<m<<" ";
    if(ans[n][m]!=-1) return ans[n][m];
    if(v[n][m]=='#'){ans[n][m]=0; return ans[n][m];}
    ans[n][m]=0;
    if(n>0) ans[n][m]+=fun(n-1,m);
    ans[n][m]%=MOD;
    if(m>0) ans[n][m]+=fun(n,m-1);
    ans[n][m]%=MOD;
    return ans[n][m];
} 
  
int main() 
{   
    int n,m;
    cin>>n>>m;
    MEM(ans,-1);
    //else ans[0][0]=0;
    forx(i,0,n) forx(j,0,m) cin>>v[i][j];
    if(v[0][0]=='.') ans[0][0]=1;
    cout<<fun(n-1,m-1); 
    return 0; 
} 

Measured memory_bytes: 75648
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
#define MV 1000
struct edge{int to,cost; };
vector <edge> G[MV];
int V,E;
ll d[MV+1];
bool bellmanford(int s){
	rep(i,V){
		d[i]=INFl;
	}
	d[s] = 0;
	int c = 0;
	//bool upd = false;
	bool goalupd=false;//出発点から目的地までの経路での負の閉路の存在判定
	while(true){
		//upd = false;
		goalupd = false;
		for(int i = 0;i < V;i++){
			for(int j = 0;j < G[i].size();j++){
				edge e = G[i][j];
				if(d[i] != INFl && d[e.to] > d[i] + e.cost){
					//printf("c:%d i:%d to:%d oldcost:%lld newcost:%lld\n",c,i,e.to,d[e.to],d[i] + e.cost);
					d[e.to] = d[i] + e.cost;
					//upd = true;
					if(e.to==V-1) goalupd=true;
				}
			}
		}
		if(c>=V-1&& goalupd) return true;
		if(c == 2*V-1) return false;
		c++;
	}
}
int main(){
	int N,M;
	int first=0;
	int a[2001],b[2001],c[2001];
	scan(V);scan(E);
	rep(i,E){
		scan(a[i]);scan(b[i]);scan(c[i]);
		edge e;
		e.to=b[i]-1;
		e.cost=-c[i];
		G[a[i]-1].push_back(e);
	}
	bool flag=bellmanford(first);
	if(flag) prin("inf");
	else{
		/*rep(i,V){
			prin(-d[i]);
		}*/
		prin(-d[V-1]);
	}
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
using namespace std;
int ans;
inline int read(){
	int ret=0;bool f=0;char ch=getchar();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=getchar();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=getchar();
	return f?-ret:ret;
}
int main(){
	for (int n=read();n--;) ans^=read();
	puts(ans?"No":"Yes");
	return 0;
}

Measured memory_bytes: 128
A,B,C,D,E,F = map(int,input().split())

water = []
for i in range(A+1):
    for j in range(B+1):
        if (100*A*i + 100*B*j )< F and (A*i + B*j) > 0:
            water.append(100*A*i+100*B*j)

sugar = []
for i in range(C+1):
    for j in range(D+1):
        if C*i + D*j < F:
            sugar.append(C*i+D*j)
            
water.sort()
sugar.sort()
    
MAX = 0
MAXSUGAR = 0
MAXWEIGHT = 0
tmpsugar = 0
for i in range(len(water)):
    for j in range(len(sugar)):
        tmpsugar = sugar[j]
        while (water[i]+tmpsugar)<=F and tmpsugar <= water[i]*E//100:
            if MAX  <= 100*tmpsugar/(water[i]+tmpsugar):
                MAX  = 100*tmpsugar/(water[i]+tmpsugar)
                MAXSUGAR = tmpsugar
                MAXWEIGHT = water[i]+tmpsugar
            if tmpsugar == 0:
                break
            tmpsugar += sugar[j]

print(str(MAXWEIGHT)+" "+str(MAXSUGAR))

Measured memory_bytes: 40816
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    ll a,b,c;cin>>a>>b>>c;
    if(a%2==1 || b%2==1 || c%2==1){cout<<0<<endl;return 0;}
    if(a==b && b == c && c == a){cout<<-1<<endl; return 0;}
    
    ll cnt =0;
    while(a%2== 0 && b%2 ==0 &&c%2 ==0){
        
        ll ta,tb,tc;
        ta = (b+c)/2;
        tb = (a+c)/2;
        tc = (a+b)/2;
        cnt++;
        a = ta;
        b = tb;
        c = tc;
        
    }
    
    cout<<cnt<<endl;
    
    return 0;
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 200010
#define int long long
using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int tree[N<<2],Add[N<<2];
inline void deal(int x,int y)
{
	Add[x]+=y; tree[x]+=y;
}
inline void pushdown(int rt)
{
	if(Add[rt])
	{
		deal(rt<<1,Add[rt]);
		deal(rt<<1|1,Add[rt]);
		Add[rt]=0;
	}
}
inline void updata(int L,int R,int x,int l,int r,int rt)
{
	if(L<=l&&r<=R) {deal(rt,x); return ;}
	int mid=(l+r)>>1; pushdown(rt);
	if(mid>=L) updata(L,R,x,l,mid,rt<<1);
	if(mid<R) updata(L,R,x,mid+1,r,rt<<1|1);
}
inline int query(int x,int l,int r,int rt)
{
	if(l==r) return tree[rt];
	int mid=(l+r)>>1; pushdown(rt);
	if(mid>=x) return query(x,l,mid,rt<<1);
	if(mid<x) return query(x,mid+1,r,rt<<1|1);
	return 0;
}
int n,m,A[N],sum;
signed main()
{
	n=read(); m=read();
	for(int i=1;i<=n;i++) A[i]=read();
	for(int i=2;i<=n;i++)
	{
		if(A[i-1]==A[i]) continue;
		if(A[i-1]<A[i])
		{
			if(A[i-1]+2<=A[i])
				updata(A[i-1]+2,A[i],1,1,m+1,1);
			updata(A[i]+1,A[i]+1,-(A[i]-A[i-1]-1),1,m+1,1);
			sum+=A[i]-A[i-1];
		}
		else 
		{
			if(A[i-1]+2<=m)
				updata(A[i-1]+2,m,1,1,m+1,1);
			updata(1,1,m-A[i-1]-1,1,m+1,1);
			updata(1,A[i],1,1,m+1,1);
			updata(A[i]+1,A[i]+1,A[i-1]-A[i]-m+1,1,m+1,1);
			sum+=m-A[i-1]+A[i];
		}
	}
	int pr=0,Ans=1000000000000000ll;
	for(int i=1;i<=m;i++)
		pr+=query(i,1,m+1,1),
		Ans=min(Ans,sum-pr);
	cout << Ans << endl;
	return 0 ;
}


Measured memory_bytes: 7680
/*
 * omg.cpp
 *
 *  Created on: 2019/06/03
 *      Author: J01003
 */
#include<iostream>
using namespace std;
int main(){
	int x;
	cin>>x;
	if(x==7||x==5||x==3){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
a=int(input())
d=[]
t=0
g=0
h=list(map(int,input().split()))
for i in range(a-1):
  if h[i]>=h[i+1]:
    g+=1
  else:
    d.append(g)
    g=0
d.append(g)
print(max(d))

Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vp vector<pi>
#define mp map<ll,ll>
#define pb push_back
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const ll inf=1e+18;


int32_t main(){
    
    fast;

    ll k,n;
    cin>>k>>n;

    vi v(n);
    for(ll i=0;i<n;i++)cin>>v[i];

    vi p(n,0),s(n,0);
    for(ll i=1;i<n;i++)
    	p[i]=p[i-1]+(v[i]-v[i-1]);
    for(ll i=n-2;i>=0;i--)
    	s[i]=s[i+1]+(v[i+1]-v[i]);

    ll cd=0,ad=0,mini=inf;
    for(ll i=0;i<n;i++)
    {
    	if(i!=n-1)
         ad = p[i]+(k-(v[n-1]-v[0]))+s[i+1];
        else 
         ad = min(p[i],(k-(v[n-1]-v[0]))+p[i-1]);
        if(i!=0)
         cd = s[i]+p[i-1]+(k-(v[n-1]-v[0]));
        else
         cd = min(s[i],(k-(v[n-1]-v[0]))+s[i+1]); 	 
        mini = min(mini,ad);
        mini = min(mini,cd);
       // cout<<ad<<" "<<cd<<endl;
    }


cout<<mini;
    return 0;

}


Measured memory_bytes: 4992
#include <stdio.h>


int main(){
    int h, w;
    int i, j;
    while(1){
        scanf("%d %d ", &h, &w);
        if(h==0&&w==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if(i==0||i==h-1||j==0||j==w-1){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    } 


    return 0;
}



Measured memory_bytes: 2036