akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;

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

    int m,k;cin >> m >> k;
    
    if(k >= (1 << m)){
        cout << -1 << '\n';
        return 0;
    }

    if(m == 0){
        cout << "0 0" << '\n';
        return 0;
    }
    if(m == 1){
        if(k == 0)cout << "1 1 0 0" << '\n';
        else cout << -1 << '\n';
        return 0;
    }else{
        for(int i = 0;i < (1 << m);i++){
            if(i != k)cout << i << ' ';
        }
        cout << k << ' ';
        for(int i = (1 << m) - 1;i >= 0;i--){
            if(i != k)cout << i << ' ';
        }
        cout << k << '\n';
    }
}

Measured memory_bytes: 3576
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
     String[] nyu=sc.nextLine().split(" ");

  //   String nyu=sc.nextLine();
int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

int res=A*B;
if(res%2==0){

System.out.println("Even");
}else{
System.out.println("Odd");

}




	}
}

Measured memory_bytes: 21588
#include<stdio.h>

int main() {

  int i,j,k,v,N,A[100];

  
  scanf("%d",&N);

  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }

  for(i=0; i<N; i++){
    k = i;
    v = A[i];
    j = i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(k=0; k<N; k++){
      printf("%d",A[k]);
      if(k==N-1){
	printf("\n");
	break;
      }
      printf(" ");
    }
  }

  return 0;
}

	

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
long long n, s;
int main() {
	cin >> n >> s;
	for (long long b = 2; b*b <= n; ++ b) {
		long long t = 0;
		long long x = n;
		while (x > 0) { t += x % b; x /= b; }
		if (t == s) {
			cout << b << endl;
			return 0;
		}
	}
	long long r = 1LL<<60;
	if (n == s) {
		r = n + 1;
	}
	if (n >= s) {
		long long ns = n - s;
		for (long long a = 1; a*a <= ns; ++ a) {
			if (ns % a == 0) {
				long long b = ns / a + 1;
				if (n / b < b && n / b + n % b == s) {
					r = min(r, ns / a + 1);
				}
			}
		}
	}
	if (r != 1LL<<60) {
		cout << r << endl;
		return 0;
	}
	cout << -1 << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) VL vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
typedef struct{ll to;ll cost;} Graphs;
typedef V<V<Graphs>> AdjList;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
   
  int n;
  cin>>n;
  cinv(n,d);
  SORT(d);
  if(n&1){out(0);return 0;}
  int center=n/2;
  int ans=d[center]-d[center-1];
  out(ans);
  


  return 0;
}


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


ll prime[1000010] ;
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll n , ans = 0 ;
     cin >> n ;
    for (ll i = 1 ; i <=n; i++)
    {
        for (ll j = i ; j <=n; j += i)
        {
               prime[j]++;
        }
    }
     for(ll i = 1 ; i < n ; i++)
     {
          ans += prime[i] ;
          // cout << prime[i] << endl ;
     }
     cout << ans << endl ;
}

Measured memory_bytes: 11320
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define trav(x, v) for(auto &x : v)
#define all(v) v.begin(),v.end()
#define sz(v) int(v.size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int inf = 1e9;

int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n;
	cin >> n;

	vector<pii> lr(n);
	trav(pa, lr) cin >> pa.first >> pa.second;

	vector<pii> pnx(n+1), snx(n+1);
	pnx[0] = snx[n] = {1e9, 0};
	rep(i,0,n){
		pnx[i+1] = {
			min( pnx[i].first, lr[i].second),
			max( pnx[i].second, lr[i].first)
		};
	}
	rrep(i,0,n){
		snx[i] = {
			min( snx[i+1].first, lr[i].second),
			max( snx[i+1].second, lr[i].first)
		};
	}
	int ans = 0;
	rep(i,0,n){
		int res = min(snx[i+1].first, pnx[i].first) - max(snx[i+1].second, pnx[i].second) + 1;
		ans = max(ans, lr[i].second - lr[i].first + 1 + max(0, res));
	}
	vi ps(n);
	iota(all(ps), 0);
	sort(all(ps), [&](int i, int j){return lr[i] < lr[j];});

	vi is;
	trav(i, ps){
		while(!is.empty() && lr[is.back()].second >= lr[i].second) is.pop_back();
		is.push_back(i);
	}

	int m = sz(is);
	vector<pii> pp(m+1), ss(m+1);
	pp[0] = ss[m] = {1e9, 0};
	rep(i,0,m){
		pp[i+1] = {
			min( pp[i].first, lr[is[i]].second),
			max( pp[i].second, lr[is[i]].first)
		};
	}
	rrep(i,0,m){
		ss[i] = {
			min( ss[i+1].first, lr[is[i]].second),
			max( ss[i+1].second, lr[is[i]].first)
		};
	}
	rep(i,1,m){
		int aa = pp[i].first-pp[i].second+1;
		int bb = ss[i].first-ss[i].second+1;
		ans = max(ans, aa+bb );
	}
	cout << ans << endl;
}


Measured memory_bytes: 5112
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int gcd = a[0];
        for (int i = 0; i < n; i++) {
            gcd = gcd(gcd, a[i]);
        }
        Arrays.sort(a);
        if (k <= a[n - 1] && k % gcd == 0) {
            System.out.println("POSSIBLE");
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }

    static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }
}

Measured memory_bytes: 48868
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5 + 5;

int n;
vector <pii> v;

multiset <int> s;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        int x; cin >> x;
        v.push_back(MP(x, i));
    }
    s.insert(0), s.insert(0);
    s.insert(n + 1), s.insert(n + 1);
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    ll ans = 0;
    for(auto i : v) {
        int num = i.fi, p = i.se;
        auto it = s.lower_bound(p);
        int R1 = *it++;
        int R2 = *it--;
        --it;
        int L1 = *it--;
        int L2 = *it;
        if(L1) ans += 1ll * num * (L1 - L2) * (R1 - p);
        if(R1 <= n) ans += 1ll * num * (p - L1) * (R2 - R1);
        s.insert(p);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5748
#include <stdio.h>
#define MAX 100005
#define NIL -1

typedef struct Node {
  int p;
  int l;
  int r;
}N;

N T[MAX];
int D[MAX],H[MAX];


int setHei(int u){
  int h1=0,h2=0;
  if(T[u].l!=NIL)h1=setHei(T[u].l)+1;
  if(T[u].r!=NIL)h2=setHei(T[u].r)+1;
  return H[u]=(h1>h2?h1:h2);
}


void setDep(int u,int p){
  if(u==NIL)return;
  D[u]=p;
  setDep(T[u].r,p+1);
  setDep(T[u].l,p+1);
}

int getSib(int u){
  if(T[u].p==NIL)return NIL;
  if(T[T[u].p].l!=u&&T[T[u].p].l!=NIL)
    return T[T[u].p].l;
 if(T[T[u].p].r!=u&&T[T[u].p].r!=NIL)
    return T[T[u].p].r;
  return NIL;
}

int main(){
  int i,j,n,k,l,r,root=0,deg=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].p=NIL;

  for(i=0;i<n;i++){
scanf("%d%d%d",&k,&l,&r);

    T[k].l=l;
    T[k].r=r;
    if(l!=NIL)T[l].p=k;
    if(r!=NIL)T[r].p=k;

  }
  for(i=0;i<n;i++)
    if(T[i].p==NIL)root=i;

  setDep(root,0);
  setHei(root);

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, ",i,T[i].p,getSib(i));
if(T[i].l!=NIL)deg++;
    if(T[i].r!=NIL)deg++;

    printf("degree = %d, depth = %d, height = %d, ",deg,D[i],H[i]);

    if(T[i].p==NIL)printf("root");
    else if(T[i].l==NIL&&T[i].r==NIL)printf("leaf");
    else printf("internal node");

    printf("\n");
    deg=0;
  }

  return 0;
}



Measured memory_bytes: 2104
A, B = map(int, input().split())
res = B - A
res = res % 4
if A % 2 == 0:
    ans = B
    for i in range(1, res+1):
        ans = ans ^ (B - i)
    print(ans)
    exit()
else:
    ans = A
    for i in range(0, res):
        ans = ans ^ (B - i)
    print(ans)
    exit()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
 #include <iostream>
 using namespace std;
 int main(){
   int A;
  cin >> A;
   if(A == 3 || A == 5 || A == 7){
     cout <<"YES" << endl;
 }
 else{
   cout << "NO" << endl;
 
 }
 }
  

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

int main() {
	int N, K;
	cin >> N >> K;
	int value[220000] = {};
	int valueSize = 0;
	for (int i = 0; i < N; ++i) {
		int A;
		cin >> A;
		value[A]++;
		if (value[A] == 1) valueSize++;
	}

	sort(value, value + 220000);

	int i = 220000 - valueSize;
	int res = 0;
	while (K < valueSize) {
		res += value[i];
		++i;
		--valueSize;
	}
	
	cout << res << endl;
}

Measured memory_bytes: 4044
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <numeric>

int main() {
  size_t n;
  scanf("%zu", &n);
  char buf[16384];
  scanf("%s", buf);
  std::string s = buf;

  for (size_t i = 0; i < s.length(); ++i) {
    s[i] += n;
    if (s[i] > 'Z') s[i] -= 26;
  }
  printf("%s\n", s.c_str());
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int s;
    cin >> s;
    cout << 48-s;
}

Measured memory_bytes: 256
#include<stdio.h>
char n[20][20],m[20][20];
int i,j,a;
void s(int x,int y){
    n[x][y]='0';
    if(n[x+1][y]=='1')s(x+1,y);
    if(n[x][y+1]=='1')s(x,y+1);
    if(n[x-1][y]=='1')s(x-1,y);
    if(n[x][y-1]=='1')s(x,y-1);
}
int main(){
    while(scanf("%s",n[0])!=EOF){
        a=0;
        for(i=1;i<12;i++)scanf("%s",n[i]);
        for(i=0;i<12;i++){
            for(j=0;j<12;j++){
                if(n[i][j]=='1')s(i,j),a++;
            }
        }
        printf("%d\n",a);
    }    
    return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}


ll chmin(ll &a, ll b){ return a = min(a, b); }
int main(){
	int V;
	ll E;
	cin >> V >> E;
	typedef pair<int ,ll> P;
	vector<vector<P>> vec(V, vector<P>());//vec[i][j].first: 頂点iと繋がる頂点j, second: iとjを結ぶ辺の長さ
	const ll INF = 1001001001001001;
	vector<vector<ll>> dist(V, vector<ll>(V, INF));
	for(ll i=0; i<E; i++){
		int s, t, d;
		cin >> s >> t >> d;
		//int bin = 1<<t;//tを2進表記する
		vec[s].emplace_back(t, d);
		dist[s][t] = d;
	}
	
	// dp[state][town]: 現在頂点townにいて，状態stateになりうる最小コスト
	vector<vector<ll>> dp_((1<<V), vector<ll>(V, INF));
	
	ll ans = INF;
	for(int begin=0; begin<V; begin++){
		vector<vector<ll>> dp = dp_;
		dp[1<<begin][begin] = 0;
		for(int s=0; s<(1<<V); s++){
			for(int town=0; town<V; town++){
				//cout << " begin: " << begin << " s: " << s << " town: " << town << endl;
				if(dp[s][town] == INF) continue;
				for(int k=0; k<vec[town].size(); k++){
					int n_town = vec[town][k].first;
					if((s>>n_town) % 2 == 1) continue; //すでに訪れている場合はcontinue
					int n_s = s | (1 << n_town);
					int cost = dp[s][town] + vec[town][k].second;	
					chmin(dp[n_s][n_town], cost);
				}
			}
		}
		for(int i=0; i<V; i++){
			chmin(ans, dp[(1<<V)-1][i] + dist[i][begin]);
		}
	}
	if(ans == INF) ans = -1;
	cout << ans << endl;
}




Measured memory_bytes: 12628
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0,i;
	long long h,w,a,b;
	scanf("%d%lld%lld",&n,&h,&w);
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a,&b);
		if(h<=a&&w<=b)
			ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
/*
** 线性搜索
*/

# include <cstdio>

static const int maxn = 10000 + 5;

// 根据书上的技巧，加入数组标记，节省了for循环的每次比较运算
int line_search(int s[], int n, int t) {
	int i = 0; 
	s[n] = t;
	while (s[i] != t) i++;
	if (i != n)
		return 1;
	else
		return 0;
}

int main() {
	// freopen("infile", "r", stdin);
	// freopen("outfile", "w", stdout);
	int n, q, s[maxn], t;
	while (scanf("%d", &n) != EOF) {
		for (int i = 0; i < n; i++) scanf("%d", &s[i]);
		scanf("%d", &q);
		int ans = 0;
		for (int i = 0; i < q; i++) {
			scanf("%d", &t);
			ans += line_search(s, n, t);
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2756
#include<cstdio>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;

inline char nc(){ return getchar();static char buf[100000] , *p1,*p2; return p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,100000,stdin),p1 == p2) ? EOF : *p1++;}
template<class T>inline void rd(T & x){ x = 0;char ch = nc(); for(;!isdigit(ch);ch = nc()); for(;isdigit(ch);ch = nc()) x = x * 10 - 48 + ch;}

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr,__VA_ARGS__)

typedef pair<int,int> pii;

const int maxn = 4000 + 5;

int n,m,p,ans,s[maxn] , t[maxn] , deg[maxn] , dep[maxn] , par[maxn] , dis[maxn][maxn] , vis[maxn][maxn];
vector<int> adj[maxn] , pth[maxn];
bool del[maxn] , ers[maxn] ,rev[maxn];
vector<pii> bel[maxn];


void dfs(int u){
	for(int i = 0;i < adj[u].size();i++){
		int v = adj[u][i];
		if(v == par[u]) continue;
		par[v] = u;dep[v] = dep[u] + 1; dfs(v);
	}
} 

int Dis(int x,int y){
	if(x == y) return 0;
	if(dis[x][y]) return dis[x][y];
	return dep[x] >= dep[y] ? (dis[x][y] = Dis(par[x],y) + 1) : (dis[x][y] = Dis(x,par[y]) + 1);
}


inline void Add(int i,int x,int y){
	if(x == y) return ;
	s[i] = x;  t[i] = y;
	vector<int > l,r;
	int u = x,v = y;
	while(u != v){
		if(dep[u] >= dep[v]) l.pb(u) , u = par[u];
		else r.pb(v) , v = par[v];
	}
	reverse(r.begin() , r.end());
	for(int j = 0;j < l.size();j++) pth[i].pb(l[j]);
	pth[i].pb(u);
	for(int j = 0;j < r.size();j++) pth[i].pb(r[j]);
	for(int j = 0;j < pth[i].size();j++){
		bel[pth[i][j]].pb(mp(i,j));
		if(j < pth[i].size() - 1){
			int u = pth[i][j] , v = pth[i][j + 1];
			if(u > v) swap(u,v);
			if(vis[u][v] < 2) ++ vis[u][v] , ++ans;
		}
	}
}


inline bool check(int i,int j,int x){ return (j < pth[i].size() - 1 && pth[i][j + 1] == x) || (j && pth[i][j - 1] == x);}
inline int ad(int i,int j,int x) { return j < pth[i].size() - 1 && pth[i][j + 1] == x ? pth[i].back()  : pth[i][0];}
inline void work(int i,int x,int y){
	if(rev[i]) swap(x,y);
	if(Dis(s[i],x) + Dis(y,t[i]) + 1 != Dis(s[i],t[i])) rev[i] ^= 1;
}

void solve(){
	int x = 0;
	for(int i = 1;i <= n;i++) if(!ers[i] && deg[i] == 1)  x = i;
	if(!x) return;
	int y = 0;
	for(int i = 0;i < adj[x].size();i++) if(!ers[adj[x][i]]) y = adj[x][i];
	ers[x] = 1 , -- deg[y];
	pii a = mp(0,0) , b = mp(0,0);
	for(int i = 0;i < bel[x].size();i++){
		pii p = bel[x][i];
		if(!del[p.X] && check(p.X,p.Y,y)){
			if(a.X) b = p;
			else a = p;	
		}
	}
	if(!b.X) solve();
	else {
		work(a.X,y,x) ; work(b.X,x,y);
		Add(++p,ad(a.X,a.Y,y) , ad(b.X,b.Y,y));
		del[a.X] = del[b.X] = 1;
		int q = p; solve();
		rev[a.X] ^= rev[q] ; rev[b.X] ^= rev[q];
	}
}



int main(){
	rd(n); rd(m);
	for(int i = 1,u,v;i < n;i++){
		rd(u); rd(v);
		adj[u].pb(v) ; adj[v].pb(u);
		++deg[u] ; ++deg[v];
	}
	dfs(1);
	for(int i = 1,x,y;i <= m;i++){
		rd(x); rd(y);
		Add(++p,x,y);
	}
	printf("%d\n",ans);
	solve();
	for(int i = 1;i <= m;i++){
		if(rev[i]) swap(s[i],t[i]);
		printf("%d %d\n",s[i],t[i]);
	}
	return 0;
}


Measured memory_bytes: 93952
#include <iostream>
#include <iomanip>
using namespace std;
 
int main() {
  int H,W;

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

  return 0;
}




Measured memory_bytes: 3036
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int a, b;
	int res = -20000;

	scanf("%d %d", &a, &b);

	if (a + b > res)
	{
		res = a + b;
	}
	if (a - b > res)
	{
		res = a - b;
	}

	if (a * b > res)
	{
		res = a * b;
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

struct Point{
    int x,y,z;
};

Point READ(){
    int x,y,z;
    cin >>x >>y >>z;
    return {x,y,z};
}

int n;
Point s,g;
int ans;

Point rot_x(Point p){
    return {p.x, n-1-p.z, p.y};
}

Point rot_y(Point p){
    return {p.z, p.y, n-1-p.x};
}

Point rot_z(Point p){
    return {n-1-p.y, p.x, p.z};
}

int dist(Point p, Point q){
    return abs(p.x-q.x) + abs(p.y-q.y) + abs(p.z-q.z);
}

bool IN(Point p){
    return 0<=p.x && p.x<n && 0<=p.y && p.y<n && 0<=p.z && p.z<n;
}

const int dx[6]={1,-1,0,0,0,0};
const int dy[6]={0,0,1,-1,0,0};
const int dz[6]={0,0,0,0,1,-1};
const int add[3]={1,2,1};

void dfs(int d, Point p, int cost){
    ans = min(ans, dist(p,g)+cost);
    if(d==6) return;

    Point np;
    rep(i,6){
        np = p;
        np.x += dx[i];
        np.y += dy[i];
        np.z += dz[i];
        if(IN(np)) dfs(d+1, np, cost+1);
    }

    if(p.x != g.x){
        np = p;
        rep(i,3){
            np = rot_x(np);
            dfs(d+1, np, cost+add[i]);
        }
    }

    if(p.y != g.y){
        np = p;
        rep(i,3){
            np = rot_y(np);
            dfs(d+1, np, cost+add[i]);
        }
    }

    if(p.z != g.z){
        np = p;
        rep(i,3){
            np = rot_z(np);
            dfs(d+1, np, cost+add[i]);
        }
    }
}

int main(){
    cin >>n;
    s = READ();
    g = READ();

    ans = dist(s,g);
    dfs(0,s,0);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3128
#include<iostream>
using namespace std;
int main(){

while(1){
int H,W;
cin>>H>>W;   
    
if(W==0&&H==0) break;
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cout<<"#";
}
cout<<endl;
}
cout<<endl;
}
return 0;
}


Measured memory_bytes: 3088
#include<iostream>
using namespace std;
int main()
{
    int s,k,ans=0;
    cin>>k>>s;
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<=k;j++) if(s-j-i>=0&&s-i-j<=k) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
  H, W = map(int, input().split(" "))
  Ch, Cw = map(int, input().split(" "))
  wiz_pos = [Ch-1, Cw-1]
  Dh, Dw = map(int, input().split(" "))
  goal_pos = [Dh-1, Dw-1]

  cell_or_wall = []
  count = 0
  for _ in range(H):
    cell_or_wall.append([x == "." for x in list(input())])

  cost_of_cells = [[None] * W for i in range(H)]
  next_cells = set([tuple(wiz_pos)])
  cells_of_wall_side = []

  cost = 0
  
  while len(next_cells) != 0:
    temp_next_cells = set()
    for target_cell in next_cells:
      cost_of_cells[target_cell[0]][target_cell[1]] = cost
      # 周辺の壁じゃないセルを確認する。
      adjacents = [
        [target_cell[0] - 1, target_cell[1]],
        [target_cell[0] + 1, target_cell[1]],
        [target_cell[0], target_cell[1] - 1],
        [target_cell[0], target_cell[1] + 1]
      ]

      for adjacent in adjacents:
        h = adjacent[0]
        w = adjacent[1]
        if h < 0 or h >= H:
          continue
        if w < 0 or w >= W:
          continue

        # print("[h, w] : {}".format([h, w]), "cell_or_wall[h][w] : {}".format(cell_or_wall[h][w]))
        if not cell_or_wall[h][w]:
          # 壁際だった場合は壁際セルリストに追加する。
          if len(cells_of_wall_side) == 0:
            cells_of_wall_side.append(target_cell)
          elif cells_of_wall_side[-1][0] != target_cell[0] or cells_of_wall_side[-1][1] != target_cell[1]:
            cells_of_wall_side.append(target_cell)
          # else: 
          #   print("cells_of_wall_side : {}".format(cells_of_wall_side), "target_cell : {}".format(target_cell))
        elif cost_of_cells[h][w] is None:
          temp_next_cells.add((h, w))
    # print(target_cell)
    # print(temp_next_cells)
    next_cells = temp_next_cells

    if len(next_cells) != 0:
      continue

    # 壁際のセルを確認して、ワープで飛べないか確認する。
    # print(cells_of_wall_side)
    for target_cell in cells_of_wall_side:
      # 飛べるなら next_cells に追加する
      for h in range(target_cell[0] - 2, target_cell[0] + 3):
        if h < 0 or h >= H:
          continue
        for w in range(target_cell[1] - 2, target_cell[1] + 3):
          if w < 0 or w >= W:
            continue
          if cell_or_wall[h][w] and cost_of_cells[h][w] is None:
            next_cells.add((h, w))
    cells_of_wall_side = []
    cost += 1
  
  # for cost_line in cost_of_cells:
  #   print("")
  #   for cell in cost_line:
  #     if cell is None:
  #       print("*", end="")
  #     else:
  #       print(cell, end="")
  # print("")

  if cost_of_cells[goal_pos[0]][goal_pos[1]] is None:
    print(-1)
  else:
    print(cost_of_cells[goal_pos[0]][goal_pos[1]])

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 115352
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    char[] sChar = s.toCharArray();
    if (sChar[sChar.length - 1] == 's') {
      s = s + "es";
    } else {
      s = s + "s";
    }
    System.out.println(s);
    sc.close();
  }
}

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

int main() {
  int n, b, f, r, v, a[4][3][10] = {0};                                                                                                                       
  cin >> n;
  for (int i = 0; i < n; i++) {
    while (n--) {                                                                                                                                             
      cin >> b >> f >> r >> v;                                                                                                                                
      a[b - 1][f - 1][r - 1] += v;
    }                                                                                                                                                         
  }
  for (int i = 0; i < 4; i++) {
    if (i) {
      for (int j = 0; j < 20; j++)
        cout << '#';
      cout << endl;
    }                                                                                                                                                         
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << ' ' << a[i][j][k];
      }
      cout << endl;
    }                                                                                                                                                         
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define sz 10010
#define MOD 1000000007
#define ll long long

inline ll add(ll a, ll b)
{
    a = ((a % MOD) + MOD) % MOD;
    b = ((b % MOD) + MOD) % MOD;
    return (a + b) % MOD;
}

inline ll sub(ll a, ll b)
{
    a = ((a % MOD) + MOD) % MOD;
    b = ((b % MOD) + MOD) % MOD;
    return ((a - b) % MOD + MOD) % MOD;
}

ll dp[sz][2][105];
string s;
int D, N;

ll f(int idx, bool tight, int val)
{
    if (idx == N)
        return (val == 0);
    ll &ans = dp[idx][tight][val];
    if (ans != -1)
        return ans;
    ans = 0;
    if (tight)
    {
        int dig = s[idx] - '0';
        for (int i = 0; i < dig; i++)
            ans = add(ans, f(idx + 1, 0, (val - i + D) % D));
        ans = add(ans, f(idx + 1, 1, (val - dig + D) % D));
    }
    else
    {
        for (int i = 0; i <= 9; i++)
            ans = add(ans, f(idx + 1, 0, (val - i + D) % D));
    }
    return ans;
}

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

    memset(dp, -1, sizeof(dp));

    cin >> s >> D;

    N = s.length();

    cout << sub(f(0, 1, 0), 1);



    return 0;
}

Measured memory_bytes: 17536
#include <stdio.h>
#include <math.h>

double longHand(int h, int m);
double shortHand(int h, int m);

int main(void){
  double al,as;
  int n,h,m;
  double d;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d:%d",&h,&m);
    al=longHand(h,m);
    as=shortHand(h,m);
    d=fabs(as-al);
    if(d>180){
      d=360-d;
    }

    if(d<30){
      printf("alert\n");
    }
    else if(d>=90){
      printf("safe\n");
    }
    else{
      printf("warning\n");
    }
  }
  return 0;
}

double longHand(int h, int m){
  return 360.0*m/60;
}

double shortHand(int h, int m){
  return 360.0*h/12+30.0*m/60;
}



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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    double ans=0;
    for(int i=0; i<n; i++){
        ans += (double)1/a[i];
    }
    ans  = 1/ans;
    cout << setprecision(10) << ans << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n, m;
  while(cin >> n >> m) {
    int c[n], v[n], d[n], l[n];
    REP(i,n) {
      cin.ignore();
      string line;
      getline(cin, line);
      cin >> c[i] >> v[i] >> d[i] >> l[i];
    } 
    int dpv[n+1][m+1], dpd[n+1][m+1], dpl[n+1][m+1];
    memset(dpv,0,sizeof(dpv));
    memset(dpd,0,sizeof(dpd));
    memset(dpl,0,sizeof(dpl));
    REP(i,n) {
      REP(j,m+1) {
        if (j<c[i]) {
          dpv[i+1][j] = dpv[i][j];
          dpd[i+1][j] = dpd[i][j];
          dpl[i+1][j] = dpl[i][j];
        } else {
          dpv[i+1][j] = max(dpv[i][j], dpv[i+1][j-c[i]] + v[i]);
          dpd[i+1][j] = max(dpd[i][j], dpd[i+1][j-c[i]] + d[i]);
          dpl[i+1][j] = max(dpl[i][j], dpl[i+1][j-c[i]] + l[i]);
        }
      }
    }
    int tmp = max(dpv[n][m], dpd[n][m]);
    cout << max(tmp, dpl[n][m]) << endl;
  }
}

Measured memory_bytes: 1996
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){

  int a,b,c;
  double s,l,h,d,e;
  
  cin >>a>>b>>c;

  d=c*M_PI/180;
  s=((double)1/(double)2)*a*b*sin(d);
  l=a*a+b*b-2*a*b*cos(d);
  h=b*sin(d);
  e=sqrt(l)+a+b;

  printf("%0.8f\n%0.8f\n%0.8f\n",s,e,h);

  return 0;

}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <functional>
#include <cassert>
using namespace std;

template <class T> class RAQRSQ {
	int n;
	T init;
	vector<T> node, lazy;
	static int ceil2(int n) {
		int m = 1;
		while (m < n) m *= 2;
		return m;
	}
	void eval(int k, int l, int r) {
		if (lazy[k] != 0) {
			node[k] += lazy[k];
			if (r - l > 1) {
				lazy[2 * k + 0] += lazy[k] / 2;
				lazy[2 * k + 1] += lazy[k] / 2;
			}
			lazy[k] = 0;
		}
	}
	void add_impl(int a, int b, const T& x, int k, int l, int r) {
		eval(k, l, r);
		if (b <= l || r <= a) {
			return;
		} else if (a <= l && r <= b) {
			lazy[k] += x * (r - l);
			eval(k, l, r);
		} else {
			add_impl(a, b, x, 2 * k + 0, l, (l + r) / 2);
			add_impl(a, b, x, 2 * k + 1, (l + r) / 2, r);
			node[k] = node[2 * k + 0] + node[2 * k + 1];
		}
	}
	T query_impl(int a, int b, int k, int l, int r) {
		if (b <= l || r <= a) {
			return init;
		}
		eval(k, l, r);
		if (a <= l && r <= b) {
			return node[k];
		} else {
			auto vl = query_impl(a, b, 2 * k + 0, l, (l + r) / 2);
			auto vr = query_impl(a, b, 2 * k + 1, (l + r) / 2, r);
			return vl + vr;
		}
	}

public:
	RAQRSQ(const vector<T>& vec, const T& _init) : init(_init) {
		build(vec);
	}
	void build(const vector<T>& v) {
		n = ceil2(v.size());
		node.assign(n * 2, init);
		lazy.assign(n * 2, 0);
		for (size_t i = 0; i < v.size(); ++i) {
			node[i + n] = v[i];
		}
		for (size_t i = n - 1; i > 0; --i) {
			node[i] = node[i * 2 + 0] + node[i * 2 + 1];
		}
	}
	void add(int l, int r, const T& x) {
		add_impl(l, r, x, 1, 0, n);
	}
	T operator[](int i) {
		assert(0 <= i && i < n);
		return operator()(i, i + 1);
	}
	T operator()(int l, int r) {
		assert(0 <= l && l < r && r <= n);
		return query_impl(l, r, 1, 0, n);
	}
	vector<T> to_a() {
		vector<T> res(n);
		for (int i = 0; i < n; ++i) {
			res[i] = operator[](i);
		}
		return res;
	}
};

using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, q;
	cin >> n >> q;
	RAQRSQ<ll> seg(vector<ll>(n, 0), 0);
	for (int i = 0; i < q; ++i) {
		int com;
		cin >> com;
		if (com == 0) {
			int s, t;
			ll x;
			cin >> s >> t >> x;
			seg.add(s - 1, t, x);
		} else if (com == 1) {
			int s, t;
			cin >> s >> t;
			cout << seg(s - 1, t) << '\n';
		}
	}
}


Measured memory_bytes: 7756
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    string s;
    cin >> s;
    deque<char> dq;
    for(int i=0;i<s.size();i++) dq.push_back(s[i]);
    int q;
    cin >> q;
    bool rev=false;
    for(int i=0;i<q;i++){
        int t;
        cin >> t;
        if(t==1){
            if(rev) rev=false;
            else rev=true;
        }else{
            int f;
            char c;
            cin >> f >> c;
            if(f==1){
                if(rev) dq.push_back(c);
                else dq.push_front(c);
            }else{
                if(rev) dq.push_front(c);
                else dq.push_back(c);
            }
        }
    }
    if(rev){
        for(int i=dq.size()-1;i>=0;i--){
            cout << dq[i];
        }
        cout << endl;
    }else{
        for(int i=0;i<dq.size();i++){
            cout << dq[i];
        }
        cout << endl;
    }
}


Measured memory_bytes: 896
import java.util.Scanner;

public interface Main {
	static int a = 1;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.printf("%d %d\n", a*b, (a+b)*2);
	}
}



Measured memory_bytes: 25904
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const int INF = 10000;

int main(){
	double x,y,s;
	while(cin>>x>>y>>s){
		if(x==0&&y==0&&s==0)break;
		x+=100;
		y+=100;
		int sum=0;
		FOR(i,1,s+100)FOR(j,1,s+100){
			if(floor(i*x/100)+floor(j*x/100)==s){
				int tmp=floor(i*y/100)+floor(j*y/100);
				sum=max(sum,tmp);
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

int main(){
    string s;
    string t;
    cin>>s>>t;
    if(t.substr(0,s.length())==s) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
	int n; scanf("%d", &n);
	vector<ll> a(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	ll ans = 0;
	for(ll bit = 0; bit <= 60; bit++){
		ll c0 = 0, c1 = 0;
		for(int i = 0; i < n; i++){
			if((a[i] >> bit) & 1) c1++;
			else c0++;
		}
		(ans += ((c0*c1)%MOD) * ((1LL << bit)%MOD)) %= MOD;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 5652
n,m=map(int,input().split())
lis=[[0 for i in range(n)] for _ in range(n)]
for i in range(m):
	x,y=map(int,input().split())
	lis[x-1][y-1]=1
	lis[y-1][x-1]=1
s=""
k=[]
import itertools
for i in range(n):
	s+=str(i)
for i in itertools.permutations(s):
	k.append(i)
ans=0
for i in range(len(k)):
	if k[i][0]!="0":
		continue
	for j in range(n-1):
		if lis[int(k[i][j])][int(k[i][j+1])]==0:
			break
		elif j==n-2:
			ans+=1
print(ans)


Measured memory_bytes: 8052
#include <stdio.h>
void getH(int,int);

typedef struct {
  int parent;
  int child;
  int brother;
  int child2;
  int deg;
} node;

node n[100000];
int H;
int main()
{
  int a,c,d,e,i,j,num,depth;
  scanf("%d", &num);
  for(i=0;i<num;i++){
    n[i].parent=-1;
    n[i].brother=-1;
 n[i].child=-1;
  }
  for(i=0;i<num;i++){

    scanf("%d",&a);
    n[a].deg=0;    
scanf("%d%d",&n[a].child,&n[a].child2);

    if(n[a].child2!=-1){
      n[n[a].child2].parent=a;
      n[n[a].child2].brother=n[a].child;
      n[a].deg++;
}
 if(n[a].child!=-1){
n[n[a].child].parent=a;
      n[n[a].child].brother=n[a].child2;
 n[a].deg++;
}

  }
  
for(i=0;i<num;i++){
  printf("node %d: parent = %d, sibling = %d, degree = %d, ",i,n[i].parent,n[i].brother,n[i].deg);
    
c=n[i].parent;    
    depth=0;    
while(c!=-1){
depth++;
      c=n[c].parent;


}
    printf("depth = %d, ",depth);
    H=0;    
getH(i,0);
    printf("height = %d, ",H);    

if(n[i].parent==-1)
      printf("root\n");
    else if(n[i].child==-1&&n[i].child2==-1)printf("leaf\n");
    else printf("internal node\n");

 }

  

    return 0;
  }



void getH(int x,int h){
  if(x==-1)return;

  getH(n[x].child,h+1);
getH(n[x].child2,h+1);

 if(H<h)H=h;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(v) (v).begin(),(v).end()

const int MOD = 1000000007;
const int N = 3005;
const double PI =4*atan(1);

ll dp[N][N];
ll n;
ll a[N];

ll dfs(ll l ,ll r){
	if(l>r)return 0;
	if(dp[l][r]>-1e17)return dp[l][r];
	ll to_return = -1e17;
	to_return =max(to_return , a[r]-dfs(l,r-1));
	to_return =max(to_return , a[l]-dfs(l+1,r));
	return dp[l][r]=to_return;
}

int main(){
    ios::sync_with_stdio(0);
    //freopen("baklava.in","r",stdin);
    cin.tie(0);
    cout.tie(0);
    //start
    cin >> n;
    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++){
    		dp[i][j]=-1e17;
    	}
    }
    for(int i=0;i<n;i++)cin >> a[i];
    ll ans=dfs(0,n-1);
    cout << ans;

    return 0;
}


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

long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

int main (){

    ll N;
    cin >> N;
    long long int A[N],ans=0;
    map<long long int,long long int>m;
    map<long long int,long long int>n;
    for(ll i = 0; i < N; i++) {
        cin >> A[i];
        m[A[i]]++;
    }

    for(ll i = 0; i < N; i++) {
        if(n[A[i]] == 0) {
            if(m[A[i]] % 2 == 1) {
                ans++;
            }
            n[A[i]]++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13568
import scala.io.StdIn

object Main extends App {
  val s = StdIn.readLine

  val res = if (s.charAt(0) == 'A' && s.count(_.isUpper) == 2) {
    s.substring(2,s.length-1)
     .count(_ == 'C')
     .==(1)
  } else false

  println(if (res) "AC" else "WA")
}

Measured memory_bytes: 25532
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<ldouble, ldouble> pdd;

char S[310];
int K;
int D[310][310][310];

void solve() {
	scanf("%s%d", S+1, &K);
	int L = (int)strlen(S+1);
	for(int i=1;i<=L;i++) rep(j, K+1) D[i][i][j] = 1;
	for(int i=1;i<L;i++) for(int j=1;j+i<=L;j++) {
		int l = j, r = j + i;
		for(int k=0;k<=K+1;k++) {
			D[l][r][k] = max(D[l+1][r][k], D[l][r-1][k]);
			if(S[l] == S[r]) D[l][r][k] = max(D[l][r][k], D[l+1][r-1][k] + 2);
			else {
				if(k) D[l][r][k] = max(D[l][r][k], D[l+1][r-1][k-1] + 2);
			}
		}
	}
	printf("%d\n", D[1][L][K]);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 114560
#include<stdio.h>
#include<string.h>
#define N 1000001
void insertStr(char []);
int findStr(char []);
long long getKey(char []);
char dic[N][12];
int n;
int main(){
  int i;
  char command[6],str[12];
  scanf("%d",&n);
  for(i=0;i<1000001;i++){
    dic[i][0] = '\0';
  }
  for(i=0;i<n;i++){
    scanf("%s %s",command,str);
    if( command[0] == 'i' ){
      insertStr(str);
    }
    else {
      if( findStr(str) ){
	printf("yes\n");
      }
      else {
	printf("no\n");
      }
    }
  }
  return 0;
}
void insertStr(char str[]){
  int key,i,h,q;
  i = 0;
  key = getKey(str);
  while(1){
    h = ((key%N) + i * (1+key%(N-1))) % N;
    if( dic[h][0] == '\0' ){
      strcpy(dic[h],str);
      return ;
    }
    i++;
  }
  return ;
} 
int findStr(char str[]){
  int i,key,h;
  i = 0;
  key = getKey(str);
  while(1){
    h = (key%N + i * (1+key%(N-1))) % N;
    if( strcmp(dic[h],str) == 0 ){
      return 1;
    }
    else if( strlen(dic[h]) == 0 ){
      return 0;
    }
    else{
      i++;
    }
  }
}
long long getKey(char str[]){
  int i,sum,p;
  sum = 0;
  p = 1;
  for(i=0;i<strlen(str);i++){
    if( str[i] == 'A'){
      sum += p*1;
    }
    else if( 'C' == str[i] ){
      sum += p*2;
    }
    else if( 'G' == str[i] ){
      sum += p*3;
    }
    else{
      sum += p*4;
    }
    p *= 5;
  }
  return sum;
}

Measured memory_bytes: 12324
n = int(input())
d = dict()

for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

M = max(d.values())

ans_list = []
for k,v in d.items():
    if v == M:
        ans_list.append(k)

ans_list.sort()
for i in ans_list:
    print(i)


Measured memory_bytes: 32096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    //ios::sync_with_stdio(false);
	//cin.tie(0);
 
    double w,h;
    cin>>w>>h;
    double x,y;
    cin>>x>>y;
    if(x==w || y==h){
        double ans = w*h/2;
        printf("%.12f",ans);
        cout <<" "<<0<<endl;
        return 0;
    }
    
    
    double ans = w*h/2;
    printf("%.12f",ans);
    if(w/2==x && h/2==y){
        cout<<" "<<1<<endl;
    }
    else cout<<" "<<0<<endl;
}

Measured memory_bytes: 256
use std::cmp::max;

fn main() {
    let (r, c, k) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut it = buf.trim_end().split_whitespace();
        let r: usize = it.next().unwrap().parse().unwrap();
        let c: usize = it.next().unwrap().parse().unwrap();
        let k: u32 = it.next().unwrap().parse().unwrap();
        (r, c, k)
    };

    let mut k_mat = vec![vec![0; c as usize]; r as usize];
    for _ in 0..k {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut it = buf.trim_end().split_whitespace();
        let mut r: usize = it.next().unwrap().parse().unwrap();
        let mut c: usize = it.next().unwrap().parse().unwrap();
        let v: u64 = it.next().unwrap().parse().unwrap();
        r -= 1;
        c -= 1;
        k_mat[r][c] = v
    }

    let mut dp = vec![vec![vec![0 as u64; 4]; (c + 1) as usize]; (r + 1) as usize];

    for i in 0..r {
        for j in 0..c {
            for k in (0..3).rev() {
                dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k] + k_mat[i][j])
            }

            for k in 0..4 {
                dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
                dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
            }
        }
    }

    let mut ans = 0;
    for k in 0..4 {
        ans = max(ans, dp[r - 1][c - 1][k])
    }

    println!("{}", ans);
}


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

int main() {
  int N, L;
  cin >> N >> L;
  int j;
  j=0;
  for(int i=0; i<N; i++){
    j+=L+i;
  }
  if(L<=0 && L+N-1>=0)
    cout << j;
  if(L>0)
    cout << j-L;
  if(L+N-1<0)
    cout << j-(L+N-1);
    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
   int A,B,C,D;
   scanf("%d %d %d %d",&A,&B,&C,&D);
   int turn = 1;
   while(A>0&&C>0){
   if(turn>0){
      C-=B;
   }else{
      A-=D;
   }
   turn *= -1;
   }
   if(A>0){
      printf("Yes\n");
   }else{
      printf("No\n");
   }
   return 0;
}


Measured memory_bytes: 1632
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  [r,c] <- getl (wrds toInt)
  unless (r == 0 && c == 0) $ do
    putStrLn $ solve r c
    main

solve :: Int -> Int -> String
solve r c
  | odd r && odd c = "no"
  | otherwise = "yes"

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4000
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<limits>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i = 0;i < (n); ++i)

int main() {
	ll n;
	cin >> n;
	ll p=1;
	ll q = n;
	ll r = sqrt(n);
	for (int i = 2; i < r+1; i++) {
		if (n % i == 0)p = i;
	}
	q = n / p;
	cout << p + q - 2 << endl;
	return 0;
}

Measured memory_bytes: 256
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def main():
    x = int(input())
    for i in range(x, 10**10+1):
        if is_prime(i):
            print(i)
            return
        

if __name__ == '__main__':
    main()

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

//----------------------------------------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 2e4 + 1;//                                                             |
//----------------------------------------------------------------------------------


//main func
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll t;cin>>t;
    string s="abcdefghijklmnopqrstuvwxyz";
    
    string ans="";
    while(t>0){
        t--;
        ans+=s[t%26];
        t/=26;
    }
    
    reverse(all(ans));
    cout<<ans<<"\n";
    
    
	return 0;
}


Measured memory_bytes: 3604