akhauriyash/Code-Regression huggingface dataset:
class in{struct myIterator{int it;const bool rev;explicit constexpr myIterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(myIterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const myIterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const myIterator& begin(){return i;}const myIterator& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

#ifdef COMMENT
.XR... R := ??????????????´?????????????????????????§????L?????????????????´?????????
X@.... ????±??????\????????????????????????????¶?????????????R/L????¶????????????????????????°??????
L.....
......
#endif

int h, w;
int dp[1000][1000][8];
vector<string> fld;
const int INF = 1e9;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
inline bool range_out(int y, int x) { return y >= h || x >= w || y < 0 || x < 0;}
int dfs(int y, int x, int code) {
    if(y == h - 1 && x == w - 1) return 0;
    int& res = dp[y][x][code];
    if(res != -1) return res;
    res = INF;
    
    bool from = code & 1, other = code & 2;
    vector<int> cand;
    int sum = 0, right = 0, down = 0;
    for(int i : in(4)) {
        int ax = x + dx[i], ay = y + dy[i];
        if(range_out(ay, ax)) continue;
        if(fld[ay][ax] == '.') continue;
        if(i == 0) if(from || other) continue;
        if(i == 1) if(!from || other) continue;
        cand.emplace_back(i);
        sum += fld[ay][ax] - '0';
        if(i == 2) right = fld[ay][ax] - '0';
        if(i == 3) down = fld[ay][ax] - '0';
    }
    // east
    if(x < w - 1) {
        int nxt_code = 1;
        if(!from && (code & 4)) nxt_code |= 2;
        if(cand.empty()) res = min(res, dfs(y, x + 1, nxt_code));
        for(int i : cand) {
            int plus = sum - (fld[y + dy[i]][x + dx[i]] - '0');
            if(i != 2 && right) plus -= right;
            int tcode = i != 3 && down ? 4 : 0;
            res = min(res, dfs(y, x + 1, nxt_code | tcode) + plus);
        }
    }
    // south
    if(y < h - 1) {
        int nxt_code = 0;
        if(from && (code & 4)) nxt_code |= 2;
        if(cand.empty()) res = min(res, dfs(y + 1, x, nxt_code));
        for(int i : cand) {
            int plus = sum - (fld[y + dy[i]][x + dx[i]] - '0');
            if(i != 3 && down) plus -= down;
            int tcode = i != 2 && right ? 4 : 0;
            res = min(res, dfs(y + 1, x, nxt_code | tcode) + plus);
        }
    }
    if(fld[y][x] != '.') res += fld[y][x] - '0';
    return res;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    fld.resize(h);
    for(auto& s: fld) cin >> s;
    memset(dp, -1, sizeof(dp));
    cout << dfs(0, 0, 0) << endl;
//    for(int y : in(h)) for(int x : in(w)) for(int code : in(8))
//      cout << y << ' ' << x << ' ' << code << ' ' << dp[y][x][code] << endl;
    return 0;
}

Measured memory_bytes: 35760
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;
    int aa = 0, bb = 0;
    for (auto &&x : s) {
        if(aa+bb+1 > a+b || (x == 'b' && bb+1 > b) || x == 'c') cout << "No" << "\n";
        else {cout << "Yes" << "\n"; if(x == 'a') aa++; else bb++;}
    }
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
  int n; cin >> n;
  double ans=0;
  for(int i=0;i<n;i++){
    double x;
    string s;
    cin >> x >> s;
    if(s=="JPY") ans += x;
    else ans += x*380000.0;
  }
  printf("%.8f",ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N; cin>>N;
  vi A(N),C;
  int sum=0;
  rep(i,0,N){
    cin>>A[i];
    }
  rep(i,0,N){
    int B; cin>>B;
    int K=A[i]-B;
    sum+=K;
    if(K>=0)
      C.push_back(K);
    }
  int ans=N;
  if(sum>=0){
    sort(ALL(C));
    rep(i,0,C.size()){
      if(sum<C[i])
        break;
      else{
        sum-=C[i];
        ans--;
        }
      }
    }
  else
    ans=-1;
  cout<<ans<<endl;
  }


Measured memory_bytes: 2168
#入力
N = int(input())
A = list(map(int,input().split()))
#2で割り切れるものいれるリスト,要素として0は入らないのでとりあえず0
B = [0 for _ in range(N)]
#2で割り切れるリストの数カウント
count = 0
#2で割り切れるリストに偶数要素を代入&要素数カウント
for i in range(N):
  if A[i] % 2 == 0:
    B[i] = A[i]
    count += 1
#0は後からいれた要素ではありえないので削除
C = [i for i in B if i != 0]
#3と5のどちらでも割り切れない場合はだめ
flag = 0
for i in range(count):
  if C[i] % 3 != 0 and C[i] % 5 != 0:
    flag += 1
if flag == 0:
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int  a,b,m;
	int  a1[100005],b1[100005],x,y,c;
	int a2[100005],b2[100005],ans;
	cin>>a>>b>>m;
	for(int i=0;i<a;i++){
		cin>>a1[i];
		a2[i]=a1[i];
	}
	for(int i=0;i<b;i++){
		cin>>b1[i];
		b2[i]=b1[i];
	}
	sort(a2,a2+a);
	sort(b2,b2+b);
	ans=a2[0]+b2[0];
	for(int i=0;i<m;i++){
		cin>>x>>y>>c;
		if(ans>a1[x-1]+b1[y-1]-c)
			ans=a1[x-1]+b1[y-1]-c;
	}
	cout<<ans<<endl;
  return(0);
}

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


// サンプルだとちゃんと答えが出るのに、同じサンプルでのテストがRE139になる。理由が分からない。
/* UnionFind：素集合系管理の構造体(union by size)
    isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
    unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
    treeSize(x): x を含む集合の要素数。
*/
struct UnionFind {
    vector<int> size, parents;
    UnionFind() {}
    UnionFind(int n) {  // make n trees.
        size.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++) {
            makeTree(i);
        }
    }
    void makeTree(int x) {
        parents[x] = x;  // the parent of x is x
        size[x] = 1;
    }
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
    bool unite(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return false;
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    int findRoot(int x) {
        if (x != parents[x]) {
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x) {
      return size[findRoot(x)];
    }
};

int main() {
  ll n, m;
  cin >> n >> m;
  vector<int> A(m), B(m);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    A[i] = a;
    B[i] = b;
  }

  vector<ll> ans(m + 1, 0);
  ans[m] = n * (n - 1) / 2;
  UnionFind tree(n);
  for(int i = m - 1; i >= 0; i--) {
    if (tree.findRoot(A[i]) == tree.findRoot(B[i])) {
      ans[i] = ans[i + 1];
    } else {
      ans[i] = ans[i + 1] - tree.treeSize(A[i]) * tree.treeSize(B[i]);
    }
    tree.unite(A[i], B[i]);
  }
  
  rep(i, m) cout << ans[i + 1] << endl;
  return 0;
}

Measured memory_bytes: 5580
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T& t,const V& v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T& t,const V& v){for(auto &e:t)fill_v(e,v);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
struct UnionFind{
    vector<ll> par,siz;
    UnionFind(int n){
        par.resize(n);
        siz.resize(n,1);
		for(int i=0;i<n;i++)par[i]=i;
    }
    int find(int x){
		if(par[x]==x){
			return x;
		}else{
			return par[x]=find(par[x]);
		}
	}
	bool unite(int u,int v){
		u=find(u),v=find(v);
		if(u==v)return false;
		if(siz[u]<siz[v])swap(u,v);
		par[v]=u;
		siz[u]+=siz[v];
		return true;
	}
	bool same(int u,int v){
		return find(u)==find(v);
	}
};
int main(){
    int n,m;cin>>n>>m;
    vector<int> a(m),b(m);
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];--a[i];--b[i];
    }
    UnionFind uf(n);
    vector<ll> s(m);
    for(int i=m-1;i>=0;i--){
        ll ans=uf.siz[uf.find(a[i])]*uf.siz[uf.find(b[i])];
        if(uf.unite(a[i],b[i])){
            s[i]=ans;
        }else{
            s[i]=0;
        }
    }
    for(int i=0;i<m;i++){
        if(i)s[i]+=s[i-1];
        cout<<s[i]<<endl;
    }
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int X[15],Y[15],A[15];
double AS[1<<15],DS[1<<15],V[1<<15];
double D[15][15];
vector<int> C[1<<15];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>X[i]>>Y[i]>>A[i];
	FOR(x,N) FOR(y,N) D[x][y]=hypot(X[x]-X[y],Y[x]-Y[y]);
	
	for(int mask=1;mask<1<<N;mask++) {
		FOR(i,N) if(mask&(1<<i)) {
			AS[mask]+=A[i];
			C[mask].push_back(i);
		}
			
		if(__builtin_popcount(mask)==1) {
			V[mask]=AS[mask];
			continue;
		}
		
		DS[mask]=1e10;
		for(int smask=(mask-1)&mask; smask>0; smask=(smask-1)&mask) {
			FORR(x,C[smask]) FORR(y,C[smask^mask]) {
				DS[mask]=min(DS[mask],DS[smask]+DS[mask^smask]+D[x][y]);
			}
		}
		V[mask]=(AS[mask]-DS[mask])/__builtin_popcount(mask);
		for(int smask=(mask-1)&mask; smask>0; smask=(smask-1)&mask) {
			V[mask]=max(V[mask],min(V[smask],V[mask^smask]));
		}
	}
	_P("%.12lf\n",V[(1<<N)-1]);
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

int main() {

    char b; cin >> b;
    string ans;
    if (b == 'A') {ans = 'T';}
    if (b == 'T') {ans = 'A';}
    if (b == 'G') {ans = 'C';}
    if (b == 'C') {ans = 'G';}
    cout << ans << endl;

}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int a[5];
    for(int i=0;i<5;i++) cin >> a[i];
    int ans = 0;
    for(int i=0;i<5;i++) ans += (a[i]+9)/10*10;
    
    int t = 0;
    for(int i=0;i<5;i++){
        if(a[i] % 10 == 0) continue;
        t = max(t, 10-a[i]%10);
    }

    cout << ans -t << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

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

bool has_key_using_count(map<char, char> &m, char n){
    if (m.count(n) == 0){
		//cout << "m doesn't have " << n << "." << endl;
        return false;
    }
    else{
        //cout << "m has " << n << "." << endl;
        return true;
    }
}

int main()
{
	//ifstream cin("sampleA.txt");

	int n = 0;
	//map<string, string> table;
	map<char, char> table;
	string input = "", ans = "";
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		table.clear();
		ans = "";
		input = "";

		//cin >> n;
		rep(i, n) {
			// テヲツ堋療・ツ渉キティツ。ツィテ」ツつ知apテ」ツ?ォティツソツステ・ツ環?」ツ?凖」ツつ?
			char a, b;
			cin >> a >> b;
			//table.insert( map<string, string>::value_type(a, b));
			table.insert( map<char, char>::value_type(a, b));
		}
		
		// テ・ツ、ツ嘉ヲツ渉崚・ツッツセティツアツ。テヲツ鳴?・ツュツ療・ツ按療」ツ?ョティツェツュテ」ツ?ソティツセツシテ」ツ?ソ&テ・ツ?コテ・ツ環?
		cin >> n;
		rep(i, n) {
			char t = 'a';
			cin >> t;
			input.push_back(t);

			// ティツ。ツィテ」ツ?ォテ」ツ?ェテ」ツ??・ツ?エテ・ツ青暗」ツ?ッテ」ツ?敕」ツ?ョテ」ツ?セテ」ツ?セテ・ツ?コテ・ツ環?
			//if (table[t] != null) {
			if ( has_key_using_count(table, t)) {
				ans.push_back(table[t]);
			} else {
				ans.push_back(t);
			}
		}

		// テ・ツ?コテ・ツ環崚」ツ?凖」ツつ?
		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;

int n , m;
int a[21][21];
int b[21];
int c;

int main(){
    scanf("%d%d%d",&n,&m,&c);
    for(int i = 1;i <= m;i++)
        scanf("%d",&b[i]);
    for(int i = 1; i <= n;i++)
        for(int j = 1;j <= m;j++)
            scanf("%d",&a[i][j]);
    int ans = 0;
    for(int i = 1;i <= n;i++){
        int s = 0;
        for(int j = 1;j <= m;j++){
            s += a[i][j] * b[j];
        }
        s += c;
        if(s > 0)
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void solve()
{
	int r;
	cin >> r;
	cout << r * r;
}
 
int main()
{
    Red;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
 

int main(){
  int N,K;
  string S;
  cin>>N>>S>>K;
rep(i,N){
  if(S.at(i)!=S.at(K-1)){
    S.at(i)='*';
  }
}
  cout<<S<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;

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

    vector<ll> a(n);
    for(int i= 0; i<n; i++){
        cin >> a.at(i);
    }

    ll snum = 1;

    for(int i = 0; i< n; i++){
        if(a.at(i) == snum){
            snum++;
        }
    }
    if(snum == 1){
        cout << -1 << endl;
        return 0;
    }
    snum--;
    ll answer = n-snum;

    cout << answer << endl;
}


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

int N, M, Ai, Bi;
queue<pair<int,int> > Q;
int dist[200005];
vector<int> G[200005];

int main() {

  cin >> N >> M;
  while (M--) {
    cin >> Ai >> Bi;
    G[Ai].push_back(Bi);
    G[Bi].push_back(Ai);
  }

  int SAUCE = 1;
  memset(dist, -1, sizeof(dist));
  Q.push(make_pair(0, SAUCE));
  while (!Q.empty()) {
    int d = Q.front().first, u = Q.front().second;
    Q.pop();
    if (dist[u] != -1) continue;
    dist[u] = d;
    for (int i=0; i < G[u].size(); i++) {
      Q.push(make_pair(d + 1, G[u][i]));
    } 
  }

  if (dist[N]==2) {
    cout << "POSSIBLE\n";
  }
  else {
    cout << "IMPOSSIBLE\n";
  }

}

Measured memory_bytes: 14192
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{

	public static int COUNT = 0;

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];

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

			a[i] = Integer.parseInt(br.readLine());

		}

		Main m = new Main();
		m.shellSort(a, n);

		System.out.println(COUNT);

		for(int i = 0; i < n; i++){
			System.out.println(a[i]);
		}


	}

	public void insertionSort(int[] a, int n, int g){

		for(int i = g; i < n; i++){

			int temp = a[i];
			int j = i - g;

			while(j >= 0 && a[j] > temp){

				a[j + g] = a[j];
				j -= g;
				COUNT++;

			}

			a[j + g] = temp;

		}

	}

	public void shellSort(int[] a, int n){

		int m = 0;
		int[] g = new int[100];

		while((int)Math.pow(2, m + 1) - 1 <= n){

			g[m] = (int)Math.pow(2, m + 1) - 1;
			m++;

		}

		System.out.println(m);

		for(int i = m - 1; i >= 0; i--){

			System.out.print(g[i]);

			if(i != 0){
				System.out.print(" ");
			}else{
				System.out.print("\n");
			}

		}

		for(int i = m - 1; i >= 0; i--){

			insertionSort(a, n, g[i]);

		}

	}
}

Measured memory_bytes: 106576
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                   int a = scan.nextInt();
		int b = scan.nextInt();
		if(a >= -1000 && b <= 1000){
		    if(a<b){
			 System.out.println("a < b");
		     }
	              if(a>b){
			  System.out.println("a > b");
		     }
                         if(a==b){
			  System.out.println("a == b");
			}
		}
	}
}

Measured memory_bytes: 26260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)

const ll INF = 1000000000000000000;

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    bool zeroflag = false;
    rep(i, n) {
        cin >> a[i];
        if(a[i] == 0) zeroflag = true;
    }
    if(zeroflag) {
        cout << 0 << endl;
        return 0;
    }
    ll now = 1;
    rep(i, n) {
        if((INF)/now < a[i]) {
            cout << -1 << endl;
            return 0;
        } else {
            now *= a[i];
        }
    }

    cout << now << endl;

    return 0;
}



Measured memory_bytes: 3976
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define sz size()
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
bool isincluded(char x, string str) {
	bool f = 0;
	for (size_t i = 0; i < str.size(); i++) {
		if (str.at(i) == x)f = 1;
	}
	return f;
}
int ctoi(char c) {
	if ('0' <= c && c <= '9') {
		return c - '0';
	}
	return 0;
}




int main(void) {
	ll n; cin >> n;
	if (n % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 0;
	for (ll i = 10; i <= n; i *= 5) {
		ans += n / i;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int n;
    string st;
	cin >> n >> st;
    int ans = 0;
    rep(i, n-2){
      if(st.at(i) == 'A' && st.at(i+1) == 'B' && st.at(i+2) == 'C') ans++;
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch ATCoder | diff ATCoder.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address ATCoder.cpp && ./a.out

/*
 
 5/9/2019
 
 16:14-
 
 */

string S;

void solve() {
  set<char> T={'A','C','G','T'};
  int N=SZ(S);
  int res=0;
  REP(i,N) {
    FOR(j,i,N) {
      if(T.count(S[j])) SMAX(res,j-i+1);
      else break;
    }
  }
    cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>S;
  solve();
  
  return 0;
}


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

const int maxn = 2e5 + 10;

int n;

int main()
{
	
	std::ios::sync_with_stdio(false);cin.tie(0);
	cin >> n;
	int minx = maxn, ans = 0;
	for(int i = 0; i < n; i++) {
		int x; cin >> x;
		if(minx >= x) ans++;
		minx = min(minx,x);
		//cout << ans << endl; 
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr << #x << ": " << x << endl;

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int    inf = 100100100;
const int    MOD = (int)1e9 + 7;
const double EPS = 1e-9;


int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    while (cin >> n, n) {
        int m[55] = {};
        int fx[4][20] = {};
        int fy[4][20] = {};
        int px[55][20] = {};
        int py[55][20] = {};
        int dx[55][20] = {};
        int dy[55][20] = {};
        rep(i, n + 1) {
            cin >> m[i];
            rep(k, m[i]) { cin >> px[i][k] >> py[i][k]; }
            rep(k, m[i] - 1) {
                dx[i][k] = px[i][k + 1] - px[i][k];
                dy[i][k] = py[i][k + 1] - py[i][k];
            }
        }
        //四方向を登録
        rep(k, m[0] - 1) {
            fx[0][k] = dx[0][k];
            fy[0][k] = dy[0][k];
            fx[1][k] = -dy[0][k];
            fy[1][k] = dx[0][k];
            fx[2][k] = -dx[0][k];
            fy[2][k] = -dy[0][k];
            fx[3][k] = dy[0][k];
            fy[3][k] = -dx[0][k];
        }
        REP(i, 1, n + 1) {
            bool flag = false;
            if (m[i] != m[0]) continue;
            rep(j, 4) {
                flag = false;
                rep(k, m[i] - 1) {
                    if (fx[j][k] != dx[i][k] || fy[j][k] != dy[i][k]) {
                        flag = true;
                        break;
                    }
                }
                if (!flag) {
                    cout << i << endl;
                    j = 4;
                    break;
                }
            }
            if (!flag) continue;
            rep(j, 4) {
                flag = false;
                rep(k, m[i] - 1) {
                    if (fx[j][m[0] - 2 - k] != dx[i][k] || fy[j][m[0] - 2 - k] != dy[i][k]) {
                        flag = true;
                        break;
                    }
                }
                if (!flag) {
                    cout << i << endl;
                    j = 4;
                    break;
                }
            }
        }

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



Measured memory_bytes: 3160
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::ops::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let mut n = i.read_vec::<usize>(4);
    let mut e = [1usize, 9, 7, 4];
    e.sort();
    n.sort();

    let r = if &e[..] == &n[..] { "YES" } else { "NO" };

    writeln!(o, "{}", r).unwrap();
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
        pub fn read_array<A: AsMut<[T]> + Default, T: FromStr>(&mut self) -> A {
            let mut a: A = Default::default();
            {
                let a: &mut [T] = a.as_mut();
                let i = &mut self.read_line().split(' ');
                for n in 0..a.len() {
                    a[n] = read_next(i);
                }
            }
            a
        }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
string s;
int main()
{
    cin>>s;
    int cnt=0,ans=0;
    for(int i=0;i<3;++i)
    if(s[i]=='R') cnt++;
    else ans=max(ans,cnt),cnt=0;
    ans=max(ans,cnt);
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,t,a,b,m,c,d,y,x,k,s,r,temp,n;
    t=1;
    // cin>>t;
    while(t--)
    {
        string s;
        cin>>n;
        cin>>s;
        if(s.length()<=n)cout<<s;
        else cout<<s.substr(0,n)<<"...";
    }
}

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

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<double> a(N);
    for(auto& d : a) cin >> d;
    const int MAX = 150010;
    vector<double> dp(MAX, 0), tmp;
    rep(i, MAX) dp[i] = abs(a[0] - i) / a[0];
    REP(i, 1, N) {
        tmp.assign(MAX, 1.0e9);
        const int ub = (int)(1.5 * a[i] + 1.0);
        REP(k, 1, ub)
          for(int j = 1; k * j < ub; ++j) {
              double upd = max(dp[k] , abs(a[i] - k * j) / a[i]);
              tmp[k * j] = min(tmp[k * j], upd);
          }
        dp.swap(tmp);
    }
    cout << fixed << setprecision(10) << *min_element(dp.begin(), dp.end()) << endl;
    return 0;
}

Measured memory_bytes: 5328
#include <bits/stdc++.h>
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod         (ll)1000000007
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = (ll)1e18;
ld pi = 3.141592653589;
using namespace std;

ll bpow(ll x, ll v) {	
	if (v == 0)
		return 1 % mod;
	if (v % 2 == 1)
		return (x * bpow(x, v - 1)) % mod;
	ll r = bpow(x, v / 2);
	return (r * r) % mod;	
}

ll lcm(ll a,ll b)
{
	ll ret=(a*b)/__gcd(a,b);
	return ret;
} 

ll solve(){ 
	ll n,ans=0; cin>>n;
	string a; cin>>a;
	string b = "ABC";
	lp(i,0,n){
		string d = a.substr(i,3);
		if(d == b)
			ans++;
	}
	cout<<ans;
}
int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
    	solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define INF 1ll<<60
using namespace std;
int gcd(int a,int b){
	if(a%b==0)
		return b;
	return gcd(b,a%b);
}
signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int N,Q;
  cin>>N>>Q;
  cout<<max(N+Q,max(N-Q,N*Q))<<endl;
}


Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))

l = []
count = 0

for j in range(n):
    for i in reversed(range(len(b))):
        if b[i] == i+1:
            l.append(b.pop(i))
            count += 1
            break
if count != n:
    print(-1)
else:
    for i in reversed(range(n)):
        print(l[i])

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>

int main(){
	char a[15], b[15], c[15];
	int d,e;
	
	scanf("%s %s\n%d %d\n%s",&a,&b,&d,&e,&c);
	if(strcmp(a,c)==0){
		printf("%d %d", d-1,e);
	}	
	else if(strcmp(b,c)==0){
		printf("%d %d",d,e-1);
	}
	return 0;
}

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

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

  if (S[0] == S[1] || S[1] == S[2]  || S[2] == S[3]) cout << "Bad" << endl;
  else cout << "Good" << endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
ary = gets.chomp.split(' ').map(&:to_i)

def insertionSort(a, n)
  (1..n-1).each do |i|
  	v = a[i]
  	j = i - 1
  	while(j >= 0 && a[j] > v) do
  	  a[j+1] = a[j]
  	  j -= 1
  	end
  	a[j+1] = v
  	puts a.join(' ')
  end
end

puts ary.join(' ')
insertionSort(ary, n)


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

int main(int argc, char const* argv[])
{
  const std::string left =  "qwertasdfgzxcvb";
  const std::string right = "yuiophjklnm";

  while (true) {
    std::string s;
    std::cin >> s;
    if (s == "#")
      break;
    int side = -1;
    int sw = 0;
    for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) {
      if (left.find(*it) != std::string::npos) {
        if (side == 1)
          ++sw;
        side = 0;
      } else {
        if (side == 0)
          ++sw;
        side = 1;
      }
    }
    std::cout << sw << std::endl;
  }
  return 0;
}

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

int main(){
    int n; 
    cin >> n;
    vector<ll> A(n);
    rep(i,n) cin >> A[i];
    ll x = 0;
    rep(i,n) {
        if(i%2==0){
            x+=A[i];
        }
        else{
            x-=A[i];
        }
    }
    x/=2;
    vector<int> ans(n);
    ans[0] = x;
    rep(i,n-1) {
        ans[i+1] = A[i]-ans[i];
    }
    rep(i,n) ans[i]*=2;
    rep(i,n){
        printf("%d%c", ans[i], ' ');
        
    }
    return 0;
}

Measured memory_bytes: 2432
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    if n%2==0:
        ans=0
        i=0
        while 10*5**i<=n:
            ans+=n//(10*5**i)
            i+=1
        print(ans)
    else:print(0)

if __name__=='__main__':
    main()

Measured memory_bytes: 38256
n = int(input())
h = list(map(int, input().split()))

dp = [10**9]*(n+10)
dp[0] = 0
for i in range(n):
    if 0<=i+1<n: dp[i+1] = min(dp[i+1], dp[i] + abs(h[i]-h[i+1]))
    if 0<=i+2<n: dp[i+2] = min(dp[i+2], dp[i] + abs(h[i]-h[i+2]))
print(dp[n-1])

Measured memory_bytes: 13904
S = gets.strip
T = gets.strip

ns = S.length
nt = T.length

n_try = ns - nt + 1

i = 0
mm = 0

n_try.times do
  j = 0
  m = 0
  nt.times do
    if S[i+j] == T[j]
      m+=1
    end
    j += 1
  end
  if m > mm
    mm = m
  end
  i += 1
end

puts nt - mm

Measured memory_bytes: 14308
#include <iostream>

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

using namespace std;

int main(){
	
	int n;
	cin >> n;
	
	int lowest[2];
	lowest[0] = 0;
	
	long long int input_a, input_b;
	
	REP(i,n){
		cin >> input_a >> input_b;
		if(input_a>=lowest[0]){
			lowest[0] = input_a;
			lowest[1] = input_b;
		}
	}
	
	cout << lowest[0] + lowest[1] << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング


// func declaration
template <class T> void calcVec(vector<T>&, int, char);

void printVec(vector<int>& vec) {
    auto N = vec.size();
    REP(i, N) {
        cout << vec.at(i);
        if (i < N - 1) cout << " ";
    }
    cout << endl;
}

void insertionSort(vector<int>& vec) {
    printVec(vec);
    for (int i = 1; i <= (vec.size() - 1); i++) {
        int key = vec.at(i);  // i: 1 to (N - 1) // most left
        int j = i - 1;  // done-index

        while (j >= 0 && key < vec.at(j)) {  // 左（操作済み）のほうが大きかったら入れ替える
            vec.at(j + 1) = vec.at(j);
            j--;
        }
        vec.at(j + 1) = key;  // 最後のマイナス分1を足す
        printVec(vec);
    }
}

int main() {
    // input
    int N;
    cin >> N;
    vector<int> vec(N);
    REP(i, N) cin >> vec.at(i);
    
    // output
    insertionSort(vec);
    
    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}



int main() {
	//int a, b, c,d; cin >> a>>b>>c;
	//string s,t,u; cin >> s>>t>>u;
	vector<int> n(3);
	for (int i = 0; i < 3; i++) {
		cin >> n[i];
	}
	ssort(n);
	eerase(n);
	cout << n.size();

	cout << endl;
	return 0;
}


Measured memory_bytes: 256
program abc
	implicit none
	integer :: n
	integer :: an(32)=1 

	an(4) = 2
    an(6) = 2
    an(8) = 5
    an(9) = 2
    an(10) = 2
    an(12) = 5
    an(14) = 2
    an(16) = 14
    an(18) = 5
    an(20) = 5
    an(21) = 2
	an(22) = 2
    an(24) = 15
    an(25) = 2
    an(26) = 2
    an(27) = 5
    an(28) = 4
    an(30) = 4
    an(32) = 51
    
	read(*,*) n
	
	write(*,*) an(n)
    
end program abc

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

#define MAX 500000

int N, K;
int a[MAX];

int main() {
	cin >> N >> K;
	for( int i = 0; i < N; i++ ) {
		cin >> a[i];
	}

	sort( a, a + N );
	int t = 0;
	int ans = N;
	for( int i = N - 1; i >= 0; i-- ) {
		if( t + a[i] < K ) {
			t += a[i];
		}
		else {
			ans = min( ans, i );
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    vector<int> dp(N, 0);
    dp[1] = abs(h[1] - h[0]);
    for (int i = 0; i < N - 1; i++) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        if (i + 2 < N) dp[i + 2] = dp[i] + abs(h[i + 2] - h[i]);
    }
    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true){
      int a = sc.nextInt();
      int b = sc.nextInt();
      if ( a == 0 && b == 0){ break; }
      for (int i = 1; i <= a; i++) {
        for (int j = 1; j <= b; j++){
          if (i == 1 || i == a){
            System.out.print("#");
          } else{
            if (j == 1 || j == b) {
              System.out.print("#");
            } else {
              System.out.print(".");
            }
          }
        }
        System.out.print("\n");
      }
      System.out.print("\n");
    }
  }
}



Measured memory_bytes: 37064
#include<cstdio>
#include<cstdlib>
using namespace std;

const int maxn = 2e5;

int T,n,t[maxn + 5];

int main(){
	scanf("%d %d", &n, &T);
	for(int i = 1; i <= n; i++){
		scanf("%d", &t[i]);
	}
	int pos = 0;
	int X = 0;
	if(n >= 3){
		for(int i = 2; i <= n; i++){
			pos = t[i - 1] + T;
			if(t[i] <= pos){
				X = X + t[i] - t[i - 1];
			}
			else X = T + X;
		}
		X = X + T;
	}
	else if(n == 1){
		X = T;
	}
	else if(n == 2){
		if(t[2] <= T) X = t[2] + T;
		else X = 2 * T;
	}
	printf("%d\n", X);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i *= 2)
	{
		ans = i;
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
$total = array_sum($a);
$ans = abs($total - 2 * $a[0]);
$x = 0;
for ($i = 0; $i < $n-1; $i++)
{
    $x += $a[$i];
    $ans = min($ans, abs($total - 2*$x));
}
echo $ans;

Measured memory_bytes: 20980
//Tran Thuy Duong
#include <bits/stdc++.h>
#define task ""
#define maxn 100005
#define maxs 400005
#define MOD 1000000007
#define pii pair<int, int>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define reset(x) memset(x, 0, sizeof x)

using namespace std;
typedef long long ll;
const ll MM = 1ll * MOD * MOD;

int n, q, dem = 0;
string s[maxn];
int Child[maxs][26], dd[maxs], val[maxs];

void Add(string st, int id)
{
    int node = 0;
    for (int c, i=0; i<st.length(); i++)
    {
        c = st[i] - 'a';
        if (Child[node][c] == 0) Child[node][c] = ++dem;
        node = Child[node][c];
        val[node]++;
    }
    dd[node] = id;
}

int tmp[26][26], sstr = 0, sub[maxn];
int cnt[maxn][26][26];
void DFS(int u)
{
    int node;
    for (int c=0; c<='z'-'a'; c++)
    {
        if (Child[u][c] == 0) continue;
        node = Child[u][c];
        for (int x=0; x<='z'-'a'; x++)
            tmp[c][x] += val[Child[u][x]];
        if (dd[node])
        {
            int id = dd[node];
            sub[id] = sstr;
            for (int x=0; x<='z'-'a'; x++)
                for (int y=0; y<='z'-'a'; y++)
                    cnt[id][x][y] = tmp[x][y];
        }
        sstr += (dd[node] != 0);
        DFS(node);
        sstr -= (dd[node] != 0);
        for (int x=0; x<='z'-'a'; x++)
            tmp[c][x] -= val[Child[u][x]];
    }
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//freopen(task".INP", "r", stdin);
	//freopen(task".OUT", "w", stdout);
    cin >> n;
    for (int i=1; i<=n; i++)
    {
        cin >> s[i];
        Add(s[i], i);
    }
    DFS(0);

    int k, ans, x, y;
    string p;
    cin >> q;
    while (q--)
    {
        cin >> k >> p;
        ans = 0;
        for (int i=0; i<p.length(); i++)
            for (int j=0; j<i; j++)
            {
                x = p[i] - 'a'; y = p[j] - 'a';
                ans += cnt[k][x][y];
            }
        cout << ans + sub[k] + 1 << "\n";
    }
	return 0;
}


Measured memory_bytes: 284800
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > A(N);
  std::map<int, int> mp;
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
    mp[A[i]]++;
  }
  int size = mp.size();
  if ((N-size)%2==0){
    std::cout << size << std::endl;
  } else {
    std::cout << size-1 << std::endl;
  }
  return 0;
}


Measured memory_bytes: 5376
process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.on('SIGINT', function(){
    input_stdin_array = input_stdin.split("\n");
    main();
    process.exit();
});

process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");
    main();    
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

/////////////// ignore above this line ////////////////////

function reverse(cad){
	var ret='';
	for (var i = cad.length-1; i>=0; i--)
		ret+=cad[i];
	return ret;
}

function main() {
	var s = readLine();
	/*eliminating \r , this is only for windows*/
	/*s = s.substr(0,s.length-1);*/
	
	s = reverse(s);
	while (s.length > 0){
		t=s.substr(0,5);
		r=s.substr(0,6);
		y=s.substr(0,7);
		if (t.localeCompare('maerd') == 0){
			s = s.substr(5);
		} else if (t.localeCompare('esare') == 0){
			s = s.substr(5);
		} else if (r.localeCompare('resare') == 0){
			s = s.substr(6);
		} else if (y.localeCompare('remaerd') == 0){
			s = s.substr(7);
		} else {
			break;
		}
	}
	
	if (s.length == 0){
		console.log("YES");
	} else {
		console.log("NO");
	}
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int a, b;
  cin >> a >> b;

  if (a + b == 15) {
    cout << "+" << endl;
  } else if (a * b == 15) {
    cout << "*" << endl;
  } else {
    cout << "x" << endl;
  }

  return 0;
}


Measured memory_bytes: 256