akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!
line1 = int(input())
cards = [[False for i in range(13)]for j in range(4)]
pattern = ["S","H","C","D"]
for i in range(line1):
    date = input().split()
    ch = date[0]
    rank = int(date[1])
    cards[pattern.index(ch)][rank-1] = True

for i in range (4):
    for j in range(13):
        if cards[i][j]==False:
            print(pattern[i],j+1)


Measured memory_bytes: 5608
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

char c[6][6];

bool judge(bool *patternH, bool *patternW, int H, int W, int K) {
    int cnt = 0;
    for(int i = 0; i < H; i++) {
        if(patternH[i]) {
            continue;
        }
        for(int j = 0; j < W; j++) {
            if(patternW[j]) {
                continue;
            }
            if(c[i][j] == '#') {
                cnt++;
            }
        }
    }

    return cnt == K;
}

int main() {
    int H, W, K;

    cin >> H >> W >> K;

    for(int y = 0; y < H; y++) {
        for(int x = 0; x < W; x++) {
            cin >> c[y][x];
        }
    }

    bool patternH[(int)pow(2, H)][H];
    for(int bit = 0; bit < (1 << H); bit++) {
        for(int i = 0 ; i < H; i++) {
            patternH[bit][i] = bit & (1<<i);
        }
    }

    bool patternW[(int)pow(2, W)][W];
    for(int bit = 0; bit < (1 << W); bit++) {
        for(int i = 0 ; i < W; i++) {
            patternW[bit][i] = bit & (1<<i);
        }
    }

    int ans = 0;
    for(int i = 0; i < pow(2, H); i++) {
        for(int j = 0; j < pow(2, W); j++) {
            if(judge(patternH[i], patternW[j], H, W, K)) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4044
#include<stdio.h>
void swap(int *x, int *y) {
	int temp;    // 値を一時保存する変数

	temp = *x;
	*x = *y;
	*y = temp;
}

/* pushdouwn操作 */
void pushdown(int array[], int first, int last) {
	int parent = first;   // 親
	int child = 2 * parent;   // 左の子
	while (child <= last) {
		if ((child < last) && (array[child] < array[child + 1])) {
			child++;   // 右の子の方が大きいとき、右の子を比較対象に設定
		}
		if (array[child] <= array[parent]) { break; }   // ヒープ済み
		swap(&array[child], &array[parent]);
		parent = child;
		child = 2 * parent;
	}
}

/* ヒープソート */
void heap_sort(int array[], int array_size) {
	int i;

	for (i = array_size / 2; i >= 1; i--) {
		pushdown(array, i, array_size);   // 全体をヒープ化
	}
	for (i = array_size; i >= 2; i--) {
		swap(&array[1], &array[i]);   // 最大のものを最後に
		pushdown(array, 1, i - 1);   // ヒープ再構築
	}
}
int main(void) {
	int n, i, j;
	float tmp, a[n - 1];
	scanf("%d", &n);

	for (i = 1; i<n+1; i++) {
		scanf("%f", &a[i]);
	}

	heap_sort(a, n);

	tmp = (a[1] + a[2]) / 2;
	for (j = 3; j<n+1; j++) {
		tmp = (tmp + a[j]) / 2;
	}

	printf("%f", tmp);
	return 0;
}

Measured memory_bytes: 128
import numpy as np
c1j = np.array(list(map(int, input().split())))
c2j = np.array(list(map(int, input().split())))
c3j = np.array(list(map(int, input().split())))
grids = np.vstack([c1j, c2j, c3j])
ci1 = grids[:,0]
ci2 = grids[:,1]
ci3 = grids[:,2]
if len(set(c1j - c2j)) == 1 and len(set(c2j - c3j)) == 1 and len(set(c3j-c1j)) \
        and len(set(ci1 - ci2)) == 1 and len(set(ci2 - ci3)) == 1 and len(set(ci3 - ci1)) == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 101010;
char s[maxn];
int sum[maxn];
int main(void) {
    int n,q; scanf("%d%d",&n,&q);
    scanf("%s",s+1);
    for (int i=1;i<=n;i++) {
        sum[i]=sum[i-1]+(s[i]=='A' && s[i+1]=='C');
    }
    for (int i=0;i<q;i++) {
        int l,r; scanf("%d%d",&l,&r);
        ll ans=sum[r-1]-sum[l-1];
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 1280
/* created   : 2019-09-04 00:48:16
 * accepted  : 2019-09-04 00:50:36
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int j = i;
    while (i + 1 < n && a[i] >= a[i + 1]) {
      i++;
    }
    ans = max(ans, i - j);
  }
  cout << ans << '\n';
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> a(N+1, 0);
    for (int i = 1; i <= N; i++) cin >> a[i];

    int M = 0;
    vector<int> b(N+1, 0);
    for (int i = N; i > 0; i--) {
        int boxnum = N/i;
        int ball = 0;
        for (int j = i; j <= N; j += i) {
            ball += b[j];
        }

        if (ball % 2 == 0 && a[i] == 0) b[i] = 0;
        else if (ball % 2 == 0 && a[i] == 1) b[i] = 1;
        else if (ball % 2 != 0 && a[i] == 0) b[i] = 1;
        else if (ball % 2 != 0 && a[i] == 1) b[i] = 0;

        M += b[i];
    }

    cout << M << endl;
    for (int i = 1; i <= N; i++) {
        if (b[i] == 1) cout << i << " ";
    }
    cout << endl;




}


Measured memory_bytes: 2432
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
int n,l,q;
int a[maxn];
LL dp[maxn][40];
int main() {
    while (~scanf("%d",&n)) {
        memset(a,0,sizeof(a));
        memset(dp,0,sizeof(dp));
        for (int i=1;i<=n;i++) scanf("%d",&a[i]);
        scanf("%d%d",&l,&q);
        for (int i=1;i<=n;i++) {
            int ix=upper_bound(a+1,a+1+n,a[i]+l)-a-1;
            if (a[i]+l>=a[n]) dp[i][0]=n;
            else dp[i][0]=ix;
        }
        for (int i=1;i<=30;i++)
            for (int j=1;j<=n;j++) 
                dp[j][i]=dp[dp[j][i-1]][i-1];

        int x,y;
        LL ans;
        for (int i=1;i<=q;i++) {
            scanf("%d%d",&x,&y);
            ans=0;
            if (x>y) swap(x,y);
            for (int i=30;i>=0;i--) {
                if (dp[x][i]<y) {
                    ans+=((LL)1<<i);
                    x=dp[x][i];
                }
            }
            printf("%lld\n", ans+1);
        }
    }
    return 0;
}


Measured memory_bytes: 32384
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, n;
	int ans = 0;
	int ans2 = 0;
	
	cin>>N;
	
	n = N;
	

	
	for(int i = 1; i*i <= N; i++){
		int a = N/i, b = N%i;
		
		if(a == b){
			ans2 += i;
		}
		if(i == a-1) break;
		if(a-1 > 1 && N/(a-1) == N%(a-1)){
			ans2 += a-1;
		}
	}
	
	// cout<<ans<<endl;
	cout<<ans2<<endl;
	
	return 0;
}

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

typedef long long ll;
typedef long double ld;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define rev_all( x ) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;
const int mod = 1e9 + 7;
const int inf = 1e12 + 5;
const long double PI = 3.141592653589793;

void solve(){
  string s;
  cin >> s;
  int sum = 0;
  for(char c:s){
    sum += (c-'0');
  }
  cout << (sum%9 == 0 ? "Yes" : "No") << endl;
  return;
}
signed main(){
  fast;
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/28  Problem: ABC 109 D / Link: http://abc109.contest.atcoder.jp/tasks/abc109_d  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

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

	LL H, W; cin >> H >> W;
	vector<vector<LL>> a(H, vector<LL>(W));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> a[i][j];
		}
	}
	using tp = tuple<int, int, int, int>;
	vector<tp>ans;
	FOR(i, 0, H) {
		if (i % 2 == 0) {
			FOR(j, 0, W) {
				if (j == W - 1) {
					if (i == H - 1)continue;
					if (a[i][j] % 2) {
						a[i + 1][j]++;
						ans.push_back(tp(i, j, i + 1, j));
					}
				}
				else {
					if (a[i][j] % 2) {
						a[i][j + 1]++;
						ans.push_back(tp(i, j, i, j + 1));
					}

				}
			}
		}
		else {
			FORR(j, W - 1, 0 - 1) {
				if (j == 0) {
					if (i == H - 1)continue;
					if (a[i][j] % 2) {
						a[i + 1][j]++;
						ans.push_back(tp(i, j, i + 1, j));
					}
				}
				else {
					if (a[i][j] % 2) {
						a[i][j - 1]++;
						ans.push_back(tp(i, j, i, j - 1));
					}

				}
			}

		}
	}
	cout << SZ(ans) << endl;
	for (auto it : ans) {
		int b, c, d, e;
		tie(b, c, d, e) = it;
		b++, c++, d++, e++;
		cout << b << " " << c << " " << d << " " << e << endl;
	}

	return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    int a;
    rep(i,m){
        cin >> a;
        n -= a;
    }
    if(n >= 0){
        cout << n << endl;
    }else{
        cout << "-1" << endl;
    }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
vector<int> prime;
//ll dp[102][101][100] = {};
int dfs(int idx, int num){
    if(num > 75 || prime.size() == idx)return 0;
    if(num == 75){
        return 1;
    }
    int cnt = 0;
    rep(i,1,prime[idx]+2){
        cnt += dfs(idx+1, num * i);
    }
    return cnt;
}
main(){
    int N;
    cin >> N;
    
    int cnt[101] = {};
    rep(i,1,N+1){
        int num = i;
        for(int j = 2;num != 1;j++){
            if(num % j == 0){
                cnt[j]++;
                num /= j;
                j = 1;
            }
        }
        cnt[num]++;
    }
    rep(i,2,100)if(cnt[i])prime.push_back(cnt[i]);
    //for(auto i:prime)cout << i << " ";cout << endl;
    cout << dfs(0,1) << endl;
 
}

Measured memory_bytes: 256
import java.util.Scanner;
  
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int n = sc.nextInt();
    for(int i = 0; i < n; i++){
      String stroutput = "";
      String meirei = sc.next();
      if(meirei.equals("print")){
        int a = sc.nextInt();
        int b = sc.nextInt();
        for(int x = a; x <= b; x++){
          char c = str.charAt(x);
          stroutput += c;
        }
      	System.out.println(stroutput);
      }else if(meirei.equals("reverse")){
        int a = sc.nextInt();
        int b = sc.nextInt();
        for(int x = 0; x < a; x++){
          char c = str.charAt(x);
          stroutput += c;
        }
        for(int x = b; x >= a; x--){
          char c = str.charAt(x);
          stroutput += c;
        }
        for(int x = b+1; x < str.length(); x++){
          char c = str.charAt(x);
          stroutput += c;
        }
        str = stroutput;
      }else{
        int a = sc.nextInt();
        int b = sc.nextInt();
        String p = sc.next();
        for(int x = 0; x < a; x++){
          char c = str.charAt(x);
          stroutput += c;
        }
        for(int x = 0; x <= b-a; x++){
          char c = p.charAt(x);
          stroutput += c;
        }
        for(int x = b+1; x < str.length(); x++){
          char c = str.charAt(x);
          stroutput += c;
        }
        str = stroutput;
      }
    }
  }
}


Measured memory_bytes: 142440
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M;cin>>N>>M;
    int array[N]={0};
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
      array[a-1]++;
      array[b-1]++;
    }
    bool ans=1;
    for(int i=0;i<N-1;i++){
        if(array[i]%2)ans=0;
    }

    if(ans)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n, cnt = 0;
  string s;
  cin >> n >> s;
  REP(i, 10) {
    REP(j, 10) {
      REP(k, 10) {
        int step = 1;
        REP(l, n) {
          if(step == 1 && i == (int)(s[l] - '0')) {
            step = 2;
            continue;
          }
          if(step == 2 && j == (int)(s[l] - '0')) {
            step = 3;
            continue;
          }
          if(step == 3 && k == (int)(s[l] - '0')) {
            cnt++;
            break;
          }
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


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

#define smax(a, b) a = max(a, b)
#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 1000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

ll dp[101][100001];
int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, w;
    cin >> n >> w;
    ll wt[n], v[n];

    for (int i = 0; i < n; i++)
        cin >> wt[i] >> v[i];

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= w; j++) {
            dp[i][j] = dp[i - 1][j];
            if (wt[i - 1] <= j)
                smax(dp[i][j], dp[i - 1][j - wt[i - 1]] + v[i - 1]);
        }
    }

    cout << dp[n][w];

    return 0;
}


Measured memory_bytes: 78464
#include <stdio.h>
#define A 100001

int partition(int a[],int b,int c){
  int x,i,t,j;
  x=a[c];
  i=b-1;

  for(j=b;j<c;j++){
    if(a[j]<=x){
      i++;
      t=a[i];
      a[i]=a[j];
      a[j]=t;
    }
  }
  t=a[i+1];
  a[i+1]=a[c];
  a[c]=t; 
  return i+1;

}

int main(){
  int i,n,b[A],x;

  scanf("%d",&n);

  for(i=0;i<n;i++)scanf("%d",&b[i]);

  x=partition(b,0,n-1);

  for(i=0;i<n;i++){
    if(i==x)printf("[%d]",b[i]);
    else printf("%d",b[i]);
    if(i<n-1)printf(" ");

  }
  printf("\n");


  return 0;
}



Measured memory_bytes: 2156
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
vector<int> positions;

long long bit[200010];
long long N, D, A;

void add(int a, long long w){
  for(int x = a; x <= N + 1; x += x & -x){
    bit[x] += w;
  }
}

long long sum(int a){
  long long ret = 0;
  for(int x = a; x > 0; x -= x & -x){
    ret += bit[x];
  }
  return ret;
}

int idx(long long position, vector<pair<long long, long long>>& enemies){
  return lower_bound(enemies.begin(), enemies.end(), make_pair(position, 0LL)) - enemies.begin();
}

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

  vector<pair<long long, long long>> enemies(N);
  for(int i = 0; i < N; i++){
    long long x, h;
    cin >> x >> h;
    enemies[i] = make_pair(x, h);
  }
  sort(enemies.begin(), enemies.end());

  long long ans = 0;
  for(int i = 0; i < N; i++){
    long long x = enemies[i].first, h = enemies[i].second;

    //long long bomb_power = query(i) * A;
    long long bomb_power = sum(i + 1) * A;
    if(bomb_power < h){
      int bomb_area_end_idx = idx(x + 2 * D + 1, enemies); // lower_bound
      long long added = (h - bomb_power + A - 1) / A;
      //add(added, i, bomb_area_end_idx); // add to [i: bomb_area_end_idx)
      add(i + 1, added);
      add(bomb_area_end_idx + 1, -added);
      ans += added;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include<stdio.h>
int main(void)
{
    int a,b,c;
	scanf("%d %d",&a,&b);
	c=a+b;
	if(c%3==0||a%3==0||b%3==0) printf("Possible\n");
	else printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;
using ll = long long;

int main() {
	
	string s, t;

	cin >> s >> t;

	cout << t + s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x;
    cin>>x;
    if(x%7==1) cout<<"fri"<<endl;
     if(x%7==2) cout<<"sat"<<endl;
      if(x%7==3) cout<<"sun"<<endl;
       if(x%7==4) cout<<"mon"<<endl;
        if(x%7==5) cout<<"tue"<<endl;
         if(x%7==6) cout<<"wed"<<endl;
          if(x%7==7) cout<<"thu"<<endl;
           if(x%7==0) cout<<"thu"<<endl;
return 0;
}
 


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
void fast(){
cin.tie(0);
cin.sync_with_stdio(0);
}
int main()
{
   string s;
   cin>>s;long long k;cin>>k;
   if(s.size()==1)
        cout<<s;
   else if(s[0]=='1')
       {
           for(long long  i=0;i<k;i++)
   {
       if(s[i]!='1'){cout<<s[i];return 0;};
   }
    cout<<'1';
       }
    else
    cout<<s[0];
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main()
{
    string S;
    cin >> S;
    if(S.at(0)==S.at(1) || S.at(1)==S.at(2) || S.at(2)==S.at(3)) cout << "Bad" << endl;
    else cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

#import
#import math
#import numpy as np
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N

for i in range(1, N):
    if i == 1:
        dp[i] = abs(H[i] - H[i - 1])
    
    else:
        dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))

print(dp[-1])



Measured memory_bytes: 84908
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 10;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    vector<int> prime(MAX_N, 1);
    prime[0] = prime[1] = 0;
    for(int i = 2; i * i < MAX_N; i++)
    {
        for(int j = 2 * i; j < MAX_N; j += i) prime[j] = 0;
    }
    while(cin >> n, n)
    {
        for(int i = n; i >= 0; i--)
        {
            if(prime[i] and prime[i - 2])
            {
                cout << i - 2 << " " << i << endl;
                break;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define REP(i,n) for(LL i=0;i<(LL)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<LL,LL>
#define pll pair<LL,LL>

using namespace std;

int main(){

    string s;cin>>s;
    LL n=s.size();
    LL isOdd[n+1];
    fill_n(isOdd,n+1,0);

    LL dp[n+1];
    fill_n(dp,n+1,1000000);
    dp[0]=0;

    map<LL,LL> bLLoid;
    LL vec[n+1];
    fill_n(vec,n+1,-1);
    vec[0]=0;
    bLLoid[0]=0;

    LL nid = 1;

    REP(i,n){
        LL c = s[i]-'a';
        isOdd[i+1]=(isOdd[i]^(1<<c));
        REP(j,26){
            LL k = isOdd[i+1]^(1<<j);
            if(bLLoid.find(k)==bLLoid.end()){
                dp[i+1]=min(dp[i+1],dp[i]+1);
                continue;
            }
            LL id = bLLoid[k];
            //for(LL v : vec[id])dp[i+1]=min(dp[i+1],dp[v]+1);
            dp[i+1]=min(dp[i+1],dp[vec[id]]+1);
        }
        if(bLLoid.find(isOdd[i+1])!=bLLoid.end()){
            LL id = bLLoid[isOdd[i+1]];
            if(dp[i+1]<dp[vec[id]]+1){
                vec[id]=i+1;
            }else{
                dp[i+1]=dp[vec[id]]+1;
            }
        }

        if(bLLoid.find(isOdd[i+1])==bLLoid.end()){
            bLLoid[isOdd[i+1]]=nid++;
        }
        if(vec[bLLoid[isOdd[i+1]]]<0)vec[bLLoid[isOdd[i+1]]]=(i+1);

    }

    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 17668
#include<iostream>
#include<algorithm>
using namespace std;
int x[1001], n, m; char c;
void _a() {
	for (int i = 1; i <= n; i++) {
		if (x[i] == 0) { x[i] = 1; return; }
	}
}
void _b() {
	for (int i = n; i >= 1; i--) {
		if (x[i] == 0 && x[i - 1] != 1 && x[i + 1] != 1) {
			x[i] = 2; return;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (x[i] == 0) { x[i] = 2; return; }
	}
}
void _c() {
	for (int i = 1; i <= n; i++) {
		if (x[i] >= 1) {
			if (x[i + 1] == 0 && i < n) { x[i + 1] = 3; return; }
			if (x[i - 1] == 0 && i >= 2) { x[i - 1] = 3; return; }
		}
	}
	if (n % 2 == 0) { x[(n / 2) + 1] = 3; }
	else { x[(n + 1) / 2] = 3; }
}
void _d(int p) {
	int dist[1000];
	for (int i = 0; i < 1000; i++) { dist[i] = 10000000; }
	if (p == 0) { x[1] = 4; return; }
	for (int i = 1; i <= n; i++) {
		if (x[i] == 0) { continue; }
		for (int j = 1; j <= n; j++) {
			int D = i - j;
			if (D < 0) { D = -D; }
			dist[j] = min(dist[j], D);
		}
	}
	int maxn = 0, maxid = 0;
	for (int i = 1; i <= n; i++) {
		if (maxn < dist[i]) { maxn = dist[i]; maxid = i; }
	}
	x[maxid] = 4;
}
int main() {
	while (true) {
		cin >> n >> m; if (n == 0 && m == 0) { break; }
		for (int i = 1; i <= 1000; i++) { x[i] = 0; }
		for (int i = 0; i < m; i++) {
			cin >> c;
			int d = c - 'A' + 1;
			if (d == 1) { _a(); }
			if (d == 2) { _b(); }
			if (d == 3) { _c(); }
			if (d == 4) { _d(i); }
		}
		for (int i = 1; i <= n; i++) {
			if (x[i] == 0) { cout << '#'; }
			if (x[i] == 1) { cout << 'A'; }
			if (x[i] == 2) { cout << 'B'; }
			if (x[i] == 3) { cout << 'C'; }
			if (x[i] == 4) { cout << 'D'; }
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(){
int a,s,h,m,mm,aa;
scanf("%d",&s);
h=s/3600;
mm=s-h*3600;
m=mm/60;
aa=mm-m*60;
a=s-h*3600-m*60;
printf("%d:%d:%d\n",h,m,a);
return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main() {
    std::string s, t; std::cin >> s >> t;
    s += 'A';
    t += 'B';

    std::vector<std::vector<int>> dp(s.size() + 1, std::vector<int>(t.size() + 1, 0));
    for(int i = 0; i < s.size(); i++) {
        for(int j = 0; j < t.size(); j++) {
            if(s[i] == t[j]) {
                dp[i + 1][j + 1] = std::max(dp[i + 1][j + 1], dp[i][j] + 1);
            }
            dp[i + 1][j] = std::max(dp[i + 1][j], dp[i][j]);
            dp[i][j + 1] = std::max(dp[i][j + 1], dp[i][j]);
        }
    }
    
    std::string ans = "";
    int x = s.size() - 1, y = t.size() - 1;
    while(x + y) {
        if(x and dp[x - 1][y] == dp[x][y]) {
            x--;
        } else if(y and dp[x][y - 1] == dp[x][y]) {
            y--;
        } else {
            x--; y--;
            ans += s[x];
        }
    }
    
    reverse(begin(ans), end(ans));
    printf("%s\n", ans.c_str());
    return 0;
}


Measured memory_bytes: 35584
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
import itertools
import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

N = iIn()
XY = iInLD(N)

lst = list(itertools.permutations(range(N)))

ssum = 0
for i in range(len(lst)):
    for j in range(1,N):
        pre_x = XY[lst[i][j-1]][0]
        pre_y = XY[lst[i][j-1]][1]
        post_x = XY[lst[i][j]][0]
        post_y = XY[lst[i][j]][1]
        ssum += ((post_x - pre_x)**2 + (post_y - pre_y)**2)**0.5

ans = ssum / len(lst) * 1.0
print(ans)

Measured memory_bytes: 80772
#include<bits/stdc++.h>
using namespace std;
long long int dp[1000055]; long long int a[1000055];
int main()
{
    long long int t,i,n,j,k,mini,x;
        cin>>n>>k;
        for(j=1;j<=n;j++)
            cin>>a[j];
        dp[1]=0;
        for(i=2;i<=k;i++)
        {
            dp[i]=abs(a[i]-a[1]);
        }
        for(j=k+1;j<=n;j++)
        {
            mini=999999999;
            for(i=1;i<=k;i++)
            {
                x=dp[j-i]+abs(a[j-i]-a[j]);
                if(mini>x)
                    mini=x;
            }
            dp[j]=mini;
        }
        cout<<dp[n]<<endl;
    return 0;
}


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

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

    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    s[k-1] = tolower(s[k-1]);

    cout << s << "\n";

    return 0;
}

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

int main(){
    int n,t;
    cin >> n >> t;
    int ans=0;
    vector<int> time(n);
    for(int i=0; i<n; i++){
        cin >> time[i];
    }

    for(int i=0; i<n-1; i++){
        ans += min(t, time[i+1]-time[i]);
    }
    ans += t;
    cout << ans << endl;    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio
    ll a[5],k;
    rep(i,0,4)cin>>a[i];cin>>k;
    if(a[4]-a[0]>k)cout<<":("<<endl;
    else cout<<"Yay!"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
char str[55];
int mx[26];
int cnt[26];
int main(){
    scanf("%d",&n);
    for(int i=0;i<26;i++)mx[i]=1e9;
    while(n--){
        scanf(" %s",str);
        for(int i=0;i<26;i++)cnt[i]=0;
        for(int i=0;str[i];i++)cnt[str[i]-'a']++;
        for(int i=0;i<26;i++)mx[i]=min(mx[i],cnt[i]);
    }
    string ans;
    for(int i=0;i<26;i++){
        for(int j=0;j<mx[i];j++)ans+=i+'a';
    }
    printf("%s\n",ans.c_str());
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


// 二項係数nCk mod pの計算-------------------------------------
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  COMinit();
  int N,K; cin >>N >>K;
  int L = N-K; // 赤いボールの数
  // 連続して並ぶ青いボールが何グループあるか
  for (int i=1; i<=K; i++){
    // 青いボールのグループの間に最低1つずつは赤ボールを置く必要がある
    int l = L - (i-1);
    // 間に置く赤ボールが足りないなら不可能で0
    if (l < 0){ cout <<0 <<endl; continue; }

    // 青いボールについても各グループに最低1つは置かないとダメ
    int k = K - i;

    // 赤いボールはl個をi+1グループに0個以上置く必要がある
    // i個の仕切りとl個のボールを並べると考える
    // (l+i) C i = (L+1) C i通り
    
    // 青いボールはk個をiグループに0個以上置く必要がある
    // i-1個の仕切りとk個のボールを並べると考える
    // (k+i-1) C k = (K-1) C k 通り
    ll res = COM(L+1, i) * COM(K-1, k) % MOD;
    cout <<res <<endl;
  }
}

Measured memory_bytes: 12160
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	fastio();
	int n;
	cin >> n;
	if (n < 1200)
	{
		cout << "ABC";
		return 0;
	}
	if (n < 2800)
	{
		cout << "ARC";
		return 0;
	}
	cout << "AGC";
	system("pause");
}

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

int H, W;

int main() {
  while(1){
    cin >> H >> W;
    if(H == 0 && W == 0) break;
    for(int i = 0; i < H; i++){
      for (int j = 0; j < W; j++) {
        if(i == 0 || i == H-1 || j == 0 || j == W-1){
          cout << "#";
        }else{
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3088
#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;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    rep(i, N) cin >> p.at(i);

    sort(p.begin(), p.end());

    int ans = 0;
    rep(i, K) {
        ans += p.at(i);
    }

    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  for(int i = 0 ; i < N ; i++) {
    string s;
    cin >> s;
      if(s == "Y") {
        cout << "Four" << endl;
        break;
      }
      else {
        if(i >= N-1)
          cout << "Three" << endl;
      }  
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>

using namespace std;
using ll = long long;



int main() {
	ll N;
	string str;
	cin >> N;
	cin >> str;
	ll ans = 0;
	ll count = 0;
	for (size_t i = 0; i < N; i++)
	{
		count = 0;
		for (char c = 'a'; c <= 'z'; c++)
		{
			bool right = false, left = false;
			for (ll j = 0; j < i; j++)
			{
				if (str[j] == c) right = true;
			}
			for (ll j = i; j < N; j++)
			{
				if (str[j] == c) left = true;
			}
			if (right && left) count++;
		}
		ans = max(count, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
const int INF=INT_MAX;


int main(){
  ll n,t,ans=0;cin>>n>>t;
  vll T(n);
  rep(i,0,n){
    cin>>T[i];
  }
  rep(i,0,n-1){
    ans+=min(t,T[i+1]-T[i]);
  }
  cout<<ans+t<<endl;
}

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

typedef long long ll;
static const int MAX_N = 1 << 17;

struct StarrySky {
	int datm[2 * MAX_N], data[2 * MAX_N], n;
	StarrySky() {}
	StarrySky(int n_) { init(n_); }

	void init(int n_) {
		n = 1;
		while (n<n_) n *= 2;
		for (int i = 0; i<n * 2; i++) datm[i] = data[i] = 0;
	}

	void add(int a, int b, int x, int k, int l, int r) {
		if (r <= a || b <= l) return;
		if (a <= l && r <= b) {
			data[k] += x;
			return;
		}
		add(a, b, x, k * 2 + 1, l, (l + r) / 2);
		add(a, b, x, k * 2 + 2, (l + r) / 2, r);
		datm[k] = max(datm[k * 2 + 1] + data[k * 2 + 1], datm[k * 2 + 2] + data[k * 2 + 2]);
	}

	int get(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return datm[k] + data[k];
		int vl = get(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = get(a, b, k * 2 + 2, (l + r) / 2, r);
		return max(vl, vr) + data[k];
	}

	void add(int a, int b, int x) {
		add(a, b, x, 0, 0, n);
	}

	int get(int a, int b) {
		return get(a, b, 0, 0, n);
	}

};

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

	StarrySky ss(n);

	for (int i = 0; i < q; i++) {
		int c, s, t, x;
		cin >> c;
		if (c) {
			cin >> x;
			cout << ss.get(x - 1, x) << endl;
		}
		else {
			cin >> s >> t >> x;
			ss.add(s - 1, t, x);
		}
	}
	return 0;
}


Measured memory_bytes: 5164
A, B, C, X, Y = map(int, input().split())
ans = 0
mxy = min(X, Y)
if 2*C <= A + B:
    ans += 2*C * mxy
else:
    ans += (A+B) * mxy
X -= mxy
Y -= mxy
if X == 0:
    if 2*C <= B:
        ans += 2*C * Y
    else:
        ans += B * Y
elif Y == 0:
    if 2*C <= A:
        ans += 2*C * X
    else:
        ans += A * X
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

int dp[1003][10003];
char arr[10003][10003]={0};

int main(){
    int h, w;
    cin>>h>>w;


    //int dp[h+1][w+1]={0};

    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin>>arr[i][j];
        }
    }

    for(int i=0; i<=h; i++){
        for(int j=0; j<=w; j++){

            if(i==0 or j==0){
                dp[i][j]=0;
            }
            else{
                if(arr[i][j]=='.'){
                    dp[i][j]=(dp[i-1][j] + dp[i][j-1])%mod;
                }
                if(i==1 and j==1) dp[i][j]=1;
            }
        }
    }

    cout<<dp[h][w];
    /*for(int i=0; i<=h; i++){
        for(int j=0; j<=w; j++){
            cout<<dp[i][j]<<"  ";
        }
        cout<<"\n";
    }*/

    return 0;
}


Measured memory_bytes: 48768
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

vector<vector<pint>> to;
vector<int> cl;

void dfs(int u, int col=-1, int p = -1) {
    int k = 1;
    for(auto v : to[u]) {
        int ve = v.second, ed = v.first;
        if (ve == p) continue;
        if (k == col) k++;
        cl[ed] = k; k++;
        dfs(ve, cl[ed], u);
    }
}

int main()
{
    int n;
    cin >> n;
    to.resize(n);
    cl.resize(n-1);
    rep(i,n-1) {
        int a,b ;
        cin >> a >> b; a--; b--;
        to[a].emplace_back(i, b);
        to[b].emplace_back(i, a);
    }
    dfs(0);
    int numc = 0;
    rep(i,n) numc = max(numc, int(to[i].size()));
    cout << numc << "\n";
    rep(i,n-1) cout << cl[i] << "\n";
    return 0;
}


Measured memory_bytes: 8320
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>

inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch > '9' || ch < '0') { if(ch == '-') f = -1; ch = getchar(); }
    do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
    return x * f;
}

int main() {
    int n = read();
    if(n % 10 == 7 || n / 10 % 10 == 7 || n / 100 == 7) std::puts("Yes");
    else std::puts("No");
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){    
    ll X;
    cin>>X;
    int ans=0;
    ll cash=100;
    while(cash<X){
        cash=floor((double)cash*1.01);
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

vector<int> sieve(int n) {
  vector<int> p(n);
  REP(i,2,n) p[i]=i;
  for(int i=2; i*i<n; i++) {
    if(p[i]) {
      for(int j=i*i; j<n; j+=i) p[j]=0;
    }
  }
  p.erase(remove(all(p),0),p.end());
  return p;
}

int main() {
  vector<int> p=sieve(2000000);
  int n;
  while(cin >> n && n) {
    int i=0;
    while(p[i]<n) i++;    if(p[i]==n) pr(0);
    else pr(p[i]-p[i-1]);
  }
  return 0;
}


Measured memory_bytes: 8724
a, b, k = map(int, input().split())
def doit(a, b, k):
    for i in range(max(a, b), 0, -1):
        if a % i == 0 and b % i == 0:
            k -= 1
            if k == 0:
                return i
print(doit(a, b, k))

Measured memory_bytes: 2940
D=[1<<99]*K=gets.to_i
D[1]=1
q=[1]
while !q.empty?
	n=q.shift
	[[n*10%K,0,:unshift],[(n+1)%K,1,:<<]].each{|e,d,m|
		if D[e]>D[n]+d
			D[e]=D[n]+d
			q.send(m,e)
		end
	}
end
p D[0]

Measured memory_bytes: 3144
n=int(input())
a=list(map(int,input().split()))
m=0
mi=1
ans=[0 for i in range(n+1)]
for i,z in enumerate(a,1):
    if(abs(z)>abs(m)):
        m=z
        mi=i
if(m>=0):
    ans[1]=[mi,1]
    for i in range(2,n+1):
        ans[i]=[i-1,i]
else:
    ans[1]=[mi,n]
    for i in range(2,n+1):
        ans[i]=[n-i+2,n+1-i]
print(2*n)
for i in ans[1:]:
    print(i[0],i[1])
    print(i[0],i[1])

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

int main(){
        int n;
        scanf("%d", &n);
        char fie[n][n];
        for(int i=0; i<n; i++) scanf("%s", fie[i]);

        int ans = 0;
        for(int i=0; i<n; i++){
                int cnt = 0;
                for(int j=0; j<n; j++){
                        for(int k=j; k<n; k++){
                                if(fie[j][(i+k)%n]!=fie[k][(i+j)%n]) break;
                                cnt++;
                        }
                }
                if(cnt==n*(n+1)/2) ans++;
        }
        printf("%d\n", ans*n);
        return 0;
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := new(big.Int)
	b := new(big.Int)
	fmt.Sscan(getNextString(scanner), a)
	fmt.Sscan(getNextString(scanner), b)
	fmt.Fprintln(writer, a.Mul(a, b))
}



Measured memory_bytes: 1300