akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	static int[] T, A;
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		T = new int[N];
		A = new int[N];
		for(int i=0; i<N;i++) {
			T[i] = scanner.nextInt();
			A[i] = scanner.nextInt();
		}
		long t = T[0];
		long a = A[0];

		for(int i=1; i<N;i++) {
			long nt = t/T[i];
			long na = a/A[i];
			if(t%T[i]!=0) nt++;
			if(a%A[i]!=0) na++;

			if(nt>na) {
				t = nt * T[i];
				a = nt * A[i];
			}
			else {
				t = na * T[i];
				a = na * A[i];
			}
		}
		System.out.println(t+a);
		scanner.close();
	}
}


Measured memory_bytes: 25716
#include<bits/stdc++.h>
using namespace std;
vector<int> in(100001);
vector<int> dis(100001);
queue<int> q;
vector<int> adj[100001];
void bfs(int n){
	for(int i=1;i<=n;i++){
		if(in[i]==0)
			q.push(i);
	}
	while(!q.empty()){
		int z=q.front();
		q.pop();
		for(int i=0;i<adj[z].size();i++){
			in[adj[z][i]]--;
			if(in[adj[z][i]]==0){
				q.push(adj[z][i]);
			}
			dis[adj[z][i]]=max(dis[adj[z][i]],1+dis[z]);
		}
	}
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
		in[y]++;
	}
	bfs(n);
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=max(ans,dis[i]);
	}
	cout<<ans;
	return 0;
}

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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

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

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> N >> M;
    if (N + M < 10) cout << N + M << endl;
    else cout << "error" << endl;
  
    return 0;
}



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

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
// const long long MOD = (ll)1e6+3;
const long long MAX = (ll)1e5+10;

int main(void) {
   char s;
   cin>>s;
   cout<<(char)((int)s+1)<<endl;


   return 0;

}



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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int tmp = a;
    while(a <= 1000000){
        if(a % b == c){
            cout << "YES";
            return 0;
        }
        a += tmp;
    }
    cout << "NO";
	return 0;

}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  cout << (a / 2) * (a % 2 + a / 2) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
typedef array<int, 3>arr3;


void solve() {
	int N; cin >> N;
	vector<int>X(N), Y(N), H(N);
	REP(i, N) {
		cin >> X[i] >> Y[i] >> H[i];
	}
	REP(cx, 101)REP(cy, 101) {
		set<int>st;
		REP(i, N) {
			if (H[i] == 0)continue;
			int h = H[i] + abs(cx - X[i]) + abs(cy - Y[i]);
			st.insert(h);
		}
		if (st.size() != 1)continue;
		int h = *st.begin();
		bool ok = true;
		REP(i, N) {
			if (H[i] == 0) {
				if (h - abs(cx - X[i]) - abs(cy - Y[i]) > 0)ok = false;
			}
		}
		if (ok) {
			pe(cx); pe(cy); print(h); return;
		}
	}
}

signed main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
		solve();
}



Measured memory_bytes: 256
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

from bisect import bisect_right as bs
n,m,k = ip()
a = ip()
b = ip()
x = [0]*(n+1)
for i in range(n):
    x[i+1] = x[i]+a[i]
y = [0]*(m+1)
for i in range(m):
    y[i+1] = y[i]+b[i]
ans = 0
for i in range(n+1):
    if x[i] <= k:
        ans = max(ans,i+bs(y,k-x[i])-1)
    else:
        break
print(ans)



Measured memory_bytes: 109468
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll N;
	cin >> N;
	cout << N * (N - 1) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, K, L;
    cin >> N >> K >> L;
    vvc<ll> GK(N), GL(N);
    rep(i, K) {
        ll p, q;
        cin >> p >> q;
        p--, q--;
        GK[p].eb(q), GK[q].eb(p);
    }
    rep(i, L) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        GL[a].eb(b), GL[b].eb(a);
    }

    ll cnt = 0;
    auto dfs = [&](auto&& dfs, ll& now, vvc<ll>& G, vvc<ll>& V, vl& D, vc<bool>& used) -> void{
        used[now] = true;
        V[cnt].eb(now), D[now] = cnt;
        repa(to, G[now]) {
            if (used[to]) continue;
            used[to] = true;
            dfs(dfs, to, G, V, D, used);
        }
    };

    vvc<ll> VK(N), VL(N);
    vl DK(N), DL(N);
    vc<bool> useK(N), useL(N);

    rep(i, N) if (!useK[i]) dfs(dfs, i, GK, VK, DK, useK), cnt++;
    cnt = 0;
    rep(i, N) if (!useL[i]) dfs(dfs, i, GL, VL, DL, useL), cnt++;

    rep(i, N) {
        if (VK[i].empty()) break;
        sort(all(VK[i]));
    }
    rep(i, N) {
        if (VL[i].empty()) break;
        sort(all(VL[i]));
    }

    map<pair<ll, ll>, ll> mp;
    vl ans(N);
    rep(i, N) mp[{DK[i], DL[i]}]++;
    rep(i, N) ans[i] = mp[{DK[i], DL[i]}];

    rep(i, N) cout << ans[i] << (i == N - 1 ? '\n' : ' ');
}

Measured memory_bytes: 53596
#include<stdio.h>

int main(){
    int num;
    int i,j;

    scanf("%d",&num);
    int jousi[num-1]; //4つの箱を用意
    int count[num-1];

    for(i=0;i<num-1;i++){
      scanf("%d",&jousi[i]);
      count[i]=0;
    } //初期化
    
    for(i=0;i<num-1;i++){
      count[jousi[i]-1]++;
    }
    
    for(i=0;i<num-1;i++)
      printf("%d\n",count[i]);
    printf("0");
  }

Measured memory_bytes: 3272
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        UnionFindTree uf = new UnionFindTree(n);
        for(int i = 0; i < m; i++){
            int x = sc.nextInt()-1;
            int y = sc.nextInt()-1;
            int z = sc.nextInt()%2;
            uf.union(x,y);
        }
        HashSet<Integer> hs = new HashSet<Integer>();
        for(int i = 0; i < n; i++){
            hs.add(uf.find(i));
        }
        System.out.println(hs.size());
    }
}

class UnionFindTree {
	int[] parent;
	int[] rank;
	int[] size;
	
	public UnionFindTree(int size) {
		this.parent = new int[size];
		this.rank = new int[size];
		this.size = new int[size];
		
		for (int i = 0; i < size; i++) {
			makeSet(i);
		}
	}
	
	public void makeSet(int i) {
		parent[i] = i;
		rank[i] = 0;
		size[i] = 1;
	}
	
	public void union(int x, int y) {
		int xRoot = find(x);
		int yRoot = find(y);
		if (xRoot > yRoot) { 
			parent[yRoot] = xRoot;
			size[xRoot] += size[yRoot];
		} else if(xRoot < yRoot) {
			parent[xRoot] = yRoot;
			size[yRoot] += size[xRoot];
		} else if (xRoot != yRoot){
			parent[yRoot] = xRoot;
			size[xRoot] += size[yRoot];
			rank[xRoot]++; 
		}
	}
	
	public int find(int i) {
		if (i != parent[i]) {
			parent[i] = find(parent[i]);
		}
		return parent[i];
	}
	
	public boolean same(int x, int y) {
		return find(x) == find(y);
	}

	public int size(int x) {
		return size[find(x)];
	}
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

int main(){
  int64_t A, B;
  cin >> A >> B;
  vector<int64_t> a(40);
  vector<int64_t> b(40);
  A--;
  int64_t x = 2;
  int64_t y = 1;
  for(int i=0; i<40; i++){
    a.at(i) = A/x * y + max((int64_t)0, A%x - (y-1));
    x *=2;
    y *=2;
  }
  x = 2;
  y = 1;
  for(int i=0; i<40; i++){
    b.at(i) = B/x * y + max((int64_t)0, B%x - (y-1));
    x *=2;
    y *=2;
  }
  
  
  x = 1;
  int64_t ans = 0;
  for(int i=0; i<40; i++){
    if((b.at(i) - a.at(i)) %2 == 1){
      ans += x;
    }
    x *=2;
  }
  cout << ans << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        using ll = long long;
         
        int main()
        {
          ll h; cin >> h;
          ll r = 1;
          while (h)
          {
            h >>= 1;
            r <<= 1;
          }
          
          cout << r - 1 << endl;
        }

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

int main(){

  int ans = 0;
  string s;	//文字列(string型)で受け取る
  cin >> s;
  
  for(int i = 0; i < 3; ++i){
    if(s.at(i) == '1'){
      ++ans;
    }
  }
	//for文による繰り返し(1.11の内容)
	//if文(1.06の内容)、文字列.at()(1.12の内容)
	//x++ or ++x で xに１を足す(1.09の内容)
  cout << ans << endl;

}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc166/submissions/12731897
// abs(j - i) = A[i] + A[j]
// i < j とすると j - i = A[i] + A[j]
// iを固定して、j - i = A[i] + A[j]を満たすjの数を求める。
// -A[i] - i = A[j] - jから、
// idxs[p] := { A[j] - j == p を満たす インデックスjを昇順に並べた配列} とし、
// 各A[i]について、
// idxs[-A[i] - i]の配列で(i+1)以上N未満の要素の数を求め、それを足せばよい
#include <bits/stdc++.h>
using namespace std;

template<typename T>
class RangeCountExact {
    map<T,int> mp;
    vector<vector<int>> idxs;

    int get(int r, T x)
    {
        if(mp.count(x) == 0) return 0;
        int a = mp[x];
        return lower_bound(idxs[a].begin(), idxs[a].end(), r) - idxs[a].begin();
    }

public:
    RangeCountExact(const vector<T> &as) {
        for(auto &a : as) mp[a];
        int N = 0;
        for(auto  &p : mp) {
            p.second = N++;
        }
        idxs.resize(N);
        for(int i = 0; i < as.size(); ++i) {
            idxs[mp[as[i]]].push_back(i);
        }
    }

    // [l, r)
    int get(int l, int r, T x) { return get(r,x) - get(l, x); }
};

int main()
{
    int n;
    cin >> n;
    vector<int> as(n);

    for(int i = 0; i < n; ++i) cin >> as[i];
    for(int i = 1; i < n; ++i) as[i] -= i;  // as`[i] = as[i] - i

    RangeCountExact<int> cnt(as);

    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        // -as`[i] - 2*i = -as[i] - i
        ans += cnt.get(i+1, n, -as[i] - 2*i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 22620
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
using namespace std;

#define eps 1e-8
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

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

int n;
vector<int> a;

int main() {
    cin >> n;
    a.resize(n + 1);
    for (int i = 1; i <= n; ++i) cin >> a[i];
    int index = 1, cnt = 0;
    while (index != 2 && a[index] > 0) {
        ++cnt;
        a[index] = -a[index];
        index = -a[index];
    }
    cout << (index == 2 ? cnt : -1);

    return 0;
}

Measured memory_bytes: 640
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	private static final char WALL = '#';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt();
			int w = scanner.nextInt();

			scanner.nextLine();

			char[][] map = new char[h][w];
			int[][] scoreMap = new int[h][w];
			int white = 0;
			for (int i = 0; i < h; i++) {
				String line = scanner.nextLine();
				for (int j = 0; j < w; j++) {
					map[i][j] = line.charAt(j);
					scoreMap[i][j] = Integer.MAX_VALUE;
					if (map[i][j] == '.') {
						white++;
					}
				}
			}

			scoreMap[0][0] = 0;

			List<Point> moves = new ArrayList<>(4);
			moves.add(new Point(0, -1));
			moves.add(new Point(1, 0));
			moves.add(new Point(0, 1));
			moves.add(new Point(-1, 0));

			int result = check(0, 0, moves, new Point(w - 1, h - 1), 0, scoreMap, map, Integer.MAX_VALUE, w, h);
			if (result == Integer.MAX_VALUE) {
				System.out.println(-1);
			} else {
				System.out.println(white - result - 1);
			}
		}
	}

	private static int check(int startX, int startY, List<Point> moves, Point end, int cost, int[][] scoreMap, char[][] map, int minPath, int w, int h) {
		int nowMinPath = minPath;

		cost++;
		for (Point move : moves) {
			int x = startX + move.x;
			int y = startY + move.y;
			if (x < 0 || x >= w || y < 0 || y >= h) {
				continue;
			}
			if (map[y][x] == WALL) {
				continue;
			}
			if (end.x == x && end.y == y) {
				if (cost < minPath) {
					nowMinPath = cost;
				}
				continue;
			}
			if (cost < scoreMap[y][x]) {
				scoreMap[y][x] = cost;
				if (cost == nowMinPath) {
					continue;
				}
				int p = check(x, y, moves, end, cost, scoreMap, map, nowMinPath, w, h);
				if (p < nowMinPath) {
					nowMinPath = p;
				}
			}
		}
		return nowMinPath;
	}
}


Measured memory_bytes: 29296
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a[10];
	int k;
	for(int i=0;i<10;i++)
		a[i]=0;
	while(cin>>k){
		if(k==0){
			int i=9;
			while(true){
				if(a[i]!=0){
					cout<<a[i]<<endl;
					a[i]=0;
					break;
				}
				i--;
			}
		}
		else{
			int i=0;
			while(true){
				if(a[i]==0){
					a[i]=k;
					break;
				}
				i++;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;

int N;
string S;
vector<int> B;
int MOD = 1e9 + 7;

void solve() {
	cin >> N >> S;
	B.resize(2 * N);
	if (S[0] == 'W') {
		cout << 0 << endl;
		return;
	}
	B[0] = 1;
	long long lc = 1;
	for (int n = 1; n < 2 * N; n++) {
		if (S[n] == S[n - 1])B[n] = 1 - B[n - 1];
		else B[n] = B[n - 1];
		lc += B[n];
	}
	if (lc != N) {
		cout << 0 << endl;
		return;
	}
	lc = 0;
	long long ans = 1;
	for (int n = 0; n < 2 * N; n++) {
		if (B[n] == 1)lc++;
		else {
			ans *= lc;
			ans %= MOD;
			lc--;
		}
	}
	for (int n = 2; n <= N; n++) {
		ans *= n;
		ans %= MOD;
	}
	cout << ans << endl;
	return;
}

Measured memory_bytes: 1412
program ABC
    integer(8) a, b, c, d, L
    read*, a, b, c, d
    a = a - 1
    L = c * d / GCD(c, d)
    print*, ((b - b / c - b / d + b / L) - (a - a / c - a / d + a / L))
contains
    !GCDを求めるよ！
    recursive function GCD (a, b) result (res)
        integer(8) a, b, res
        res = a
        if (b > 0) then;res = GCD(b, mod(a, b)); endif
    endfunction
end program ABC

Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n = I()
a = CI(n)

for i in range(n):
    if a[i]%2!=0:
        print("first")
        exit()
print("second")
exit()

Measured memory_bytes: 85124
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>  
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
const double PI=acos(-1.0);

typedef long long Int;
typedef long long LL;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <double, double> PDD;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 50;
const int LEN = 21;
const int BASE = 1000000000;
const int MOD = 1000000007;

int main()
{
  Int a, b;
  cin >> a >> b;
  if (abs(a-b) <= 1)
  cout << "Brown" << endl;
  else
  cout << "Alice" << endl;
  






    



  


  return 0;
}




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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
const ll MOD = 1e9 + 7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin >> n;
    map<ll, ll> left, right;
    ll temp;
    for (ll i = 0; i < n; i++)
        cin >> temp, left[temp + i + 1]++, right[i + 1 - temp]++;
    ll ans = 0;
    for (auto it : left)
    {
        ans += (it.ss) * (right[it.ff]);
    }
    cout << ans << endl;
    return 0;   
}

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

int main(){
    int H,W;cin>>H>>W;
    bool white;
    char a[110][110];
    
    vector<int> v_row;
    for(int i=0;i<H;i++){
        white=true;
        for(int j=0;j<W;j++){
            cin>>a[i][j];
            if(a[i][j]=='#')white=false;
        }
        if(!white)v_row.push_back(i);
    }

    vector<int> v_col;
    for(int j=0;j<W;j++){
        white=true;
        for(int i=0;i<H;i++)
            if(a[i][j]=='#')white=false;
        if(!white)v_col.push_back(j); 
    }

    for(int i=0;i<v_row.size();i++){
        for(int j=0;j<v_col.size();j++){
            if(j==v_col.size()-1)
                cout<<a[v_row[i]][v_col[j]]<<endl;
            else cout<<a[v_row[i]][v_col[j]]; 
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define N 1000000
int a[N];
int main(){
	int i,j;
	a[0]=0;a[1]=0;
	for(i=2;i<N;i++){
		a[i]=1;
	}
	for(i=2;i<N/2+1;i++){
		j=2;
		while(i*j<N){
			a[i*j]=0;
			j+=1;
		}
	}
	int n;
	while(cin>>n){
		j=0;
		for(i=2;i<=n;i++){
			j+=a[i];
		}
		cout<<j<<endl;
	}
}

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

int main()
{
  while(1){
    int a,b;
    char c;
    cin >> a >> c >> b;
    if(c == '?') break;
    switch(c){
    case '+': cout << a+b << endl; break;
    case '-': cout << a-b << endl; break;
    case '*': cout << a*b << endl; break;
    case '/': cout << a/b << endl; break;
    }
  }
  return 0;
}

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

int main() {
    int a, b, c; cin >> a >> b >> c;
    if(a > c) swap(a, c);
    if(a > b) swap(a, b);
    if(b > c) swap(b, c);
    printf("%d\n", 10*c + a + b);
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int r, g, b;
  scanf("%d %d %d", &r, &g, &b);
  
  const int result = r*100 + g*10 + b;
  if ((result != 0) && ((result % 4) == 0))
  {
    printf("YES\n");
  }
  else
  {
    printf("NO\n");
  }
  
  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;


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

  vector<string> v(h, "@");
  for(int i = 0; i < h; i++)
  {
    cin >> v[i];
    v[i] = "#" + v[i] + "#";
  }

  for(int i = 0; i < w + 2; i++){
    cout << "#";
  }
  cout << endl;

  for(int i = 0; i < h; i++)
  {
    cout << v[i] << endl;
  }

  for(int i = 0; i < w + 2; i++){
    cout << "#";
  }
  cout << endl;
  
}

Measured memory_bytes: 256
N, D = gets.chomp.split.map &:to_i

XY = Array.new(N, Array.new(2,0))

(0...N).each do |n| 
  XY[n] = gets.chomp.split.map &:to_i
end

cnt = 0

(0...N).each do |n| 
  dis = Math.sqrt(XY[n][0]**2+XY[n][1]**2)
  cnt += 1 if dis <= D
end

print cnt

Measured memory_bytes: 28552
#include <iostream>
#include <algorithm>
#include <string.h>


using namespace std;

int main()
{
    char s[200];
    cin>>s;
    int n=strlen(s);
int a, m=1000, f, x, y, z;
    for(int i=0; i<n-2; i++){
        x=(s[i])-48;
        y=(s[i+1])-48;
        z=(s[i+2])-48;
        a=x*100+y*10+z;
        if(abs(a-753)<m){
            m=abs(a-753);
            f=abs(a-753);
        }
    }
    cout<<f;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			int n = in.nextInt();
			long ans = 0;
			if(n > 0) {
				ans = 1;
				for(int i = 2; i <= n; i++) ans*=(long)i;
			}
			System.out.println(ans);
		}
	}
}

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

int main(){

	for(int D=0; D<5; D++){
	
		int n,m;
		cin >> n >> m;

		if(n==0 && m==0){
			break;
		}
		else{

			int st[1001];
			for(int i=1; i<=n; i++){
				int ope;
				cin >> ope;
				st[i] = ope;
			}

			int dis[1001];
			for(int i=1; i<=m; i++){
				int dl;
				cin >> dl;
				dis[i] = dl;
			}

			int now=1,i;

			for( i=1; i<=m; i++){

				now+=dis[i];
				if(now >= n){
					break;
				}

				now+=st[now];

				if(now >= n){
					break;
				}
			}

			cout << i << endl;

		}
	
	}
	
	return 0;

}



Measured memory_bytes: 2992
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=100005;
int n,m,i,j,k,col[N],sum[N],ans,head[N],adj[N*2],nxt[N*2],dep[N],g,a[N],cnt,fa[N],c[N];
bool v[N],vis[N];
int Abs(int a)
{
	return a>0?a:-a;
}
void dfs(int x,int dad,bool b)
{
	if(b)
	{
		if(dad==-1||col[dad]==1)
			col[x]=-1;
		else
			col[x]=1;
	}
	sum[x]=col[x];
	for(int y=head[x];y;y=nxt[y])
		if(adj[y]!=dad&&(y+1)/2!=g)
		{
			fa[adj[y]]=x;
			dfs(adj[y],x,b);
			sum[x]+=sum[adj[y]];
		}
	ans+=Abs(sum[x]);
}
void work(int x,int dad)
{
	v[x]=true;
	for(int y=head[x];y;y=nxt[y])
		if(!v[adj[y]])
		{
			dep[adj[y]]=dep[x]+1;
			work(adj[y],x);
		}
		else if(adj[y]!=dad)
		{
			g=(y+1)/2;
			k=Abs(dep[x]-dep[adj[y]]);
		}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;++i)
	{
		scanf("%d%d",&j,&k);
		adj[i*2-1]=k;
		nxt[i*2-1]=head[j];
		head[j]=i*2-1;
		adj[i*2]=j;
		nxt[i*2]=head[k];
		head[k]=i*2;
	}
	if(m==n-1)
	{
		ans=0;
		dfs(1,-1,true);
		if(sum[1]!=0)
			printf("-1");
		else
			printf("%d",ans);
		return 0;
	}
	work(1,-1);
	if(k%2==0)
	{
		dfs(1,-1,true);
		if(sum[1]%2)
		{
			puts("-1");
			return 0;
		}
		ans=Abs(sum[1]/2);
		col[adj[g*2-1]]-=sum[1]/2,col[adj[g*2]]-=sum[1]/2;
		dfs(1,-1,false);
		printf("%d",ans);
		return 0;
	}
	i=adj[g*2-1],j=adj[g*2];
	if(dep[i]<dep[j])
		swap(i,j);
	dfs(1,-1,true);
	if(sum[1])
	{
		printf("-1");
		return 0;
	}
	c[i]=1,c[j]=-1;
	while(i!=j)
	{
		if(dep[i]<dep[j])
			swap(i,j);
		vis[i]=true;
		a[++cnt]=c[i]*sum[i];
		c[fa[i]]=c[i];
		i=fa[i];
	}
	a[++cnt]=0;
	ans=0;
	for(i=1;i<=n;++i)
		if(!vis[i])
			ans+=Abs(sum[i]);
	sort(a+1,a+1+cnt);
	for(i=1;i<=cnt;++i)
		ans+=Abs(a[(cnt+1)/2]-a[i]);
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	cin>>n;
	int res=0,t=inf;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if(t>x) res++;
		t=min(t,x);
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
#include<math.h>
int main()
{
	int x;
	cin>>x;
	if(x==4||x==11||x==18||x==25)
		cout<<"mon"<<endl;
	if(x==5||x==12||x==19||x==26)
		cout<<"tue"<<endl;
	if(x==6||x==13||x==20||x==27)
		cout<<"wed"<<endl;
	if(x==7||x==14||x==21||x==28)
		cout<<"thu"<<endl;
	if(x==1||x==8||x==15||x==22||x==29)
		cout<<"fri"<<endl;
	if(x==2||x==9||x==16||x==23||x==30)
		cout<<"sat"<<endl;
	if(x==3||x==10||x==17||x==24)
		cout<<"sun"<<endl;
	return 0;
}


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

int prime[100010];
bool p[1299710];

void eratos(){
    fill(p, p+1299710, true);
    p[0]=p[1]=false;
    for(int i=2; i*i<=1299709; i++){
        if(p[i]){
            for(int j=i; i*j<=1299709; j++){
                p[i*j]=false;
            }
        }
    }
    int now=0;
    for(int i=2; i<=1299709; i++){
        if(p[i]){
            prime[now++]=i;
        }
    }
}

int main(){
    int n;
    eratos();
    
    while(cin>>n, n){
        if(p[n]) {
            cout<<0<<"\n";
        }
        else{
            int idx=(int)(lower_bound(prime, prime+100001, n)-prime);
            cout << prime[idx]-prime[idx-1]<<"\n";
        }
    }
    
}


Measured memory_bytes: 4720
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;


string res;

int counter;

int query(string& s){
    ++counter;
    cout<<"? "<<s<<endl;
    int ret;
    cin>>ret;
    return ret;
}

const int m = 62;
int cnt[62][200], n;
string ans, cha;

void solve(int l, int r){
    if(l+1==r){
        rep(i,m)if(cnt[i][r]!=cnt[i][l]){
            ans[l]=cha[i];
            return;
        }
    }
    int mid=(l+r)/2;
    int sum = 0, num = 0;
    vector<int> c(m);
    int j = -1;
    vector<int> rem;
    REP(i,0,m){
        if(cnt[i][l]==cnt[i][r]){
            cnt[i][mid]=cnt[i][l];
            sum -= cnt[i][l];
            j=i;
        }
        else rem.push_back(i);
    }
    if(j == -1){
        for(auto i : rem){
            if(i == 0)continue;
            string s(n, 'a');
            REP(k,0,mid)s[k]=cha[i];
            c[i] = query(s) - n + cnt[0][n];
            sum += c[i];
            num++;
        }
        assert((mid+sum)%(num+1)==0);
        int ret = (mid + sum)/(num + 1);
        cnt[0][mid]=cnt[0][0]+ret;
        REP(i,1,m){
            if(cnt[i][l]==cnt[i][r]){
                continue;
            }
            cnt[i][mid]=cnt[i][0]-c[i]+ret;
        }
    }
    else {
        sum += cnt[j][l];
        for(auto i : rem){
            if(i == rem.back()){
                c[i] = (rem.size()+1)*cnt[j][mid] - sum - mid;
                continue;
            }
            string s(n, cha[j]);
            REP(k,0,mid)s[k]=cha[i];
            c[i] = query(s) - n + cnt[j][n];
            sum += c[i];
        }
        for(auto i : rem){
            cnt[i][mid]=cnt[i][0]-c[i]+cnt[j][mid];
        }
    }
    solve(l,mid);
    solve(mid,r);
}

int main(){
    rep(i,26)cha += 'a'+i;
    rep(i,26)cha += 'A'+i;
    rep(i,10)cha += '0'+i;
    vector<int> c(m); 
    rep(i,m){
        string s(128,cha[i]);
        c[i]=query(s);
        n += 128 - c[i];
    }
    rep(i,m)cnt[i][n]=128-c[i];
    ans.resize(n, '-');
    solve(0,n);
    if(counter>761){
        cout<<3<<endl;
    }
    cout<<"! "<<ans<<endl;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int x,n;
	cin >> x >> n;
	bool a[102] = {0};
  
	int t;
	for (int i = 0; i < n; i++)
	{
		cin >> t;
    	a[t] =1;
	}
  
	int ans = 0;
  
	for (int i = 0; i <= 101; i++)
	{
    	if (a[i] == 0)
		{
    		if(abs(x-i) < abs(x-ans))
			{
        		ans = i;
			}
    	}
	}
         
	cout << ans;
	return 0;
}

Measured memory_bytes: 3632
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 120000;

int n;
ll a[MAXN][3];
ll dp[MAXN][3];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < 3; ++j)
			cin >> a[i][j];
	for (int j = 0; j < 3; ++j)
		dp[0][j] = a[0][j];
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < 3; ++j)
			for (int k = 0; k < 3; ++k)
				if (k != j)
					dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
	}
	ll ans = max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 5376
package main

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

func main() {
	n := getInt()
	as := getIntSlice(n + 1)
	bs := getIntSlice(n)

	ans := 0
	for i := 0; i < n; i++ {
		if as[i] < bs[i] {
			if as[i]+as[i+1] < bs[i] {
				ans += as[i] + as[i+1]
				as[i], as[i+1] = 0, 0
			} else {
				ans += bs[i]
				as[i+1] -= (bs[i] - as[i])
				as[i] = 0
			}
		} else {
			ans += bs[i]
			as[i] -= bs[i]
		}
	}

	fmt.Println(ans)
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 1100;
const int maxs = 30100;
ll dp[maxn][maxs], n;

struct block{
public:
    ll w, s, v;
};

block tower[maxn];

bool compare(block a, block b) {
    return a.w + a.s < b.w + b.s;
}

int main() {
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>tower[i].w>>tower[i].s>>tower[i].v;
    }
    sort(tower+1, tower+n+1, compare);

    ll result = 0LL;
    for(int i=1;i<=n;i++) {
        for(int j=0;j<maxs;j++) {
            dp[i][j] = dp[i-1][j];
            if(j - tower[i].w >= 0 && tower[i].s >= j - tower[i].w) {
                dp[i][j] = max(dp[i][j], dp[i-1][j-tower[i].w] + tower[i].v);
            }
            result = max(result, dp[i][j]);
        }
    }

    cout<<result<<"\n";
    return 0;
}


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

void print_ok() {
  cout << "AC" << endl;
}

void print_ng() {
  cout << "WA" << endl;
}

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

  if (s[0] != 'A') {
    print_ng();
  } else if (!islower(s[1]) || !islower(s[s.size()-1])) {
    print_ng();
  } else {
    int cnt = 0;
    bool ok = true;
    for (int i = 1; i < s.size() -1; i++) {
      if (s[i] == 'C') cnt++;
      else {
        if (!islower(s[i])) {
          ok = false;
          break;
        }
      }
    }

    if (!ok) print_ng();
    else if (cnt != 1) print_ng();
    else print_ok();
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	int l = 1;
	int count = 1;
	String lw = String.valueOf(s.charAt(0));

	while(l < s.length()) {
		String a = String.valueOf(s.charAt(l));
		if((lw.length() > 1) || (lw.length() == 1 && !(lw.equals(a)))) {
			lw = a;
			l++;
			count++;
		}else {
			if(l != s.length()-1) {
				lw += String.valueOf(s.charAt(l+1));
				l += 2;
				count++;
			}else {
				l++;
			}
		}
	}

	System.out.println(count);
	sc.close();
	}
}

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

using namespace std;
using i64 = std::int_fast64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  i64 N, D, A;
  cin >> N >> D >> A;
  vector<i64> X(N), H(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> H[i];
  }

  vector<int> idx(N);
  for (int i = 0; i < N; i++) {
    idx[i] = i;
  }
  sort(idx.begin(), idx.end(), [&](int i, int j) { return X[i] < X[j]; });

  vector<i64> NX(N), NH(N);
  for (int i = 0; i < N; i++) {
    NX[i] = X[idx[i]], NH[i] = H[idx[i]];
  }
  X = NX, H = NH;

  vector<i64> S(N + 1, 0);
  i64 res = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] < H[i]) {
      i64 cnt = (H[i] - S[i] + A - 1) / A;

      i64 right = X[i] + 2 * D;
      int p = upper_bound(X.begin(), X.end(), right) - X.begin();

      S[i] += cnt * A;
      S[p] -= cnt * A;

      res += cnt;
    }
    S[i + 1] += S[i];
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 8832
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
	 int water,sugar;
	 Scanner sc=new Scanner(System.in);
	 int A=sc.nextInt(),B=sc.nextInt(),C=sc.nextInt(),D=sc.nextInt(),E=sc.nextInt(),F=sc.nextInt();
	 double noudo=0.0;
	 int maxm=0;
	 int maxsugar=0;
	 double maxnoudo=0.0;
	 for(int a=0;a*A*100<=F;a++) {
		 for(int b=0;b*100<=F-a*A*100;b++) {
			 water=100*A*a+100*B*b;
			 if(water==0) {
				 continue;
			 }
			 for(int c=0;c*C<=F-water;c++) {
				 for(int d=0;d*D<=F-water-c*C;d++) {
				     sugar=c*C+d*D;
					 noudo=(double)sugar/((double)sugar+(double)water);
						
				  if(sugar<=E*(A*a+B*b)&&noudo>=maxnoudo) {
					 maxnoudo=noudo;
					 maxm=sugar+water;
					 maxsugar=sugar;
					 
				  }
					 
				 }
				 
				 
			 }
			 
		 }
	 }
	 System.out.println(maxm+" "+maxsugar);
	 
 }
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

string S, T;
vector <int> s[26], t[26];

int main(){
  cin >> S >> T;
  for (int i = 0; i < S.length(); i++){
    s[S[i] - 'a'].push_back(i);
    t[T[i] - 'a'].push_back(i);
  }

  for (int i = 0; i < 26; i++){
    bool flag = false;
    for (int j = 0; j < 26; j++){
      if (s[i] == t[j]) flag = true;
    }
    if (flag) continue;
    No(); return 0;
  }
  Yes();
  return 0;
}


Measured memory_bytes: 5940
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
 
static const double EPS = 1e-8;

static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

void disp(int stage[12][12], const int stage_size){
  for(int y = 0; y < stage_size; y++){
    for(int x = 0; x < stage_size; x++){
      printf("%d ",stage[y][x]);
    }
    printf("\n");
  }
  printf("\n");
}

class Cell {
public:
  int x;
  int y;
  int energy;
  Cell(int x,int y,int energy)
    : x(x), y(y), energy(energy) {}
};

bool check_all_zero(int stage[12][12], const int stage_size){
  for(int y = 0; y < stage_size; y++){
    for(int x = 0; x < stage_size; x++){
      if(stage[y][x] != 0) return false;
    }
  }
  return true;
}

Cell find_starting_point(int stage[12][12], const int stage_size){
  for(int y = 0; y < stage_size; y++){
    for(int x = 0; x < stage_size; x++){
      if(stage[y][x] < 0){
        return Cell(x,y,-stage[y][x]);
      }
    }
  }
  return Cell(-1,-1,0);
}

bool dfs(int stage[12][12], const int stage_size,
         int sx, int sy,int life){
  bool res = false;
  if(life < 0){
    return false;
  }
  if(life == 0){
    // disp(stage,stage_size);

    if(check_all_zero(stage,stage_size)){
      return true;
    }
    else{
      Cell c = find_starting_point(stage,stage_size);
      if(c.x == -1 && c.y == -1) return false;
      stage[c.y][c.x] = 0;
      // disp(stage,stage_size);
      // cout << c.energy << endl;
      res |= dfs(stage,stage_size,c.x,c.y,c.energy);
      stage[c.y][c.x] = -c.energy;
    }
  }

  for(int i = 0; i < 4; i++){
    int dx = tx[i] + sx;
    int dy = ty[i] + sy;
    if(dx < 0 || dy < 0 || dx >= stage_size || dy >= stage_size){
      continue;
    }
    if(stage[dy][dx] <= 0){
      continue;
    }
    if(life - stage[dy][dx] < 0){
      continue;
    }

    int tmp = stage[dy][dx];
    stage[dy][dx] = 0;
    res |= dfs(stage,stage_size,dx,dy,life - tmp);
    stage[dy][dx] = tmp;
  }
  return res;
}

int main(){
  int stage_size;
  while(~scanf("%d",&stage_size)){
    if(stage_size == 0) break;
    int stage[12][12];
    for(int y = 0; y < stage_size; y++){
      for(int x = 0; x < stage_size; x++){
        scanf("%d",&stage[y][x]);
      }
    }

    printf("%s\n",dfs(stage,stage_size,0,0,0) ? "YES" : "NO");
  }
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define INF 1000000000
#define MOD 1000000007

void solve() {
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,0,sz(s)) {
        ans += s[i] != t[i];
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}



Measured memory_bytes: 3756