akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main(){
  int n,q;
  int a[200] = {};
  int min = 0;
  int min2;
  int d;
  int m;

  while(cin >> n >> q){
    if(n == 0 && q == 0){
      break;
    }
    min = 0;
    min2 = 0;

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

      for(int j = 0;j < m; j++){
        cin >> d; 
        a[d-1]++;
      }

    }

    for(int j = 0;j < 200; j++){
      if(a[j] >= q && min < a[j]){
        min = a[j];
        min2 = j+1;
      }
      a[j] = 0;
    }


    cout << min2 << endl;
  }
}





 

Measured memory_bytes: 3024
#include <stdio.h>

int min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}

int main(void){
  int N;
  scanf("%d",&N);

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

  int ans = 1 << 27;
  for(int i = -100;i <= 100;i++){
    int res = 0;
    for(int j = 0;j < N;j++){
      res += (i-a[j])*(i-a[j]);
    }
    ans = min(ans,res);
  }

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

  return 0;
}

Measured memory_bytes: 128
#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 all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1000000007;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	cout << s[0] << n-2 << s[n-1] << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)
#define all(v) (v).begin(),(v).end()

int main() {
    ll n,q,b,l,r;
    cin>>n;
    set<ll> a;
    rep(i,n){
        cin>>l;
        a.insert(l);
    }
    cin>>q;
    rep(i,q){
        cin>>b;
        if(a.find(b)!=a.end())cout<<1<<endl;
        else cout<<0<<endl;
    }
}


Measured memory_bytes: 7772
n = int(input())
nt, nx, ny = 0, 0, 0
for _ in range(n):
  t, x, y = map(int, input().split())
  d = abs(x-nx) + abs(y-ny)
  dt = t - nt
  if d > dt or d%2 != dt%2:
    print("No")
    break
  nt, nx, ny = t, x, y
else:
  print("Yes")

Measured memory_bytes: 3064
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())

total=0
for i in range(N):
    for (j) in range(i+1,N):
        total+=math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)

print(total/N*2)


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

int main(){
    int h,w;
    cin >> h >> w;
    //cout << h <<" "<< w<< endl;
    int g1=0,g2=0,g4=(h/2)*(w/2);
    if(h*w%2>0){
        g1=1;
        g2=h/2+w/2;
    }else if(h%2>0)g2=w/2;
    else if(w%2>0)g2=h/2;
   // cout << g1 << " " << g2 << " " << g4 << endl;
    vector<int> alf(30,0);
    for(int i=0;i<h;i++){ 
        for(int j=0;j<w;j++){
            char c;
            cin >> c;
            int n=c;
            alf[n-97]++;
        }
    }
    for(int i=0;i<30;i++){
        //cout << alf[i] << endl;
        g4-=alf[i]/4;
        alf[i]%=4;
        g2-=alf[i]/2;
        alf[i]%=2;
        g1-=alf[i];
    }
    //cout << g1 << " " << g2 << " " << g4 << endl;
    if(g1==0 && g2==0 && g4==0)cout << "Yes" << endl;
    else if(g1==0 && g4<0 && g2+g4*2==0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<list>
using namespace std;
static const int MAX = 100000;

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;

void dfs(int u){
	V[u] = true;
	for(int i = 0; i < G[u].size(); i++){
		int v = G[u][i];
		if(!V[v]) dfs(v);
	}
	out.push_front(u);
}

int main(){
	int s, t, M;

	cin >> N >> M;

	for(int i = 0; i < N; i++) V[i] = false;

	for(int i = 0; i < M; i++){
		cin >> s >> t;
		G[s].push_back(t);
	}

	for(int i = 0; i < N; i++){
		if(!V[i]) dfs(i);
	}

	for(list<int>::iterator it = out.begin(); it != out.end(); it++)
		cout << *it << endl;

	return 0;
}

Measured memory_bytes: 6036
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <string.h>
using namespace std;
int main()
{
    long long n;
    cin >> n;
    long long i = 1, tmp = 0;
    while (tmp < n)
    {
        tmp += i;
        i++;
    }
    cout << i - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

template <typename T> struct BIT {
    int n;
    vector<T> bit;
    BIT(int n_) : n(n_ + 1), bit(n, 0) {
    }

    void add(int i, T x) {
        if (i == 0) {
            cout << "BIT add ERROR" << endl;
            exit(1);
        }
        for (int idx = i; idx < n; idx += (idx & -idx)) {
            bit[idx] += x;
        }
    }

    T sum(int i) {
        T s(0);

        for (int idx = i; idx > 0; idx -= (idx & -idx)) {
            s += bit[idx];
        }
        return s;
    }
};

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

    int N, Q;
    cin >> N >> Q;

    vec<int> mp(N + 1);
    vec<int> ball(N + 1);

    rep(i, N) {
        int c;
        cin >> c;
        int now = i + 1;
        if (mp[c] == 0) {
            mp[c] = now;
        } else {
            ball[mp[c]] = now;
            mp[c]       = now;
        }
    }

    vec<vec<pair<int, int>>> query(N + 1);
    vec<int> l(Q), r(Q);
    rep(i, Q) {
        cin >> l[i] >> r[i];
        query[l[i]].push_back({r[i], i});
    }

    BIT<ll> bit(N);
    vec<int> ans(Q);
    for (int i = N; i > 0; --i) {
        if (ball[i] != 0) bit.add(ball[i], 1);
        for (auto [R, index] : query[i]) {
            ans[index] = bit.sum(R);
        }
    }

    rep(i, Q) {
        cout << r[i] - l[i] + 1 - ans[i] << endl;
    }
}


Measured memory_bytes: 39076
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

val = []
for i in range(N):
	val.append(V[i] - C[i])
val.sort()
val.reverse()
cnt = 0
valsum = 0
while cnt < N and val[cnt] >= 0:
	valsum += val[cnt]
	cnt += 1

print(valsum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N;
    cin>>N;
    
    ll cnt=0,bef=0;
    VECi(ll,A,N+1,0);
    VECi(ll,w,N+2,0);
    VECi(ll,d,N+1,0);
    REP1(i,N){
        cin>>A[i];
        w[i]=w[i-1]+abs(A[i]-A[i-1]);
        if(i>=2)d[i-1]=w[i]-(w[i-2]+abs(A[i]-A[i-2]));
    }
    w[N+1]=w[N]+abs(A[N]);
    d[N]=w[N+1]-(w[N-1]+abs(A[N-1]));
    REP1(i,N){
        cout<<w[N+1]-d[i]<<endl;
    }
    
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <stdio.h>
#include <ctype.h>
#define y second
#define x first
#define lsb(x) (x&-x)
#define pb push_back
#define y second
const int NMAX=100666; //LOL
const int MOD=1000000007; //LOL
const int SQRT=350;
using namespace std;
const double eps=1e-5;
const double PI=acos(-1.0);
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLD;
typedef vector<int> VI;
const int dx[]={-1, 0, 0, 1};
const int dy[]={0, 1, -1, 0};
const int MAXN=(1<<26);
char c;
int n;
string s;
int p[100666];
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    //freopen("input.in", "rt", stdin);
    //freopen("output.out", "wt", stdout);
	cin>>s;
	cin>>n;
	int j=0;
	for(int i=0; i<s.size(); ++i)
	{
		int r='z'-s[i]+1;
		if(s[i]!='a')
		{
			if(r<=n)
			{
				n-=r;
				s[i]='a';
			}
		}
	}
	if(n>0)
		s[s.size()-1]='a' + (s[s.size()-1]-'a'+n)%26;
	cout<<s;

	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
    ll a,b,c,k; cin >> a >> b >> c >> k;
    if(a+b < k) cout << a - (k - a - b) << endl;
    else cout << min(a,k) << endl;
}

Measured memory_bytes: 3636
n = input().split()
a = int(n[0])
b = int(n[1])
c = int(n[2])
if a <= b <= c:
    print(a, b, c)
elif a <= c <= b:
    print(a, c, b)
elif b <= a <= c:
    print(b, a, c)
elif  b <= c <= a:
    print(b, c, a)
elif c <= a <= b:
    print(c, a, b)
else:
    print(c, b, a)

Measured memory_bytes: 6724
while true
  x, y = gets.split(' ').map(&:to_i)
  break if x == 0 && y == 0
  results = []
  prices = gets.split(' ').map(&:to_i)
  (0..x-1).each do |i|
    (0..i-1).each do |j|
      sum = prices[i] + prices[j]
      results.push(sum) if sum <= y
    end
  end
  puts results.empty? ? 'NONE' : results.max
end


Measured memory_bytes: 23216
N = int(input()) 
A = list(int(i) for i in input().split())  
Q = int(input()) 
B_C = [[int(i) for i in input().split()] for i in range(Q)] 
first_sum = sum(A)
import collections
c = collections.Counter(A)
for i in range(Q):
  change_value = (B_C[i][1]-B_C[i][0])*c[B_C[i][0]]
  c[B_C[i][1]] += c[B_C[i][0]]
  c[B_C[i][0]] = 0
  first_sum += change_value
  print(first_sum)
  #print(c)

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

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin >> s.at(i);
  }
  sort(s.begin(),s.end());
  int ans=1;
  for(int i=0;i<n-1;i++){
    if(s.at(i)!=s.at(i+1)){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 9548
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    const int nmax =  8;
    bool[,] graph = new bool[nmax, nmax];

    Scanner cin;
    

    public void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int M = cin.nextInt();

        for(int i = 0;i<M;i++)
        {
            int A = cin.nextInt();
            int B = cin.nextInt();
            graph[A - 1, B - 1] = true;
            graph[B - 1, A - 1] = true;
        }

        bool[] visited = new bool[nmax];

        visited[0] = true;
        Console.WriteLine(dfs(0, N, visited));
    }

    int dfs(int v, int N, bool[] visited)
    {
        bool all_visited = true;
        for(int i = 0;i<N;i++)
        {
            if (!visited[i]) all_visited = false;
        }
        if (all_visited) return 1;

        int ret = 0;
        for (int i = 0; i < N; i++)
        {
            if (!graph[v, i]) continue;
            if (visited[i]) continue;

            visited[i] = true;
            ret += dfs(i, N, visited);
            visited[i] = false;
        }

        return ret;
    }   
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 13140
//Deep Godhani
//DAIICT

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

#define N 100000000000
#define PI acos(-1)
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define ll long long int
#define ld long double
#define precision(x,d) cout << fixed << setprecision(d) << x
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

void solve()
{
  string s,t;
  cin >> s >> t;

  int ans = INT_MAX;
  for(int i=0;i<=s.length()-t.length();i++)
  {
    int f = 0;
    for(int j=0;j<t.length();j++)
    {
      if(s[i+j] != t[j])
      {
        f++;
      }
    }
    ans = min(ans, f);
  }
  cout << ans << endl;
}

int main()
{
    FAST;
    ll t=1;
    //cin >> t;
    while(t--)
    {
      solve();
    }
		return 0;
}


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

int main(){
    ll n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    ll ans =1+(n-2)*(b-a);
    if(ans<=0)ans=0;
    printf("%lld\n",ans);
}

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

int main(void){
    int H,W;
    cin >> H >> W;
    char S[H][W];
    rep(i,H) cin >> S[i];
    lint dp[H][W]={};
    dp[0][0]=1;
    rep(i,H) rep(j,W){
        if(i!=H-1) if(S[i+1][j]!='#') dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD;
        if(j!=W-1) if(S[i][j+1]!='#') dp[i][j+1]=(dp[i][j+1]+dp[i][j])%MOD;
    }
    cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll m=1e9L+7;
ll dp[1007][1007];
string arr[1007];
ll h,w;
ll f(ll i,ll j)
{
if(i==h-1&&j==w-1)
return 1;
if(i>=h||j>=w||arr[i][j]=='#')
return 0;
if(dp[i][j]!=-1)
return dp[i][j];
return dp[i][j]=(f(i+1,j)+f(i,j+1))%m;
}
int main()
{
cin>>h>>w;
ll i,j;
for(i=0;i<=h;i++){
if(i!=h)
cin>>arr[i];
for(j=0;j<=w;j++)
dp[i][j]=-1;}
cout<<f(0,0);
return 0;
}

Measured memory_bytes: 9216
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x7fffffff
#define INFL 0x7fffffffffffffffLL

int main() {
	ll		b,c,i,j,k,n,m,x,y,ans = 0;
	string	str;

	cin >> n;
	vector<int> a(n+1);
	for(i=1;i<n;i++) {
		cin >> j;
		a[j]++;
	}

	for(i=1;i<=n;i++) {
		cout << a[i] << endl;
	}


}


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

int main()
{
    string s;
    cin >> s;
    if (s == "ABC")
    {
        cout << "ARC" << endl;
        return (0);
    }
    else if (s == "ARC")
    {
        cout << "ABC" << endl;
        return(0);
    }

}

Measured memory_bytes: 3596
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N, K; std::cin >> N >> K;
  std::string S; std::cin >> S;
  S += 'a';

  int cnt = 0;
  std::vector<int> cnts;
  if (S[0] == '0') cnts.push_back(0);
  for (int i = 0; i < N; ++i) {
    ++cnt;
    if (S[i] != S[i+1]) {
      cnts.push_back(cnt);
      cnt = 0;
    }
  }
  if (S[N-1] == '0') {
    cnts.push_back(0);
  }

  int ans = 0;
  for (int j = 0; j < cnts.size(); j += 2) {
    int sum = 0;
    int imax = std::min(j + 2*K+1, (int)cnts.size());
    for (int i = j; i < imax; ++i) {
      sum += cnts[i];
    }
    ans = std::max(ans, sum);
  }

  std::cout << ans << std::endl;
}


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

int main() {

    int n, z, w, a[2000];

    cin >> n >> z >> w;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    if(n == 1) cout << abs(a[n - 1] - w) << endl;
    else cout << max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])) << endl;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]

CounterS = Counter(S)
CounterT = Counter(T)

Max = 0
for key in CounterS.keys():
    i = int(CounterS.get(key, 0)) - int(CounterT.get(key, 0))
    if Max < i:
        Max = i
print(Max)

Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int top,S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}
int main(){
  int a,b;
  top=0;
  char s[100];
  while( scanf("%s",s) !=EOF ){
    if (s[0] == '+'){
      a = pop();
      b = pop();
      push(a+b);
    }else if( s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }else if( s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }else {
      push(atoi(s));
    }
  }

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

  return 0;
}
    



Measured memory_bytes: 2100
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
const int INF = 1000000000;

int h, w;
int c[11][11];
int A[301][301];
int dist[11][11];

void WF(int n) {
	REP(i, 0, n) {
		REP(j, 0, n) {
			REP(k, 0, n) {
				dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
			}
		}
	}
}


int main()
{
	cin >> h >> w;
	REP(i, 0, 10) {
		REP(j, 0, 10) {
			cin >> c[i][j];
			dist[i][j] = c[i][j];
		}
	}
	REP(i, 0, h) {
		REP(j, 0, w) {
			cin >> A[i][j];
		}
	}

	WF(10);

	long long ans = 0;
	REP(i, 0, h) {
		REP(j, 0, w) {
			if (A[i][j] == -1) continue;
			ans += dist[A[i][j]][1];
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
from functools import reduce
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N = int(input())
    L = list(map(int, input().split()))

    ans = 0
    l = 0
    r = 0
    tmp_sum = 0
    tmp_bit = 0
    while l < N:
        while r < N and tmp_bit ^ L[r] == tmp_sum+L[r]:
            tmp_bit ^= L[r]
            tmp_sum += L[r]
            r += 1
        ans += r-l
        if(l == r):
            r += 1
        else:
            tmp_bit ^= L[l]
            tmp_sum -= L[l]
            l += 1
    print(ans)


solve()


Measured memory_bytes: 24128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[100010],b[100010];

int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	ll nowa=1,nowb=1;
	for(int i=0;i<n;i++){
		ll so=(a[i]+nowa-1)/a[i];
		so=max(so,(b[i]+nowb-1)/b[i]);
		nowa=a[i]*so;nowb=b[i]*so;
	}
	cout << nowa+nowb;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s;
    cin >> s;
    if(s.size() == 1){
        output(s, 0);
        return 0;
    }
    int cnt = 1 << (s.size() - 1);
    ll ret = 0;
    rep(i, cnt){
        ll sum = 0;
        ll tmp = s[0] - '0';
        rep(j, s.size() - 1){
//            cout << (i >> j) << endl;
            if((i >> j & 1) == 1){
                sum += tmp;
                tmp = s[j + 1] - '0';
            }
            else{
                tmp = tmp * 10 + s[j + 1] - '0';
            }
        }
        sum += tmp;
//        cout << i << ": " << sum << endl;
        ret += sum;
    }
    
    output(ret, 0);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull a, b;
ull gcd(ull a, ull b){
	return b?gcd(b, a%b):a;
} 
int main(){
	//freopen("in", "r", stdin);
	for(;cin>>a>>b;){
		ull _gcd=gcd(a, b), _lcm=a/_gcd*b;
		cout<<_gcd<<' '<<_lcm<<endl;
	}
}

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

int main(){
    double T, X;
    cin >> T >> X;
    //T:Bでする時間
    //X:X倍

    double ans = T / X;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>

using namespace std;

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

    cout << 3 * r * r << endl;
}

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

using namespace std;

int main(int argc, char const* argv[])
{
		string S;
		cin >> S;

		long long all_sum = 0;

		for (int i = 0; i < 1 << (S.length()-1) ; i++) {
				int start_index = 0;
				for (int j = 0; j < S.length(); j++) {
						if(i & (1 << j)) {
								all_sum += stoll(S.substr(start_index, j - start_index + 1));
								start_index = j+1;
						}
				}
				all_sum += stoll(S.substr(start_index));
		}

		cout << all_sum << endl;
		return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<int> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
bool check(VI arr){
    fore1(i,1,arr.size()){
        if(arr[i]<arr.size()-1)return false;
    }
    return true;
}
int main()
 {  fast();
ll x,y;
  cin>>x>>y;
  if(y%2==0&&y/2>=x&&y<=4*x)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 }


Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int a[3];
int main(){
	scanf("%d%d%d",a,a+1,a+2);std::sort(a,a+3);
	if(a[0]==5&&a[1]==5&&a[2]==7)printf("YES\n");else printf("NO\n");
}

Measured memory_bytes: 128
from operator import mul
from functools import reduce
from collections import Counter
from itertools import combinations

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
items = list(map(int, input().split()))
counts = Counter(items)
cobinations = {}
count_sum = 0

for key,value in counts.items():
  if value not in cobinations:
    if value > 1:
      count = cmb(value, 2)
      cobinations[value] = count
    else:
      cobinations[value] = 0
  count_sum+=cobinations[value]

for key in items:
  value = counts[key]
  if value - 1 not in cobinations:
    if value - 1 > 1:
      # tmp_key = list(range(value-1))
      # count = len(list(combinations(tmp_key, 2)))
      # cobinations[value-1] = count
      count = cmb(value-1, 2)
      cobinations[value-1] = count
    else:
      cobinations[value-1] = 0
  
  before = cobinations[value]
  after = cobinations[value-1]
  print(count_sum - before + after)



Measured memory_bytes: 26896
from collections import Counter

MOD = 998244353
N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit()

C = sorted(Counter(D).most_common(), key=lambda x: x[0])

if C[0][1] > 1:
    print(0)
    exit()

ans = 1
for i in range(1, len(C)):
    if C[i][0] - C[i-1][0] > 1:
        print(0)
        exit()
    ans *= C[i - 1][1] ** C[i][1]

print(ans % MOD)


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

using namespace std;

const long long maxi=1e16+951;

long long k;
long long a[1000];
long long n;
int main()
{
    cin>>k;

   n=50ll;

   if (k<n)
       a[1]=n*k;
    else
    {
         for (int i=1;i<=n;i++)
            a[i]+=k/n+49;
         long long p=k%n;

         for (int i=1;i<=p;i++)
            a[i]++;
         for (int i=p+1;i<=n;i++)
            a[i]-=p;
    }

   printf("%lld\n",n);

   for (int i=1;i<=n;i++)
    printf("%lld ",a[i]);
   printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,j,ans=0;cin>>N;ll x[N],y[N];REP(i,N)cin>>x[i]>>y[i];map<P,ll>W;
  REP(i,N)REP(j,N)if(i!=j)W[P(x[i]-x[j],y[i]-y[j])]++;
  for(auto k:W)ans=max(ans,k.S);
  cout<<N-ans<<endl;
  return 0;
}

Measured memory_bytes: 3756
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, c;
    cin >> n >> c;
    vector<vector<int>> d(c, vector<int>(c));
    for (int i = 0; i < c; ++i) {
        for (int j = 0; j < c; ++j) {
            cin >> d[i][j];
        }
    }
    vector<vector<int>> grid(n, vector<int>(n));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> grid[i][j];
            --grid[i][j];
        }
    }
    vector<pair<int, int>> cand(c);
    for (int color = 0; color < c; ++color) {
        int sum = 0;
        for (int y = 0; y < n; ++y) {
            for (int x = 0; x < n; ++x) {
                int mdist = (x + y) % 3;
                if (mdist != 2)
                    continue;
                sum += d[grid[y][x]][color];
            }
        }
        cand[color] = {sum, color};
    }
    sort(cand.begin(), cand.end());
    int ans = inf;
    for (int i = 0; i < c; ++i) {
        for (int j = 0; j < c; ++j) {
            if (i == j)
                continue;
            int k;
            for (int a = 0; a < 3; ++a) {
                if (cand[a].second != i && cand[a].second != j) {
                    k = cand[a].second;
                    break;
                }
            }
            int sum = 0;
            for (int y = 0; y < n; ++y) {
                for (int x = 0; x < n; ++x) {
                    int mdist = (x + y) % 3;
                    int color = mdist == 0 ? i : mdist == 1 ? j : k;
                    sum += d[grid[y][x]][color];
                }
            }
            ans = min(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll , ll> P;
typedef pair<ll, ll> PL;
const ll INT_INF = 2147483646;
const ll ll_INF = 9223372036854775807;
ll mod = 1e9+7;

bool SecondCompare(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return a.second>b.second;
}


int n;
string w[110];

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> w[i];
    }

    for(int i = 1; i < n; i++){
        if(w[i-1][w[i-1].length()-1] != w[i][0]){
            cout << "No\n";
            return 0;
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if(w[i] == w[j]){
                cout << "No\n";
                return 0;
            }
        }
    }

    cout << "Yes\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int n;
  cin>>n;
  double a=n/2;
  double ans=(double)(n-a)/(double)(n);
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int d,r;
    d=a/b;
    r=a%b;
    printf("%d %d %.5lf\n",d,r,a*1.0/b);
    return 0;
}


Measured memory_bytes: 3204
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)




int main(){
    int x;
    cin >> x;
    if(x == 0){
        cout << 1;
    }
    else if(x == 1){
        cout << 0;
    }
    
}



Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i,0,(n))
#define pb(n) push_back(n)
#define mp(n,m) make_pair(n, m)
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;

int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};
int n, d;
vector<string> s;

bool outOfRange(int y, int x){
	if(y < 0 || y >= n || x < 0 || x >= n) return true;
	return false;
}

bool check(int ny, int nx, int dir){
	if(outOfRange(ny, nx)) return true;
	for(int i = 0; i < 4; i++){
		if(i == (dir+2)%4) continue;
		int nny = ny + dy[i], nnx = nx + dx[i];
		if((!outOfRange(nny, nnx)) && s[nny][nnx] == '#') return true;
	}
	return false;
}

int main(){
	cin>>d;
	for(int i = 0; i < d; i++){
		if(i!=0) printf("\n");
		cin>>n;
		s = vector<string>(n,string(n, ' '));
		pii pos = pii(n-1, 0);
		int dir = 0;
		while(1){
			if(s[pos.fi][pos.se]=='#') break;
			s[pos.fi][pos.se] = '#';
			int ny = pos.fi+dy[dir], nx = pos.se+dx[dir], cnt = 4;
			while(check(ny, nx, dir) &&(--cnt)){
				dir++; dir%=4;
				ny = pos.fi+dy[dir]; nx = pos.se+dx[dir];

			}
			if(cnt == 0) break;
			pos=pii(ny ,nx);
		}
		rep(i, n) cout<<s[i]<<endl;
	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

// lcm = a*(b/gcd) least common multiple                                  
// gcd: greatest common divisor                                          
//                                                                         
ll gcd(ll a, ll b) {
  if(a < b) gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}



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

  ll a,b;
  cin >> a >> b;
  ll ans=a*b/gcd(a,b);
  cout << ans << endl;

  
  return 0;
    

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
 {
	 int width, length;
	 //面積を格納する変数
	 int area;
	 //周の長さを格納する変数
	 int per;

	 scanf("%d %d", &width, &length);
	 area = width * length;
	 per = (width * 2) + (length * 2);

	 printf("%d %d\n", area, per);
	 return (0);
}



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

int main(){
	int m,d,d10,ans = 0,i;
	cin >> m;
	cin >> d;

	if((m < 4)||(d < 22)){
		cout << ans;
		return 0;
	}
	else{
		for(i = 4; i <= m; i++){
			for(d10 = 2; d10 <= d/10; d10++){
				if((i%d10 == 0)&&(i/d10 >= 2)&&(i/d10 <= 9)&&
				((d10 != d/10)||((d10 == d/10)&&(i/d10 <= d%10)))){
					ans++;
				}
			}
		}
	}

	cout << ans;
	return 0;
}


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

int main()
{
  int n, k;
  cin >> n >> k;
  for (int i=1, a=1; ; i++) {
    a *= k;
    if (n < a) {
      cout << i;
      return 0;
    }
  }
  return 1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
  int a,b;
  cin >> a >> b;
  cout << ((b-a)*((b-a)+1))/2-b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <list>
#include <string>
using namespace std;
#define int long long
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	int k;
	cin >> k;

	vector<int> h;

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

		h.push_back(hi);
	}

	vector<int> dp(n, 9999999999999LL);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			if (j + i >= n)
			{
				break;
			}
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}

	cout << dp[n-1] << "\n";
	
}


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

typedef long long ll;
int ans = 0;
int count(ll a,ll b){
  if(b/a != 0){
    ans++;
    a *= 2;
    return count(a, b);
  }
  else{
    return ans;
  }
}

int main(){
  ll A, B;
  cin >> A >> B;
  cout << count(A,B);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)
double dp[21][200001];
const double INF=(1LL<<50);
int a[21];
int n;
double dfs(int idx,int lastNum){
    if(idx==-1)
        return 0.0;
    if(!EQ(INF,dp[idx][lastNum]))
        return dp[idx][lastNum];
    double minCost=INF;
    if(idx==n-1)
        for(int i = 1; i <= 200000; i++){
            minCost=min(minCost,max(dfs(idx-1,i),(double)abs(a[idx]-i)/a[idx]));
        }
    else
        // lastNumðèØéÅJÚ
        for(int i = 1; i*i <= lastNum; i++){
            if(lastNum%i==0){
                minCost=min(minCost,max(dfs(idx-1,i),(double)abs(a[idx]-i)/a[idx]));
                minCost=min(minCost,max(dfs(idx-1,(lastNum/i)),(double)abs(a[idx]-(lastNum/i))/a[idx]));
            }
        }
    return dp[idx][lastNum]=minCost;
}

int main(){
    for(int i = 0; i < 21; i++)
        for(int j = 0; j < 200001; j++)
            dp[i][j]=INF;
    cin>>n;
    for(int i = 0; i < n; i++) cin>>a[i];
    //for(int i = 0; i < n; i++){
    //    if(i==0){
    //        for(int j=0; j <=200000;j++)
    //            dp[i+1][j]=min(dp[i+1][j],(double)abs(a[i]-j)/a[i]);
    //        continue;
    //    }
    //    for(int j = 0; j <= 200000; j++){
    //        //if(j%
    //    }
    //}
    double res=dfs(n-1,0);
    printf("%.9f\n",res);
    return 0;
}

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

using namespace std;

#define ll long long

void solve() {
	double a, b;
	cin >> a >> b;
	double c = (a+b)/2;
	cout << ceil(c) << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    int n;cin>>n;
    VI x(n);
    REP(i, n) cin >> x[i];

    SORT_ASC(x);
    
    LL result = INF_LL;

    for(int i=x[0];i<=x[n-1];i++){
        LL tmp=0;
        REP(j,n){
            tmp += (i-x[j])*(i-x[j]);
        }

        result = min(result,tmp);
    }

    std::cout << result << endl;

	return;
}

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

Measured memory_bytes: 256
n,m=map(int,input().split())
l=[]
for i in range(m):
    l.append([int(i) for i in input().split()[1:]])
p=[int(i)*(-2)+1 for i in input().split()]
ans=0
for state in range(2**n):
    chk=True
    for j in range(m):
        ll=l[j]
        test=1
        for i in ll:
            test*=-2*((state>>(i-1))&1)+1
        if test!=p[j]:
            chk=False
    if chk:
        ans+=1
print(ans)


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

int main() {
    string s;
    cin >> s;
    int n = s.size();

    if (s[n - 1] == 's') {
        s += "es";
    }
    
    else s += "s";
    cout << s << endl;

    return 0; 
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <map>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define MAXN 200005
#define ll long long
using namespace std;
int f1[MAXN],f2[MAXN],res[MAXN];
typedef pair<int,int> pii;
map<pii,int> m;
void init(int n)
{
    rep(i,1,n)
        f1[i] = f2[i] = i,res[i] =1;
}
int getf(int x,int f[])
{
    if(x != f[x])
        f[x] = getf(f[x],f);
    return f[x];
}
void Union(int a,int b,int f[])
{
    a = getf(a,f);
    b = getf(b,f);
    if(a != b){
        f[a] = f[b];
    }
}
bool isSame(int a,int b,int f[])
{
    return getf(a,f) == getf(b,f);
}
int main()
{
    //freopen("data","r",stdin);
    int n,k,l;
    scanf("%d%d%d",&n,&k,&l);
    init(n);
    int a,b;
    rep(i,1,k)
    {
        scanf("%d%d",&a,&b);
        Union(a,b,f1);
    }
    rep(i,1,l)
    {
        scanf("%d%d",&a,&b);
        Union(a,b,f2);
    }
    rep(i,1,n){
        m[make_pair(getf(i,f1),getf(i,f2))]++;
    }
    rep(i,1,n)
    {
        printf("%d ",m[make_pair(getf(i,f1),getf(i,f2))]);
    }
    return 0;
}


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

using namespace std;

bool test(int n){
    int pre = n%10;
    n /= 10;
    while(n != 0){
        if(pre != n%10) return false;
        n /= 10;
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    while(1){
        if(test(n)){
            cout << n << endl;
            break;
        }
        n++;
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 100010;

int n;

int32_t main() {
	cin >> n;
	int ans = 0;
	for (int i =1;i<=n;i++) {
		int a; cin >> a;
		if ((i%2) and (a % 2)) ans++;
	}
	cout << ans;
}




Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int q = sc.nextInt();

        int[] sets = new int[n];
        for (int i = 0; i < n; i++) {
            sets[i] = i;
        }

        for (int i = 0; i < q; i++) {
            int com = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();

            if(com == 0) {
                int newSet = sets[y];
                for (int j = 0; j < n; j++) {
                    if(sets[j] == newSet) {
                        sets[j] = sets[x];
                    }
                }
            } else {
                if(sets[x] == sets[y]) {
                    System.out.println(1);
                } else {
                    System.out.println(0);
                }
            }
        }
    }
}

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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

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

const ll SIZE = 1e5+10;

ll a,b,c;

int main(){
    cin >> a >> b >> c;
    ll tmp = 0;
    if(a == b) ++tmp;
    if(a == c) ++tmp;
    if(b == c) ++tmp;
    if(tmp == 1)    cout << "Yes\n";
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

	int A, B, T, i, ans=0;

	scanf("%d %d %d", &A, &B, &T);

	
	for (i = A; i <= T; i=i+A) {
		ans = ans + B;
	}
	
	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 128
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
double pi=3.14159265358979;
int main()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double t1=2*pi*(h*60+m)/720,t2=2*pi*m/60;
	printf("%.12f\n", sqrt(a*a+b*b-2*a*b*cos(t1-t2)));
}


Measured memory_bytes: 4228
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def solve(S):
    if S[0] != "A":
        return "WA"
    if S[2:-1].count("C") != 1:
        return "WA"
    for c in S:
        if c != "A" and c != "C":
            if str(c).isupper():
                return "WA"
    return "AC"


def main():
    S = input()

    print(solve(S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948