akhauriyash/Code-Regression huggingface dataset:
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {
    var n = readLine.split(" ").map(_.toInt)

    while( n(0) != 0 || n(1) != 0) {
      for(i <- 0 to n(0)-1) {
        val str = if(i%2==0) "#."*n(1) else ".#"*n(1)
        println(str.take(n(1)))
      }
      println()
      n = readLine.split(" ").map(_.toInt)
    }
  }
}

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

#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 

#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

const int N =1e5+7;

int mod= 1e9+7;
int dx[4]={0,0,+1,-1};
int dy[4]={+1,-1,0,0};

vi v[N]; 
int a[N],maxi;

int dfs(int u){
   if(!a[u]){
     
	   for(auto  to: v[u])
		    a[u] = max(a[u],dfs(to));
	   a[u]++;
   }
   return a[u];

}

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

	rep(i,0,m){
      int x,y;
	  cin>>x>>y;
	  --x,--y;
	  v[x].pb(y);
	}

	rep(i,0,n){
       maxi=max(dfs(i),maxi);		
	}
  
	cout<<maxi-1<<endl;


}



int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
		solve();


	return 0;	   
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    else if(s=="Cloudy") cout<<"Rainy"<<endl;
    else cout<<"Sunny"<<endl;
    return 0;
}

Measured memory_bytes: 256
// OURL: https://atcoder.jp/contests/abc085/tasks/abc085_c
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N,Y;
  cin >> N >> Y;
  // int _i,_j,_k;
  REP(i,N+1) {
    REP(j,N+1-i) {
      int k = N - i - j;
      if (1e4*i+5*1e3*j+1e3*k == Y) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	var cnta, cntb, cntc int
	fmt.Scan(&s)
	for i := 0; i < len(s); i++ {
		switch string(s[i]) {
		case "a":
			cnta++
		case "b":
			cntb++
		case "c":
			cntc++
		}
	}
	if cnta == 1 && cntb == 1 && cntc == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
S = str(input())
N = len(S)//2
i = 0
n = 0

while i <= N-1:
    if S[i] == S[-(i+1)]:
        n += 0
        i += 1
    elif S[i] != S[-(i+1)]:
        n += 1
        i += 1

print(n)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <stack>

using namespace std;

int main(void){
	string token;
	stack<int> st;

	while(cin >> token){
		if(token == "+"){
			int op2 = st.top();
			st.pop();
			int op1 = st.top();
			st.pop();
			st.push(op1 + op2);
		}else if(token == "-"){
			int op2 = st.top();
			st.pop();
			int op1 = st.top();
			st.pop();
			st.push(op1 - op2);
		}else if(token == "*"){
			int op2 = st.top();
			st.pop();
			int op1 = st.top();
			st.pop();
			st.push(op1 * op2);
		}else if(token == "/"){
			int op2 = st.top();
			st.pop();
			int op1 = st.top();
			st.pop();
			st.push(op1 / op2);
		}else{
			int op = 0;
			for(int i = 0;i < token.length();i++){
				op = op * 10 + (char)token[i] - '0';
			}
			st.push(op);
		}
	}
	cout << st.top() << endl;

	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main(){
	int n,c[500],s[500],f[500],ans[500],time;

	cin>>n;
	for(int i=1;i<n;i++)cin>>c[i]>>s[i]>>f[i];

	time = 0;
	for(int i=1;i<n;i++){	//スタート位置;
		time=0;
		for(int j=i;j<n;j++){
			if(time<=s[j])
				time=s[j]+c[j];
			else {
				if(time%f[j])time+=f[j]-(time%f[j])+c[j];
				else time+=c[j];
			}
		}
		ans[i]=time;
	}
	for(int i=1;i<n;i++)
		cout<<ans[i]<<endl;
	cout<<"0"<<endl;
}

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

int n, m, a[101], score[101]; 

int main()
{
  cin >> n >> m;
  for(int i = 1; i <= m; i++) cin >> a[i];
  
  for(int i = 1; i <= m; i++){
    int w = 0;
    for(int j = 1; j <= n; j++){
      int b;
      cin >> b;
      if(a[i] == b) score[j]++;
      else w++;
    }
    score[a[i]] += w;
  }
    
  for(int i = 1; i <= n; i++) cout << score[i] << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#define ll long long
using namespace std;
int main()
{
    int n,i,j,k,ans;ans=0;
    int a[100005],b[100005];
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    scanf("%d",&a[i]);
    for(i=1;i<=n;i++)
    {
        if(a[i]==i)
        {
            ans+=1;
            if(a[i+1]==i+1)
                i=i+1;
        }
    }
    printf("%d",ans);
    return 0;
}


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

int main(){
	int N; cin>>N;
	int n = 0, r = 0;
	vector<int> A(N);
	rep(i, N){ cin>>A[i]; n = max(n, A[i]); }
	// rep(i, N) if(abs(n - r*2) > abs(n - A[i]*2)) r = A[i];
	// rep(i, N) if(abs(n - r*2) >= abs(n - A[i]*2)) r = A[i];
	// rep(i, N) if(abs(n/2 - r) > abs(n/2 - A[i])) r = A[i];
	// rep(i, N) if(abs(n/2 - r) >= abs(n/2 - A[i])) r = A[i]; // NG!
	// rep(i, N) if(abs((n+2-1)/2 - r) > abs((n+2-1)/2 - A[i])) r = A[i];
	rep(i, N) if(abs((n+2-1)/2 - r) >= abs((n+2-1)/2 - A[i])) r = A[i]; // NG
	cout<< n <<" "<< r <<endl;
}


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

using namespace std;

typedef long long ll;

#define p(x) cout << x << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define range(i, begin, end) for (int i = begin; i < (int)(end + 1); i++)
#define all(x) (x).begin(), (x).end()

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

  double as[n];
  rep(i, n) { cin >> as[i]; }

  double ans = 0;
  rep(i, n) { ans += (1 / as[i]); }
  p(1 / ans);
  return 0;
}


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

int main() {
  int A,B,a,b,c,d,xa,N=0;
  cin >>A>>B;
  for(int x=A;x<B+1;x++){
    xa=x;
    a=xa/10000;
    xa=xa%10000;
    b=xa/1000;
    xa=xa%1000;
    xa=xa%100;
    c=xa/10;
    xa=xa%10;
    d=xa/1;
    if(a==d && b==c)
      N++;
}
  cout<< N<<endl;
}

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

using ll=long long;
const ll MOD=924844033;
ll ans;
ll dp[2234][2234];//dp[i][j]:i-1本目まで見てj本選ぶ
ll DP[5000][5000];//DP[i]:i本選んだ通り
ll F[5000];

signed main(){
  int n,k;cin>>n>>k;

  F[0]=1;
  for(int i=1;i<5000;i++)F[i]=F[i-1]*i%MOD;

  dp[0][0]=dp[1][0]=dp[1][1]=1;
  for(int i=1;i<2200;i++){
    for(int j=0;j<2200;j++){
      (dp[i+1][j]+=dp[i][j])%=MOD;
      (dp[i+1][j+1]+=dp[i-1][j])%=MOD;
    }
  }
  DP[0][0]=1;
  for(int i=0;i<k;i++){
    int U=(n-i-k-1)/(k*2)+1,D=(n-i-1)/(k*2)+1;
    if(n-i-k-1<0)U=0;
    if(n-i-1<0)D=0;
    int A=U+D-1;
    for(int j=2000;j>=0;j--){
      for(int l=0;l<=A;l++){
        (DP[i+1][j+l]+=DP[i][j]*dp[A][l])%=MOD;
      }
    }
  }
  for(int i=0;i<k;i++){
    int U=(n-i-k-1)/(k*2)+1,D=(n-i-1)/(k*2)+1;
    if(n-i-k-1<0)U=0;
    if(n-i-1<0)D=0;
    int A=U+D-1;
    for(int j=2000;j>=0;j--){
      for(int l=0;l<=A;l++){
        (DP[i+k+1][j+l]+=DP[i+k][j]*dp[A][l])%=MOD;
      }
    }
  }
  ll ans=0;
  for(int i=0;i<=n;i++){
    ll tmp=DP[2*k][i]*F[n-i]%MOD;
    if(i&1)tmp*=-1;
    tmp+=MOD;
    (ans+=tmp)%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 196096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string T;
    cin >> T;
    int t[n];
    rep(i, 0, n) {
        if (T[i] == 'r') t[i] = 0;
        if (T[i] == 's') t[i] = 1;
        if (T[i] == 'p') t[i] = 2;
    }
    int score[3] = {r, s, p};
    int dp[n][3] = {};
    rep(i, 0, k) {
        rep(j, 0, 3) {
            if ((j + 1) % 3 == t[i]) dp[i][j] = score[j];
        }
    }
    rep(i, k, 2 * k) {
        for (int j = i; j < n; j += k) {
            rep(l, 0, 3) {
                rep(m, 0, 3) {
                    if (l == m) continue;
                    if ((l + 1) % 3 == t[j]) dp[j][l] = max(dp[j][l], dp[j - k][m] + score[l]);
                    else dp[j][l] = max(dp[j][l], dp[j - k][m]);
                }
            }
        }
    }
    int ans = 0;
    rep(i, 0, k) {
        int mx = 0;
        rep(j, 0, 3) {
            mx = max(mx, dp[n - 1 - i][j]);
        }
        ans += mx;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2048
import itertools

S=input()
N=len(S)-1
PRD1=list(itertools.product(['+','_'], repeat=N))

PRD3=[]
for i in range(len(PRD1)):
    PRD3.append(['']*(2*N+1))

for i in range(len(PRD1)):
    PRD3[i][::2]=S
    PRD3[i][1::2]=PRD1[i]

ans=0
for i in range(len(PRD3)):
    PRD3[i]=['' if j=='_' else j for j in PRD3[i]]
    ans+=eval(''.join(PRD3[i]))

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,a) for(int i=0;i<(a);i++)
#define MOD 1000000007

const int MA=90001;
int px[MA],py[MA];
int d[MA];
 
int main(){
  int H,W,D;
  cin>>H>>W>>D;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      int a;
      cin>>a;
      px[a]=i,py[a]=j;
    }
  }
  for(int i=H*W-D;i>0;i--){
    d[i]=d[i+D]+abs(px[i]-px[i+D])+abs(py[i]-py[i+D]);
  }
  int Q;
  cin>>Q;
  for(int i=0;i<Q;i++){
    int l,r;
    cin>>l>>r;
    cout<<d[l]-d[r]<<endl;
  }
  return 0;
}

Measured memory_bytes: 2176
$n=<>;
@W=glob<>;
@A;$A[0]=0;
$A[$_]=$A[$_-1]+$W[$_-1] for(1..$n);
$min=1e9;
$min=(abs($A[$n]-$_*2)<$min)?abs($A[$n]-$_*2):$min for(@A);
print $min

Measured memory_bytes: 768
import collections

def main():
    N, Q = map(int, input().split())
    saw_list = [False] * (N+1)
    relation = [[] for _ in range(N+1)]
    values = [0] * (N+1)

    for _ in range(N-1):
        a, b = map(int, input().split())
        relation[a].append(b)
        relation[b].append(a)

    for _ in range(Q):
        p, x = map(int, input().split())
        values[p] += x

    deque = collections.deque()
    deque.append(1)
    saw_list[1] = True
    while deque:
        node = deque.pop()
        for val in relation[node]:
            if not saw_list[val]:
                deque.append(val)
                values[val] += values[node]
                saw_list[val] = True

    ret = ""
    for i in range(1, len(values)):
        ret += str(values[i]) + " "
    print(ret)

main()

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

using namespace std;
using ll = long long;
 
#define rep(i, n)      for (int i = 0; i < (n); i++)
#define repr(i, n)     for (int i = (n) - 1; i >= 0; i--)
#define repe(i, l, r)  for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define repi(i, l, r)  for (int i = (l); i <= (r); i++)
#define repir(i, l, r) for (int i = (r); i >= (l); i--)
#define range(a) a.begin(), a.end()
void initio() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

ll count(vector<pair<ll, ll>> a) {
  const int n = a.size();
  vector<pair<ll, int>> events;
  rep(i, a.size()) {
    events.emplace_back(a[i].first, i);
    events.emplace_back(a[i].second, i + n);
  }
  sort(range(events));
  ll res = 0;
  int cnt = 0;
  ll prev = 0;
  for (auto kv : events) {
    if (kv.second < n) {
      if (cnt == 0) {
        prev = kv.first;
      }
      cnt++;
    } else {
      cnt--;
      if (cnt == 0) {
        res += kv.first - prev;
      }
    }
  }
  return res;
}

ll floordiv(ll n, ll d) {
  if (n >= 0) return n / d;
  return (n - d + 1) / d;
}

int main() { initio();
  ll N, X, D; cin >> N >> X >> D;
  map<ll, vector<pair<ll, ll>>> mp;
  if (D == 0) {
    if (X == 0) {
      cout << 1 << endl;
      return 0;
    }
    cout << N + 1 << endl;
    return 0;
  }
  if (D < 0) {
    X *= -1;
    D *= -1;
  }
  mp[0].emplace_back(0, 1);
  for (ll i = 1; i <= N; i++) {
    // 0 + 1 + 2 + ... (i-1)
    ll mn = i * X + i * (i - 1) / 2 * D;
    // (N-1-(i-1)) (N-1)
    ll mx = i * X + (N-1-(i-1) + (N-1)) * i / 2 * D;
    mp[((mn % D) + D) % D].emplace_back(floordiv(mn, D), floordiv(mx+D, D));
  }
  ll ans = 0;
  for (auto kv : mp) {
    ans += count(kv.second);
  }
  cout << ans << endl;
}


Measured memory_bytes: 22144
n = int(input())
str = ''
if n == 0:
  str = '0'
else:
  while n != 0:
    if n % 2 == 0:
      str = '0' + str
      n /= (-2)
    else:
      str = '1' + str
      n -= 1
      n /= (-2)
print(str)

Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    char a, b; cin >> a >> b;
    cout << (a == b ? "H" : "D") << endl;
}


Measured memory_bytes: 256
def yakusuu(n):
    cnt = 0
    for i in range(1,n+1):
        if n % i == 0:
            cnt += 1
    return cnt
        

N = int(input())
ans = 0
for i in range(1,N+1):
    if i % 2 != 0:
        if yakusuu(i) == 8:
            ans += 1
print(ans)


Measured memory_bytes: 63144
#include <cstdio>

using namespace std;

bool isPrime(int n){
	if (n <= 1)
		return false;
	if (n == 2)
		return true;
	if (n % 2 == 0)
		return false;
	for(int i = 3; i*i <= n; i+=2){
		if (n % i == 0)
			return false;
	}
	return true;
}

bool C(int n){
	return isPrime(n) && isPrime((n+1)/2);
}

int main(){
	int q;
	scanf("%d", &q);

	int sum[100001] = {};
	for(int i = 1; i <= 100000; i++){
		sum[i] = sum[i-1] + (int)(C(i));
	}

	for(int i = 0; i < q; i++){
		int l, r;
		scanf("%d%d", &l, &r);
		printf("%d\n", sum[r] - sum[l-1]);
	}

	return 0;
}

Measured memory_bytes: 896
import java.util.*;
import java.util.function.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    sc.close();

    long ans = 0;
    if (N % 2 == 0) for (long n = N / 2; 0 < n; n /= 5) ans += n / 5;
    System.out.println(ans);
  }
}

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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using  vi = vector<int>;
using  vl = vector<ll>;
using  vd = vector<double>;
template<class T,class U>
using umap = unordered_map<T,U>;
template<class T>
using uset = unordered_set<T>;

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

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

template<class T>
inline void putv(const vector<T>&v,char c = '\n'){
  for(auto&&e:v){
    cout << e << c;
  }
}

template<class T>
inline void readv(vector<T>&v){
  if(v.empty()){
    cerr << "void readv(vector<T>&v) v.empty()\n";
  }
  for(auto&&e:v){
    cin >> e;
  }
}

int main(){
  int n; cin >> n;
  vector<int>h(n);
  readv(h);
  for(int i = n - 2; i >= 0; --i){
    if(h[i] - h[i + 1] >= 2){
      cout << "No\n";
      return 0;
    } else if(h[i] - h[i + 1] > 0){
      h[i]--;
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;


int memo[32];
int N;


int rec(int n)
{
  if(memo[n] != -1) return memo[n];

  if(n == N) return 1;
  if(n >= N) return 0;

  int ret = 0;
  for(int i = 1; i <= 3; i++) {
    ret += rec(n+i);
  }

  return memo[n] = ret;
}

int main()
{
  for(; cin >> N && N; ) {
    memset(memo, -1, sizeof memo);
    cout << ceil(rec(0) / 3650.0) << endl;
  }
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long n=0;
    string s;
    cin>>s;
    for(auto u:s)
        n+=u-'0';
    if(n%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, 1, -1};
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep (i, h) cin >> s[i];
    int res = 0;
    rep (i, h) {
        rep (j, w) {
            int tmp = 0;
            if (s[i][j] == '#') continue;
            vector<vector<int> > maze(h, vector<int>(w, 1e7));
            maze[i][j] = 0;
            queue<pair<int, int> > q;
            q.push(make_pair(i, j));
            while (!q.empty()) {
                int x, y;
                x = q.front().first, y = q.front().second;
                q.pop();
                rep (k, 4) {
                    int nx, ny;
                    nx = x + dx[k], ny = y + dy[k];
                    if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                    if (s[nx][ny] == '#') continue;
                    if (maze[nx][ny] != 1e7) continue;
                    maze[nx][ny] = maze[x][y] + 1;
                    tmp = max(tmp, maze[nx][ny]);
                    q.push(make_pair(nx, ny));
                }
            }
            res = max(res, tmp);
        }
    }
    cout << res << endl;
    
    return 0;
}



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

namespace modulo {
    using ll = long long;
    const ll MOD = 1000000007;
 
    ll add(ll a) { return a; }
    ll mul(ll a) { return a; }
    ll mod(ll a) { return (a % MOD) + (a < 0) * MOD; }
    ll inv(ll a, const ll m = MOD) { return (a > 1 ? m - inv(m % a, a) * m / a : 1); }
 
    template<typename... Args>
    ll add(ll a, Args... args) { return (a += add(args...)) >= MOD ? (a -= MOD) : a; }
    template<typename... Args>
    ll mul(ll a, Args... args) { return a * mul(args...) % MOD; }
 
    ll sub(ll a, ll b) { return (a -= b) < 0 ? (a += MOD) : a; }
    ll div(ll a, ll b) { return mul(a, inv(b)); }
    ll pow(ll a, ll n, ll r = 1) {
        if (n < 0) n = -n, a = inv(a);
        while (n) {
            if (n & 1) r = mul(r, a);
            n >>= 1LL, a = mul(a, a);
        }
        return r;
    }
}

std::array<std::array<int, 2020>, 2020> c;

int choice(int k, int n) {
    if (k > n || c[k][n])
        return c[k][n];
    if (k == n || k == 0)
        c[k][n] = 1;
    else if (k == 1)
        c[k][n] = n;
    else
        c[k][n] = modulo::add(choice(k - 1, n - 1), choice(k, n - 1));
    return c[k][n];
}

int solve(int s) {
    if (s < 3)
        return 0;

    int ans = 0;
    for (int i = 1; i <= s / 3; i++)
        ans = modulo::add(ans, choice(i - 1, s - 2 * i - 1));

    return ans;
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);

    int s;
    std::cin >> s;

    std::cout << solve(s);
}

Measured memory_bytes: 8240
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

struct Segment {
    int s, t, x;
};

const int N = 2e5 + 2;

int n, q;
vector<Segment> a;
int ans[N];

int main()
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    cin >> n >> q;
    for (int i = 0; i < n; ++i) {
        int s, t, x;
        cin >> s >> t >> x;
        s -= x, t -= x;
        a.push_back({s, t, x});
    }
    for (int i = 0; i < q; ++i) {
        int d;
        cin >> d;
        a.push_back({d, i, -1});
    }

    sort(a.begin(), a.end(), [](const Segment& p, const Segment& q) {
        return p.s < q.s || (p.s == q.s && p.x > q.x);
    });
    auto compx = [](const Segment& p, const Segment& q) {
        return p.x > q.x;
    };

    priority_queue<Segment, vector<Segment>, decltype(compx)> pq(compx);
    for (const auto& ev : a)
        if (ev.x != -1) {
            pq.push(ev);
        }
        else {
            while (!pq.empty() && pq.top().t <= ev.s) pq.pop();
            ans[ev.t] = (pq.empty() ? -1 : pq.top().x);
        }

    for (int i = 0; i < q; ++i) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 12524
function Main(s){
  var a = [0];
  var c = [0];
  var q = [0];
  var l = s.length;
  for(var i = 1; i <= l; i++){
    if(s[i-1] === "?"){a[i] = a[i-1]; c[i] = c[i-1]; q[i] = q[i-1] + 1;}
    else if(s[i-1] === "A"){a[i] = a[i-1] + 1; c[i] = c[i-1]; q[i] = q[i-1];}
    else if(s[i-1] === "C"){a[i] = a[i-1]; c[i] = c[i-1] + 1; q[i] = q[i-1];}
    else {a[i] = a[i-1]; c[i] = c[i-1]; q[i] = q[i-1];}
  }
  var ans = 0;
  for(var i = 2; i < l; i++){
    if(s[i-1] !== "B" && s[i-1] !== "?")continue;
    ans += abmod(a[i-1], c[l]-c[i], powmod(3,q[i-1]), powmod(3,q[l]-q[i]));
    ans += abmod(q[i-1], c[l]-c[i], powmod(3,q[i-1]-1), powmod(3,q[l]-q[i]));
    ans += abmod(a[i-1], q[l]-q[i], powmod(3,q[i-1]), powmod(3,q[l]-q[i]-1));
    ans += abmod(q[i-1], q[l]-q[i], powmod(3,q[i-1]-1), powmod(3,q[l]-q[i]-1));
    ans %= mod
  }
  console.log(ans);
}
var mod = 1e9 + 7;
function abmod(){var a=arguments,r=a[0],i=1;for(;i<a.length;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i++])%mod;return r;}
function powmod(a,n){var r=1;while(n>0){if(n&1)r=abmod(a,r);a=abmod(a,a);n>>=1;}return r;}

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

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  string s;
  cin >> s;
  bool seen[26] = {};
  for(const auto& c : s)
  {
    seen[c - 'a'] = true;
  }
  for(int i = 0; i < 26; ++i)
  {
    if (!seen[i])
    {
      cout << (char)(i + 'a');
      return;
    }
  }
  cout << "None";
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3740
r, c = map(int, input().split())

tableA = []
resultC = []

for i in range(r):
    tableA.append(list(map(int, input().split())))

for index_column in range(c):
    sumC = 0
    for index_row in range(r):
        sumC = sumC + tableA[index_row][index_column]
    resultC.append(sumC)

tableA.append(resultC)


for j in range(len(tableA)):
    tableA[j].append(sum(tableA[j]))

for i in tableA:
    print(*i, sep=" ")


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

#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n,ans=1;
string s;
signed main(){
    cin>>n>>s;
    rep(i,n-1){
        if(s[i]!=s[i+1])ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
# coding: utf-8
# Your code here!
from operator import mul
from functools import reduce

def cmb(n, r):
	if n < r:
		return 0
	r = min(n - r, r)
	if r == 0:
		return 1
	numer = reduce(mul, range(n, n - r, -1))
	denom = reduce(mul, range(1, r + 1))
	return numer // denom % INF

N,K = map(int,input().split())
INF = 10**9 + 7
for i in range(1,K+1):
    print(cmb(K-1, i-1) * cmb(N-K+1, i) % INF)

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

int main()
{
  int N;
  cin >> N;
  int c[4] = {0};
  for (int i = 0; i < N; i++)
  {
    string s;
    cin >> s;
    if (s == "AC")
      c[0]++;
    if (s == "WA")
      c[1]++;
    if (s == "TLE")
      c[2]++;
    if (s == "RE")
      c[3]++;
  }
  cout << "AC x " << c[0] << '\n';
  cout << "WA x " << c[1] << '\n';
  cout << "TLE x " << c[2] << '\n';
  cout << "RE x " << c[3] << '\n';
}

Measured memory_bytes: 3636
#include <stdio.h>
struct dice{
    int d[6], tmp[6];
};
struct dice dice1;
struct dice dice2;
struct dice dice3[110];
void copy1(int a){
    int i;
    for (i=0;i<6;i++){
        dice3[a].d[i]=dice2.d[i];
        dice3[a].tmp[i]=dice2.tmp[i];
    }
}
void copy2(int a){
    int i;
    for (i=0;i<6;i++){
        dice2.d[i]=dice3[a].d[i];
        dice2.tmp[i]=dice3[a].tmp[i];
    }
}
void init1(int n[6]){
    int i;
    for (i=0;i<6;i++){
        dice1.d[i]=n[i];
    }
}
void init2(int n[6]){
    int i;
    for (i=0;i<6;i++){
        dice2.d[i]=n[i];
    }
}
void throwdice(char c){
    int i;
    for(i=0;i<6;i++){
        dice1.tmp[i]=dice1.d[i];
    }
    if(c=='N'){
        dice1.d[0]=dice1.tmp[1];
        dice1.d[1]=dice1.tmp[5];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[0];
        dice1.d[5]=dice1.tmp[4];
    }
    else if(c=='E'){
        dice1.d[0]=dice1.tmp[3];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[0];
        dice1.d[3]=dice1.tmp[5];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[2];
    }
    else if(c=='W'){
        dice1.d[0]=dice1.tmp[2];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[5];
        dice1.d[3]=dice1.tmp[0];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[3];
    }
    else if(c=='S'){
        dice1.d[0]=dice1.tmp[4];
        dice1.d[1]=dice1.tmp[0];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[5];
        dice1.d[5]=dice1.tmp[1];
    }
    else if(c=='R'){
        dice1.d[0]=dice1.tmp[0];
        dice1.d[1]=dice1.tmp[3];
        dice1.d[2]=dice1.tmp[1];
        dice1.d[3]=dice1.tmp[4];
        dice1.d[4]=dice1.tmp[2];
        dice1.d[5]=dice1.tmp[5];
    }
}
int compare(){
    int i;
    for(i=0;i<6;i++){
        if(dice1.d[i]!=dice2.d[i]){
            return 0;
        }
    }
    return 1;
}
int main()
{
    int n[6];
    int m;
    int i,j,k,l;
    int ok=0;
    scanf("%d",&m);
    for(i=0;i<6;i++){
        scanf("%d",&n[i]);
    }
    init2(n);
    copy1(0);
    for(i=0;i<m-1;i++){
        for(j=0;j<6;j++){
            scanf("%d",&n[j]);
        }
        init1(n);
        for(j=0;j<i+1;j++){
            copy2(j);
            for(k=0;k<4;k++){
                for(l=0;l<4;l++){
                    throwdice('N');
                    throwdice('E');
                    throwdice('S');
                    if(compare()) ok=1;
                }
                throwdice('N');    
            }
            throwdice('E');
            for(k=0;k<2;k++){
                for(l=0;l<4;l++){
                    throwdice('N');
                    throwdice('E');
                    throwdice('S');
                    if(compare()) ok=1;
                }
                throwdice('W');    
                throwdice('W');    
            }
        }
        copy1(i+1);
    }
    if(!ok) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=1;i<=n;i++)
using namespace std;
map<vector<int>,vector<int> > mp;
bool vis[100010];
string s[100010];
int main(){
	int n;
	cin>>n;
	REP(i,n)cin>>s[i];
	REP(i,n){
		vector<int> cnt(26);
		REP(j,s[i].size()){
			cnt[s[i][j]-'a']++;
		}
		mp[cnt].push_back(i);
	}
	long long ans=0;
	REP(i,n){
		vector<int> cnt(26);
		REP(j,s[i].size()){
			cnt[s[i][j]-'a']++;
		}
		if(!vis[i]&&mp[cnt].size()!=1){
			REP(j,mp[cnt].size()){
				vis[mp[cnt][j]]=true;
			}
			ans+=mp[cnt].size()*(mp[cnt].size()-1)/2;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 30848
n, k, q = map(int,input().split())
di = {i:0 for i in range(1,n+1)}

for i in range(q):
  di[int(input())]+=1
  
giri_ans = q-k
  
for i in range(1,n+1):
  if di[i]>giri_ans:
    print('Yes')
  else:
    print('No')
      
  

Measured memory_bytes: 19404
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
vector<double> x;
vector<double> y;
double calcdist(vector<int> dist) {
    double res = 0;
    REP(i, dist.size() - 1) {
        int cur = dist[i];
        int ne = dist[i + 1];
        double diff = sqrt((x[ne] - x[cur]) * (x[ne] - x[cur]) +
                           (y[ne] - y[cur]) * (y[ne] - y[cur]));
        res += diff;
    }
    return res;
}
int main() {
    int N;
    cin >> N;
    //全探査
    // permutation
    x.resize(N);
    y.resize(N);
    REP(i, N) { cin >> x[i] >> y[i]; }
    vector<int> v;
    REP(i, N) { v.push_back(i); }
    double ans = 0;
    do {
        ans += calcdist(v);
    } while(std::next_permutation(v.begin(), v.end()));
    ll div = 1;
    for(int i = 1; i <= N; i++) {
        div *= i;
    }
    std::cout << std::fixed;
    cout << setprecision(10) << ans / (double)div << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;
int main() {
    int N; cin >> N;
    int x[N],y[N];
    for (int i=0; i<N; i++) {
        cin >> x[i] >> y[i];
    }
 
    vector<int> v(N);
    vector<double> d;
    iota(v.begin(), v.end(), 0);
    int cnt = 0;
    do {
        for (int i=0; i<N-1; i++) {
            int xx = (x[v[i]] - x[v[i+1]]) * (x[v[i]] - x[v[i+1]]);
            int yy = (y[v[i]] - y[v[i+1]]) * (y[v[i]] - y[v[i+1]]);
            d.push_back(sqrt(xx + yy));
        }
        cnt++;
    } while( next_permutation(v.begin(), v.end()) );
 
    double ans = 0.0;
    for (auto x : d) {
        ans += x;
    }
    cout << fixed << ans/cnt << endl;
    return 0;
}


Measured memory_bytes: 6512
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;

	if (a == b) {
		cout << "EQUAL" << endl;
	} else if (a.size() > b.size()) {
		cout << "GREATER" << endl;
	} else if (a.size() < b.size()) {
		cout << "LESS" << endl;
	} else {
		for (int i = 0; i < a.size(); i++) {
			if (a[i] > b[i]) {
				cout << "GREATER" << endl;
				break;
			} else if (a[i] < b[i]) {
				cout << "LESS" << endl;
				break;
			} else {
				continue;
			}
		}
		
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int a,b,c,d,e,f,k,n,m,x,y,z;
	long[] ans;
	String[] S;
	long num = 100000;

	Main(){
		// 整数の入力
		n = sc.nextInt();
		ans = new long[n];

		for(int i=0;i<n;i++){
			ans[i]=i+sc.nextLong()*num;
		}

		Arrays.sort(ans);

		// 出力
		for(long l:ans){
			System.out.println(l%num+1);
		}
	}

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

Measured memory_bytes: 63368
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    ll temp=1;
    REP(i,n){
        cin>> a[i];
    }
    REP(i,n){
         if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    REP(i,n){
       
        if(log10(temp)+log10(a[i]) > 18){
            cout << -1 << endl;
            return 0;
        }
        temp*=a[i];
    }
    if(temp>1000000000000000000){
        cout << -1 << endl;
    }else{
        cout << temp << endl;
    }
    return 0;
}

Measured memory_bytes: 4104
import math
from functools import reduce




a, b, x = map(int, input().split())
total = a * a * b
def get_vol(vals, x, y):
    return vals * 2.0 / (x * y)

if x == total:
    print(0.0)
elif x > total // 2:
    h = get_vol(total - x, a, a)
    angle = math.degrees(math.atan( h * 1.0 / a))
    print(angle)
else:
    h = get_vol(x, b, b)
    angle = math.degrees(math.atan(h * 1.0/ a))
    print(90 - angle)

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

#define int long long

template <typename T> 
struct WeightedUnionFind{	
  int n;
  T d;
  vector<int> r,p;
  vector<T> ws;
  WeightedUnionFind(){}
  WeightedUnionFind(int sz,T d_):
    n(sz),d(d_),r(n,1),p(n),ws(n,d){iota(p.begin(),p.end(),0);}
  int find(int x){
    if(x==p[x]){
      return x;
    }else{
      int t=find(p[x]);
      ws[x]+=ws[p[x]];
      return p[x]=t;
    }
  }
  T weight(int x){
    find(x);
    return ws[x];
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y,T w){
    w+=weight(x);
    w-=weight(y);
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y),w=-w;
    r[x]+=r[y];
    p[y]=x;
    ws[y]=w;
  }
  T diff(int x,int y){
    return weight(y)-weight(x);
  }
};

signed main() {
	int n, m;
	while ( cin >> n >> m, n ) {
	
		WeightedUnionFind<int> uf(n, 0);
		for ( int i = 0; i < m; i++ ) {
			char c;
			cin >> c;
			int a, b;
			cin >> a >> b;
			a--; b--;
			if ( c == '!' ) {
				int c;
				cin >> c;
				uf.unite(a, b, c);
			} else {
				if ( !uf.same(a, b) ) cout << "UNKNOWN" << endl;
				else cout << uf.diff(a, b) << endl;			
			}
		}
	}
	
}



Measured memory_bytes: 5200
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	vector<int> t(n + 1);
	vector<pair<int, int>> p(n + 1);
	rep(i,n){
		cin >> t[i + 1] >> p[i + 1].first >> p[i + 1].second;
	}
	t[0] = 0;
	p[0] = make_pair(0,0);

	range(i,1,n + 1){
		int sum = abs(p[i].first - p[i - 1].first) + abs(p[i].second - p[i - 1].second);
		if(sum > t[i] - t[i - 1]){
			cout << "No" << endl;
			return 0;
		}else if((t[i] - t[i - 1] - sum) % 2 == 1){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 1408
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n=sc.nextInt();
        int d[]=new int[11];
        for (int i = 0; i < 3; i++) {
			d[sc.nextInt()]++;
		}
        for (int i = 0; i < d.length; i++) {
			if(d[i]==2)ret("Yes");
		}

        out.println("No");
     	out.flush();
    }
   
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}


class P implements Comparable<P>{
    int p,h,f; long m;
    P(int p,int h, int f, long m) {
    	this.p=p;
    	this.h=h;
    	this.f=f;
    	this.m=m;
    }

    public int compareTo(P p){
    	if(this.p==p.p) {
    		if(this.f==-1) return 1;
    		return -1;
    	}
        return this.p-p.p;
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;

int main()
{
	string S, T;
	cin >> S >> T;
	for (int k = 0; k < 2; k++) {
		for (int i = 0; i < 26; i++) {
			char c = 'A';
			for (int j = 0; j < T.size(); j++) {
				if (T[j] == 'a' + i) {
					if (c == 'A') c = S[j];
					else if (c != S[j]) {
						cout << "No" << endl;
						return 0;
					}
				}
			}
		}
		swap(S, T);
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 776
S=int(input())
ans=[0]*(S+1)
MOD=10**9+7

if S<=2:
    print(0)
    exit(0)
elif S==3:
    print(1)
    exit(0)   
ans[3]=1
for i in range(4,S+1):
    ans[i]=ans[i-1]+ans[i-3]

print(ans[i]%MOD)

Measured memory_bytes: 9180
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N;
  cin>>N;
  for(int a=1;a<=9;a++){
    for(int b=1;b<=9;b++){
    if(a*b==N){
      cout<<"Yes"<<endl;
      return 0;
    }
    
    }
  }
      cout<<"No"<<endl;
  
}
  

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

const int MOD = 1e9+7;

int main() {
    int N; cin >> N;
    ll ans = 1;
    FOR(i,1,N+1) {
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,in;
	cin>>n;
	vl v;
	rep(i,n){
		cin>>in;
		if(in==0){
			cin>>in;
			v.push_back(in);
		}
		else if(in==1){
			cin>>in;
			cout<<v[in]<<"\n";
		}
		else v.pop_back();
	}
}




Measured memory_bytes: 4972
// --------------
// Tejas Pandey  |
// 13 - 09 - 20  |
// Atcoder BC 178|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

ll mpow(ll a, ll b){
	ll res = 1;
	while(b){
		if(b&1) res *= a,res %= mod;
		a *= a;
		a %= mod;
		b >>= 1;
	}
	return res;
}
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin >> n;
  if(n == 1) cout << "0\n";
  else{
	ll ans = mpow(10,n);
	ans -= (2*mpow(9,n))%mod;
	while(ans < 0) ans += mod;
	ans += mpow(8,n);
	ans %= mod;
	cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 3648
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
	int n;
	string s;
	cin >> n >> s;

	REP(i,SIZE(s)){
		s[i] = (s[i]-'A'+n)%26 + 'A';
	}
	cout << s << endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

// N 個の要素を含む 0-オリジンの配列 A
int bubbleSort(vector<int> &A, int N) {
  bool flag = true; // 逆の隣接要素が存在する

  int i = 0;

  while (flag) {
    flag = false;

    for (int j = 1; j < N; j++) {
      if (A.at(j) < A.at(j - 1)) {
        swap(A.at(j), A.at(j - 1));
        flag = true;
        i++;
      }
    }
  }

  return i;
}

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

  vector<int> A(N);

  for (int i = 0; i < N; i++) cin >> A.at(i);

  int ans = bubbleSort(A, N);

  for (int i = 0; i < N; i++) {
    if (i != N - 1) {
      cout << A.at(i) << " ";
    } else {
      cout << A.at(i) << endl;
    }
  }

  cout << ans << endl;
}



Measured memory_bytes: 3120
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  int N, M;
  cin >> N >> M;
  VS A(N), B(M);
  REP(i, N) {
    cin >> A[i];
  }
  REP(i, M) {
    cin >> B[i];
  }

  REP(x, N - M + 1) {
    REP(y, N - M + 1) {
      bool flag = true;

      REP(i, M) {
        REP(j, M) {
          if (A[j + y][i + x] != B[j][i]) {
            flag = false;
          }
        }
      }
      if (flag) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256