akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

	int N, A, B;
	cin >> N >> A >> B;
	cout << min(N*A, B) << endl;
}


Measured memory_bytes: 892
#include <stdio.h>
int main()
{
   int a,b,c[3],i,temp=-99999;
   scanf("%d %d",&a,&b);
   c[0]=a+b;
   c[1]=a-b;
   c[2]=a*b;
   for(i=0;i<3;i++){
    if(c[i]>temp){
        temp=c[i];
    }
   }
   printf("%d\n",temp);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <utility>
#include <cstdio>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <assert.h>
#include <cmath>
using namespace std;

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

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

struct State {
    int v, cost;

    State(int v, int cost): v(v), cost(cost) {}

    // 昇順
    bool operator<(const State& s) const {
        return cost < s.cost;
    }
    // 降順
    bool operator>(const State& s) const {
        return cost > s.cost;
    }
};

template<typename T>
void dump_vector(vector<T> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << (i < vec.size() - 1 ? " " : "\n");
    }
}

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

    vector<ll> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }

    ll ans = 0;
    for (int i = 1; i < n; i++) {
        if ((x[i] - x[i - 1]) * a > b) {
            ans += b;
        } else {
            ans += (x[i] - x[i - 1]) * a;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se>b.se;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //------------------------------
    int n;cin>>n;
    if(n%1000==0){
        cout<<0<<endl;
        return 0;
    }
    n%=1000;
    n=1000-n;
    cout<<n<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------






































Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

using namespace __gnu_pbds;
using namespace std;
const int mod = 1e9 + 7;
// const int mod=998244353;
//const int mod=1e9+9;
//const int INF=4e18+10;
const int INF = 4e18 + 10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) \
int n;      \
cin >> n;
#define readv(x, n)   \
vector<int> x(n); \
for (auto &i : x) \
    cin >> i;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template <typename T1, typename T2>
void set_min(T1 &a, T2 b)
{
    a = min(a, (T1)b);
}

int multiply(int a, int b, int in_mod) { return (a * b) % in_mod; }
int mult_identity(int a) { return 1; }


auto power(auto a, int b, int in_mod)
{
    auto prod = mult_identity(a);
    auto mult = a % in_mod;
    while (b != 0)
    {
        if (b % 2)
        {
            prod = multiply(prod, mult, in_mod);
        }
        mult = multiply(mult, mult, in_mod);
        b /= 2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod - 2, in_mod);
}


void solve()
{
    int n;
    cin>>n;
    int z,w;
    cin>>z>>w;
    readv(a,n);
    reverse(all(a));
    a.insert(a.end(), w);
    a.insert(a.end(), z);


    vector<vector<int>> dp(n+3,  vector<int>({0, INF}));

    for(int i= 1;i<=n;i++)
    {
            //first player

            for(int k = 1;k<i;k++)
                dp[i][0] = max(dp[i][0], dp[k][1]);
            dp[i][0] = max(dp[i][0], abs(a[i] - a[0]) );

            //second player
            for(int k = 1;k<i;k++)
                dp[i][1] = min(dp[i][1], dp[k][0]);
            dp[i][1] = min(dp[i][1], abs(a[i] - a[0]) );

    }

    cout<<dp[n][0]<<endl;


}



signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cerr.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t = 1;
    // cin >> t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<":\n";
        //cout<<"Trip #"<<test<<": ";
        // cout<<endl;
        solve();
        // solveB();

        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 3788
n, x, y = map(int, input().split())
x, y = x-1, y-1

d = {i:0 for i in range(1, n)}
for i in range(n-1):
    for j in range(i+1, n):
        d[min(j-i, abs(j-y)+1+abs(x-i))] += 1
print(*d.values(), sep='\n')

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	ll X, Y;
	cin >> X >> Y;
	if(X >= Y && X % Y == 0){
		cout << -1 << endl;
	}
	else{
		cout << X << endl;
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=5+2;
char str[maxn];
int main(){
	scanf("%s",str+1);
	int len=strlen(str+1);
	for (int i=1;i<len;i++)
		if (str[i]=='A'&&str[i+1]=='C'){
			printf("Yes");
			return 0;
		}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
    int k;
    s(k);
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    out<<a[k-1]<<endl;
}

class AKthTerm {
public:
	void solve(std::istream& in, std::ostream& out) {
        ios_base::sync_with_stdio(false);
        in.tie(0);out.tie(0);
        int t;
        int READ = 0;
        if(READ) s(t);
        else t = 1;
        while(t--){
            ssolve(in, out);
        }
	}
};


integer main() {
	AKthTerm solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


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

typedef long long ll;

// see: https://drken1215.hatenablog.com/entry/2020/06/21/225500
int main() {
  ll N;
  cin >> N;

  vector<int> list;
  ll num = N;
  while (num > 0) {
    num--;

    list.push_back(num % 26);
    num /= 26;
  }

  for (int i = list.size() - 1; i >= 0; i--) {
    cout << (char)('a' + list[i]);
  }
  cout << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
    
    // Your code here!
    int n, k;
    cin >> n >> k;
    ll a[n];
    ll ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        ans += a[i];
    }
    sort(a, a+n,greater<int>());
    
    for(int i = 0; i < k; i++){
        if(ans > 0){
            ans -= a[i];
        }else {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
N,A,B = [ int(it) for it in input().split() ]
li = [ int(it) for it in input().split() ]
s = 0
for i in range(len(li)-1):
  d = li[i+1] - li[i]
  if (A*d<B):
    ds = d*A
  else:
    ds = B
  s+=ds
print (s)
    
  



Measured memory_bytes: 62832
n=int(input())
a=list(map(int,input().split()))
m=max(a)
alist=[0]*(m+1)
for i in a:
  for j in range(i,m+1,i):
    alist[j]+=1
cnt=0
for i in a:
  if alist[i]==1:
    cnt+=1
print(cnt)

      

Measured memory_bytes: 32316
k=int(input())
l=[]
for i1 in range(10):
  l.append(i1)
  for i2 in range(max(i1-1,0),min(i1+2,10)):
    l.append(i1*(10**1)+i2)
    for i3 in range(max(i2-1,0),min(i2+2,10)):
      l.append(i1*(10**2)+i2*(10**1)+i3)
      for i4 in range(max(i3-1,0),min(i3+2,10)):
        l.append(i1*(10**3)+i2*(10**2)+i3*(10**1)+i4)
        for i5 in range(max(i4-1,0),min(i4+2,10)):
          l.append(i1*(10**4)+i2*(10**3)+i3*(10**2)+i4*(10**1)+i5)
          for i6 in range(max(i5-1,0),min(i5+2,10)):
            l.append(i1*(10**5)+i2*(10**4)+i3*(10**3)+i4*(10**2)+i5*(10**1)+i6)
            for i7 in range(max(i6-1,0),min(i6+2,10)):
              l.append(i1*(10**6)+i2*(10**5)+i3*(10**4)+i4*(10**3)+i5*(10**2)+i6*(10**1)+i7)
              for i8 in range(max(i7-1,0),min(i7+2,10)):
                l.append(i1*(10**7)+i2*(10**6)+i3*(10**5)+i4*(10**4)+i5*(10**3)+i6*(10**2)+i7*(10**1)+i8)
                for i9 in range(max(i8-1,0),min(i8+2,10)):
                  l.append(i1*(10**8)+i2*(10**7)+i3*(10**6)+i4*(10**5)+i5*(10**4)+i6*(10**3)+i7*(10**2)+i8*(10**1)+i9)
                  for i10 in range(max(i9-1,0),min(i9+2,10)):
                    l.append(i1*(10**9)+i2*(10**8)+i3*(10**7)+i4*(10**6)+i5*(10**5)+i6*(10**4)+i7*(10**3)+i8*(10**2)+i9*(10**1)+i10)

l=list(set(l))
l.sort()
print(l[k])

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

int main() {
    deque<long long int> deq;
    int q;
    cin >> q;
    for(int i = 0; i < q; i++) {
        int command;
        cin >> command;
        if(command == 0) {
            int d;
            long long int x;
            cin >> d >> x;
            d == 0 ? deq.push_front(x) : deq.push_back(x);
        } else if(command == 1) {
            int p;
            cin >> p;
            cout << deq[p] << endl;
        } else if(command == 2) {
            int d;
            cin >> d;
            d == 0 ? deq.pop_front() : deq.pop_back();
        }
    }
    return 0;
}


Measured memory_bytes: 6260
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            Set<Character> set = new HashSet<>();
            for (int i = 0; i < n; ++i) set.add(in.nextCharacter());
            out.println(set.size() == 3 ? "Three" : "Four");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            int res = 0;
            do {
                if (c == ',') {
                    c = pread();
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public char nextCharacter() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            return (char) c;
        }

    }
}



Measured memory_bytes: 21332
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
#define ll long long
using namespace std;

int n;
char a[100];
char b[100];
const ll mod = 1e9 + 7;

int main()
{
    scanf("%d",&n);
    scanf("%s%s",a,b);
    bool pre = false;
    ll ans;
    int now;
    if(a[0] == b[0])
    {
        now = 1;
        ans = 3;
    }else
    {
        now = 2;
        ans = 6;
        pre = true;
    }

    while(now < n)
    {
        if(a[now] == b[now])
        {
            if(!pre)
            {
                ans = ans * 2 % mod;
            }else pre = false;
            ++now;
        }else
        {
            if(pre) ans = ans * 3 % mod;
            else ans = ans * 2 % mod;
            pre = true;
            now += 2;
        }
    }
    printf("%lld\n",ans);

}


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

int main(){
  int n,m;
  cin >>n >>m;
  vector<int> a(n);
  int sum = 0;
  rep(i,n) {
    cin >>a[i];
    sum += a[i];
  }
  sort(a.begin(), a.end(),greater<int>());
  bool can = true;
  rep(i,m){
    if(a[i]<(sum+4*m-1)/(4*m)) can = false;
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

sa = set()  # 島1と便がある島
sb = set()  # 島Nと便がある島

for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        sa.add(b)
    if b == n:
        sb.add(a)

if len(sa & sb) > 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 18936
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int N, M;

int main(){
    scanf("%d%d", &N, &M);
  	int K = N - M;

    ll int ans = (1900 * M + 100 * K);
  	REP(i, M) ans *= 2;
    printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int H=12,W=6;

int count(char grid[][W+1],int i,int j,char c,bool vis[][W])
{
	if(i<0 || H<=i || j<0 || W<=j || vis[i][j] || grid[i][j]!=c)
		return 0;
	vis[i][j]=1;
	int res=1;
	for(int k=0;k<4;k++)
		res+=count(grid,i+"\xff\x1\0\0"[k],j+"\0\0\xff\x1"[k],c,vis);
	return res;
}

void reset(char grid[][W+1],int i,int j,char c)
{
	if(i<0 || H<=i || j<0 || W<=j || grid[i][j]!=c && grid[i][j]!='O')
		return;
	if(grid[i][j]=='O')
		grid[i][j]='.';
	else{
		grid[i][j]='.';
		for(int k=0;k<4;k++)
			reset(grid,i+"\xff\x1\0\0"[k],j+"\0\0\xff\x1"[k],c);
	}
}

void drop(char grid[][W+1])
{
	for(int j=0;j<W;j++)
		for(int i=H-1,k=H-1;i>=0;i--)
			if(grid[i][j]!='.')
				swap(grid[k--][j],grid[i][j]);
}

int main()
{
	int tc; cin>>tc;
	while(tc--){
		char grid[H][W+1];
		for(int i=0;i<H;i++)
			cin>>grid[i];
		
		int res=0;
		for(;;res++){
			bool updated=false;
			bool vis[H][W]={};
			for(int i=0;i<H;i++)
				for(int j=0;j<W;j++){
					if(grid[i][j]=='.' || grid[i][j]=='O'
					|| count(grid,i,j,grid[i][j],vis)<4)
						continue;
					reset(grid,i,j,grid[i][j]);
					updated=true;
				}
			if(!updated)
				break;
			drop(grid);
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr<<#x<<'='<<x<<' '
#define f first
#define s second
typedef long long ll;
typedef pair<int,int> pi;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m; cin >> n >> m;
    int ac = 0, pen = 0;
    vector<int> cnt(n+5), wrong(n+5);
    for (int i = 0; i < m; ++i) {
		int p; string x;
		cin >> p >> x;
		if (x=="AC") {
			if (cnt[p]) continue;
			cnt[p] = 1;
		} else {
			if (!cnt[p]) ++wrong[p];
		}
	}
	for (int i = 0; i <= n; ++i) {
		if (cnt[i]) {
			++ac;
			pen += wrong[i];
		}
	}
	cout << ac << ' '<< pen;
    return 0;
}


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



//-----------------------------------------------------------------------------------
typedef long long ll;
ll X, Y;
//-----------------------------------------------------------------------------------
int main() {
    cin >> X >> Y;
    if (abs(X - Y) <= 1) printf("Brown\n");
    else printf("Alice\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

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

using namespace std;

typedef pair<int,int> ii_t;

#define MAX 100010
#define RMAX 1000
char is_prime[MAX];
#define PMAX 100000
int prime[PMAX];

long long order=0;


int main() {

    int n;
    cin >> n; 
    vector<int> vec(n);
    for (int i=0;i<n;i++) cin >> vec[i];
    sort(ALL(vec),greater<int>());
    long long answer = 0;
    priority_queue<pair<int,ii_t> > que;
    int first = 0;
    int second = 0;
    int other = 0;
    for (int i=0;i<n;i++){
        if (i==0) {
        } else if (i==1) {
            answer += vec[0];
            que.push(pair<int,ii_t>(min(vec[0],vec[1]),ii_t(vec[0],vec[1])));
            que.push(pair<int,ii_t>(min(vec[0],vec[1]),ii_t(vec[1],vec[0])));
        } else {
            pair<int,ii_t> p = que.top(); que.pop();
            answer += p.first;
            que.push(pair<int,ii_t>(min(p.second.first,vec[i]),ii_t(p.second.first,vec[i])));
            que.push(pair<int,ii_t>(min(p.second.second,vec[i]),ii_t(p.second.second,vec[i])));
        }
        // cerr << "answer : " << answer << endl;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 7196
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int V, E;
    read(V, E);

    vector<int> cnt(V);
    rep(i, E) {
        int a, b;
        read(a, b);
        --a, --b;
        cnt[a] += 1;
        cnt[b] += 1;
    }

    if (all_of(all(cnt), [](int e){ return e % 2 == 0; })) {
        print("YES");
    } else {
        print("NO");
    }

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cctype>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <ctime>
#include <cstring>
#include <utility>
#include <bitset>
#include <numeric>
#include <iomanip>
#include <string.h>
#include <unordered_map>
#include <fstream>
using namespace std;

typedef long int32;
typedef unsigned long uint32;
typedef long long int64;
typedef unsigned long long uint64;

#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rFOR(i,a,b) for(int i = (a); i >= (b); i--)
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))

auto main() -> int
{
  #ifdef DEBUG
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
  #endif
  // Fast I/O
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  // Code starts here ----

	int n;
	cin >> n;
	int a[n], b[n], c[n];
	FOR(i,0,n) cin >> a[i];
	FOR(i,0,n) {
		cin >> b[i];
		c[i] = a[i] - b[i];
	}
	sort(c,c+n);
	int res = 0;
	rFOR(i,n-1,0) {
		if(c[i] < 0)
			break;
		else
			res += c[i];
	}
	cout << res;
}


Measured memory_bytes: 256
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)1e5+20
#define INF 1e18+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
#define int LL
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,a,b;
	cin>>n>>a>>b;
	if((a-b)&1) cout<<"Borys";
	else cout<<"Alice";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<map>
#include<string>
 
using namespace std;
 
map<string,int> tab{{"SUN",7},{"MON",6},{"TUE",5},{"WED",4},{"THU",3},{"FRI",2},{"SAT",1}};
int main()
{
  string s;
cin >> s;
cout<<tab[s];
return 0;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
#define pff(a,b) printf("%d  %d\n",a,b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

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

	vector<int> div;
	int h = 1;
	while (h <= min(a, b)) {
		if (a%h == 0 and b%h == 0) div.push_back(h);
		h++;
	}
	pf(div[div.size() - k]);

	return 0;
}

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

int main(){
int n,a,b,c,d,count;
while(scanf("%d",&n) != EOF){

count=0;

for(a=0;a<10;a++){
	for(b=0;b<10;b++){
		for(c=0;c<10;c++){
			for(d=0;d<10;d++){
				if(a+b+c+d==n)
					count+=1;
			}
		}
	}
}

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

Measured memory_bytes: 1024
#include<stdio.h>
 
int main(void){
    int N=0;
    int ans[60000]={0};
    
    int count=0;
    while(1){
        int sa=10000000;
        int a[60000]={0};
        scanf("%d",&N);
        if(N==0) break;
        for(int i=0;i<N;i++){
            scanf("%d",&a[i]);
        }
        while(1){
            int sw=0;
            int temp=0;
            for(int i=0;i<N-1;i++){
                if(a[i]>a[i+1]){
                    temp=a[i];
                    a[i]=a[i+1];
                    a[i+1]=temp;
                    sw=1;
                }
            }
            if(sw==0) break;
        }
        for(int i=0;i<N-1;i++){
            int tempsa=0;
            tempsa=a[i]-a[i+1];
          
            tempsa*=-1;
            if(tempsa<sa) sa=tempsa;
        }
      
        ans[count]=sa;
        count++;
    }

   
    for(int i=0;i<count;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
    
}



Measured memory_bytes: 2248
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

int main(){
    const ll MX=500;
    ll n,c;
    cin>>n>>c;
    vector<pll> A(n);
    for(auto &I:A){cin>>I.F;}
    for(auto &I:A){cin>>I.S;}
    vector<vector<ll>> sum(MX,vector<ll>(MX,0));
    for(int i=0;i<MX;i++){sum[0][i]=1;}
    for(int i=1;i<MX;i++){
        for(ll t=0;t<MX;t++){sum[i][t]=sum[i-1][t]*t%MOD;}
    }
    for(int i=0;i<MX;i++){
        for(int t=1;t<MX;t++){sum[i][t]+=sum[i][t-1]; sum[i][t]%=MOD;}
    }
    vector<ll> dp(c+1,0);
    vector<ll> next(c+1);
    dp[0]=1;
    for(int i=0;i<n;i++){
        for(auto &I:next){I=0;}
        for(int j=0;j<=c;j++){
            for(int t=0;j+t<=c;t++){
                next[j+t]+=dp[t]*(sum[j][A[i].S]-sum[j][A[i].F-1])%MOD;
                next[j+t]%=MOD;
            }
        }
        dp=next;
    }
    ll ans=dp[c];
    ans%=MOD;
    if(ans<0){ans+=MOD;}
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
using namespace std;
int main(){
	int a, b;
	while(cin >> a >> b) {
		if(a==0&&b==0) break;
		int cnt = 0;
		if(a<b) swap(a,b);
		while(b) {
			int t = a/b;
			swap(a-=b*t,b);
			cnt++;
		}
		cout << a << " " << cnt << endl;
	}
}

Measured memory_bytes: 1160
/* **********************************JAI SAI RAM ************************************* */
//HELP IN CODEFORCES ROUND 641
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll P=1000000007;
ll MAX=1e15;
ll MIN=-1*(1e15);
ll a[200001];
void  solve()
{
    ll n,i,j,k,l,m,o,q,r,t;
    ll ans=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    ans+=a[n-1];
    j=n-2;
    for(i=n-3;i>=0;)
    {
      if(i>=0)
      {
      ans+=a[j];
      i--;
      }
      if(i>=0)
      {
      ans+=a[j];
      i--;
      }
      j--;
    }
    cout<<ans<<endl;
}
int main()
{
    ll t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5184
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n; cin >> n;
    vector<long long int> s(n); rep(i,n) cin >> s[i];
    ll ans = 0;

    for(int k=1;k<n;k++){
        set<long long int> st; 
        ll t = 0;
        ll x = 0;
        while(x*k < n){
            int a = (n-1)-x*k;
            int b = a - k; if(b <= 0) break;
            if(st.count(x*k) > 0 || st.count(n-1-x*k) > 0 || x*k == n-1-x*k) break;
            st.insert(x*k); st.insert(n-1-x*k); 
            t += s[n-1-x*k] + s[x*k];
            ans = max(ans, t);
            x++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7424
def get_ac_count(S):
    buf = None
    temp = []
    count = 0
    for c in S:
        if c == "A":
            buf = "A"
        elif buf == "A" and c == "C":
            buf = None
            count += 1
        elif buf == "A":
            buf = None
        temp.append(count)
    return temp
N, Q = map(int, input().split())
S = input()
ac_count = get_ac_count(S)
for i in range(Q):
    l,r = map(int, input().split())
    print(ac_count[r-1]-ac_count[l-1])

Measured memory_bytes: 6152
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

ll wazu = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (wazu - inv(wazu % x) * (wazu / x)) % wazu;
        if (a >= 0) { return a; }
        else { return wazu + a; }
    }
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    int H, W;
    cin >> H >> W;

    vector<vector<char> > C(H, vector<char>(W));

    rep(i, H) rep(j, W) cin >> C[i][j];

    rep(i, H) {
        rep(j, W) {
            cout << C[i][j];
        }
        cout << endl;
        rep(j, W) {
            cout << C[i][j];
        }
        cout << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    long long int X,Y;
    cin >> X >> Y;
    int i = 0;
    long long int S = X;
    while(S<=Y)
    {
    	S *= 2;
    	i++;
    }
    cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [int(i) for i in input().split()]

a.insert(0,0)
result = []

tmp = []
for i in range(N+1):
  tmp.append([a[i],i])

tmp_sorted = sorted(tmp)

for i in range(1,N+1):
  result.append(tmp_sorted[i][1])

print(*result)

Measured memory_bytes: 24396
x, y, z, k = gets.split(' ').map(&:to_i)
as = gets.split(' ').map(&:to_i).sort.reverse
bs = gets.split(' ').map(&:to_i).sort.reverse
cs = gets.split(' ').map(&:to_i).sort.reverse

# Ptn.1
# 普通に loop * 3 で解くと as.size * bs.size * cs.size の計算量
anss = []
for l in 1 .. x
  for m in 1 .. y
    break if l*m > k
    for n in 1 .. z
      break if l*m*n > k
      anss << as[l-1]+bs[m-1]+cs[n-1]
    end
  end
end
puts anss.sort{|n,m|m<=>n}.take(k)

Measured memory_bytes: 6520
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))

l_gcd_list = [0]
r_gcd_list = [0]
for i in range(N):
    l_gcd_list.append(gcd(l_gcd_list[i], A[i]))
    r_gcd_list.append(gcd(r_gcd_list[i], A[-(i+1)]))
r_gcd_list = r_gcd_list[::-1]

results = []
for i in range(N):
    results.append(gcd(l_gcd_list[i], r_gcd_list[i+1]))

print(max(results))


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

map<int,int> dp[11][1024];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, s;
    while (cin >> n >> s) {
        for (int i=0; i<11; ++i) {
            for (int j=0; j<1024; ++j) {
                dp[i][j].clear();
            }
        }
        dp[0][0][0] = 1;
        for (int i=0; i<n; ++i) {
            for (int j=0; j<1024; ++j) {
                if (dp[i][j].empty()) continue;
                for (auto it = dp[i][j].begin(); it != dp[i][j].end(); ++it) {
                    for (int k=0; k<=9; ++k) {
                        if ((j & (1<<k)) == 0) {
                            dp[i+1][j|(1<<k)][it->first + (i+1)*k] += it->second;
                        }
                    }
                }
            }
        }
        int res = 0;
        for (int i=0; i<1024; ++i) {
            res += dp[n][i][s];
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3692
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int MOD = 1000000007;

// Binary Indexed Tree
class BIT
{
    int n;
    vector<int> data;
public:
    BIT(int n){ // コンストラクタ
        this->n = n;
        data.assign(n+1, 0);
    }
    void add(int k, int x){ // k番目の要素にxを加算する
        ++ k;
        while(k <= n){
            data[k] += x;
            k += k & -k;
        }
    }
    int sum(int k){ // 区間[0,k]の総和を返す
        ++ k;
        int ret = 0;
        while(k > 0){
            ret += data[k];
            k -= k & -k;
        }
        return ret;
    }
    int sum(int a, int b){ // 区間[a,b]の総和を返す
        return sum(b) - sum(a-1);
    }
};

int main()
{
    vector<long long> factorial(100001);
    factorial[0] = 1;
    for(int i=1; i<=100000; ++i){
        factorial[i] = factorial[i-1] * i;
        factorial[i] %= MOD;
    }

    for(;;){
        int n, r;
        cin >> n >> r;
        if(n == 0)
            return 0;

        vector<int> a(n);
        for(int i=0; i<n; ++i)
            a[i] = i;

        while(--r >= 0){
            int x, y;
            cin >> x >> y;
            swap(a[x-1], a[y-1]);
        }

        BIT b(n);
        long long ret = 0;
        for(int i=0; i<n; ++i){
            ret += factorial[n-1-i] * (a[i] - b.sum(a[i] - 1));
            ret %= MOD;
            b.add(a[i], 1);
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 2744
import sys

inf = (1 << 31) - 1

def solve():
    n, q = map(int, sys.stdin.readline().split())

    a = [inf] * n
    sg = SegTree(a)

    for qi in range(q):
        c, x, y = map(int, sys.stdin.readline().split())

        if c == 0:
            sg.update(x, y)
        else:
            ans = sg.find(x, y + 1, 0, 0, 2**sg.depth)

            print(ans)


class SegTree:

    def __init__(self, a):
        self.n = len(a)
        self.depth = 0

        while 2**self.depth < self.n:
            self.depth += 1

        self.dat = [inf] * (2**(self.depth + 1) - 1)

        self.dat[2**self.depth - 1:2**self.depth - 1 + self.n] = a[:]

        for i in range(2**self.depth - 2, -1, -1):
            self.dat[i] = min(self.dat[2*i + 1], self.dat[2*i + 1])

    def update(self, i, x):
        i += 2**self.depth - 1
        self.dat[i] = x

        while i > 0:
            i = (i - 1) // 2
            self.dat[i] = min(self.dat[2*i + 1], self.dat[2*i + 2])

        return

    def find(self, s, t, k, left, right):
        if t <= left or right <= s:
            return inf
        if s <= left and right <= t:
            return self.dat[k]

        vl = self.find(s, t, 2*k + 1, left, (left + right) // 2)
        vr = self.find(s, t, 2*k + 2, (left + right) // 2, right)

        return min(vl, vr)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 12344
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;
 
template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}
 
struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      std::string ss; scan(ss);
      std::string rev = ss; std::reverse(rev.begin(), rev.end());
      puts(ss == rev ? "Yes" : "No");
   }
};
 
int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}
 

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

const int INF = 10000000;

void print(vector<int> x){
  for (int n = 0; n < x.size(); n++){
    cout << x[n] << " ";
  }
  cout << endl;
}

int main(){
  
  // 部屋をnとしたらto_room[n]から接続している先の部屋のベクタ
  vector<int> to_room[100010];

  int N, M;
  cin >> N >> M;

  for (int n = 1; n <= M; n++){
    int a,b;
    cin >> a >> b;
    to_room[a].push_back(b);
    to_room[b].push_back(a);
  }

  // 部屋をnとしたらcost[n]は部屋1に至るまでの距離
  // まだ距離を計算できていない場合は最大値(INF)である
  vector<int> cost(N+1, INF);

  // 部屋1から通ってきた部屋の記録
  // 制約に"どの2部屋間も、通路をいくつか通って行き来できる"とあるので、
  // 必ずすべての部屋へ到達できる
  vector<int> route(N+1, -1);
  
  // 部屋1の評価値の初期化
  cost[1] = 0;

  // 探索する部屋
  queue<int> q;
  q.push(1);

  while(!q.empty()){
    int n = q.front();		// 探索元の部屋番号
    q.pop();
    for (int m: to_room[n]){	// m: 接続先の部屋番号
      if (cost[m] != INF){	// costが更新されていたら評価は行わない
	continue;
      }
      cost[m] = cost[n] + 1;
      route[m] = n;		// 部屋mは部屋nを経由する
      q.push(m);
    }
  }
  //cout << "cost" << endl;
  //print(cost);

  // 全ての部屋のコストが-1でないならyesを出力する
  // 実は答えは必ずyesである。
  bool check = true;
  for (int n = 2; n <= N; n++){
    if (cost[n] == INF){
      check = false;
    }
  }
  
  if (check == true){
    cout << "Yes" << endl;
    for (int n = 2; n <= N; n++){
      cout << route[n] << endl;
    }
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 10600
N = int(input())
a = [int(i) for i in input().split()]

li_ans = []
ans = 0

for j in range(min(a), max(a)):
    for k in a:
        ans += abs(k - j) ** 2
    
    li_ans.append(ans)
    ans = 0

if len(li_ans) == 0:
    print(0)
else:
    print(min(li_ans))


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

using namespace std;

typedef long long ll;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a % 2 && b % 2 && c % 2) {
        cout << min(a * b, min(b * c, c * a)) << endl;
    } else {
        cout << 0 << endl;
    }
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(), h.end());
  k = min(n,k);
  rep(i,k) {
    h.pop_back();
  }
  ll ans = 0;
  rep(i,h.size()) ans += h[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
class priorityQueue {
  constructor() {
    this.keys = [];
    Number.prototype.parentIdx = function() { return Math.ceil(this/2 - 1); };
    Number.prototype.leftIdx = function() { return this * 2 + 1; };
    Number.prototype.rightIdx = function() { return this * 2 + 2; };
  }

  insert(key) {
    this.heapIncrease(this.keys.push(key) - 1);
  }

  heapIncrease(idx) {
    const keys = this.keys;
    for (let i=idx, p=idx.parentIdx(); i > 0 && keys[i] > keys[p]; i=p, p=i.parentIdx()) {
      keys[p] = [keys[i], keys[i] = keys[p]][0];
    }
  }

  extract() {
    const keys = this.keys;
    const res = keys[0];
    keys[0] = keys.pop();
    this.maxHeapify(0);
    return res;
  }

  maxHeapify(idx) {
    const keys = this.keys;
    const n = keys.length;
    const innerMaxHeapify = (i) => {
      let left, right, largest = i;
      left = i.leftIdx();
      right = i.rightIdx();
      if (left < n && Number(keys[left]) > Number(keys[largest])) largest = left;
      if (right < n && Number(keys[right]) > Number(keys[largest])) largest = right;
      if (largest != i) {
        keys[largest] = [keys[i], keys[i] = keys[largest]][0];
        innerMaxHeapify(largest);
      }
    };
    innerMaxHeapify(idx);
  }
}

(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  lines.pop();
  const queue = new priorityQueue();
  let str = '';
  lines.forEach(function(cmd) {
    switch(cmd.charAt(0)) {
      case 'i': queue.insert(Number(cmd.split(' ')[1])); break;
      case 'e': str += `${queue.extract()}\n`; break;
    }
  });
  process.stdout.write(str);
})();



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

using namespace std;

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

vector<string> inputs(int H) {
  vector<string> data(H);
  rep(i, H){
    cin >> data.at(i);
  }
  return data;
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> data = inputs(H);
  vector<bool> flag_yoko(H, false);
  vector<bool> flag_tate(W, false);
  
  rep(i, H){
    rep(j, W){
      if(data.at(i).at(j) == '#')
        flag_yoko.at(i) = true;
    }
  }
  rep(i, W){
    rep(j, H){
      if(data.at(j).at(i) == '#')
        flag_tate.at(i) = true;
    }
  }
  rep(i, H){
    rep(j, W){
      if(flag_yoko.at(i) && flag_tate.at(j))
        cout << data.at(i).at(j);
    }
    if(!flag_yoko.at(i))
      continue;
    cout << endl;
  } 
}

Measured memory_bytes: 256
a, b = map(int, input().split())
s = input()
ans = True
for i in range(a + b + 1):
    if s[a] != "-":
        ans = False
        break
    else:
        if i == a:
            pass
        else:
            for j in range(10):
                if s[i] == str(j):
                    break
            else:
                ans = False

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9164
def binarySearch(A, key):
    left = 0
    right = len(A)
    while left < right:
        mid = (left + right) // 2
        if A[mid] == key:
            return mid
        elif key < A[mid]:
            right = mid
        else:
            left = mid + 1
    return 'Not_found'

if __name__ == '__main__':
    c = 0
    n = int(input())
    hoge1 = [int(x) for x in input().split()]
    q = int(input())
    for key in (int(x) for x in input().split()):
        if binarySearch(hoge1, key) == 'Not_found':
            continue
        else:
            c += 1
    print (c)


Measured memory_bytes: 16896
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
	string s;
	cin>>s;
	cout<<(((s.size()%2)^(s[s.size()-1]==s[0]))?"First":"Second");
	return 0;
}

Measured memory_bytes: 512