akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */





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

    int H, W; std::cin >> H >> W;
    std::vector<std::vector<int>> fi(H+5, std::vector<int>(W+5, 1)), dp(H+5, std::vector<int>(W+5, 0));
    repr(i, 1, H+1) repr(j, 1, W+1) std::cin >> fi[i][j];
    
    int width = 0;
    repr(i, 1, H+1) repr(j, 1, W+1) if (fi[i][j]==0) {
        dp[i][j] = min(dp[i-1][j], min(dp[i-1][j-1], dp[i][j-1])) + 1;
        chmax(width, dp[i][j]);
    }
    std::cout << width*width << std::endl;

    return 0;
}


Measured memory_bytes: 18380
import sys

inf = 1<<30

def solve():
    n, m = map(int, input().split())
    c = [int(i) for i in input().split()]
    c.sort()

    dp = [inf] * (n + 1)
    dp[0] = 0

    for i in range(1, n + 1):
        for cj in c:
            if i - cj < 0:
                break
            dp[i] = min(dp[i], dp[i - cj] + 1)

    ans = dp[n]
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//cout<<fixed<<setprecision(15)<<

signed main(){
    int n; cin >> n;
    string s; cin >> s;
    if(n%2!=0){
        coutn;
        return 0;
    }
    rep(i,n/2){
        if(s[i]!=s[n/2+i]){
            coutn;
            return 0;
        }
    }
    couty;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    string s;
    cin >> s;

    if(s == "SUN"){
        cout << 7 << endl;
    } else if(s == "MON"){
        cout << 6 << endl;
    } else if(s == "TUE"){
        cout << 5 << endl;
    } else if(s == "WED"){
        cout << 4 << endl;
    } else if(s == "THU"){
        cout << 3 << endl;
    } else if(s == "FRI"){
        cout << 2 << endl;
    } else if(s == "SAT"){
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,c=1;
  cin>>n;
  if(n==1){
    cout<<1;
    return 0;
  }
  ll a[n];
  cin>>a[0]>>a[1];
  int b;
  if(a[1]-a[0]<0){
    b=-1;
  }else if(a[1]-a[0]>0){
    b=1;
  }else{
    b=0;
  }
  for(int i=2;i<n;i++){
    cin>>a[i];
    if(b==1){
      if(a[i]-a[i-1]<0){
        b=0;
        c++;
      }
    }else if(b==-1){
      if(a[i]-a[i-1]>0){
        b=0;
        c++;
      }
    }else{
      if(a[i]-a[i-1]>0){
        b=1;
      }else if(a[i]-a[i-1]<0){
        b=-1;
      }else{
        b=0;
      }
    }
  }
  cout<<c;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    set<int> s;
    for(int i = 0; i < N; i++) {
        int d; cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 3608
#define rep(i,n) REP(i,0,n)
#define REP(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

const ll MAXN = (ll)1e3+10;
const ll DIV = (ll)1e9+7;
ll dp[MAXN][MAXN];

int main(void) {
   ll H,W;
   cin>>H>>W;
   vector<vector<char>> A(H,vector<char>(W));
   // rep(i,H) rep(j,W) cin>>A[i][j];
   rep(i,H) {
      string s;
      cin>>s;
      rep(j,W) A[i][j] = s[j];
   }

   rep(i,MAXN)rep(j,MAXN) dp[i][j] = 0;
   dp[0][0] = 1;
   rep(i,H) rep(j,W) {
      if (A[i][j] == '#') dp[i][j] = 0;
      else {
         if (i!=0) dp[i][j] += dp[i-1][j];
         if (j!=0) dp[i][j] += dp[i][j-1];
      }
      dp[i][j] = dp[i][j]%DIV;
   }
   cout<<dp[H-1][W-1]%DIV<<endl;
   // rep(i,H) rep(j,W) {
   //    cout<<dp[i][j]<<endl;
   // }


   return 0;
}

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

int main(){
    int A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    long kyori = abs(A - B);
    long scondKyori = V - W;
    if (scondKyori <= 0)
    {
        cout << "NO";
    }else if (scondKyori * T >= kyori)
    {
        cout << "YES";
    }else
    {
        cout << "NO";
    }
    
    
    
    
}

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

long long gcd(long long a,long long b){
    if(a==0)return b;
    if(b==0)return a;

    long long M=max(a,b);
    long long m=min(a,b);
    return gcd(m,M%m);
}
long long lcm(long long a,long long b){
    return a*b/gcd(a,b);
}

int main(){
    long long a,b,c,d,e;
    cin>>a>>b>>c>>d;
    e=lcm(c,d);
    cout<<b-a+1-(b/c-(a-1)/c+b/d-(a-1)/d-b/e+(a-1)/e)<<endl;

    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    for (int i = 0; i < 5; i++) {
      if (sc.nextInt() == 0)
        System.out.println(i + 1);
    }
    sc.close();
  }
}


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

int main(int argc, const char * argv[]) {



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

    /////////////////////
    // Write code below /
    /////////////////////
    
int N;

cin >>N;

if(N % 2 == 1){
    cout <<N/2 + 1<<endl;
}
else{
    cout <<N/2<<endl;
}

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>

int main(void)
{
    char S[101],T[101];
    char V[2];
    int N;
    int a[3];
    int i,j,cost;
    int aa[3][3];
    scanf("%s",S);
    scanf("%s",T);

    N=strlen(S);
    for (i=0;i<N;i++) {
        for(j=0;j<N;j++) {
            if(S[j]!=T[j]) break;
            if(j==N-1) {
                printf("Yes\n");
                return 0;
            }
        }
        V[0] = S[N-1];
        for(j=N-1;j>0;j--) {
            S[j]=S[j-1];
        }
        S[0]=V[0];
    }
    printf("No\n");
    return 0;
}

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

using ll = long long;
// #define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  int a[n];
  REP(i,n) {
    cin >> a[i];
  }
  int min_total = INT_MAX;
  for(int i = -100; i <= 100; ++i) {
    int tmp_total = 0;
    REP(j,n) {
      int dis = abs(a[j] - i);
      tmp_total += dis*dis;
    }
    min_total = min(min_total, tmp_total);
  }
  cout << min_total;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<stdlib.h>

int main()
{
  int x;
  long a,b;
  int max_roop = 130;
  bool roop_break = false;
  int i,j;
  
  scanf("%d",&x);
  
  for(a = -max_roop; a <=max_roop; a++)
  {
    for(b = -max_roop; b <=max_roop; b++)
    {
      if((a*a*a*a*a - b*b*b*b*b) == x)
      {
        printf("%d %d\n",a,b);
        roop_break = true;
        break;
      }
    }
    
    if(roop_break)
    {
      break; 
    }
  }
  
  return 0;
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,sum=0,sum1=0,sum2=0;
    cin>>n>>m;
    int i;
    for(i=n-1;i>=0;i--)
    {
       sum1=sum1+i;
    }
    for(i=m-1;i>=0;i--)
    {
        sum2=sum2+i;
    }
    sum=sum1+sum2;

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 256
s = input()
ans = ""
k = int(input())
x = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(s)-1):
    if (26-(ord(s[i])-ord("a")))%26 <= k:
        ans += "a"
        k -= (26-(ord(s[i])-ord("a")))%26 
    else:
        ans += s[i]

last = x[(ord(s[-1])-ord("a")+k)%26]
ans += last

print(ans)


Measured memory_bytes: 3444
n = int(input())
h = [0 for _ in range(5)]

for i in range(n) :
    s = input()
    if s[0] == 'M' :
        h[0] += 1
    if s[0] == 'A' :
        h[1] += 1
    if s[0] == 'R' :
        h[2] += 1
    if s[0] == 'C' :
        h[3] += 1
    if s[0] == 'H' :
        h[4] += 1

ans = 0
for i in range(5) :
    for j in range(i+1, 5) :
        for k in range(j+1, 5):
            ans += h[i] * h[j] * h[k]

print(ans)

Measured memory_bytes: 3064
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 l = sc.nextInt();
        int[] aji = new int[n];
        int sum = 0;
        int sabun = 99999;
        int min = 999999;
        int num = 0;

        for(int i = 0;i<n;i++){
            aji[i] = l+i;
            sum +=aji[i];
        }
        //System.out.println(sum);

        for(int i = 0;i<n;i++){
            sabun = Math.abs(sum - (sum - aji[i]));
            if(min>sabun){
                min = sabun;
                num = i;
            }
        }
        //System.out.println(min);
        System.out.println(sum-aji[num]);

    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#define MAX 20001
using namespace std;

class Data{
public:
  int t,s,d;
  bool operator<(const Data&a)const{
    return t < a.t;
  }
};


int main(){
 
  int n,m;
  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0)break;
    Data data[m];
    bool node[n+1];
    for(int i = 0 ; i < m ; i++){
      cin >> data[i].t >> data[i].s >> data[i].d;
    }
    sort(data,data + m);
    for(int i = 0 ; i < n+1 ; i++)node[i] = false;
    node[1] = true;
    for(int i = 0 ;i < m ; i++){
      if(node[data[i].s])node[data[i].d] = true;
    }

    int cnt = 0 ;
    for(int i = 0 ; i < n+1 ; i++){
      if(node[i])cnt++;
    }
    cout << cnt << endl;
  }  
  return 0;
}

Measured memory_bytes: 1108
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
#include<map>
#include<unordered_map>
#include<iomanip>
#include<queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;
ll amari = 1000000007;
#define rep(n,x) for(ll i=0;i<n;i++) cin>>x[i];
#define forr(a,b) for(ll i=a;i<b;i++);
ll modpow(ll a, ll n, ll mod)
{
	ll res = 1;
	while (0 < n)
	{
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
ll gcd(ll x, ll y)
{
	if (x % y == 0) return y;
	else return gcd(y, x % y);
}
// 1or素数だと１を返す
ll prime(ll x)
{
	for (ll i = 2; i * i <= x; i++)
	{
		if (x % i == 0) return 0;
	}
	return 1;
}



int main()
{
	ll x, y;
	cin >> x >> y;
	ll ans, p, q;
	if ((2 * x - y) % 3 != 0||2*y<x||2*x<y)
	{
		ans = 0;
	}
	else
	{
    
		p = (2 * y - x) / 3;
		q = (2 * x - y) / 3;
      
		ll r;
		r = p + q;
		vector<ll> fact(r + 100);
        vector<ll> inv(r + 100);
        vector<ll> factinv(r + 100);
		fact[1] = 1;
        fact[0]=1;
		inv[1] = 1;
		factinv[1] = 1; 
      	factinv[0]=1;
		for (ll i = 2; i < r + 10; i++)
		{
			fact[i] = (fact[i - 1] * i) % amari;
			inv[i] = (amari - (inv[amari % i] * (amari / i))%amari) % amari;
			factinv[i] = (factinv[i - 1] * inv[i]) % amari;
		}

		ans = amari*10+(fact[p + q] * factinv[p] % amari) * factinv[q];
       ans%=amari;
	}

	cout <<ans << "\n";

	return 0;
}

Measured memory_bytes: 18808
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;

struct Edge{int to,from,cost;};

#ifdef DEBUG
//#define debug cout
#else
SS ss;
//#define debug ss
#endif

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
//#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

vpint l[3010];
int s[3010];
int d[3010];

int main() {
	int n,m,k;
	cin>>n>>m>>k;
	rep(i,m){
		int from,to,cost;
		cin>>from>>to>>cost;
		--from,--to;
		l[from].PB(MP(to,cost));
		l[to].PB(MP(from,cost));
	}
	rep(i,k)s[i]=in()-1;
	rep(i,n)d[i]=INF;
	priority_queue<pint,vector<pint>,greater<pint> > que;
	rep(i,k)que.push(MP(0,s[i]));
	while(!que.empty()){
		pint now=que.top();
//debug<<now.first<<" "<<now.second<<endl;
		que.pop();
		if(d[now.second]<=now.first)continue;
		d[now.second]=now.first;
		rep(i,sz(l[now.second])){
			que.push(MP(now.first+l[now.second][i].second,l[now.second][i].first));
		}
	}
//rep(i,n)debug<<i<<" "<<d[i]<<endl;
	int mx=0;
	rep(i,n)rep(j,sz(l[i])){
		chmax(mx,(d[i]+d[l[i][j].first]+l[i][j].second+1)/2);
	}
	cout<<mx<<endl;
	return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  if(a <= 8 && b <= 8) cout << "Yay!"<< endl;
  else cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * A-un Breathing
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int N = parseInt(br.readLine());

		int a = 0, u = 0;
		boolean order = true;

		for (int i = 0; i < N; i++) {

			if (br.readLine().equals("A")) {
				a++;
			} else {
				u++;
				if (u > a) {
					order = false;
					break;
				}
			}
		}

		if ((a == u) && order) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	} //end main
}

Measured memory_bytes: 24456
n, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x = sorted(x)
y = [x[i+1]-x[i] for i in range(n)]

def eu(a, b):
    a, b = sorted([a,b])
    while a != 0:
        b, a = a, b%a
    return b
d = y[0]
for i in range(1, n):
    d = eu(d, y[i])
print(d)

Measured memory_bytes: 15020
//{{{
#include <bits/stdc++.h>
using namespace std;
//types
typedef long long ll;
typedef pair<int,int> pii;
//input
bool SR(int &_x){return scanf("%d",&_x)==1;}bool SR(ll &_x){return scanf("%lld",&_x)==1;}
bool SR(double &_x){return scanf("%lf",&_x)==1;}bool SR(char *_s){return scanf("%s",_s)==1;}
bool RI(){return true;}
template<typename I,typename... T>bool RI(I &_x,T&... _tail){return SR(_x) && RI(_tail...);}
//output
void SP(const int _x){printf("%d",_x);}void SP(const ll _x){printf("%lld",_x);}
void SP(const double _x){printf("%.16lf",_x);}void SP(const char *s){printf("%s",s);}
void PL(){puts("");}
template<typename I,typename... T>void PL(const I _x,const T... _tail)
{SP(_x);if(sizeof...(_tail)) putchar(' ');PL(_tail...);}
//macro
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=int(b);i--)
#define pb push_back
#define mkp make_pair
#define F first
#define S second
//debug
#ifdef darry140
template<typename A,typename B>
ostream& operator <<(ostream&_s, const pair<A,B> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It>
ostream& _OUTC(ostream &_s,It _b,It _e)//container
{
    _s<<"{";
    for(auto _it=_b;_it!=_e;_it++) _s<<(_it==_b?"":" ")<<*_it;
    _s<<"}";
    return _s;
}
template<typename A,typename B>
ostream& operator <<(ostream&_s, const map<A,B> &_c){return _OUTC(_s,ALL(_c));}
template<typename T>
ostream& operator <<(ostream&_s, const set<T> &_c){return _OUTC(_s,ALL(_c));}
template<typename T>
ostream& operator <<(ostream&_s, const vector<T> &_c){return _OUTC(_s,ALL(_c));}
template<typename I>
void _DOING(const char *_s,I&& _x){cerr<<_s<<"="<<_x<<endl;}//without ','
template<typename I,typename... T>
void _DOING(const char *_s,I&& _x,T&&... _tail)//with ','
{
    int _c=0;
    static const char _bra[]="({[";
    static const char _ket[]=")}]";
    while(*_s!=',' || _c!=0)//eg. mkp(a,b)
    {
        if(strchr(_bra,*_s)) _c++;
        if(strchr(_ket,*_s)) _c--;
        cerr<<*_s++;
    }
    cerr<<"="<<_x<<", ";
    _DOING(_s+1,_tail...);
}
#define debug(...) do{\
    fprintf(stderr,"%s:%d - ",__PRETTY_FUNCTION__,__LINE__);\
    _DOING(#__VA_ARGS__,__VA_ARGS__);\
}while(0)
#else
#define debug(...)
#endif
//}}}
const int maxn=1e5+5;
int n,a[maxn];
void read()
{
    RI(n);
    REP1(i,1,n) RI(a[i]);
}
void build()
{
}
void sol()
{
    int f=0;
    while(1)
    {
        debug(vector<int>(a+1,a+n+1));
        int c1=count_if(a+1,a+n+1,[&](int x){return x%2==1;});
        if(c1>1 || count_if(a+1,a+n+1,[&](int x){return x==1;}))
        {
            int det=(accumulate(a+1,a+n+1,0LL)-n)%2;
            if(det==f) PL("Second");
            else PL("First");
            return;
        }
        REP1(i,1,n) if(a[i]%2==1)
            a[i]--;
        int g=a[1];
        REP1(i,1,n) g=__gcd(g,a[i]);
        REP1(i,1,n) a[i]/=g;
        f^=1;
    }
}
int main()
{
    read();
    build();
    sol();
    return 0;
}




































/*End Of File*/




Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AGC001
{
    public class A
    {
        private void Run()
        {
            var N = int.Parse(Console.ReadLine().Trim());
            var input = Console.ReadLine().Trim().Split().Select(int.Parse).OrderBy(x => x).ToArray();

            Console.WriteLine(input.OrderBy(x => x).Where((x, i) => i % 2 == 0).Sum());
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new A().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


Measured memory_bytes: 3032
a, b, c = STDIN.gets.chomp.split(" ")
a, b, c = [a.to_f, b.to_f, c.to_i]

c = Math::PI * c / 180
d2 = (a * a) + (b * b) - 2 * a * b * Math.cos(c)
d = Math.sqrt(d2)

h = b * Math.sin(c)
l = a + b + d
s = a * h / 2

p s
p l
p h


Measured memory_bytes: 6932
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
int n;
  scanf("%d",&n);
  char s[n][11];
 /* for(int i=0;i<n;i++){
	for(int j=0;j<11;j++){
	s[i][j]=0;
    }
  }*/
  for(int i=0;i<n;i++){
	scanf("%s",&s[i]);
    qsort(s[i],10,sizeof(char),strcmp);
    //printf("%s\n",s[i]);
                   
  }
  qsort(s,n,sizeof(char)*11,strcmp);
  long long c=1,sum=0;
  /*for(int i=0;i<n;i++){
	printf("%s\n",s[i]);
    
  }*/
  for(int i=0;i<n-1;i++){
	if(strcmp(s[i],s[i+1])==0)c++;
    else {sum+=c*(c-1)/2;
      c=1;
         }
  }
  sum+=c*(c-1)/2;
    printf("%lld",sum);
    return 0;
  }

Measured memory_bytes: 2300
#include "bits/stdc++.h"
using namespace std;

int main() {
	int W, A, B;
	cin >> W >> A >> B;
	if ((A + W) < B) {
		cout <<  B - A - W << endl;
	}
	else if (A > (B + W)) {
		cout << A - B - W << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 3568
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {

    Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        int N = scanner.nextInt();
        HashMap<Integer,Boolean> used=new HashMap<>();
        for (int i = 0; i < N; i++) {
            int current = scanner.nextInt();
            if(used.containsKey(current)){
                used.remove(new Integer(current));
            }else{
                used.put(current,true);
            }
        }
        System.out.println(used.size());
    }
}


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

class Program{
    public static void Main(){
        int R = int.Parse(ReadLine());
        if(R < 1200){
            WriteLine("ABC");
        }
        else if (R < 2800){
            WriteLine("ARC");
        }
        else{
            WriteLine("AGC");
        }
    } 
}

Measured memory_bytes: 13140
/// You just can't beat the person who never gives up
/// ICPC next year

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ;

int n ,l ,q ,x[N] ,nxt[N] ,lst[N] ;
int main(){
    scanf("%d",&n);
    int sq = sqrt(n) ;
    for(int i=1;i<=n;++i) scanf("%d",x+i);
    scanf("%d",&l);
    for(int i=1;i<=n;++i){
        int st = i ,en = n ;
        while(st<en){
            int mid = (st+en+1)/2 ;
            if(x[mid]-x[i]>l) en = mid-1 ;
            else st = mid ;
        }
        nxt[i] = st ;
    }
    for(int i=1;i<=n;++i){
        int cur = i ;
        for(int j=0;j<sq;++j){
            if(cur==n){
                cur = 1e9+5 ;
                break ;
            }
            cur = nxt[cur] ;
        }
        lst[i] = cur ;
    }
    lst[n] = 1e9+5 ;
    scanf("%d",&q);
    while(q--){
        int a,b;
        scanf("%d%d",&a,&b);
        if(a>b) swap(a,b);
        if(a==b){
            puts("0");
            continue ;
        }
        int ans = 0 ;
        while(lst[a]<=b){
            a = lst[a] ;
            ans += sq ;
        }
        while(a<b){
            ++ans ;
            a = nxt[a] ;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2048
use proconio::input;

fn main() {
        input! {
        k: usize,
        a: usize,
        b: usize,
                }

        if let Some(_) = (a..b+1).find(|&n| n % k == 0) {
                println!("OK")
        } else {
                println!("NG")
        }
}

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

int main(void) {
  int a[4] = {};
  for (int i = 0; i < 6; i++) {
    int x;
    cin >> x;
    a[x - 1] += 1;
  }
  for (int i = 0; i < 4; i++) {
    if (a[i] >= 3) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int main(){
    int c = 0;
    std::cin >> c;
    float n[c];
    int t;
    int a;
    int tmp;

    std::cin >> t >> a;

    for(int i = 0; i < c; i++){
        std::cin >> tmp;
        n[i] = std::fabs(a-(t-tmp*0.006));
    }

    float ans = n[1];
    int ans_index;
    for(int i = 0; i < c; i++){
        if(ans > n[i]){
            ans = n[i];
            ans_index = i;
        }
    }
    std::cout << ans_index+1 << std::endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; ++i) cin >> H[i];
  
  vector<int> A(N);
  int cnt = 0;
  for (int n = N - 1; n > 0; --n) {
    A[n] = cnt;
    if (H[n - 1] >= H[n]) ++cnt;
    else cnt = 0;
  }
  A[0] = cnt;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (A[i] > ans) ans = A[i];
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
#include <cmath>
#include <vector>
#include <iostream>
#include <limits>
#include <iostream>
#include <vector>
#include <cassert>
#include <complex>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long Long;

vector<int> V;
Long mem[51][3010][51];
Long dp(int id, int sum, int cnt, int S){
	if(id == V.size())return cnt && sum == S * cnt;
	if(mem[id][sum][cnt] != -1)return mem[id][sum][cnt]; 
	Long w = dp(id+1,sum,cnt, S) + dp(id+1, sum + V[id], cnt+1, S);
	return mem[id][sum][cnt] = w;
}

int main(){

	memset(mem,-1,sizeof(mem));
	int N , S;
	cin >> N >> S;
	V = vector<int>(N);
	for(int &v : V)
		cin >> v;
	cout << dp(0, 0, 0, S) << endl;
	
}


/*




 */


Measured memory_bytes: 61440
#include <iostream>
#include <cmath>

using namespace std;

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

    if (a==1 || b==1)
    	cout<<1<<endl;
	else if (a%2==1 && b%2==1)
    	cout<<(a*b+1)/2<<endl;
    else
    	cout<<(a*b)/2<<endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.CodeDom;

class TEST
{
    public static void Main()
    {
        string str = Console.ReadLine();
        int best = 0;

            int count = 0;
        for (int i = 0; i < str.Length; i++)
        {
            if (str[i] == 'R')
            {
                count++;
                if (best < count)
                    best = count;
            }
            else
            {
                count = 0;
            }
        }

        Console.WriteLine(best);
   //     Console.ReadLine();
    }


}

Measured memory_bytes: 25760
from collections import defaultdict

N = int(input())

D = defaultdict(list) 
S = {} #STEPD
for i in range(1,N+1):S[i] = -1
R = defaultdict(int) #ROOT
for i in range(N-1):
    u,v,w = map(int,input().split())
    D[u].append(v)
    D[v].append(u)
    R["{}-{}".format(u,v)] = w
    R["{}-{}".format(v,u)] = w
    
T = [(1,0)]
S[1] = 0
while T:
    n,w = T.pop()
    for d in D[n]:
        wr = R["{}-{}".format(n,d)]
        if S[d]>=0:continue
        else: S[d] = (w+wr)%2
        T.append((d,(w+wr)%2))
        
for k in range(1,N+1):
    print(S[k] if S[k]>=0 else 0)

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

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i = 0; i < N; ++i) cin >> H[i];
  int h = 0, ans = 0;
  for(int i = 0; i < N; ++i){
    if(H[i] >= h) ++ans, h = H[i];
  }
  cout << ans << endl;
}


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

int main(){
	string S;
	cin >> S;
	int N = (int)S.size();
	int dp[N];
	dp[0] = 1;
	if(S[0] == S[1]) dp[1] = 1;
	else dp[1] = 2;
	if(S[2] == S[1]){
		if(S[1] == S[0])dp[2] = 2;
		else dp[2] = 2;
	}
	else dp[2] = dp[1] + 1;
	for(int i=3;i<N;i++){
		if(S[i] == S[i-1])dp[i] = dp[i-3] + 2;
		else dp[i] = dp[i-1] + 1;
	} 
	cout << dp[N-1] << endl;
}

Measured memory_bytes: 1920
import sys
from math import ceil
def main():
    T1, T2, A1, A2, B1, B2 = map(int, sys.stdin.read().split())
    
    # 相対速度
    BA1 = A1 - B1
    BA2 = A2 - B2

    if BA1 == 0:
        print(0)
        sys.exit()

    # A1, B1の速い方が速い方をAとする
    if BA1 < 0:
        BA1 = -BA1
        BA2 = -BA2
    
    d = BA1 * T1 + BA2 * T2
    if d > 0:
        print(0)
        sys.exit()
    if d == 0:
        print('infinity')
        sys.exit()
    
    n = ceil((- BA1 * T1) / d)
    if n * d == - BA1 * T1:
        ans = 2 * n
    else:
        ans = 2 * n - 1
    
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  int flag=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==0){
      if(a[i]%3==0 || a[i]%5==0)continue;
      else	flag=1;
    }
  }
  if(flag)	cout<<"DENIED"<<endl;
  else	cout<<"APPROVED"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int count=0;
void visit(int u, int *jude, int *d, int *f, int size);
int d[101], f[101],jude[101];
int matrix[101][101];
int main(int argc, char** argv) {
    int size;
    int degree;

    scanf("%d", &size);
    
    
    for(int i=0;i<size;i++)
    {
        jude[i]=0; 
        for(int j=0;j<size;j++)
        {
            matrix[i][j]=0;
        }
    }
    int temp, a;
    for(int i=0;i<size;i++)
    {
        scanf("%d %d",&temp, &degree);
        for(int j=0;j<degree;j++)
        {
            scanf("%d", &a);
            matrix[temp-1][a-1]=1;
        }
    }
    for(int i=0;i<size;i++)
    {
        if(jude[i]==0)
            visit(i,jude,d,f, size);
    }
    
    for(int i=0;i<size;i++)
    {
        printf("%d %d %d\n", i+1, d[i], f[i]);
    }
  
    return (EXIT_SUCCESS);
}


void visit(int u, int *jude, int *d, int *f, int size)
{
  int i;
  jude[u]=1;
  d[u]=++count;
  for(i=0;i<size;i++){
    if(matrix[u][i]==1)
    {
      if(jude[i]==0)
          visit(i, jude, d, f, size);
    }
  }
  jude[u]=2;
  f[u]=++count;
}



Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s;
  cin >> s;

  // 文字列"AKIHABARA"から、いくつかのAを除いてできる文字列を全列挙してどれかと一致したらYES
  string target = "AKIHABARA";
  bool flag[4];
  for (int i = 0; i < 16; i++) {
    for (int j = 0; j < 4; j++) {
      flag[j] = true;
      if ((i >> j) & 1) flag[j] = false;
    }
    string tmp = "";
    int cnt = 0;
    for (int j = 0; j < target.size(); j++) {
      if (target[j] == 'A' && flag[cnt++]) {
        tmp += 'A';
      } else if (target[j] != 'A') {
        tmp += target[j];
      }
    }
    //cout << i << ": " << tmp << endl;
    if (tmp == s) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
lis = input().split()

count_list = [0] * (N + 1)

for k in lis:
  count_list[int(k)] += 1

Sum = 0
for k in count_list:
  Sum += ( k * (k-1)) // 2



for i in lis:
  count = count_list[int(i)]
  s = int(count) - 1
  ans = Sum - s
  print(ans)

Measured memory_bytes: 21676
# ARC078D - Fennec VS. Snuke (ABC067D)
from collections import deque


def bfs(s: int, d: "List[int]") -> None:
    q = deque([s])
    while q:
        v = q.popleft()
        for u in G[v]:
            if not d[u]:
                q.append(u)
                d[u] = d[v] + 1


def main():
    global G, DB, DW
    N, *E = map(int, open(0).read().split())
    G = [[] for _ in range(N + 1)]
    for i in range(0, (N - 1) * 2, 2):
        v, u = E[i : i + 2]
        G[v] += [u]
        G[u] += [v]
    # DB, DW: distance from G[i] (black) and G[N] (white)
    DB, DW = [0] * (N + 1), [0] * (N + 1)
    bfs(1, DB), bfs(N, DW)
    b, w = 0, 0
    for i, j in zip(DB[1:], DW[1:]):
        if i <= j:
            b += 1
        else:
            w += 1
    flg = b > w
    print("Fennec" if flg else "Snuke")


if __name__ == "__main__":
    main()

Measured memory_bytes: 32492
#include<bits/stdc++.h>
#define pb push_back
 using namespace std;
  int main(){
    int n;
    cin>>n;
    long long  int sum=0;
    unordered_map<int, int>mp;
    for(int i=0; i<n; i++)
     {
          int x;
           cin>>x;
           sum+=x;
           mp[x]++;
     }
     int q;
      cin>>q;                                    // segment tree ka use karna hi hoga//
      while(q--){
          int bi,ci;
           cin>>bi>>ci;
          auto it=mp.find(bi);
           if(it!=mp.end())
           {
               int z=ci-it->first;
                     sum+=(z*it->second);
                     
                   int dd=it->second;
                   mp.erase(it);
                   if(mp.find(ci)!=mp.end())
                   {
                       mp[ci]= mp[ci]+dd;
                   }
                   else
                   mp[ci]=dd;
                    cout<<sum<<endl;
               }
               else
                cout<<sum<<endl;
               
               
           }
          
      }
      
 

Measured memory_bytes: 6556
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;
 
typedef long long ll;
typedef pair < int , int > ii;

int n,a[N],dp[N];

int main() 
{	
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];

	dp[0] = 0;
	dp[1] = abs(a[0] - a[1]);

	for (int i = 2; i < n; ++i)
	{
		dp[i] = min(dp[i-1] + abs(a[i-1] - a[i]), dp[i-2] + abs(a[i-2] - a[i]));
	}

	cout << dp[n - 1];

	return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  cin >> s;
	int p=s.size();
	int ret=0;
	for(int i=0;i<p/2;i++){
		if(s[i]=='i'&&s[p-i-1]=='i');
		else if(s[i]=='w'&&s[p-i-1]=='w');
		else if(s[i]=='('&&s[p-i-1]==')');
		else if(s[i]==')'&&s[p-i-1]=='(');
		else ret++;
	}
	if(p%2 && s[p/2]!='i' && s[p/2]!='w') ret++;
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n;
  cin>>n;
  int i;
  int *arr = new int[n];
  for(i=0;i<n;i++){
   cin>>arr[i]; 
  }
  double ans=0;
  for(i=0;i<n;i++){
   ans = ans + 1.0/arr[i]; 
  }
  ans = 1/ans;
  cout<<ans<<endl;
  delete []arr;
 return 0; 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			String in = sc.next();
			if (in.equals("#END")) {
				return;
			}
			String ans = "";
			for (int i = 1; i < in.length(); i++) {
				String lcs = lcs(in.substring(0, i), in.substring(i, in.length()));
				if (lcs.length() > ans.length()) {
					ans = lcs;
				}
			}
			System.out.println(ans);
		}
	}

	String lcs(String s, String t) {
		int n = s.length();
		int m = t.length();
		int[][] dp = new int[n + 1][m + 1];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (s.charAt(i) == t.charAt(j)) {
					dp[i + 1][j + 1] = dp[i][j] + 1;
				} else {
					dp[i + 1][j + 1] = Math.max(dp[i + 1][j], dp[i][j + 1]);
				}
			}
		}
		char[] res = new char[dp[n][m]];
		while (n > 0 && m > 0) {
			if (dp[n][m] == dp[n - 1][m]) {
				n--;
			} else if (dp[n][m] == dp[n][m - 1]) {
				m--;
			} else {
				res[dp[n - 1][m - 1]] = s.charAt(n - 1);
				n--;
				m--;
			}
		}
		return String.valueOf(res);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

vector<vector<ll>> dp(1001, vector<ll>(1001, -1));
int h, w;
char a[1001][1001];

int dfs(int i, int j){
  if(dp[i][j] >= 0) return dp[i][j];
  int res = 0;
  if(i+1 <= h && a[i+1][j] == '.') res = (res + dfs(i+1, j)) % mod;
  if(j+1 <= w && a[i][j+1] == '.') res = (res + dfs(i, j+1)) % mod;
  return dp[i][j] = res;
}

int main(){
  cin >> h >> w;
  rep(i, h){
    rep(j, w) cin >> a[i+1][j+1];
  }
  dp[h][w] = 1;
  cout << dfs(1, 1) << endl;
  return 0;
}


Measured memory_bytes: 9216
from collections import Counter

def solve():
    N = int(input())
    S = [input() for i in range(N)]    
    ctr = Counter(S)
    max_cnt = max(ctr.values())
    names = [name for name, cnt in ctr.items() if cnt == max_cnt]
    names.sort()
    return names

print(*solve(), sep = "\n")



Measured memory_bytes: 35564
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

bool from1[2505];
bool fromN[2505];
bool ok[2505];
vector<vl> G(2505);
vector<vl> rG(2505);

ll GCD(ll a, ll b){
    if(b==0) return a;
    else return GCD(b,a%b);
}

int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    vl lgcd(n);
    vl rgcd(n);
    lgcd[0] = a[0];
    rgcd[n-1] = a[n-1];
    REP(i,1,n) lgcd[i] = GCD(lgcd[i-1], a[i]);
    for(ll i=n-2; i>=0; i--) rgcd[i] = GCD(rgcd[i+1], a[i]);
    ll mx = 0;
    rep(i,n){
        if(i==0) mx = max(mx, rgcd[1]);
        if(i==n-1) mx = max(mx, lgcd[n-2]);
        else mx = max(mx, GCD(lgcd[i-1], rgcd[i+1]));
    }
    cout << mx << endl;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    double l;
    cin >> l;
    double ans = l/3 * l/3 * l/3;

    // cout << ans << endl;
 printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>

using namespace std;

#define BUF_SIZE 1024
#define ARRAY_SIZE 100

int main(){

	char buf[BUF_SIZE] = {0};
	int n = atoi(fgets(buf,BUF_SIZE,stdin));

	int array[ARRAY_SIZE] = {0};

	for(int i = 0; i < n; i++){
		cin >> array[i];
	}

	for(int k = 0;k < n; k++){
		if(k != n-1){
			printf("%d ",array[k]);
		}else{
			printf("%d\n",array[k]);
		}
	}

	int v = 0;
	int j = 0;
	for(int i = 1; i < n; i++){
		v = array[i];
		j = i-1;
		while(j >= 0 && array[j] > v){
			array[j+1] = array[j];
			j--;
		}
		array[j+1] = v;
		for(int k = 0;k < n; k++){
			if(k != n-1){
				printf("%d ",array[k]);
			}else{
				printf("%d\n",array[k]);
			}
		}
	}

}



Measured memory_bytes: 3152
#include <stdio.h>

int main(void)
{
	char a[100],b[100],c[100];
	int a_last=0,b_last=0;
	
	scanf("%s %s %s",a,b,c);
	
	for(int i=0;a[i]!='\0';i++){
		a_last++;
	}
	for(int j=0;b[j]!='\0';j++){
		b_last++;
	}
	
	if(a[a_last-1]!=b[0]){
		printf("NO\n");
	}else if(b[b_last-1]!=c[0]){
		printf("NO\n");
	}else{
		printf("YES\n");
	}
	
	return 0;
}
			

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
#define mod 1000000007
int main()
{	
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int w=1;
	// cin>>w;
	while(w--){
		int n,k;
		cin>>n>>k;
		vi v(n);
		F(i,0,n){
			cin>>v[i];
		}
		vi dp(n);
		dp[0]=0;
		dp[1]=abs(v[0]-v[1]);
		F(i,2,n){
			dp[i]=INT_MAX;
			F(j,1,k+1)
			if(i-j>=0)
			dp[i]=min(dp[i-j]+abs(v[i]-v[i-j]),dp[i]);
		}
		cout<<dp[n-1];
	}
}

Measured memory_bytes: 3980
n=int(input())
a=list(map(int,input().split()))

max=min=0
total=a[0]
for i in range(n-1):
    if(a[i+1]>a[max]):
        max=i+1
    if(a[i+1]<a[min]):
        min=i+1
    total+=a[i+1]
print('%d %d %d' % (a[min],a[max],total))



Measured memory_bytes: 6596
n = int(input())
if n % 2 == 0:
    lst = []
    for i in range(1, n + 1):
        for j in range(i, n + 1):
            if i != j and i + j != n + 1:
                lst.append((i, j))

    print(len(lst))
    for s in lst:
        print(*s)
else:
    lst = []
    for i in range(1, n):
        for j in range(i, n):
            if i != j and i + j != n:
                lst.append((i, j))
    for i in range(1, n):
        lst.append((i, n))
    print(len(lst))
    for s in lst:
        print(*s)

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

#define rep(i, n)     for(int i = 0;      i < int(n); ++i)
#define rep3(i, a, b) for(int i = int(a); i < int(b); ++i)
#define all(x)        (x).begin(),(x).end()
#define sz(x)         int(x.size())

typedef long long ll;

using namespace std;

int main(){
  string s;
  cin >> s;
  replace(all(s), '1', 'x');
  replace(all(s), '9', '1');
  replace(all(s), 'x', '9');
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int n;
    int x;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0) {
            cout << " " << i;
        } else {
            x = i;
            while (x) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	string s,t;
	cin>>s>>t;
	long cd=0;
	for(int i=0;i<s.size();i++)
	{
		char ss=s.at(i);
		char tt=t.at(i);
		if(ss!=tt)
		cd++;
	}
	cout<<cd<<endl;
}

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


int main(){
    int n, k; cin >> n >> k;
    vector<string> d(k); rep(i,k) cin >> d[i];
    for(int i = n; ; ++i){
        string s = to_string(i);
        bool flag = true;
        rep(j,k){
            if(s.find(d[j]) != string::npos){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << i << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    ll x;
    cin >> x;

    ll a = 1, b = 1;
    for (int i = 0; i < n; i++) {
        a = a * 2 + 3;
        b = b * 2 + 1;
    }

    ll r = 0;
    for (int i = n; i > 0; i--) {
        a = (a - 3) / 2;
        b = (b - 1) / 2;
        if (x < 1) break;
        x--;
        if (x < a) continue;
        r += b;
        x -= a;
        if (x < 1) break;
        r++;
        x--;
        if (x < a) continue;
        r += b;
        x -= a;
        if (x < 1) break;
        x--;
        if (x == 0 && i == n) break; else throw;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<vector<int>> a(2,vector<int>(n));
    for(int i = 0;i < 2;i++){
          for(int j = 0;j < n;j++){
                cin >> a[i][j];
          }
    }
    int ans = 0;
    for(int i = 0;i < n;i++){
          int t = 0;
          for(int j = 0;j <= i;j++){
                t += a[0][j];
          }
          for(int k = i;k < n;k++){
                t += a[1][k];
          }
          ans = max(ans,t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600