akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
	int a,x;
	int b=0;
	int c=0;
	int d=0;
	int e=0;
	scanf("%d",&a);
	while(a>b){
		scanf("%d",&x);
		d=d+x;
		if(x>c)c=x;
		b=b+1;
	}
	e=d-c;
	if(c>=e)
	printf("No");
	else
	printf("Yes");
	
	return 0;
}


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

int h,w;

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

	vector<string> A(h);
	
	for(int i=0;i<h;i++)
		cin >> A[i];

	vector<bool> row(h,false);
	vector<bool> col(w,false);

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(A[i][j]=='#'){
				row[i]=true;
				col[j]=true;
			}
		}
	}

	for(int i=0;i<h;i++){
		if(row[i]){
			for(int j=0;j<w;j++){
				if(col[j])
					cout << A[i][j];
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
 
 
 
 
int main() {
    int N, ans = 0;
    cin >> N;
    string S;
    cin >> S;
    for (int i = 0; i < N; i++) {
        int a = 0;
        set<char> X, Y;
        for (int j = 0; j < i; j++) {
            X.insert(S.at(j));
        }
        for (int j = i; j < N; j++) {
            Y.insert(S.at(j));
        }
        for (char j = 'a'; j < 'z' + 1; j++) {
            if (X.count(j) && Y.count(j)) {
                a++;
            }
        }
        ans = max(a, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;




struct link { //link connecting x and y vertices
  int x;
  int y;
  int weight;
  bool operator<(const link& other) const
  {
    return weight > other.weight; // for min priority queue, trick the operator
  }
};

priority_queue<link> links;
int roots[100];

int root(int x) {
  if (x == roots[x]) {
    return x;
  } else {
    //roots[x] = root(roots[x]); //attach all to root
    return root(roots[x]);
  }
}

bool same(int x, int y) {
  return (root(x) == root(y));
}

void unite(int x, int y) {
  roots[root(x)] = root(y);
}


  
int main() {
  int min_cost = 0;
  int n;
  cin >> n;


  for (int i = 0; i < n; i++) {
    roots[i] = i; // initialize roots
    for (int j = 0; j < n; j++) {
      
      int weight;
      cin >> weight;
      if (j <= i ) continue;
      if (weight != -1) {
	link new_link = {i, j, weight};
	links.push(new_link);
	//cout << "link added has i j weight: " << i << " " << j << " " << weight << endl;
      }
    }
  }

  while (!links.empty()) {
    link cur_link = links.top();
    //cout << "cur link weight: " << cur_link.weight << " x: " << cur_link.x << " y: " << cur_link.y << endl;
    if (!same(cur_link.x, cur_link.y)) {
      min_cost += cur_link.weight;
      unite(cur_link.x, cur_link.y);
    }
    links.pop();
  }

  cout << min_cost << endl;
      
    
}

Measured memory_bytes: 3256
A,B,C,X,Y=map(int, input().split())

if X>=Y:ans,Ccnt=C*X*2,X*2
else:ans,Ccnt=C*Y*2,Y*2

for c in range(1,Ccnt//2+1):
	
	temp=(Ccnt-2*c)*C
	if (Ccnt-c*2)//2<Y:
		temp+=(Y-(Ccnt-c*2)//2)*B
	if (Ccnt-c*2)/2<X:
		temp+=(X-(Ccnt-c*2)//2)*A
	#print(X-(Ccnt-c*2)/2,Y-(Ccnt-c*2)/2,Ccnt-2*c,temp)
	ans=min(ans,temp)

print(ans)

Measured memory_bytes: 9208
def main():
  data = []
  for _ in range(3):
    data.append(list(map(int, input().split())))

  n = int(input())

  data_map = []
  for _ in range(3):
    data_map.append([0, 0, 0])

  for _ in range(n):
    x = int(input())
    if x == data[0][0]:
      data_map[0][0] = 1
    if x == data[0][1]:
      data_map[0][1] = 1
    if x == data[0][2]:
      data_map[0][2] = 1
    if x == data[1][0]:
      data_map[1][0] = 1
    if x == data[1][1]:
      data_map[1][1] = 1
    if x == data[1][2]:
      data_map[1][2] = 1
    if x == data[2][0]:
      data_map[2][0] = 1
    if x == data[2][1]:
      data_map[2][1] = 1
    if x == data[2][2]:
      data_map[2][2] = 1

  # for i in range(3):
  #   print(*data_map[i])

  # 横
  if sum(data_map[0]) == 3 or sum(data_map[1]) == 3 or sum(data_map[2]) == 3:
    print("Yes")
    return
  
  # ななめ(左->右)
  if data_map[0][0] + data_map[1][1] + data_map[2][2] == 3:
    print("Yes")
    return
  # ななめ(右->左)
  if data_map[0][2] + data_map[1][1] + data_map[2][0] == 3:
    print("Yes")
    return

  # 縦
  if data_map[0][0] + data_map[1][0] + data_map[2][0] == 3:
    print("Yes")
    return
  if data_map[0][1] + data_map[1][1] + data_map[2][1] == 3:
    print("Yes")
    return
  if data_map[0][2] + data_map[1][2] + data_map[2][2] == 3:
    print("Yes")
    return

  print("No")

if __name__ == "__main__":
  main()


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

int main() {
    int n, m;
    cin >> n >> m;

    vector<vector<int> > vec(m + 1);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        if (a > m) continue;
        vec[a].push_back(b);
    }

    priority_queue<int> pq;
    int res = 0;
    for (int i = 1; i <= m; i++) {
        for (const auto& element : vec[i]) {
            pq.push(element);
        }

        if (!pq.empty()) {
            res += pq.top();
            pq.pop();
        }
    }

    cout << res << endl;
}


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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define F first;
#define S second;
#define MP make_pair;
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;

int parent[N];

int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int res = h2*60+m2 - (h1*60+m1) - k;
    cout << res << endl;
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < 7; i++){
        string x = s.substr(0,i) + s.substr((n-7+i),7-i);
        if(x == "keyence"){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
def wa(x,y,z): #500 100 50
    global ans,a,b,c,n
    if x>a or y>b or z>c:
        return
    if x*500+y*100+z*50==n:
        ans+=1
        return
    elif x*500+y*100+z*50>n:
        return
    else:
        wa(x+1,y,z)
        wa(x,y+1,z)
        wa(x,y,z+1)
import math

def main():
    temp=input()
    a=int(temp)
    temp=input()
    b=int(temp)
    temp=input()
    c=int(temp)
    temp=input()
    n=int(temp)
    ans = 0
    for x in range(a+1):
        for y in range(b+1):
            for z in range(c+1):
                if 500*x+100*y+50*z==n:
                    ans+=1
                    
    print(ans)

    


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    string s;
    cin>>s;
    if(s[0]=='Y' &&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
}

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

using namespace std;

const int MAXN = 1e5 + 2;
int n, arr[MAXN], sorted[MAXN], pos[MAXN];

void compress()
{
    for(int i = 0;i < n;i++)
        sorted[i] = arr[i];
    sort(sorted, sorted + n);

    for(int i = 0;i < n;i++)
        arr[i] = lower_bound(sorted, sorted + n, arr[i]) - sorted;
}

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

    for(int i = 0;i < n;i++)
        sorted[i] = arr[i];
    sort(sorted, sorted + n);

    for(int i = 0;i < n;i++)
        pos[ sorted[i] ] = i;

    int cnt = 0;
    for(int i = 0;i < n;i++)
        if( abs(pos[ arr[i] ] - i) % 2 != 0 ) cnt++;

    cout << cnt / 2 << '\n';
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

int main(){
    ll N;cin>>N;
    ll a[N];
    rep(i,N)cin>>a[i];
    ll b[N],c[N],sum;
    if(a[0]<=0)b[0]=1;
    else b[0]=a[0];
    sum=b[0];
    rep(i,N-1){
        if((sum+a[i+1])*sum<0)b[i+1]=a[i+1];
        else if(sum>0)b[i+1]=-sum-1;
        else b[i+1]=-sum+1;
        sum+=b[i+1];
    }
    if(a[0]>=0)c[0]=-1;
    else c[0]=a[0];
    sum=c[0];
    rep(i,N-1){
        if((sum+a[i+1])*sum<0)c[i+1]=a[i+1];
        else if(sum>0)c[i+1]=-sum-1;
        else c[i+1]=-sum+1;
        sum+=c[i+1];
    }
    ll ans1=0,ans2=0;
    rep(i,N)ans1+=abs(a[i]-b[i]);
    rep(i,N)ans2+=abs(a[i]-c[i]);
    cout<<min(ans1,ans2)<<endl;
    return 0;
}

Measured memory_bytes: 2560
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
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-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 210000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
long long dp[410][410];
int p[410];
long long solve(int a,int b){
	if(a==b)return 0;
	if(~dp[a][b])return dp[a][b];
	long long ret=inf;
	long long ks=0;
	for(int i=a;i<=b;i++){
		ks+=p[i];
		if(i<b){
			ret=min(ret,solve(a,i)+solve(i+1,b));
		}
	}
	return dp[a][b]=ret+ks;
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	for(int i=0;i<a;i++)for(int j=0;j<a;j++)dp[i][j]=-1;
	printf("%lld\n",solve(0,a-1));
}

Measured memory_bytes: 1408
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {

        static void Main(string[] args)
        {
          //入力を受け取る
          var r = long.Parse(Console.ReadLine());
          //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
          
          Console.WriteLine(r*r);
        }
  
        // 最小公倍数
        public static long Lcm(long a, long b) {
            return a * (b / Gcd(a, b));
        }

        // ユークリッドの互除法 
        public static long Gcd(long a, long b) {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
  
}


Measured memory_bytes: 13140
def main():
    N = int(input())
    A = list(map(int, input().split()))
    m = min(A)
    M = max(A)

    p = 10**10
    for i in range(m, M+1):
        c = 0
        for a in A:
            c += (a-i)**2
        if c < p:
            p = c

    print(p)


main()


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

using namespace std;

int const NMAX = 1e5 + 11;

int  n, succ[NMAX];
bool vis[NMAX];

int dfs(int u)
{
    if (u == 1)
        return 0;
    int ans = -1;
    int v   = succ[u];

    vis[u] = true;
    if (not vis[v])
        ans = dfs(v);
    if (ans != -1)
        ++ans;

    return ans;
}

int main(void)
{
    int n;

    cin >> n;

    for (int u = 0; u < n; ++u)
        cin >> succ[u], --succ[u];

    cout << dfs(0) << endl;
    return 0;
}


Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); } } _io;
typedef long long ll; typedef long double db;

int exgcd(int a, int b, int& x, int& y)
{
    if (!b)
    {
        x = 1;
        y = 0;
        return a;
    }
    int d = exgcd(b, a % b, x, y);
    int t = x;
    x = y;
    y = t - (a / b) * y;
    return d;
}
int getInv(int a, int mod)
{
    int x, y;
    return exgcd(a, mod, x, y) == 1 ? (x % mod + mod) % mod : -1;
}

vector<int> fa;
int find(int x)
{
    if (x != fa[x]) fa[x] = find(fa[x]);
    return fa[x];
}
void merge(int a, int b)
{
    a = find(a);
    b = find(b);
    if (a != b) fa[a] = b;
}

int main()
{
    int N, M;
    cin >> N >> M;
    fa.assign(N + 1, -1);
    vector<int> cnt(N + 1, 0);
    for (int i = 1; i <= N; ++i) fa[i] = i;
    while (M--)
    {
        int a, b;
        cin >> a >> b;
        merge(a, b);
    }
    for (int i = 1; i <= N; ++i) ++cnt[find(i)];
    int ans = 1;
    for (int i = 1; i <= N; ++i)
        ans = max(cnt[i], ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int a;
  string s;
  cin >>a>>s;
  
  if(a>=3200) {
  cout << s << endl;
  }
  
  else puts("red");
  
}


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    int pc_n, student_n;
    while (cin >> pc_n >> student_n, pc_n|student_n) {
        vvi log(pc_n+1, vi(721, -1));
        int r;
        cin >> r;
        REP(i, r) {
            int t, n, m, s;
            cin >> t >> n >> m >> s;
            if (s) {
                log[n][t-540] = m;
            } else {
                for (int j = t-540-1; log[n][j] != m; j--) {
                    log[n][j] = m;
                }
            }
        }

//        FOR(i, 1, pc_n+1) {
//            REP(j, 720) {
//                if (log[i][j] != -1) {
//                    LOG("%d", log[i][j]);
//                } else {
//                    LOG(" ");
//                }
//            }
//            LOG("\n");
//        }

        int q;
        cin >> q;
        REP(i, q) {
            int ans = 0;
            int ts, te, m;
            cin >> ts >> te >> m;
            FOR(t, ts, te) {
                FOR(j, 1, pc_n+1) {
                    if (log[j][t-540] == m) {
                        ans++;
                        break;
                    }
                }
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 5660
#include <iostream>
#include <algorithm>
#include <vector>
#define X_MAX 300001
using namespace std;
 
bool isMSP[X_MAX];
vector<int> msp;
 
void make() {
  bool flag = true;
  fill(isMSP, isMSP+X_MAX, true);
  for(int i = 0; i <= 5; ++i) isMSP[i] = false;
  for(int i = 6; i < X_MAX; i += (flag) ? 2 : 5, flag = !flag) {
    if(!isMSP[i]) continue;
    msp.push_back(i);
    for(int j = i*2; j < X_MAX; j += i) isMSP[j] = false;
  }
}
 
void solve(int x) {
  cout << x << ":";
  for(int i = 0; i < msp.size() && msp[i] <= x ; ++i) {
    if(x % msp[i] == 0) cout << " " << msp[i];
  }
  cout << endl;
}
 
main() {
  int x;
  make();
  while((cin >> x) && x != 1) {
    solve(x);
  }
}

Measured memory_bytes: 1636
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

const int N = 5005;
int d[N];
int d2[N];
ll px[N];
int k;

void deal(int n, int x, int m) {
  n--;
  ll sum = 0;
  ll fulls = n/k;
  int extra = n - fulls*k;
  ll part = 0;
  for (int i = 0; i < k; ++i) {
    d2[i] = d[i] % m;
    if (d2[i] == 0) d2[i] = m;
    sum += d2[i];
    if (i < extra) {
      part += d2[i];
    }
  }
  ll tot = fulls * sum + part + x;
  ll ans = tot / m - x/m;
  cout << n-ans << nl;
}

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  int q;
  cin >> k >> q;
  for (int i = 0; i < k; ++i) {
    cin >> d[i];
    px[i+1] = px[i] + d[i];
  }
  while (q--) {
    int n,x,m;
    cin >> n >> x >> m;
    deal(n,x,m);
  }

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <math.h>
#define lli long long int
#include <limits.h>
#include <fstream>

using namespace std;

/*lli gcd(lli a,lli b)
{
	if(a==0)return b;
	return gcd(b%a,a);
}*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli i,j,tt=1;
    //cin>>tt;
    while(tt--)
    {
        lli n,ans=0,tp=0;
        cin>>n;
        lli a[n];
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        tp=n-2;
        ans=a[n-1];
        j=n-2;
        while(tp)
        {
            for(i=0;i<min(tp,2LL);i++)
            {
                ans+=a[j];
            }
            tp-=min(tp,2LL);
            j--;
        }
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 5216
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long K = sc.nextLong();
        long D = sc.nextLong();
        if (X < 0) X *= -1;
        long mod = X%D;
        long cnt;
        long min1;
        long min2;
        if (mod <= D-mod) {
            cnt = (X-mod)/D;
            min1 = mod;
            min2 = D-mod;
        } else {
            cnt = (X+(D-mod))/D;
            min1 = D-mod;
            min2 = mod;
        }
        if (K <= cnt) {
            System.out.println(Math.abs(X-K*D));
        } else if ((K-cnt)%2 == 0) {
            System.out.println(min1);
        } else {
            System.out.println(min2);
        }
    }
}


Measured memory_bytes: 35896
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    int b[m];
    for(int i = 0; i < m; ++i){
        int x;
        cin >> x;
        b[i] = x;
    }
    int a[n][m];
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            int x;
            cin >> x;
            a[i][j] = x;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        int sum = c;
        for(int j = 0; j < m; ++j){
            sum += a[i][j]*b[j];
        }
        if(sum > 0){
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000007;
 
int main(){
  string S;
  cin >> S;
  bool ans = true;
  int ans1 = -1;
  if(S[0] != 'A') ans = false;
  for(int i=2; i<S.size()-1;i++){
    if(S[i] == 'C'){
      ans1 = i;
    }
  }
  if(ans1 == -1) ans = false;
  for(int i=1;i<S.size();i++){
    if(i == ans1) continue;
    int a = 'z' - S[i];
    if(a <= 25 && a >= 0) continue;
    else{
      ans = false;
      break;
    }
  }
  if(ans) cout << "AC" << endl;
  else cout << "WA" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

typedef long long LL;

using namespace std;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	string sa, sb, sc;
	cin >> sa >> sb >> sc;
	char latest = sa[0];
	sa.erase(sa.begin());
	while (true) {
		if (latest == 'a') {
			if (sa.empty()) {
				cout << 'A';
				return 0;
			}
			else {
				latest = sa[0];
				sa.erase(sa.begin());
			}
		}
		if (latest == 'b') {
			if (sb.empty()) {
				cout << 'B';
				return 0;
			}
			else {
				latest = sb[0];
				sb.erase(sb.begin());
			}
		}
		if (latest == 'c') {
			if (sc.empty()) {
				cout << 'C';
				return 0;
			}
			else {
				latest = sc[0];
				sc.erase(sc.begin());
			}
		}
	}
	return 0;
}

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

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

	int t = a * 2;
	int k = a * 4;

	if (b >= t && b <= k && b % 2 == 0) {
		cout << "Yes" << endl;
	}

	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	int K, S; cin >> K >> S;
	int ans = 0;
	rep(x, 0, K + 1) {
		rep(y, 0, K + 1) {
			if ((S - x - y) >= 0 && (S - x - y) <= K) {
				ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

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


int sign(int v)
{
	if(v>=0) return 1;
	return -1;
}


struct solver
{
	int dx, dy, d;
	int k, x, y, bx, by, n;
	ll r;
	vpii ans;
	solver(int ik, int ix, int iy, int ibx=0, int iby=0) : k(ik), x(ix), y(iy), bx(ibx), by(iby) {
		func();
		n=(d+k-1)/k;
		r=(ll)n*k-d;
		if(n==1 && r!=0) n++;
		r=(ll)n*k-d;
		if(r%2)
		{
			n++;
			r=n*k-d;
			if(r%2) n=0;
		}
//		printf("k=%d dx=%d dy=%d n=%d\n", k, dx, dy, n);
	}
	vpii solve(void);
	void func(void)
	{
		dx=x-bx;
		dy=y-by;
		d=abs(dx)+abs(dy);
	}
};


vpii solver::solve(void)
{
	if(n==0) return ans;

	if(r>k*2)
	{
		bx-=sign(dx)*k;
		ans.push_back(make_pair(bx, by));
		func();
		n--;
		r-=k*2;
	}

	if(r)
	{
		if(abs(dx)>abs(dy))
		{
			bx+=sign(dx)*(k-r/2);
			by-=sign(dy)*r/2;
		}
		else
		{
			bx-=sign(dx)*r/2;
			by+=sign(dy)*(k-r/2);
		}
		ans.push_back(make_pair(bx, by));
		n--;
	}

	for(int i=0;i<n;i++)
	{
		func();
		int amx=min(k, abs(dx));
		int amy=k-amx;

		bx+=amx*sign(dx);
		by+=amy*sign(dy);
		ans.push_back(make_pair(bx, by));
	}

	return ans;
}


int main(void)
{
	int k, x, y;

	while(scanf("%d%d%d", &k, &x, &y)==3)
	{
		solver s(k, x, y);
		vpii ans=s.solve();

		if(ans.size()==0)
		{
			printf("%d\n", -1);
		}
		else
		{
			printf("%d\n", ans.size());
			for(auto mans:ans)
			{
				printf("%d %d\n", mans.first, mans.second);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 5488
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y;
	cin>>x>>y;
  	if(y%2==0)
    {
      if(y/2>=x&&(2*x>=y/2))
      cout<<"Yes";
      else
       cout<<"No";
    }
  	else
    {
      cout<<"No";
    }
}

Measured memory_bytes: 3576
#include <iostream>
using namespace std;
int main()
{
  int r, g, b;
  cin >> r >> g >> b;
  string ans = "NO";
  if ((r * 100 + g * 10 + b) % 4 == 0)
    ans = "YES";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#define MAX_U   10
#define MIN_U   0
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef queue<int> qi;
const int INF=numeric_limits<int>::infinity();
void printa(){cout<<"\n";}
template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
template<class... A>void printa(const A&... rest){printa(rest...);}
void prints(){cout<<" ";}
template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
template<class... A>void prints(const A&... rest){prints(rest...);}
int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
double trapezium(int a,int b,int h){return (a+b)*h/2;}
double triangle(int a,int h){return a*h/2;}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b,c;
    cin >>a>>b>>c;
    transform(a.begin(),a.end(),a.begin(), ::toupper);
    transform(b.begin(),b.end(),b.begin(), ::toupper);
    transform(c.begin(),c.end(),c.begin(), ::toupper);
    printa(a[0],b[0],c[0]);
    return 0;
}

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

using PII = pair<int, int>;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  for (auto& s : S)
    cin >> s;

  int ret = 1e+9;
  for (int i = 0; i < (1 << (H - 1)); ++i) {
    int slice = 0;
    int c = 0;
    for (int j = i; j; j >>= 1)
      c += (j & 1);

    vector<int> white(H, 0);
    bool over = false;
    bool first = true;
    for (int j = 0; j < W; ++j) {
      int ki = 0;
      for (int k = 0; k < H; ++k) {
        white[ki] += (S[k][j] == '1');
        if (white[ki] > K) {
          over = true;
          break;
        }
        if ((i >> k) & 1) {
          ++ki;
        }
      }

      if (over) {
        if (first) {
          c = 1e+9;
          break;
        }
        ++c;
        --j;
        over = false;
        first = true;
        for (int k = 0; k < H; ++k)
          white[k] = 0;
      } else {
        first = false;
      }
    }
    ret = min(ret, c);
  }
  cout << ret << "\n";

  return 0;
}


Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import math
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

ans = ''
for s in S:
    if s == '?':
        ans += 'D'
    else:
        ans += s
print(ans)

Measured memory_bytes: 10984
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pdd pair<double, double>
#define V vector<int>
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define db(x) cout << #x << "=" << (x) << endl
#define db2(x, y) cout << #x << "=" << (x) << " " << #y << "=" << (y) << endl
#define db3(x, y, z) cout << #x << "=" << (x) << " " << #y << "=" << (y) << " " << #z << "=" << (z) << endl

using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 7;
const double eps = 1e-9;

pii a[maxn];
int main()
{
    #ifdef AFei
    freopen("in.txt", "r", stdin);
    #endif

    int N;
    cin >> N;
    for(int i = 0; i < N; ++ i)
    {
        cin >> a[i].first;
        a[i].second = i+1;
    }
    sort(a, a+N);
    for(int i = 0; i < N; ++ i)
        printf(i == N-1 ? "%d\n" : "%d ", a[i].second);

    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000005;
typedef long long int lli;
int n;
int a[maxn];
lli res;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",a+i);
	int cur=0,r=0;
	for(int i=0;i<n;i++)
	{
		while(r<n&&!(cur&a[r]))
		{
			cur^=a[r];
			++r;
		}
		res+=r-i;
		cur^=a[i];
	}
	cout<<res<<endl;
	return 0;
}

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

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

#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define ll long long
#define ull unsigned long long

#define PI (3.141592653589794)
#define eps 1e-8

int main() {
	ll x, y;
	cin >> x >> y;
	if (abs(x-y) <= 1)cout << "Brown" << endl;
	else cout << "Alice" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    long long x, sum1 = 0, sum2 =0, sum3 = 0, res = 0;
    cin>>x;

    sum1 = x / 500;
    sum2 = x % 500;

    if(sum2 > 5){
        sum3 = sum2 / 5;
    }

    res = (sum1 * 1000) + (sum3 * 5);
    cout<<res<<endl;






}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n, i, a;
  double sum = 0.0, ans;
  scanf("%d", &n);
  for(i = 0; i < n; ++i){
    scanf("%d", &a);
    sum += (double)(1.0 / a);
  }
  ans = (1.0 / sum);
  printf("%f", ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<ctime>
#include<bitset>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 1e9+7;

inline ll max(ll a,ll b) { return a>b?a:b; }
inline ll min(ll a,ll b) { return a<b?a:b; }
inline ll abs1(ll a) { return a>0?a:-a; }

//const int maxn=

inline ll quickmi(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1)
            ans=ans*a%mod;  
        a=a*a%mod;  
        n>>=1;
    }
    return ans;
}


int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	ll n;
	while(cin>>n)
		cout<<(quickmi(10,n)%mod-quickmi(9,n)%mod*2%mod+quickmi(8,n)%mod+mod)%mod<<endl;
	
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>

constexpr int INF = 1 << 30;

std::vector<int> facts;
std::map<std::vector<int>, int> encs;
std::vector<std::vector<int>> decs;

void init() {
    facts.resize(9);
    facts[0] = 1;
    for (int i = 1; i <= 8; ++i) facts[i] = facts[i - 1] * i;

    decs.resize(facts[7]);
    std::vector<int> idxs(7);
    std::iota(idxs.begin(), idxs.end(), 0);
    int cnt = 0;
    do {
        decs[cnt] = idxs;
        encs[idxs] = cnt++;
    } while (std::next_permutation(idxs.begin(), idxs.end()));
}

int enc(std::vector<int> xs) {
    while (xs.size() < 7) xs.push_back(xs.size());
    return encs[xs];
}

std::vector<int> compress(const std::vector<int>::iterator& begin,
                          const std::vector<int>::iterator& end) {
    std::vector<int> idxs(begin, end);
    int n = idxs.size();

    std::vector<int> ret(n, 0);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (idxs[i] > idxs[j]) ++ret[i];
        }
    }
    return ret;
}

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> ds(n), xs(n);
    for (auto& d : ds) std::cin >> d;
    for (auto& x : xs) std::cin >> x;

    std::vector<int> dp(facts[7], -INF);
    int r = std::min(7, n);
    // exhaustive search on [0, r)
    {
        std::vector<int> idxs(r);
        std::iota(idxs.begin(), idxs.end(), 0);
        do {
            int sum = 0;

            for (int i = 0; i < r; ++i) {
                for (int j = 0; j < r; ++j) {
                    if (std::abs(i - j) > ds[i] ||
                        idxs[i] >= idxs[j]) continue;
                    sum += xs[i];
                }
            }

            dp[enc(idxs)] = sum;
        } while (std::next_permutation(idxs.begin(), idxs.end()));
    }

    auto ndp = dp;
    std::vector<int> idxs(8);
    std::iota(idxs.begin(), idxs.end(), 0);

    while (r < n) {
        std::fill(ndp.begin(), ndp.end(), -INF);

        do {
            int prev = enc(compress(idxs.begin(), --idxs.end()));
            int nxt = enc(compress(++idxs.begin(), idxs.end()));

            int sum = 0;
            for (int i = 0; i < 7; ++i) {
                int l = r - 7 + i;
                if (idxs[i] < idxs[7] && std::abs(r - l) <= ds[l]) sum += xs[l];
                if (idxs[i] > idxs[7] && std::abs(r - l) <= ds[r]) sum += xs[r];
            }

            ndp[nxt] = std::max(ndp[nxt], sum + dp[prev]);
        } while (std::next_permutation(idxs.begin(), idxs.end()));

        std::swap(dp, ndp);
        ++r;
    }

    std::cout << *std::max_element(dp.begin(), dp.end()) << "\n";
}

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

    init();
    solve();

    return 0;
}



Measured memory_bytes: 4204
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,sum,ct1,f[1000005];
char s[1000005];
int getans(int n,int m)
{
	if(n<m) return 0;
	if(n<=1) return 1;
	return getans(n/2,m/2)*getans(n%2,m%2); 
}
int main()
{
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++)
		f[i]=getans(n-1,i-1);
	for(int i=1;i<=n;i++)
		ct1+=(s[i]=='2');
	int ct=0;
	if(ct1)
	{
		for(int i=1;i<=n;i++)
			if(f[i]) ct+=(s[i]=='2');
		if(ct%2) printf("1");
		else printf("0");
	}
	else
	{
		for(int i=1;i<=n;i++)
			if(f[i]) ct+=(s[i]=='3');
		if(ct%2) printf("2");
		else printf("0");
	}
	return 0;
}

Measured memory_bytes: 4992
/**
*	created: 16.08.2020 13:39:33
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;
using P = pair<int,int>;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = LLONG_MAX;
const int MOD = 1000000007;
// const int MOD = 998244353;

int a[3005][3005];
int dp[3005][3005][4];

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int r, c, n; cin >> r >> c >> n;
    rep(i,n) {
        int x, y, v; cin >> x >> y >> v;
        a[x-1][y-1] = v;
    }
    rep(i,r) rep(j,c) {
        for (int k = 2; k >= 0; k--) {
            chmax(dp[i][j][k+1], dp[i][j][k]+a[i][j]);
        }
        rep(k,4) {
            chmax(dp[i+1][j][0],dp[i][j][k]);
            chmax(dp[i][j+1][k],dp[i][j][k]);
        }
    }
    int ans = 0;
    rep(i,4) chmax(ans,dp[r-1][c-1][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 355860
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};


int flag[20];
int main(){
    SCIN(str);
    flag[0]=1;
    bool result = true;
    if(str.front() != 'A'){
        COUT("WA");
        return 0;
    }
    int c = 0;
    for(int a = 2;a < str.size()-1;a++){
        if(str.at(a) == 'C'){
            flag[a]=1;
            c++;
        }
    }
    if(c != 1){
        COUT("WA");
        return 0;
    }
    int w = 0;
    for(int a = 0;a < str.size();a++){
        if('A' <= str.at(a) && str.at(a) <= 'Z'){
           w++;
        }
    }
    if(w != 2){
        COUT("WA");
        return 0;
    }
    COUT("AC");
    return 0;
}


Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;

      bool flag=false;

      string str,ptr;

      cin>>str>>ptr;

      ptr.pop_back();

      if(str==ptr)cout<<"Yes"<<endl;

      else cout<<"No"<<endl;



}



Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> ans;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++){
        if(a[i] > i + 1){
            cout << -1 << endl;
            return 0;
        }
    }
    while(!a.empty()){
        vector<int> b;
        for(int i = 0; i < a.size(); i++){
            if(a[i] == i + 1){
                b.emplace_back(i);
            }
        }
        ans.emplace_back(a[b.back()]);
        a.erase(a.begin() + b.back());
    }
    reverse(ans.rbegin(),ans.rend());
    for(auto v:ans)cout << v << endl;
}

Measured memory_bytes: 3104
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int func(int a, int b, int c, int cnt) {

	if (a == b && b == c) {
		cout << "onaji" << cnt << endl;
	}

	cout << cnt << endl;
	cout << "a->" << a << "b->" << b << "c->" << c << endl;


	func(a + 1, b + 1, c, cnt + 1);
	func(a + 1, b, c + 1, cnt + 1);
	func(a, b + 1, c + 1, cnt + 1);

	func(a + 2, b, c, cnt + 1);
	func(a, b + 2, c, cnt + 1);
	func(a, b, c + 2, cnt + 1);

	return 0;
}

int main() {
	int i, j, k;
	int a, b, c;
	int maxn = 0, cnt = 0;

	cin >> a >> b >> c;

	maxn = max(a, b);
	maxn = max(maxn, c);

	if (a == b && b == c) {
		cout << "0" << endl;
		getchar();
		getchar();
		return 0;
	}

	for (; ; ) {
		bool flag = false;
		if (maxn - 4 > a) {
			a += 2;
			cnt++;
			flag = true;
		}
		if (maxn - 4 > b) {
			b += 2;
			cnt++;
			flag = true;
		}
		if (maxn - 4 > c) {
			c += 2;
			cnt++;
			flag = true;
		}
		if (flag == false) break;
	}


	queue<int> qa, qb, qc;

	qa.push(a);
	qb.push(b);
	qc.push(c);

	int cnt2 = 0, cnt3 = 0;
	int a2, b2, c2;

	int kei = 1, kei2 = 0;
	for (;;) {

		if (cnt2 == kei) {
			kei = kei * 6;
			cnt2 = 0;
			kei2++;
		}

		a2 = qa.front();
		b2 = qb.front();
		c2 = qc.front();

		qa.pop();
		qb.pop();
		qc.pop();

		if (a2 == b2 && b2 == c2) break;

		cnt2++;

		qa.push(a2 + 1); qb.push(b2 + 1);  qc.push(c2);
		qa.push(a2 + 1); qb.push(b2);  qc.push(c2 + 1);
		qa.push(a2); qb.push(b2 + 1);  qc.push(c2 + 1);

		qa.push(a2 + 2); qb.push(b2);  qc.push(c2);
		qa.push(a2); qb.push(b2 + 2);  qc.push(c2);
		qa.push(a2); qb.push(b2);  qc.push(c2 + 2);

		//cnt2 = cnt2 * 6;
		//cnt2++;

	}

	cout << kei2 + cnt  << endl;

	getchar();
	getchar();
	return 0;

	if (cnt2 <= 1) {
		cout << 1 + cnt << endl;

		return 0;
	}

	int cnt4 = 0;
	for (i = 1; ; i=i*6) {
		/*
		if (cnt2 >= i && cnt2 < i * 6) {
			cout << i << endl;
			break;
		}
		*/

		cnt2 = cnt2 - i;
		/*
		if (cnt2 < i * 6) {
			cout << i << endl;
			break;
		}*/
		//cnt4++;
		if (cnt2 <= 0) {

			cout << cnt4 + cnt << endl;
			break;
		}
		cnt4++;

	}

	/*
	int num = 1;
	for (i = 1; i<200  ; i++) {
		cnt2 = cnt2 - num;
		num = num * 6;
		//cnt2 = cnt2 - num;
		if (cnt2 <= 0) {
			num = i - 1;
			break;
		}
	}

	cout << "num->" << num << endl;
	cout << "ans->" << num + cnt << endl;
	*/

	getchar();
	getchar();
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  string a, b;
  cin >> a >> b;
  string c = a + b;
  int val = atoi(c.c_str());
  string ans = "No";
  for (int i = 1; i * i <= val; ++i) {
    if (i * i == val) {
      ans = "Yes";
      break;
    }
  }
  printf("%s\n", ans.c_str());
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main(String[] args){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
			String line = reader.readLine();
        	String[] num = line.split(" ", -1);
        	int a = Integer.parseInt(num[0]);
        	int b = Integer.parseInt(num[1]);
        	int c = Integer.parseInt(num[2]);
        	int n = 0;
        	for (int i = a; i <= b; i++) {
        		if((c % i) == 0) {
        			n = n + 1;
        		} else {
        			//nothing
        		}
        	}
        	System.out.println(n);
        } catch (IOException e) {
          System.out.println(e);
        } catch (NumberFormatException e) {
          System.out.println("error");
        }
    }
}

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

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

	int x;
	cin >> x;
	auto primejudge = [&](int c) {
		if(c == 1 || c == 0) {
			return false;
		}else if(c == 2) {
			return true;
		}else {
		    for(int i = 2; i * i <= c; i++) {
			    if(c % i == 0) {
				    return false;
			    }
		    }
		}
		return true;
	};
	while(!primejudge(x)) {
		x += 1;
	}
	cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>
#include <iomanip>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int a[1000000];
int main() {
	for (int n; cin >> n, n != 0; ) {
		int m; cin >> m;
		string s; cin >> s;
		int ans = 0;
		a[0] = a[1] = 0;
		REP(i, 2, m - 1) {
			if (s.substr(i - 2, 3) == "IOI") {
				a[i] = 1;
				if (s[i - 2] == 'I') a[i] += a[i - 2];
				if (a[i] >= n) ans++;
			}
			else {
				a[i] = 0;
			}
		}
		cout << ans << endl;
	}
	return 0;
}
	

Measured memory_bytes: 5760