akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};

int N,M;
int a,b;
int h,w,k;
pi s,g;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w>>k;
    cin>>s.first>>s.second>>g.first>>g.second;
    s.first--,s.second--,g.first--,g.second--;
    
    vector<string> M(h);
    vvi dis(h,vi(w,INF));
    rep(i,h){
        cin>>M[i];
    }
    dis[s.first][s.second]=0;
    queue<pi> que;
    que.push(pi(s.first,s.second));
    while (!que.empty()){
        pi p = que.front();
        que.pop();
        int x = p.first,
            y = p.second;
        for(int i = 1;i<=k;i++){
            int nx = x+i;
            if(nx<0||nx>=h)break;
            if(M[nx][y]=='@'||dis[nx][y]<dis[x][y]+1)break;
            if(dis[x][y]+1== dis[nx][y])continue;
            dis[nx][y]=dis[x][y]+1;
            que.push(pi(nx,y));
        }
        for(int i = 1;i<=k;i++){
            int nx = x-i;
            if(nx<0||nx>=h)break;
            if(M[nx][y]=='@'||dis[nx][y]<dis[x][y]+1)break;
            if(dis[x][y]+1== dis[nx][y])continue;
            dis[nx][y]=dis[x][y]+1;
            que.push(pi(nx,y));
        }
        for(int i = 1;i<=k;i++){
            int ny = y+i;
            if(ny<0||ny>=w)break;
            if(M[x][ny]=='@'||dis[x][ny]<dis[x][y]+1)break;
            if(dis[x][y]+1== dis[x][ny])continue;
            dis[x][ny]=dis[x][y]+1;
            que.push(pi(x,ny));
        }
        for(int i = 1;i<=k;i++){
            int ny = y-i;
            if(ny<0||ny>=w)break;
            if(M[x][ny]=='@'||dis[x][ny]<dis[x][y]+1)break;
            if(dis[x][y]+1== dis[x][ny])continue;
            dis[x][ny]=dis[x][y]+1;
            que.push(pi(x,ny));
        }

    }
    if(dis[g.first][g.second]==INF)cout<<"-1"<<endl;
    else cout<<dis[g.first][g.second]<<endl;
    return 0;
}


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

int main(void) {

  int D;
  cin >> D;

  if (D == 25) {
    cout << "Christmas" << endl;
  } else if (D == 24) {
    cout << "Christmas Eve" << endl;
  } else if (D == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else {
    cout << "Christmas Eve Eve Eve" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(ll i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(ll i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

/*二項係数ライブラリ*/
/*
constexpr lint MOD = 1e9 + 7;
vector<lint> fac, facInv, inv;
void facInit(int nmax)
{
    fac = facInv = inv = vector<lint>(nmax + 1, 1);
    for (int i = 2; i <= nmax; i++)
    {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        facInv[i] = facInv[i-1] * inv[i] % MOD;
    }
}
lint nCr(int n, int r)
{
    if (n<r || r<0) return 0;
    if (n >= (int)fac.size()) facInit(n);
    return (fac[n] * facInv[r] % MOD) * facInv[n-r] % MOD;
}
lint nPr(int n, int r)
{
    if (n<r || r<0) return 0;
    if (n >= (int)fac.size()) facInit(n);
    return fac[n] * facInv[n-r] % MOD;
}
lint power(lint x, lint n, lint mod=MOD)
{
    lint ans = 1;
    while (n>0)
    {
        if (n & 1) (ans *= x) %= mod;
        (x *= x) %= mod;
        n >>= 1;
    }
    return ans;
}
lint doublefac(lint n)
{
    if (n < 0) return 0;
    lint k = (n + 1) / 2;
    if (n & 1) return fac[k * 2] * power(facInv[2], k) % MOD * power(fac[k], MOD - 2) % MOD;
    else return fac[k] * power(facInv[2], k) % MOD;
}
*/
int main() {
    ll n;
    vector<bool> a;
    ll dp[2 * 100000]; /*iの倍数のボールの和*/
    
    cin >> n;
    
    bool tmp;
    REP(i, n) {
        cin >> tmp;
        a.emplace_back(tmp);
    }
    
    vector<ll> result;
    IREP(i, n) {
        if (i * 2 >= n) {
            if (a[i] == 0) {
                /* ボールを入れない */
                dp[i] = 0;
            } else {
                /* ボールを入れる */
                dp[i] = 1;
                result.emplace_back(i + 1);
            }
        } else {
            ll cnt = 0;
            for (ll j = i + 1; j < n + 1; j += i + 1) {
                cnt += dp[j - 1];
            }
            if (cnt % 2 == a[i]) {
                /* ボールを入れない */
                dp[i] = 0;
            } else {
                /* ボールを入れる */
                dp[i] = 1;
                result.emplace_back(i + 1);
            }
        }
    }
    
    cout << result.size() << endl;
    REP(i, result.size()) {
        cout << result[i];
        if (i == result.size() - 1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
    
    return 0;
}



Measured memory_bytes: 3736
package main

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

var sc = bufio.NewScanner(os.Stdin)

func contains(target string, list []string) bool {
	for _, r := range list {
		if target == r {
			return true
		}
	}
	return false
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()

	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextF64() float64 {
	sc.Scan()

	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func isInteger(x float64) bool {
	return math.Floor(x) == x
}

func Ave(s []int) int {
	val := 0
	for _, i := range s {
		val += i
	}
	return int(val / len(s))
}
func cal(i int) (sum int) {
	for i != 0 {
		sum += i % 10
		i /= 10
	}
	return
}
func max(a []int) (idx int, val int) {
	max := a[0]
	idx = 0
	for j, i := range a {
		if max < i {
			max = i
			idx = j
		}
	}
	return idx, max
}

func draw(i int, a []int) (l []int) {
	// p = a[i]
	for j := i; j < len(a); j++ {
		if j != len(a)-1 {
			a[j] = a[j+1]
		} else if j == len(a)-1 {
			a = a[:len(a)-1]
		}
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer([]byte{}, math.MaxInt64)
	n := nextInt()
	tax := 1.08
	var out int

	for i := 1; i <= n; i++ {
		if int(float64(i)*tax) == n {
			out = i
		}
	}
	if out != 0 {
		fmt.Println(out)
	} else {
		fmt.Println(":(")
	}

}


Measured memory_bytes: 1772
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
void integrate(vector<vector<int> >& v){
  const int n = v.size(), m = v[0].size();
  FOR(i,0,n) FOR(j,0,m-1) v[i][j+1] += v[i][j]; // ?¨??¶?????????????
  FOR(i,0,n-1) FOR(j,0,m) v[i+1][j] += v[i][j]; // ????¶????????????? - > ????????§2?¬????????´?????????????????????????
}
int main()
{
  int N;
  while(cin>>N) {
    if(N == 0) return 0;
    int W, H; cin >> W >> H;
    vector<vector<int> > tree(H+1, vector<int>(W+1, 0));
    FOR(i,0,N) {
      int y, x; cin >> x >> y;
      tree[y][x] = 1;
    }
    integrate(tree);
    int S, T; cin >> S >> T;
    // ??????
    int ans = 0;
    for(int y = 1; y + T - 1 <= H; y++) {
      for(int x = 1; x + S - 1 <= W; x++) {
        int cnt = tree[y+T-1][x+S-1] - tree[y+T-1][x-1] - tree[y-1][x+S-1] + tree[y-1][x-1];
        ans = max(ans, cnt);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
const int MAX = (5e3)+2;
 
int n, k, ans, a[MAX], ss[MAX];
bitset<MAX> pref[MAX], suff[MAX];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	pref[0][0] = suff[n+1][0] = true;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		pref[i] = pref[i-1] | (pref[i-1] << a[i]);
	}
	for(int i = n; i >= 1; i--) suff[i] = suff[i+1] | (suff[i+1] << a[i]);
	for(int i = 1; i <= n; i++) {
		bool flag = false;
		for(int j = 0; j < k; j++) ss[j+1] = ss[j] + suff[i+1][j];
		for(int j = 0; j < k; j++) flag |= (pref[i-1][j] && ss[k-j] - ss[max(k-j-a[i], 0)]);
		ans += !flag;
	}
	cout << ans;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,T; cin>>n>>T;
  vll t(n); rep(i,n) cin>>t[i];
  ll ans=T;
  rep(i,n-1){
    ans+=min(T, t[i+1]-t[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "YES" : "NO")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

template <class T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using ordered_multiset = tree <T, null_type, less_equal <T>, rb_tree_tag, tree_order_statistics_node_update>;

const int siz = 2e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "1";



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

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    int n, x, t;
    cin >> n >> x >> t;

    if (n % x == 0) {
        cout << (n / x) * t;
    }
    else {
        cout << (n / x + 1) * t;
    }

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
int main(){
  int  N,L,S,total,k;
  int i,j;
  int n[5];
  while(1){
    L = 0;
    S = 0;
    total = 0;
    scanf("%d",&N);
    if(N==0000){
      break;
    }
    while(1){
      if(N == 6174){
	printf("%d\n",total);
	break;
      }
      n[0]=N/1000;
      n[1]=N%1000/100;
      n[2]=N%1000%100/10;
      n[3]=N%1000%100%10;
      if(n[0]==n[1] && n[1] == n[2] && n[2] == n[3]){
	printf("NA\n");
	break;
      }
      for( i = 0 ; i < 4 ; i++ ){
	for( j = 0 ; j+1 < 4 ; j++ ){
	  if(n[j+1] > n[j]){
	    k = n[j];
	    n[j] = n[j+1];
	    n[j+1]= k;
	  }
	}
      }
      S = 1000*n[3]+100*n[2]+10*n[1]+n[0];
      L = 1000*n[0]+100*n[1]+10*n[2]+n[3];
      N = L - S;
      total++;
    }
  }
  return 0;
}

Measured memory_bytes: 608
#include <iostream>

using namespace std;

int main(void){
	char map[52][52];

	int h, w;

	for (int i = 0; i < 51; i++){
		for (int j = 0; j < 51; j++){
			map[i][j] = '.';
		}
	}

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

	int ok = 1;

	for (int i = 1; i < h + 1; i++){
		for (int j = 1; j < w + 1; j++){
			if (map[i][j] == '#'){
				if (map[i-1][j] == '.' && map[i+1][j] == '.' && map[i][j-1] == '.' && map[i][j+1] == '.')
					ok = 0;
			}
		}

	}

	if (ok)
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n, c, k;
    cin >> n >> c >> k;
    vector<i64> t(n);
    for (auto& e : t) cin >> e;
    sort(all(t));

    i64 l = 0, r = 0;
    i64 ans = 0;
    while (r < n) {
        while (r < n && r - l < c && t[r] - t[l] <= k) r++;
        ans++, l = r;
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll x, y;
    cin >> x >> y;

    ll ans = abs(abs(x) - abs(y));
    if (abs(x) > abs(y)) {
        ans += (x > 0) + (y > 0);
    } else {
        ans += (x < 0) + (y < 0);
    }

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

Measured memory_bytes: 256
#include<iostream> 
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define c(a) cout<<a<<" ";
int main(){c("1407 38");int t=2;r(i,38){c(1);r(j,37){c(t);t++;}}r(i,37){r(j,37){c(i+2)r(l,37)cout<<37*l+39+(j+i*l)%37<<" ";}}}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairInt;
typedef tuple<int, int, int> tuple3Int;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

ll pow(ll base, uint exp) {
  if (exp == 0)
    return 1;

  if (exp % 2 == 0) {
    return pow(base * base, exp / 2);
  } else {
    return base * pow(base * base, exp / 2);
  }
}

class SegTree {
private:
  int num;
  int exp;
  int seq;
  vector<pair<int, ll>> vec;

public:
  SegTree(int n) : num(n), seq(0){
    exp = 0;
    int x = 1;
    while (x < n) {
      exp ++;
      x <<= 1;
    }

    vec.resize(2 * pow(2, exp) - 1, make_pair(-1, pow(2, 31) - 1));
  }

  void update(int s, int t, ll x) {
    _update(s, t, x, 0, 0, pow(2, exp) - 1);
    seq ++;
  }

  ll get(int i) {
    return _get(i, 0, 0, pow(2, exp) - 1).second;
  }

private:
  void _update(int s, int t, ll x, int index, int from, int to) {
    if (s <= from && to <= t) {
      vec[index].first = seq;
      vec[index].second = x;
    } else {
      if (s <= (from + to) / 2)
        _update(s, t, x, 2 * index + 1, from, (from + to) / 2);

      if ((from + to) / 2 < t)
        _update(s, t, x, 2 * index + 2, (from + to) / 2 + 1, to);
    }
  }

  pair<int, ll> _get(int i, int index, int from, int to) {
    pair<int, ll> p;
    if (from == to) {
      return vec[index];
    }

    if (i <= (from + to) / 2)
      p = _get(i, 2 * index + 1, from, (from + to) / 2);
    else
      p = _get(i, 2 * index + 2, (from + to) / 2 + 1, to);

    if (p.first < vec[index].first)
      return vec[index];
    else
      return p;
  }

};

int main(int argc, char *argv[])
{
  int n, q;

  scanf("%d%d", &n, &q);

  SegTree st(n);

  FOR(i, q) {
    int a;
    scanf("%d", &a);

    if (a == 0) {
      int s, t, x;
      scanf("%d%d%d", &s, &t, &x);
      st.update(s, t, x);
    } else {
      int b;
      scanf("%d", &b);
      printf("%lld\n", st.get(b));
    }
  }
  
  return 0;
}

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

using namespace std;

void North();
void East();
void West();
void South();
void Right();
void Left();

int up, down, north, south, east, west;
int ans;

int main(){
    string s;
    int n;
    
    while(cin >> n, n){
        ans = 1;
        up = 1, down = 6, north = 5, south = 2, east = 3, west = 4;
        for (int i = 0; i < n; i++){
            cin >> s;

            if (s == "North"){
                North();
            } else if (s == "East"){
                East();
            } else if (s == "West"){
                West();
            } else if (s == "South"){
                South();
            } else if (s == "Right") {
                Right();
            } else if (s == "Left") {
                Left();
            }
            ans += up;
        }
        cout << ans << endl;
    }
}

void North(){
    int temp;
    temp = up;
    up = south;
    south = down;
    down = north;
    north = temp;
}

void East(){
    int temp;
    temp = up;
    up = west;
    west = down;
    down = east;
    east = temp;
}

void West(){
    int temp;
    temp = up;
    up = east;
    east = down;
    down = west;
    west = temp;
}

void South(){
    int temp;
    temp = up;
    up = north;
    north = down;
    down = south;
    south = temp;
}

void Right(){
    int temp;
    temp = south;
    south = east;
    east = north;
    north = west;
    west = temp;
}

void Left(){
    int temp;
    temp = south;
    south = west;
    west = north;
    north = east;
    east = temp;
}

Measured memory_bytes: 3044
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
#define Length 80000
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

bool used[110];

bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
	return a.first * a.first + a.second * a.second > b.first*b.first + b.second * b.second;
}

void solve(int n) {
	vector<pair<int, int>>p(n), q(n);
	for (int i = 0;i < n;i++) {
		cin >> p[i].first >> p[i].second;
	}
	for (int i = 0;i < n;i++) {
		cin >> q[i].first >> q[i].second;
	}
	int dist = Length, flag = 0;
	int ans = 0;
	sort(p.begin(), p.end());
	for (int i = 0;i < n;i++) {
		dist = Length;
		flag = 0;
		for (int j = 0;j < n;j++) {
			if (!used[j]) {
				int x = q[j].first - p[i].first;
				int y = q[j].second - p[i].second;
				if ((x > 0) && (y > 0) && y < dist) {
					dist = y;
					flag = j;
				}
			}
		}
		if (dist < Length) {
			ans++;
			used[flag] = true;
		}
	}
	cout << ans << endl;
}

ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

char board[110][110];
	
int main(void){
	ll n, x, ans = 0;
	cin >> n >> x;
	/*if (n == 2 * x) {
		cout << n + x << endl;
		return 0;
	}
	/*ans = n;
	ll l1 = n - x;
	ll l2 = x;
	bool flag = true;
	while (l2!=0) {
		if (l1%l2 != 0) {
			int num = l1 / l2;
			ans += l2 * num * 2;
			ll d = l1 - l2 * num;
			l1 = l2;
			l2 = d;
		}
		else {
			int num = l1 / l2;
			ans += l2 * (num * 2 - 1);
			ll d = l1 - l2 * num;
			l1 = l2;
			l2 = d;
		}
	}
	cout << ans << endl;*/
	cout << 3 * (n - gcd(n, x)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n,x,t;
int main()
{
	cin>>n>>x>>t;
	int count = 0;
	count = n / x;
	if(n % x != 0) count++;
	printf("%d\n",count * t);
	return 0;
}

Measured memory_bytes: 3716
#include<stdio.h>
int main()
{
	int n,k,i,j,x,y;
	scanf("%d",&n);
	scanf("%d",&k);
	scanf("%d",&x);
	scanf("%d",&y);
	if(n>k)
	{
		i=x*k;
		j=y*(n-k);
		printf("%d\n",i+j);
	}
	else
	{
		i=x*n;
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 128
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		String s = scanString();
		if (s.length() < 26) {
			out.print(s);
			for (char c = 'a';; c++) {
				if (s.indexOf(c) < 0) {
					out.print(c);
					break;
				}
			}
		} else {
			boolean can[] = new boolean[26];
			i: for (int i = 25;; i--) {
				if (i < 0) {
					out.print("-1");
					break;
				}
				for (char c = (char) (s.charAt(i) + 1); c <= 'z'; c++) {
					if (can[c - 'a']) {
						out.print(s.substring(0, i));
						out.print(c);
						break i;
					}
				}
				can[s.charAt(i) - 'a'] = true;
			}
		}
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  int b = 0;
  cin >> a;
  for (int i = 0; i < 4; i++) {
    if (a[i] == '+') {
      b++;
    } else {
      b--;
    }
  }
  cout << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <vector>
#include <algorithm> // sort
#include <map>
using namespace std;

int main(){
    int n;
    cin>>n;
    int s;
    int a;
    for(int i=0;i<n;i++){
        cin>>a;
        s+=a-1;
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H, W;
	int i, j;
	int a[100][100];
	scanf("%d %d", &H, &W);
	for (i = 0; i < H; i++)
	{
		scanf("%s", a[i]);
	}

	for (i = 0; i < (W + 2); i++)
	{
		printf("#");
	}
	printf("\n");

	for (i = 0; i < H; i++)
	{
		printf("#");
		printf("%s", a[i]);
		printf("#\n");
	}

	for (i = 0; i < W + 2; i++)
	{
		printf("#");
	}
	printf("\n");
	return 0;
}


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

int main(){
  int64_t N;
  int64_t Ans=1LL;
  cin >> N;
  for(int64_t i=1LL; i<=N; i++){
    Ans=Ans*i;
    Ans=Ans%(1000000007LL);
  }
  cout << Ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

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

int popcount(int n){
    int res = 0;
    for (int i = 0; i < 32; ++i){
        if (n & (1 << i)) res++;
    }
    return res;
};

int bit_length(int n){
    for (int i = 31; i >= 0; --i){
        if (n & (1 << i)) return i+1;
    }
    return 1;
}

struct SegmentTree{
    int n;
    // cast
    int ide;
    int tree[1600000];
    SegmentTree(int k, int id){
        ide = id;
        n = k;
        if (popcount(n) > 1){
            n = 1 << bit_length(n);
        }
        for (int i = 0; i < 2 * n; ++i){
            tree[i] = ide;
        }
    }
    // rewrite
    int func(int a, int b){
        return a | b;
    };
    void update(int i, int x){
        i += n-1;
        tree[i] = x;
        while (i > 1){
            i /= 2;
            tree[i] = func(tree[2*i], tree[2*i+1]);
        };
    };
    int query(int a, int b, int k, int l, int r){
        if (r <= a || b <= l) return ide;
        if (a <= l && r <= b) return tree[k];

        return func(
            query(a, b, k*2, l, (l+r)/2),
            query(a, b, k*2+1, (l+r)/2, r)
        );
    };
};

int main(){
    int n;
    string s; cin >> n >> s;
    SegmentTree st(n, 0);
    for (int i = 1; i <= n; i++){
        st.update(i, 1 << (int)(s[i-1] - 'a'));
    }
    int q, type, l, r, res;
    char t;
    cin >> q;
    rep(i, q){
        cin >> type >> l;
        if (type == 1){
            cin >> t;
            st.update(l, 1 << (int)(t - 'a'));
        }
        else if (type == 2)
        {
            cin >> r;
            res = st.query(l, r+1, 1, 1, st.n+1);
            cout << popcount(res) << "\n";
        }
        
    }
}

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

int main(){
    string s; cin>>s;
    bool ans = false;
    if (s.at(0) == 'A') {
        if (islower(s.at(1)) and islower(s.at(s.size()-1))) {
            bool upper = false;
            for(int i=2; i<=s.size()-2; i++){
                if(isupper(s.at(i))){
                    if(upper){
                        upper = false;
                        break;
                    }
                    upper = true;
                }
            }
            if (upper) {
                ans = true;
            }
        }else ans = false;
    }else ans = false;
    
    if (ans) {
        cout<<"AC";
    } else {
        cout<<"WA";
    }
}

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

using namespace std;
#define mp make_pair
int main(){
  int n;
  string a;
  long long b,c;
  map<string,long long> data;
  vector<string> id;
  while(true){
    data.clear();
    id.clear();
    cin>>n;
    if(!n)
      break;
    for(int i=0;i<n;i++){
      cin>>a>>b>>c;
      c*=b;
      if(data.find(a)==data.end()){
	data.insert(mp(a,c));
	id.push_back(a);
      }
      else{
	data[a]+=c;
      }
    }
    bool empty = true;
    for(int i=0;i<id.size();i++){
      if(data[id[i]]>=1000000){
	cout<<id[i]<<endl;
	empty = false;
      }
    }
    if (empty)
      cout<<"NA"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define DEBUG_VARIABLE(variable) cout << #variable << ":" << variable << endl

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

void printArray(int *array, int);
void printVector(Vector &v);
void printDimention(DVector &dv);

int return2(int num){
    int cnt = 0;
    while(num % 2 == 0){
        num /= 2;
        cnt++;
    }
    return cnt;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    int a[n];
    rep(i, n)   cin >> a[i];
    
    int sum = 0;
    rep(i, n){
        sum += return2(a[i]);
    }
    cout << sum << endl;
}

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

//Vectorの表示
void printVector(Vector &v){
    rep(i, (int)v.size()){
        if(i)   cout << " ";
        cout << v[i];
    }
    cout << endl;
}

//二次元配列の表示
void printDimention(DVector &dv){
    rep(i, (int)dv.size()){
        rep(j, (int)dv[i].size()){
            if(j)   cout << " ";
            cout << dv[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
def resolve():
    N, M, Q = list(map(int, input().split()))
    Q = [list(map(int, input().split())) for _ in range(Q)]
    import itertools
    maxpoint = 0
    for seq in itertools.combinations_with_replacement(range(1, M+1), N):
        point = 0
        for a, b, c, d in Q:
            if seq[b-1] - seq[a-1] == c:
                point += d
        maxpoint = max(maxpoint, point)
    print(maxpoint)

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 73368
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;


int main()
{
    int ww,hh,n;
    cin >> ww >> hh >>n;
    vector<int> W(ww+1);
    vector<int> H(hh+1);

    rep(i,ww+1)W[i]=0;

    rep(i,hh+1)H[i]=0;

    int xf=0,xl=ww;
    int yf=0,yl=hh;
    rep(i,n)
    {
        int x,y,a;
        cin>>x >> y >>a;
        if(a==1){
            xf = max(xf,x);
            
        }else if(a==2){
            xl = min(xl,x);
            
        }else if(a==3){
            yf = max(yf,y);
         
        }else{
            yl = min(yl,y);
        }
    }
    if( (xl-xf)<=0||0>=(yl-yf)){
        cout<<0<<endl;
        return 0;
    }
    int ans = (xl-xf)*(yl-yf);
    cout<<ans<<endl;
    //cout<<W.siz+1)e()<<endl;
    return 0;

}


Measured memory_bytes: 256
n,q = gets.chomp.split(" ").map(&:to_i)

que = Array.new

n.times { |i|
	name, time = gets.chomp.split(" ")
	que << [name, time.to_i]
}

timer = 0

while true
	name,time = que.shift
	if name == nil
		break
	elsif time <= q
		timer += time
		print(name," ",timer,"\n")
	else
		timer += q
		time -= q
		que << [name,time]
	end
end

Measured memory_bytes: 14820
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		int[] nArr = (int[])arr.clone();
		Arrays.sort(nArr);
		HashSet<Integer> setEven = new HashSet<>();
		for (int i = 0; i < n; i += 2) {
			setEven.add(nArr[i]);
		}
		int count = 0;
		for (int i = 1; i < n; i += 2) {
			if (setEven.contains(arr[i])) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 51640
// abc175_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e18)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << "\n";}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    REP(i, N) {cin >> P[i]; P[i]--;}
    vector<ll> C(N);
    REP(i, N) cin >> C[i];

    vector<int> loop_idx(N, -1);
    int idx = 0;
    vector<vector<ll>> loops;
    REP(i, N){

        if (loop_idx[i] != -1){
            continue;
        }

        int x = i;
        vector<ll> loop;
        while (loop_idx[x] == -1){
            loop_idx[x] = idx;
            x = P[x];
            loop.emplace_back(C[x]);
        }
        loops.emplace_back(loop);
        idx++;
    }

//    print(loops);

    ll ans = -INF;
    for (auto& loop: loops){

        ll sm = accumulate(ALL(loop), 0ll);
        sm = max(sm, 0ll);
        int n = loop.size();

        REP(i, n){
            loop.emplace_back(loop[i]);
        }

        REP(i, n) {
            ll tmp = 0;
            REP(j, n) {
                if (j >= K) break;

                tmp += loop[i + j];
                int res = K - j - 1;
                ans = max(ans, tmp + sm * (res / n));
//                print(i, j, tmp, sm * (res/n));
            }
        }
//        print(loop, ans);
    }

    print(ans);


    return 0;
}


Measured memory_bytes: 3876
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int n, q, i, j, k = 0, key = 0;
  int *S, *T;

  scanf("%d", &n);
  S = (int *)malloc(n * sizeof(int));
  for(i = 0; i < n; i++)
    scanf("%d", &S[i]);

  scanf("%d", &q);
  T = (int *)malloc(q * sizeof(int));
  for(i = 0; i < q; i++)
    scanf("%d", &T[i]);

  for(j = 0; j < q; j++){
    //printf("T[%d] = %d\n", j, T[j]);
    for(i = 0; i < n; i++){
      if(T[j] == S[i]){
	k++;
	break;
      }
    }
  }

  /* printf??§??????????¢????
     printf("\nn = %d\n", n);
     for(i = 0; i < n; i++)
     printf("%d ", S[i]);
     printf("\n");

     printf("q = %d\n", q);
     for(i = 0; i < q; i++)
     printf("%d ", T[i]);
     printf("\n");
  */

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

  return 0;
}

Measured memory_bytes: 636
using System;
namespace MSOLUTIONS.Problems
{
    class D
    {
        static void Main()
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = int.Parse(Console.ReadLine());
            var inputs = Console.ReadLine().Split(" ");
            var a = new long[n];
            for (var i = 0; i < n; i++)
            {
                a[i] = long.Parse(inputs[i]);
            }

            var money = 1000L;
            var stock = 0L;
            var flag = true;
            for (var i = 0; i < n - 1; i++)
            {
                if (flag)
                {
                    // 極小値探索
                    if (a[i] < a[i+1])
                    {
                        // a[i]は極小値のため、株を購入
                        stock += money / a[i];
                        money -= a[i] * (money / a[i]);
                        flag = false;
                    }
                }
                else
                {
                    // 極大値探索
                    if (a[i] > a[i+1])
                    {
                        // a[i]は極大値のため、株を売却
                        money += a[i] * stock;
                        stock = 0;
                        flag = true;
                    }
                }
            }
            money += a[n-1] * stock;
            Console.WriteLine(money);
            Console.Out.Flush();
        }
    }
}


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

H,W = list(map(int,input().split()))
t = '#'*(W+2)
camp = [t]
for h in range(H):
    camp.append('#' + input().rstrip() + '#')
camp.append(t)

for h in range(1,H+1):
    for w in range(1,W+1):
        if camp[h][w] == '#':
            if camp[h][w-1] != '#' and camp[h][w+1] != '#' and camp[h-1][w] != '#' and camp[h+1][w] != '#':
                print('No')
                exit()
print('Yes')


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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    long long int num = -1;
    long long int ans = 0;
    for(long long int i = 0;i < s.size();i++){
    	if(s.at(i) == 'W' && num != -1){
    		ans += i - num;
    		num++;
    	}
    	if(s.at(i) == 'B' && num == -1){
    		num = i;
    	}
    }
    cout << ans << endl;
}

Measured memory_bytes: 720
#include <algorithm>
#include <array>
#include <functional>
#include <iostream>
#include <math.h>
#include <vector>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << (n / (a + b)) * a + min(a, n % (a + b)) << endl;
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in  range(c+1):
            if 500*i + 100*j + 50*k == x:
                count += 1
print(count)

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

const int MAX_N = 2e5;

// 辺を保持
// いろんな保持の仕方がある
vector<int> ecasdqina[MAX_N];
/*
ほかにも
bool graph[MAX_N][MAX_N];
graph[a][b] := aとbの間に辺があるか?
といった定義にもできるけど,今回はMAX_Nが大きいのでMLE
(静的なのでコンパイル時に落ちる, これが割と気づきにくい)

vector< vector<int> > graph(MAX_N, vector<int>(MAX_N, 0));
と動的配列で書いても同様に実行時にMLE!!
動的配列を使うように心がけ解くと, MLEに気付きやすいかもという利点はある

さらに発展的な話題で,辺に重みがあったりする場合もこの二通りの
表現方法があるってことは頭の片隅にでも!(わからなかったらまた聞いてね!)
*/

// 僕はよく答えが二通りの問題とかは関数にしてるけど
// いいかどうかは人それぞれなので
int solve(int n) {
  vector<int> flag(n, 0);
  // 頂点1から行ける辺にマークを付ける(フラグを建てる)
  // ちなみにvector<bool>は特殊だからvector<int>を代わりに使う
  // 詳しくは調べてね
  // もちろんvector<bool>でもbool[MAX_N]でもいいよ
  
  // 拡張for (というのはJava的で, range-based for loopっていうのかな)
  // O(M) // なぜなら, 辺の数はたかだかM個だから, ecasdqina.size()はM程度
  for(int j : ecasdqina[0]) {
    // 頂点jに頂点1から行けるので印をつける
    flag[j] = 1; // trueでもよし
  }

  // 0-indexedなので頂点Nは[n-1]だよ
  // 上記と同様にO(M)
  for(int j : ecasdqina[n - 1]) {
    // 印がついてれば 1 - j - N というつながりがある！
    if(flag[j]) return 1; // true を返してもいい
  }
  // さてここまで来たらそんな辺はなかった
  return 0;
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, m; cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    // push_back は emplace_back
    // 詳しくは調べてね
    ecasdqina[a].emplace_back(b);
    // 双方向につなぐことに注意してね
    ecasdqina[b].emplace_back(a);
  }
  // 例えばecasdqina[0]は配列になっているけど, 
  // それらは頂点1から行ける場所

  cout << (solve(n) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}



Measured memory_bytes: 12784
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)

signed main()
{
  int N, M;
  char mas[55][55], temp[55][55];
  bool ans = false;
  
  cin >> N >> M;
  Rep(i, N) Rep(j, N) cin >> mas[i][j];
  Rep(i, M) Rep(j, M) cin >> temp[i][j];

  Rep(i, N - M + 1) {
    Rep(j, N - M + 1) {
      bool flag = true;
      Rep(k, M) {
	Rep(l, M) {
	  if(temp[k][l] != mas[i + k][j + l]) flag = false;
	}
      }
      if(flag) ans = true;
    }
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b="CODEFESTIVAL2016";
int c;
int main(){
    cin>>a;
    for(int i=0;i<16;i++)
    c+=(a[i]!=b[i])?1:0;
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Card
{
public:
    int num;
    char color;
    bool operator<(const Card& c) const{
        return color < c.color || (color == c.color && num < c.num);
    }
    Card operator+(int a) const{
        Card c;
        c.num = num + a;
        c.color = color;
        return c;
    }
    bool operator==(const Card& c) const{
        return color == c.color && num == c.num;
    }
};

int main()
{
    int n;
    cin >> n;
    while(--n >= 0){
        vector<Card> c(9);
        for(int i=0; i<9; ++i)
            cin >> c[i].num;
        for(int i=0; i<9; ++i)
            cin >> c[i].color;
        sort(c.begin(), c.end());

        bitset<9> check;
        bool ok = true;
        for(int i=0; i<9; ++i){
            if(check[i])
                continue;
            if(i+2 < 9 && c[i] == c[i+1] && c[i] == c[i+2]){
                check[i] = check[i+1] = check[i+2] = true;
                continue;
            }

            int a, b;
            a = b = -1;
            for(int j=i+1; j<9; ++j){
                if(check[j])
                    continue;
                if(a == -1 && c[j] == c[i]+1)
                    a = j;
                if(b == -1 && c[j] == c[i]+2)
                    b = j;
            }
            if(a == -1 || b == -1){
                ok = false;
                break;
            }
            check[i] = check[a] = check[b] = true;
        }

        if(ok)
            cout << '1' << endl;
        else
            cout << '0' << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <list>
#include <vector>
#include <unistd.h>
#include <algorithm>
#define ll long long
using namespace std;
double A,B,C,D,E,F;
int main(){
	cin >> A >> B >> C >> D >> E >> F;
	double max_d = 0.00;
	double max_w = 0;
	double max_s = 0;
	for ( double a = 0 ; a <= 30 ; a ++ ){
		if ( a * A * 100 > F ) break;
		for ( double b = 0 ; b <= 30 ; b ++ ){
			if ( a * A * 100 + b * B * 100 > F ) break;
			for ( double c = 0 ; c <= 3000 ; c ++ ){
				if ( a * A * 100 + b * B * 100 + C * c > F ) break;
				if ( c * C > E * (a * A  + b * B) ) break;
				for ( double d = 0 ; d <= 3000 ; d ++ ){
					if ( a * A * 100 + b * B * 100 + C * c + d * D > F ) break;
					if ( c * C + d * D > E * (a * A  + b * B) ) break;
					double  temp;
					temp = 100.00 * (double)(c * C + d * D) ;
					temp = temp / (1.0 * (double)(c * C + d * D + 100.0 * a * A + 100.0 * b * B));
					if ( temp >= max_d){
						max_d = temp;
						max_w = 100* a * A + 100 * b * B;
						max_s = c*C + d*D;
					}
				}
			}
		}
	}
	cout << max_w + max_s << " " << max_s << endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn proc_r(depth: usize, node: usize, n: usize, m: &mut [bool; 8], v: &Vec<Vec<usize>> ) -> usize {
	if depth == n {
		return 1;
	}
	let mut ret = 0;
	for i in 0..v[node].len() {
		if !m[v[node][i]] {
			m[v[node][i]] = true;
			ret += proc_r(depth+1, v[node][i], n, m, v);
			m[v[node][i]] = false;
		}
	}
	return ret;
}

fn main() {
	input!(n: usize);
	input!(m: usize);

	let mut v: Vec<Vec<usize>> = vec![vec![]; n];
	for _i in 0..m {
		input!(a: usize);
		input!(b: usize);
		v[a-1].push(b-1);
		v[b-1].push(a-1);
	}

	let mut m: [bool; 8] = [false; 8];
	m[0] = true;
	println!("{}", proc_r(1, 0, n, &mut m, &v));
}


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

int freq[26];

int main() {
	
	int n, m;

	cin >> n >> m;

	for (int i = 0; i < n; ++i)
	{
		string s;

		cin >> s;

		for (int j = 0; j < m; ++j)
		{
			freq[s[j] - 'a']++;
		}
	}

	int four = (n / 2) * (m / 2);
	int two = (n % 2) * (m / 2) + (m % 2) * (n / 2);
	int one = (n % 2) * (m % 2);

	for (int i = 0; i < 26; ++i)
	{
		int tmp = min(four, freq[i]/4);
		four -= tmp;
		freq[i] -= tmp*4;

		tmp = min(two, freq[i]/2);
		two -= tmp;
		freq[i] -= tmp*2;

		tmp = min(one, freq[i]/1);
		one -= tmp;
		freq[i] -= tmp*1;

		if (freq[i] > 0)
		{
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";

	return 0;
}

Measured memory_bytes: 256
import math
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime
s = input()
S = list(s)
a = string.ascii_lowercase
od = collections.OrderedDict()
for i in range(len(a)):
    od[a[i]] = 0
for st in S:
    od[st] = 1
for k, v in od.items():
    if v == 0:
        print(join(S)+k)
        exit()

prev = S.pop()
od[prev] = 0
done = False
for i in range(len(S)):
    prev = S.pop()
    od[prev] = 0
    target = False 
    for k,v in od.items():
        if prev == k:
            target = True
            continue
        if target == True and v == 0:
            print(join(S)+k)
            done = True
            break
    if done == True:
        break
if done == False:
    print(-1)

Measured memory_bytes: 3816
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)

using Int = long;

void solve() {
    Int n,a,b;
    cin >> n >> a >> b;
    if (a > b){
        cout << 0 << endl;
        return;
    }
    if (n == 1 && a != b) {
        cout << 0 << endl;
        return;
    }
    
    cout << ((n-1) * b + a) - ((n-1) * a + b) + 1<< endl;
}

#ifdef DEBUG
#define MAIN hoge
#else
#define MAIN main
#endif

int MAIN() {
    solve();
    
    return 0;
}


Measured memory_bytes: 384
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read


n,m,*a = [int(i) for i in read().split()]

s = sum(a)
good = [1 for i in a if s <= 4*i*m]
if len(good) >= m:
    print("Yes")
else:
    print("No")

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


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

	if((a&1) == 0 || (b&1) == 0 )
	{
		cout <<"Even";
	}
	else
	{
		cout << "Odd";
	}

	return 0;
}

Measured memory_bytes: 256