akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int a, b, c;
	int na, nb, nc, nd;
	
	na = nb = nc = nd = 0;
	while (1){
		scanf("%d %d %d", &a, &b, &c);
		if (a < b) swap(a, b); if (a < c) swap(a, c);
		if (a >= b + c) break;
		
		na++;
		if (b * b + c * c == a * a) nc++;
		else if (b * b + c * c < a * a) nd++;
		else nb++;
	}
	printf("%d %d %d %d\n", na, nc, nb, nd);
	
	return (0);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  string s;cin>>s;
  int a[n+1];
  int g=0,h;
  vector<int>b={1,1,2,2};
  vector<int>c={1,2,1,2};
  for(int j=0;j<4;j++){
    a[0]=b.at(j);a[1]=c.at(j);
    if(a[0]==1){
        if(a[1]==1){
          if(s[0]=='o'){
            h=1;
          }
          else{
            h=2;
          }
        }
        else{
          if(s[0]=='o'){
            h=2;
          }
          else{
            h=1;
          }
        }
      }
      else{
        if(a[1]==1){
          if(s[0]=='o'){
            h=2;
          }
          else{
            h=1;
          }
        }
        else{
          if(s[0]=='o'){
            h=1;
          }
          else{
            h=2;
          }
        }
      }
    
    for(int i=1;i<n;i++){
      if(a[i]==1){
        if(a[i-1]==1){
          if(s[i]=='o'){
            a[i+1]=1;
          }
          else{
            a[i+1]=2;
          }
        }
        else{
          if(s[i]=='o'){
            a[i+1]=2;
          }
          else{
            a[i+1]=1;
          }
        }
      }
      else{
        if(a[i-1]==1){
          if(s[i]=='o'){
            a[i+1]=2;
          }
          else{
            a[i+1]=1;
          }
        }
        else{
          if(s[i]=='o'){
            a[i+1]=1;
          }
          else{
            a[i+1]=2;
          }
        }
      }
    }
    if(a[n]==a[0]&&h==a[n-1]){
      g=1;
      break;
    }
  }
  if(g==1){
    for(int i=0;i<n;i++){
      if(a[i]==1) cout<<"S";
      else cout<<"W";
    }
  }
  else if(g==0)
    cout<<-1<<endl;
}
    

Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main() {
    long long x;
    cin>>x;
    if(x>=400&&x<=599)
    {
        cout<<8;
    }else if(x>=600&&x<=799)
    {
        cout<<7;
    }
    else if(x>=800&&x<=999)
    {
        cout<<6;
    }
    else if(x>=1000&&x<=1199)
    {
        cout<<5;
    }
    else if(x>=1200&&x<=1399)
    {
        cout<<4;
    }else if(x>=1400&&x<=1599)
    {
        cout<<3;
    }else if(x>=1600&&x<=1799)
    {
        cout<<2;
    } else
        cout<<1;

}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int n,w;long long weight[101],value[101];
long long dp[101][100001];
long long dpe(int i,int remw)
{
    if(i==n)return 0;

long long &ret=dp[i][remw];
  if(~ret)return ret;

 ret=dpe(i+1,remw);
  if(remw>=weight[i])
      ret=max(ret,value[i]+dpe(i+1,remw-weight[i]));

  return ret;
}



int main()
{

  cin>>n>>w;
memset(dp,-1,sizeof(dp));
for(int i=0;i<n;i++)
    cin>>weight[i]>>value[i];

cout<<dpe(0,w)<<endl;

    return 0;
}

Measured memory_bytes: 82540
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(ll i = 0; i < (ll )(n); i++)
#define repi(i,a,b) for(ll i=ll (a);i<ll (b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

int  main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin>>n;
  vector<ll >res2(n+1),res3(n+1),a(n),b(n),c(n),sum(n+2);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n)cin>>c[i];
  sort(all(a));
  sort(all(b));
  sort(all(c));
  rep(i,n)
  {
    res2[i+1]=lower_bound(all(a),b[i])-a.begin();
  }
  rep(i,n+1)sum[i+1]=sum[i]+res2[i];
  ll res=0;
  rep(i,n)
  {
    ll id=lower_bound(all(b),c[i])-b.begin();
    //cout<<i<<" "<<id<<" "<<sum[id+1]<<endl;
    res3[i+1]=sum[id+1];
    res+=sum[id+1];
  }
//  rep(i,n+1)cout<<res3[i]<<endl;
  cout<<res<<endl;



  return 0;

}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
    int s, w;
    cin >> s >> w;
    if (w >= s) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(){
	int W;
	int H;
	int x;
	int y;
	int r;
	cin >> W >> H >> x >> y >> r;
	if (r<=x&&x<=W-r&&r<=y&&y<=H-r){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

vector<ll> tmp;
ll fpow(ll a,ll b){
  ll ret = 1,t = a;
  while(b){
    if(b&1) ret=((ret%MOD)*(t%MOD))%MOD;
    t=(t%MOD)*(t%MOD);
    b>>=1;
  }
  return ret;
}
ll fac(ll n){
  ll ret = 1;
  REP1(i,n) ret=(ret*i)%MOD;
  return ret;
}
ll inv(ll n){
  return fpow(n,MOD-2);
}
ll C(ll n,ll m){
  return (((fac(n)*inv(fac(m)))%MOD)*inv(fac(n-m)))%MOD;
}
int main(){
  IOS();
  ll n,m;
  cin>>n>>m;
  for(ll i=1;i<=sqrt(m);i++){
    if( m%i==0 ){
      tmp.eb(i);
      if( m/i!=i ) tmp.eb(m/i);
    }
  }
  sort(ALL(tmp));
  debug(tmp);
  ll ans = 1;
  for(ll i=2;i<MAXn;i++){
    ll ct=0;
    while( m%i==0 ) m/=i,ct++;
    if( ct ) ans = (ans*C(n+ct-1,n-1))%MOD;
  }
  if( m!=1 ) ans = (ans*C(n,n-1))%MOD;
  cout<<ans<<endl;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int naive(string S)
{
    int N = S.size();
    set<string> ss;

    for (int i=0; i<=N; i++) {
        for (int j=i; j<=N; j++) {
            reverse(S.begin() + i, S.begin() + j);
            ss.insert(S);
            // cerr << S << " " << i << " " << j << endl;
            reverse(S.begin() + i, S.begin() + j);
        }
    }

    /*
    cerr << ss.size() << endl;
    for (auto s : ss) {
        cerr << s << endl;
    }
    */
    return ss.size();
}

int main()
{
    ios::sync_with_stdio(false);

    string S;
    cin >> S;
    map<char, ll> cnt;
    ll N = S.size();

    for (auto c : S) {
        cnt[c]++;
    }

    ll dup = 0;
    for (auto p : cnt) {
        dup += p.second * (p.second-1) / 2;
    }

    // DUMP(dup);
    ll ans = N * (N + 1) / 2 - dup - N + 1;
    cout << ans << endl;

    // int naive_ans = naive(S);
    // assert(naive_ans == ans);
}

Measured memory_bytes: 720
#include <stdio.h>
#include <math.h>
#define MAX 500000 
int N,L[MAX],R[MAX],A[MAX],count=0,i;

void merge(int A[],int left,int mid,int right){
  int n1,n2,j,k;
  n1 = mid - left;
  n2 = right - mid;
  for( i = 0 ;i<n1;i++){
    L[i] = A[left + i];
      }
  for (i = 0 ;i<n2;i++){
    R[i] = A[mid + i];
      }
  L[n1] = INFINITY;
  R[n2] = INFINITY;
  i = 0;
  j = 0;
  for (k = left ;k< right;k++){
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
      count++;
    }
    else{ 
      A[k] = R[j];
      j = j + 1;
      count++;
    }
  }
}
void mergeSort(int A[],int left,int right){
  int mid;
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
      }
}
int main(){
      scanf("%d",&N);
      for(i=0;i<N;i++){
	scanf("%d",&A[i]);
      }
      mergeSort(A,0,N);
      for(i=0;i<N;i++){
	if(i!=0)printf(" ");
	printf("%d",A[i]);
      }
      printf("\n");
      printf("%d\n",count);
        return 0;
    }



Measured memory_bytes: 5652
#!/usr/bin/env python3
import sys
import math


def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a%b)

def solve(N: int, A: "List[int]"):
    l = [0] * (N+2)
    r = [0] * (N+2)
    l[1] = A[0]
    r[N] = A[N-1]
    for i in range(2, N+1):
        l[i] = gcd(l[i-1], A[i-1])
    for i in reversed(range(1, N)):
        r[i] = gcd(r[i+1], A[i-1])
    ans = 0
    for i in range(N):
        ans = max(ans, gcd(l[i], r[i+2]))
    print(ans)

    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16824
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+7,mod=1e9+7;
int n,A,B,C,D;
char a[N];
int main()
{
	scanf("%d%d%d%d%d",&n,&A,&B,&C,&D);
	scanf("%s",a+1);
	for(int i=A;i<C;i++)if(a[i]=='#'&&a[i+1]=='#'){puts("No");return 0;}
	for(int i=B;i<D;i++)if(a[i]=='#'&&a[i+1]=='#'){puts("No");return 0;}
	if(C<D)puts("Yes");
	else{
		for(int i=B;i<=D;i++)if(a[i]=='.'&&a[i-1]=='.'&&a[i+1]=='.'){puts("Yes");return 0;}
		puts("No");
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int INF = 114514810;
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A,B;
	cin >> A >> B;
	cout << max({A+B,A-B,A*B}) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int c[10001];

int main()
{
	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int x = 0;
	for(int i = 0; i < n; i++) {
		for (int j = x; j < x + a[i]; j++) {
			c[j] = i + 1;
		}
		x += a[i];
	}
	for (int l = w; l < h * w; l += 2 * w) {
		reverse(c + l, c + l + w);
	}
	for (int i = 0; i < h * w; i++) {
		cout << c[i];
		if ((i + 1) % w) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}
	return 0;
}

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

int main(int argc, char const *argv[])
{
    int a, b, k;
    cin >> a >> b >> k;
    for(int i = min(a,b); 1 <= i; i--){
        if(a % i == 0 && b % i == 0) {
            k--;
        }
        if(k == 0) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);
	    int n = scanner.nextInt();
	    int[] array = new int[n];
	    for(int i=0; i<n; i++) {
	        array[i] = scanner.nextInt();
        }

		int tmp;
	    for(int j=0; j<array.length; j++) {
			if(array[0] < array[j]) {
				tmp = array[0];
				array[0] = array[j];
				array[j] = tmp;
			}
        }
	    int maxVal = array[0];
	    for (int k=0; k<array.length; k++) {
	    	if(array[0] > array[k]) {
	    		array[0] = array[k];
			}
		}
	    int minVal = array[0];
	    System.out.println(maxVal-minVal);
    }
}

Measured memory_bytes: 20692
fn main() {
    let mut pairs = read_vec::<u32>();
    pairs.sort();
    pairs.dedup();

    if pairs.len() == 2 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

Measured memory_bytes: 2072
N, K = map(int, input().split())
As = list(map(int, input().split()))

# 1  : First
# -1 : Second

import pdb

tmp = [0 for _ in range(N)]
tmp_win = [0 for _ in range(N)]
win = [0 for _ in range(K+1)]

flg = 0

# pdb.set_trace()

for stones in range(K+1):
  for i in range(N):
    # 残数stonesの時、先行の操作の結果なり得る残数の場合をすべて求める
    tmp[i] = stones - As[i]
    if tmp[i] == 0:
      # 残数が0になるものがあればその操作を行うことで先行の勝ちが確定
      flg = 1

  if flg == 1:
    # 先行の勝ち
    win[stones] = 1
    flg = 0
    continue

  if max(tmp) < 0:
    # 残数stonesの時からどの操作を行っても残数が負になる場合は後攻の勝ち
    win[stones] = -1
    continue

  # 上記で勝ち負けがわからない場合、
  win[stones] = -1    # 一旦負けで仮置き
  for i in range(N):
    # 次の操作でとりうる個数に対しての勝ち負けを見る
    tmp_win = win[tmp[i]]
    if tmp_win == -1:
      # 次の操作後に残る数で後攻が勝つのであれば、
      # その直前の状態で先行の勝ち筋が存在
      win[stones] = 1
      break

# print(win)
winner = ['', 'First', 'Second']
print(winner[win[K]])
  # if max(tmp) < min(As):
  #   # 残数stonesの時、
  #   win[stones] = 1:
  #   continue





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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};



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

  ll n;
  cin >> n;

  ll ans;
  for(ll i = sqrt(n); i >= 1; i--){
    if(n%i == 0){
      ans = n/i + i - 2;
      break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int a;
	while(cin>>a,a){
		int sum=0;
		rep(i,9){
			int b;cin>>b;
			sum+=b;
		}
		cout<<a-sum<<endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	string s;
    cin >> s;
    int n=s.size();
    int ans=999;
    rep(i,n-2){
        int num=(s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0';
        ans=min(ans,abs(num-753));
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector <string> ans;
string Str,str;

bool check(){
  bool alph[300]={};
  alph['a']=1;
  for(int i=0;i<str.size();i++){
    int flg=0;
    if(!alph[str[i]])flg=alph[str[i]]=1;
    if(str[i]-flg!=Str[i])return 0;
  }
  return 1;
}

bool used['z'];
void saiki(int idx){
  while(used[str[idx]]||str[idx]=='z')idx++;
  
  if(idx==str.size()){
    if(check())ans.push_back(str);
    return;
  }
  
  saiki(idx+1);
  str[idx]++;
  if(!used[str[idx]-1])used[str[idx]-1]=1,saiki(idx+1),used[str[idx]-1]=0;
  str[idx]--;
}

int main(){
  while(1){
    cin>>Str;
    str=Str;
    if(Str=="#")break;
    ans.clear();
    saiki(0);
    sort(ans.begin(),ans.end());

    cout <<ans.size()<<endl;
    if(ans.size()<=10)
      for(int i=0;i<ans.size();i++)cout <<ans[i]<<endl;
    else {
      for(int i=0;i<5;i++)cout<<ans[i]<<endl;
      for(int i=0;i<5;i++)cout<<ans[ans.size()-5+i]<<endl;
    }
  } 
  return 0;
}

Measured memory_bytes: 2352
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    cout << "ABC" + to_string(N) << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int a, b, c;
  	cin >> a >> b >> c;
 	if(a==b && b==c) cout << "No" << endl;
	else if(a!=b && b!=c && c!=a) cout << "No" << endl;
	else  cout << "Yes" << 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>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n;
	cin >> n;
	map<int,int> cnt;
	rep(i,n){
		int a;
		cin >> a;
		cnt[a]++;
	}
	int counts = 0;
	for(auto p : cnt){
		auto k = p.first;
		auto v = p.second;
		if(v%2 == 1) counts++;
	}
	cout << counts << endl;
}

Measured memory_bytes: 8240
def main():
    players = {}
    players['a'] = list(input())
    players['b'] = list(input())
    players['c'] = list(input())

    x = 'a'
    while len(players[x]) > 0:
        x = players[x].pop(0)
    print(x.upper())


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define fi first
#define se second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define sz size()
#define PQ priority_queue
#define len length()
#define mll map<ll,ll>
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define mp(x,y)  make_pair(x,y)
#define pb push_back
#define pf push_front
#define ALL(v) v.begin(),v.end()
#define LAPAK ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

const ll MAX = 1e5 + 5;
vll adj[MAX];
ll in_degree[MAX];
ll dp[MAX];
bool visited[MAX];

void dfs(ll v){
    visited[v] = true;
    for(auto x : adj[v]){
        dp[x] = max(dp[x],dp[v]+1);
        --in_degree[x];
        if(in_degree[x]==0)dfs(x);
    }
}

int main() {
	ll n,m,u,v;
	cin>>n>>m;
	while(m--){
	    cin>>u>>v;
	    u--,v--;
	    ++in_degree[v];
	    adj[u].pb(v);
	}
	For(i,0,n){
	    if(in_degree[i]==0 && !visited[i])dfs(i);
	}
	ll ans = 0;
	For(i,0,n){
	    ans = max(ans,dp[i]);
	    //cout<<dp[i]<<" ";
	}
	cout<<ans;
	
	return 0;
}
 /*           *          *******        *       *     *
             * *            *          * *       *   *
            *****           *         *****       * *
           *     *      *   *        *     *       *
          *       *      * *        *       *      *
*/

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, a[200001], b[200001];

void rf()
{
    ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    cin >> n;
}

void xuli()
{
    for (ll i = 2; i <= n; i++)
    {
        cin >> a[i]; b[a[i]]++;
    }
    for (ll i = 1; i <= n; i++) cout << b[i] << endl;
}

int main()
{
    rf(); xuli();
}



Measured memory_bytes: 6732
#include <stdio.h>
 
using namespace std;
 
int main(){
    char str[20001];
    int m,tmp,length;
    while(true){
        scanf("%s",str);
        if(str[0] == '-') break;
        length = 0;
        for(int k = 0; str[k] != '\0';k++) length++;
        scanf("%d",&m);
        int index = 0;
        for(int i = 0; i < m; i++){
            scanf("%d",&tmp);
            for(int j = 0; j < tmp; j++){
                str[index+length] = str[index];
                index++;
            }
        }
        for(int p = 0; p < length; p++){
            printf("%c",str[index+p]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 2628
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
bool e[5][5];int a[5];
int main() {
	rep(i,1,3){
		int u,v;read(u);read(v);e[u][v]=e[v][u]=1;
	}
	bool ok=0;
	rep(i,1,4)rep(j,1,4)rep(k,1,4)rep(l,1,4){
		memset(a,0,sizeof(a));
		a[i]++;a[j]++;a[k]++;a[l]++;
		if(a[1]==1&&a[2]==1&&a[3]==1&&a[4]==1){
			ok|=e[i][j]&&e[j][k]&&e[k][l];
		}
	}
	printf("%s",(ok)?"YES":"NO");
	return 0;
}


Measured memory_bytes: 256
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define DEBUG
#undef DEBUG

using ll = long long;

int N, M;
#if 0
int X[100000];
int Y[100000];
#endif
ll NW, NH;
ll W[100000-1];
ll H[100000-1];

ll MOD = 1000000007;

/**
 * 入力はsort/uniq済
 *
 * x方向のみについて、長方形の上辺(下辺)として可能な組み合わせを全て考える。
 * y方向のみについて、長方形の左辺(右辺)として可能な組み合わせを全て考える。
 * 前者を {A_i}, 後者を {B_i} とおく。すると
 *   sum(A) * sum(B)
 * が求める値となる。このことは
 *   (A_1 + A_2 + ... + A_?) * (B_1 + B_2 + ... + B_?)
 * の展開式からわかる。
 *
 * 後は sum(A), sum(B) を計算する。総和内に W[i] が何回出てくるか考える。
 */
void solve()
{
    ll sum_a = 0;
    ll sum_b = 0;

    ll cnt[100000-1]; // 総和内での W[i], H[i] の出現回数

    // sum(A)
    cnt[0] = NW;
    FOR(i, 1, NW/2) {
        cnt[i] = cnt[i-1] + NW - 2*i;
    }
    if(NW%2 == 1) {
        cnt[NW/2] = cnt[NW/2-1] + NW - 2*(NW/2);
    }
    FOR(i, 0, NW/2) {
        cnt[NW-1-i] = cnt[i];
    }
    REP(i, NW) {
        sum_a += (cnt[i] * W[i]) % MOD;
        sum_a %= MOD;
    }
#ifdef DEBUG
    cout << "cnt_w: ";
    REP(i, NW) {
        cout << cnt[i] << " ";
    }
    cout << "\n";

    cout << "cnt_h: ";
    REP(i, NH) {
        cout << cnt[i] << " ";
    }
    cout << "\n";
#endif

    // sum(B)
    cnt[0] = NH;
    FOR(i, 1, NH/2) {
        cnt[i] = cnt[i-1] + NH - 2*i;
    }
    if(NH%2 == 1) {
        cnt[NH/2] = cnt[NH/2-1] + NH - 2*(NH/2);
    }
    FOR(i, 0, NH/2) {
        cnt[NH-1-i] = cnt[i];
    }
    REP(i, NH) {
        sum_b += (cnt[i] * H[i]) % MOD;
        sum_b %= MOD;
    }

    ll ans = (sum_a * sum_b) % MOD;

    cout << ans << "\n";
}

int main()
{
    cin >> N >> M;
    NW = N - 1;
    NH = M - 1;

    ll x_prev, y_prev;
    cin >> x_prev;
    REP(i, NW) {
        ll x;
        cin >> x;
        W[i] = x - x_prev;
        x_prev = x;
    }
    cin >> y_prev;
    REP(i, NH) {
        ll y;
        cin >> y;
        H[i] = y - y_prev;
        y_prev = y;
    }

#ifdef DEBUG
    cout << "W: ";
    REP(i, NW) {
        cout << W[i] << " ";
    }
    cout << "\n";

    cout << "H: ";
    REP(i, NH) {
        cout << H[i] << " ";
    }
    cout << "\n";
#endif

    solve();

    return 0;
}


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

int main(){
    ll n, k, h[2 * 100000];
    cin >> n >> k;
    rep(i, n) cin >> h[i];

    ll ans = 0;

    sort(h, h + n, greater<>());

    rep(i, n) {
        if (i >= k) {
            ans += h[i];
        } 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  string S; cin >> S;
  int K; cin >> K;

  for (int i = 0; i < S.length(); i++){
    if (S[i] != 'a'){
      int A = 'z' - S[i];
      if (K >= A + 1){
        S[i] = 'a';
        K -= A + 1;
      }
    }
  }

  if (K > 0){
    int A = S[S.length() - 1] - 'a' + K;
    A = A % 26;
    S[S.length() - 1] = 'a' + A;
  }
  

  cout << S << endl;
  

  return 0;
}


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

    
int main(){
    
    string s;
    cin >> s;
    int se,hya,zyu,iti,a;
    se=(s.at(0)-'0');
    hya=(s.at(1)-'0');
    zyu=(s.at(2)-'0');
    iti=s.at(3)-'0';
    a=1000*se+100*hya+10*zyu+iti;
    if(a<2019){cout <<"Heisei"<< endl;return 0;}
    if(a>2019){cout <<"TBD"<< endl;return 0;}
    zyu=(s.at(5)-'0');
    iti=s.at(6)-'0';
    a=10*zyu+iti;
    if(a<04){cout <<"Heisei"<< endl;return 0;}
    if(a>04){cout <<"TBD"<< endl;return 0;}
    zyu=(s.at(8)-'0');
    iti=s.at(9)-'0';
    a=10*zyu+iti;
    if(a<=30){cout <<"Heisei"<< endl;return 0;}
    if(a>30){cout <<"TBD"<< endl;return 0;}
    
}


Measured memory_bytes: 256
#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)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    int tmp = N % 10;
    if (tmp == 3) cout << "bon" << endl;
    else if (tmp == 0 || tmp == 1 || tmp == 6 || tmp == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3636
(let* ((s (read))
       (c (read))
       (ans 0))
  (setf ans (if (< s (floor c 2))
                (prog1 s (setf c (- c (* s 2))))
                (prog1 (floor c 2) (setf c 0))))
  (setf ans (+ ans (floor c 4)))
  (princ ans))

Measured memory_bytes: 15456
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        c: chars
    }
    println!("{}", ((c[0] as u8) + 1) as char);
}
/* vim:set foldmethod=marker: */


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

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

  cout << 1 - x << endl;
  return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない


int main(){

    int f[5];
    int mw=-1;
    int l=0;
    int ans=0;
    
    rep(i,5){
        cin >>f[i];
    }
    
    rep(i,5){
        int time=0;
        while(time<f[i]){
            time+=10;
        }
        int dif =time-f[i];
        if(dif>mw){
            mw=dif;
            l=i;
        }
    }
    
    rep(i,5){
        if(i!=l){
            int time=0;
            while(time<f[i]){
                time+=10;
            }
            ans+=time;
        }else{
            ans+=f[i];
        }
    }
    
    cout << ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
  
  int A, B;
  std::cin >> A >> B;
  const int larger = A > B ? A : B;
  const int smaller = A < B ? A : B;
  if(larger - smaller == 0){
    std::cout << larger * 2;
  }
  else{
    std::cout << larger * 2 - 1;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define read(a) scanf("%d", &a)
#define readl(a) scanf("%lld", &a)
#define reads(a) scanf("%s", a)
#define readf(a) scanf("%lf", &a)
#define readc(a) scanf("%c", &a)
#define debug(a, b) printf("%s = %d\n", a, b)
#define debug1(a, i, b) printf("%s[%d] = %d", a, i, b)
#define show(a) putchar(a)
#define pb emplace_back
#define mk make_pair
#define _rand mt19937 RAND(time(0))
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define mem(a) memset(a, 0, sizeof(a))
#define Buff ios::sync_with_stdio(false)
typedef long long ll;
typedef long long LL;
typedef int Int;
typedef double db;
using namespace std;
const int INF = 1e9 + 7;
const int N = 2e5 + 7;
const int M = 5e6 + 7;
signed main()
{
    Buff;
    char a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c) cout << "No\n";
    else    cout << "Yes\n";
    return 0;
}
/**

**/



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

#define rep(i,n) for(long long i=0;i<n;i++)
using namespace std;



int main() {
	

	long long  n;
	cin >> n;

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

	return 0;
}




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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        sort(S[i].begin(), S[i].end());
    }

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

    ll ans = 0;
    ll cnt = 1;
    string now = S[0];
    for (int i = 1; i < N; i++) {
        if (S[i] == S[i - 1]) {
            ++cnt;
        }
        else {
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
            now = S[i];
        }
    }


    if (cnt > 1) {
        ans += cnt * (cnt - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
($a,$b,$c,$d,$e,$f)=split(' ', <>);

for ($suma = 0; $suma <= 30; $suma += $a) {
    for ($sumb = $suma; $sumb <= 30; $sumb += $b) {
        $water{$sumb}++;
    }
}

$e30 = $e*30;

for ($sumc = 0; $sumc <= $e30; $sumc += $c) {
    for ($sumd = $sumc; $sumd <= $e30; $sumd += $d) {
        $suger{$sumd}++;
    }
}

$max = -1;
@water = sort{$a<=>$b}(keys %water);
@suger = sort{$a<=>$b}(keys %suger);
for $w (@water) {
    if ($w == 0) {
        next;
    }

    for $s (@suger) {
        if ($s > $w * $e ) {
            last;
        }
        ($s + $w*100 > $f)and last;
        if ($max < $s*100/$w) {
            $resw = $w;
            $ress = $s;
            $max = $s*100/$w;
        }
    }
}
printf("%d %d\n", $ress+$resw*100, $ress);


Measured memory_bytes: 1280
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

lint LCM(lint a,lint b){
  if(a==0 || b==0) return 0;
  lint tmp,r,x;
  x=a*b;
  if(a<b) tmp=a,a=b,b=tmp;
  r=a%b;
  while(r!=0) a=b,b=r,r=a%b;
  x=x/b;
  return x;
}

lint GCD(lint a,lint b){
  if(a==0 || b==0) return max(a,b);
  else return (a*b)/LCM(a,b);
}

int main(void){
    lint N,K;
    cin >> N >> K;
    lint A[N];
    rep(i,N) cin >> A[i];
    lint gc=A[0];
    rep(i,N-1) gc=GCD(gc,A[i+1]);
    bool ans=false;
    rep(i,N){
        if(A[i]<K) continue;
        if((K-A[i])%gc==0) ans=true;
    }
    if(ans) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<int,int,int> iii;
typedef vector<iii> viii;

#define umap unordered_map
#define uset unordered_set
#define pb push_back
#define LSOne(x) (x & (-x))
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

const int iinf = 1e9+7;
const ll inf = 1e18+7;

const int N = 1007;
char gd[N][N];

void add(int& a, int b) {
    a += b;
    if (a >= iinf) a -= iinf;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int h,w; cin >> h >> w;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            cin >> gd[i][j];
    vector<vi> dp(h, vi(w,0));
    dp[0][0] = 1;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j) {
            for (int r : {i, i + 1}) {
                int c = j;
                if (r == i) ++c;
                if (r < h && c < w && gd[r][c] == '.') {
                    add(dp[r][c],dp[i][j]);
                }
            }
        }
    cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 5248
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
	int n, sum;
	int s[1000];
	double variance, mean;

	while(true){
		cin >> n;
		if (n == 0) break;

		variance = 0;
		sum = 0;
		for (int i = 0; i < n; i++){
			cin >> s[i];
			sum += s[i];
		}
		mean = (double)sum / n;

		for (int j = 0; j < n; j++)
		{
			variance += pow(s[j] - mean, 2);
		}

		cout << fixed << setprecision(5) << sqrt(variance / n) << endl;
	}

	return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define mp make_pair
#define mo 1000000007
#define MAX_N 500004
#define INF 2000000000
 
#define fast_io ios::sync_with_stdio(false)


set<int> st[26];

int main()
{
	int n, q, ty, l, r;
	char c;
	string s;
	cin >> n >> s >> q;
	for(int i = 0; i < n; ++i)
		st[s[i] - 'a'].insert(i);
	for(int i = 1; i <= q; ++i)
	{
		cin >> ty;
		if(ty == 1)
		{
			cin >> l >> c;
			l--;
			st[s[l] - 'a'].erase(l);
			st[c - 'a'].insert(l);
			s[l] = c;
		}  
		else
		{
			cin >> l >> r;
			l--;
			r--;
			int ans = 0;
			for(int i = 0; i < 26; ++i)
				if(st[i].lower_bound(l) != st[i].end() && *st[i].lower_bound(l) <= r)
					ans++;
			cout << ans << endl;
		}

	}



}   

Measured memory_bytes: 24324
#include <stdio.h>
#include <ctype.h>

int main()
{
	char ch;
	
	while(1){
		scanf("%c",&ch);
		if(isupper(ch)){
			ch = tolower(ch);
		}else{
			ch = toupper(ch);
		}
		printf("%c",ch);
		if(ch == '\n'){
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define free __free__
const int MAX = 2010;
const int MOD = 1E9 + 7;

int n, m;
ll x, tree = 0;
vector<pair<int, pii>> edj;
vector<pair<int, pii>> free;
vector<vector<pii>> fo;

int deg2[MAX];

// UF
vi par;

void Init(){
  par.resize(n);
  for(int i = 0;i < n;++i) par[i] = i;
}

int GetPar(int vr){
  return par[vr] == vr ? vr : par[vr] = GetPar(par[vr]);
}

void Merge(int a, int b){
  a = GetPar(a), b = GetPar(b);
  par[a] = b;
}
// </end>

int up[MAX], up_cost[MAX], dpt[MAX];

void Dfs(int vr, int par = -1, int cost = 0, int depth = 0){
  up[vr] = par;
  up_cost[vr] = cost;
  dpt[vr] = depth;

  for(int i = 0;i < sz(fo[vr]);++i)
    if(fo[vr][i].fi != par)
      Dfs(fo[vr][i].fi, vr, fo[vr][i].se, depth + 1);
}

int MaxOnPath(int a, int b){
  int res = 0;
  while(a != b){
    if(dpt[a] < dpt[b]) swap(a, b);
    relaxMax(res, up_cost[a]);
    a = up[a];
  }
  return res;
}

int Count(ll up_cost){
  if(up_cost < tree) return deg2[m];

  int fixed = n - 1, floating = 0;
  for(const auto& e : free){
    int path_max = MaxOnPath(e.se.fi, e.se.se);
    ll val = tree - path_max + e.fi;
    if(val <= up_cost) ++fixed;
    else ++floating;
  }

  return (2 * 1LL * deg2[floating]) % MOD;
}

int main(){
  deg2[0] = 1;
  for(int i = 1;i < MAX;++i)
    deg2[i] = (2 * deg2[i - 1]) % MOD;

  scanf("%d%d", &n, &m);
  scanf("%lld", &x);
  edj.resize(m);
  for(auto& e : edj)
    scanf("%d%d%d", &e.se.fi, &e.se.se, &e.fi),
    --e.se.fi, --e.se.se;

  Init();
  fo.resize(n);
  sort(all(edj));
  for(const auto& e : edj){
    if(GetPar(e.se.fi) == GetPar(e.se.se)){
      free.pb(e);
    } else {
      Merge(e.se.fi, e.se.se);
      fo[e.se.fi].pb(mp(e.se.se, e.fi));
      fo[e.se.se].pb(mp(e.se.fi, e.fi));
      tree += e.fi;
    }
  }

  Dfs(0);

  int ans = Count(x - 1) - Count(x);
  if(ans < 0) ans += MOD;

  printf("%d\n", ans);

  return 0;
}


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

using namespace std;

const int N = 3e5+5;
const int mod = 998244353;

int n;
int k;
long long dp[N];
long long cm[N];
pair < int , int > pp[N];

int main(){
    scanf("%d%d" , &n , &k);
    for(int i = 1; i <= k; i++){
        int l , r;
        scanf("%d%d" , &l , &r);
        pp[i] = {l , r};
    }
    dp[n] = 1;
    cm[n] = 1;
    for(int i = n - 1; i >= 1; i--){
        for(int j = 1; j <= k; j++){
            dp[i] += cm[i + pp[j].first] + mod + mod;
            dp[i] -= cm[i + pp[j].second + 1];
            dp[i] %= mod;
        }
        //cout << dp[i] << " ";
        cm[i] = dp[i] + cm[i + 1];
        cm[i] %= mod;
    }
    printf("%lld\n" , dp[1]);
}


Measured memory_bytes: 6952
#include <iostream>
#include <string>

#define mod 1000000000+7;
typedef long long ll;
using namespace std;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	string s,t; cin >> s >> t;
	int ans{};
	for(int i{}; i<s.size(); i++){
		if(s[i]==t[i]) ++ans;
	}

	cout << ans << "\n";
}

Measured memory_bytes: 3604
## 動画見てアルゴリズムを知った
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;

lis=listA[1]
m=max(lis)
lis0=[0]*(m+1)
for i in lis:
    if lis0[i]!=2: 
        j=1
        while i*j<=m:
            lis0[i*j]+=1
            j+=1
            
count=0
for i in lis:
    if lis0[i]==1: count+=1
print(count)

Measured memory_bytes: 132836
#include<iostream>
#include<cmath>
#include<string>

using namespace std;
int main()
{
    int cnt=0;
    int a,b;
    while(cin >> b){
        if(b==0){
            break;
        }
        if(cnt==0){
            a=b;
        }else{
            a-=b;
        }
        if(cnt==9){
            cnt=0;
            cout << a << endl;
        }else{
            cnt++;
        }
    }
    return 0;
}



Measured memory_bytes: 3104
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    string S;
    
    cin >> S;

    N = S.size();

    if(S.substr(N-1,1)=="1"){
        cout << -1 << endl;
    }else if(S.substr(N-2,1)=="0"){
        cout << -1 << endl;
    }else if(S.substr(0,1)=="0"){
        cout << -1 << endl;
    }else{


        bool flag = false;
        rep(si,(N-1)/2){
            string S1 = S.substr(si,1);
            string S2 = S.substr( (N-1)-si-1 ,1 );
            if(S1 != S2){
                flag = true;
                break;
            }
        }

        if(flag){
            cout << -1 << endl;
        }else{
            ll base_node = 1;
            ll next_node = 2;
            rep(si,S.size()-1){
                
                cout << base_node << " " << next_node << endl;
                stmp = S.substr(si,1);
                if(stmp=="1"){
                    base_node = next_node;
                }
                next_node++;

            }
        }


    }

    

}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

int gcd(int n, int m) {
  return (m == 0? n :gcd(m, n % m));
}

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

  int n, a, b;
  cin >> n >> a >> b;
  if((b - a) % 2) cout << "Borys\n";
  else cout << "Alice\n";
}


Measured memory_bytes: 256