akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long INF = 123456789;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

class UF
{
  public:
    vi rank, p;
    UF() {}
    UF(ll size)
    {
        rank.resize(size, 0);
        p.resize(size, 0);
        REP(i, size)
        {
            makeSet(i);
        }
    }

    void makeSet(ll x)
    {
        p[x] = x;
        rank[x] = 0;
    }

    bool same(ll x, ll y)
    {
        return findSet(x) == findSet(y);
    }

    void unite(ll x, ll y)
    {
        link(findSet(x), findSet(y));
    }

    void link(ll x, ll y)
    {
        if (rank[x] > rank[y])
        {
            p[y] = x;
        }
        else
        {
            p[x] = y;
            if (rank[x] == rank[y])
            {
                rank[y]++;
            }
        }
    }

    ll findSet(ll x)
    {
        if (x != p[x])
        {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

class Edge
{
  public:
    ll source, target, cost;
    Edge(ll source = 0, ll target = 0, ll cost = 0) : source(source), target(target), cost(cost) {}
    bool operator<(const Edge &e) const
    {
        return cost < e.cost;
    }
};

ll kruskal(ll n, vector<Edge> edges)
{
    ll totalCost = 0;
    sort(ALL(edges));
    UF dset = UF(n + 1);
    REP(i, n)
    {
        dset.makeSet(i);
    }
    ll source, target;
    REP(i, edges.size())
    {
        Edge e = edges[i];
        if (!dset.same(e.source, e.target))
        {
            totalCost += e.cost;
            dset.unite(e.source, e.target);
        }
    }
    return totalCost;
}

int main()
{
    ll cost, source, target;
    cin >> n >> m;
    vector<Edge> edges;
    REP(i, m)
    {
        cin >> source >> target >> cost;
        edges.push_back(Edge(source, target, cost));
    }

    cout << kruskal(n, edges) << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int a,b;

int main(){
    cin >> a >> b;
    if(a > 12)cout << b << endl;
    else if(a >= 6)cout << b / 2 << endl;
    else cout << 0 << endl;
}



Measured memory_bytes: 256
N = int(input()) 
B= [int(x) for x in input().split()]
A= [int(x) for x in input().split()]
all_ene = sum(B)
c = 0
for i in range(N):
  if B[i] >= A[i]:
    B[i] = B[i]-A[i]
  else:
    B[i+1] = max(0,B[i+1]+B[i]-A[i])
    B[i] = 0

print(all_ene-sum(B))

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

vector<vector<int> > v(100009);
vector<int> long_path(100009,-1);
int longest_path(int x){
    if(v[x].size()==0){
        return 0;
    }
    if(long_path[x]!=-1){
        return long_path[x];
    }else{
        for(int i=0;i<v[x].size();i++){
            long_path[x]=max(long_path[x],1+longest_path(v[x][i]));
        }
        return long_path[x];
    }
}

int main() {
	int n,m,x,y;
	cin>>n>>m;
	for(int i=0;i<m;i++){
	    cin>>x>>y;
	    v[x].push_back(y);
	}
	vector<int> dp(n+1,-1);
	int ans=-1;
	for(int i=1;i<=n;i++){
	    dp[i]=longest_path(i);
	    ans=max(ans,dp[i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 8576
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main() {

	int r, d, x, ans;
	cin >> r >> d >> x;

	ans = x;
	for (int i = 0; i < 10; i++) {
		ans=ans * r - d;
		cout << ans << endl;
	}

	return 0;
}


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

using namespace std;

int n, x[100005], ta;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", x + i);
		ta += abs(x[i] - x[i - 1]);
	}
	ta += abs(x[n]);
	for (int i = 1; i <= n; i++)
		printf("%d\n", ta - abs(x[i] - x[i - 1]) - abs(x[i] - x[i + 1]) + abs(x[i - 1] - x[i + 1]));
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;
int main(){
    int i;
    double n, s, sum;
    double b, ave, sumb, ans;
    int list[1001] = {};
    
    while(true){
        cin >> n;
        if(n == 0) break;
        sum = 0;
        b = 0;
        sumb = 0;
        
        for(i = 0; i < n; i++){
            cin >> s;
            list[i] = s;
            sum = sum + s;
        }
        
        ave = sum / n;
        
        for(i = 0; i < n; i ++){
            b = ave - list[i];
            b = pow(b, 2);
            sumb = sumb + b;
        }
        
        ans = sumb / n;
        ans = sqrt(ans);
        
        cout << fixed;
        cout << setprecision(6) << ans << endl;
    }
    

}


Measured memory_bytes: 3212
#include <iostream>
#include<stdio.h>
using namespace std;

int main(){
 char ch;
 int counter[26]={0};
 while ( scanf("%c", &ch) != EOF){
     if ('A'<=ch && ch<='Z'){
         ch = ch + 'a' - 'A';
     }
     if ('a'<=ch && ch<='z'){
         int num = ch -'a';
         counter[num]++;
     }
}
 for (int i=0; i<26; i++){
     char s;
     s= i + 'a';
     printf("%c : %d\n",s, counter[i]);
 }

}


Measured memory_bytes: 3208
#include<iostream>
#include<vector>
#include<string>
#include<map>
#define f first
#define s second
using namespace std;
 
int h,w,ii,jj;
int X[8]={-1,1,-1,1,0,-1,0,1};
int Y[8]={-1,1,1,-1,1,0,-1,0};
char Donut[10][20];
vector<string> V;
string maxs;
map<string,pair<int,int> > M;
 
void Check(string s)
{
  if(maxs.length()<s.length())maxs=s;
  else if(maxs.length()==s.length()){
    if(maxs>s)maxs=s;
  }
}
 
void make(int x,int y)
{
  for(int k=0;k<8;k++){
    string S="";
    int a=x,b=y;
    S+=Donut[a][b];
    while(1){
      a+=Y[k];
      b+=X[k];
      if(a==-1)a=h-1;
      if(b==-1)b=w-1;
      if(a==h)a=0;
      if(b==w)b=0;
      if(a==x && b==y)break;
      S+=Donut[a][b];
      if(M[S].f==0 && M[S].s==0){
    M[S].f=x+1;
    M[S].s=y+1;
      }
      else {
    Check(S);
      }
    }
  }
}
 
int main()
{
  while(1){
    cin>>h>>w;
    if(h+w==0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)cin>>Donut[i][j];
    }
    M.clear();
    maxs="";
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
    make(i,j);
      }
    }
    if(maxs=="")cout<<0<<endl;
    else cout<<maxs<<endl;
  }
  return 0;
}


Measured memory_bytes: 37900
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto G = new long[][](N);
    foreach (_; 0 .. M)
    {
        long a, b;
        scan(a, b);
        a--, b--;
        G[a] ~= b;
        G[b] ~= a;
    }
    foreach (v; G[0])
    {
        foreach (w; G[v])
            if (w == N - 1)
            {
                writeln("POSSIBLE");
                return;
            }
    }
    writeln("IMPOSSIBLE");
}


Measured memory_bytes: 24060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

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

    queue<int> q;
    priority_queue<int> p;
    int ans=0;

    for(int i = 0; i < n; i++) {
        int d=a[i]-b[i];
        if(d<0){
            ans++;
            q.push(d);
        }
        if(d>0){
            p.push(d);
        }
    }
    bool w=true;

    while(!q.empty() && !p.empty()){
        int x=p.top();p.pop();
        ans++;
        while(!q.empty()){
            int y=q.front();q.pop();
            if(x>=abs(y)){
                x += y;
            }
            else{
                y += x;
                q.push(y);
                break;
            }
        }
        if(q.empty()) {
            w=false;
            break;
        }
    }
    if(q.empty()) {
            w=false;
        }
    if(!w) cout << ans << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 4432
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

const int MAX_N = 110;
const int MAX_V = 1e3 + 10;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n, W;
    cin >> n >> W;
    vl w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];
    vl cur(MAX_N * MAX_V, 1LL << 60);
    cur[0] = 0LL;
    rep(i, n) {
        auto nxt = cur;
        for(int j = 0; j + v[i] <= nxt.size(); ++j) chmin(nxt[j + v[i]], cur[j] + w[i]);
        swap(nxt, cur);
    }
    ll ans = 0;
    repr(i, cur.size()) {
        if(cur[i] <= W) {
            ans = i;
            break;
        }
    }

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

Measured memory_bytes: 1976
x,y,a,b,c=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort(reverse=True)
A=A[a-x:]
B=B[b-y:]

i=0
j=0
k=0
lea=len(A)
leb=len(B)
while(True):
    if len(C)<1:
        break
    if i<lea and j<leb:
        if A[i]>B[j]:
            if B[j]<C[0]:
                B[j]=C.pop(0)
                
                j+=1
            else:
                break
        else:
            if A[i]<C[0]:
                A[i]=C.pop(0)
                i+=1
            else:
                break
    elif i<lea and j>=leb:
        if A[i]<C[0]:
                A[i]=C.pop(0)
                i+=1
        else:
            break
    elif i>=lea and j<leb:
        if B[j]<C[0]:
                B[j]=C.pop(0)
                j+=1
        else:
            break
    else:
        break
sum=0


for s in range(len(A)):
    sum+=A[s]
for t in range(len(B)):
    sum+=B[t]
print(sum)
            



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

using Graph = vector<vector<int>>;

int main(void){
  int n,m; cin >> n >> m;  
  Graph g(n+1);

  rep(i,m){
    int a,b; cin >> a >> b;
    g[a].push_back(b); g[b].push_back(a);
  }

  vector<int> dist(n+1,-1);
  queue<int> q;
  q.push(1);
  dist[1]=0;
  while(!q.empty()){
    int v = q.front();q.pop();

    for(auto nv : g[v]){
      if(dist[nv]!=-1) continue;

      dist[nv] = v;
      q.push(nv);
    }
  }

  bool flag = true;
  for(int v = 1;v<=n;v++){
    if(dist[v]==-1) flag = false;
  }

  if(flag){
    cout << "Yes" << endl;
    for(int i=2;i<=n;i++){
      cout << dist[i] << endl;
    }
  }
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 10272
import java.util.*;

public class Main {
    static int n;
    static int m;
    static char[] c;
    static String[] pm = {"+", "-"};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        c = sc.next().toCharArray();

        boolean ok = false;
        String op1 = "+";
        String op2 = "+";
        String op3 = "+";

        for (int i = 0; i < 2; i++) {
            int r1 = 0;
            op1  = pm[i];
            r1 = calc(op1, Character.getNumericValue(c[0]), Character.getNumericValue(c[1]));
            for (int j = 0; j < 2; j++) {
                op2  = pm[j];
                int r2 = calc(op2, r1, Character.getNumericValue(c[2]));
                for (int k = 0; k < 2; k++) {
                    op3  = pm[k];
                    int r3 = calc(op3, r2, Character.getNumericValue(c[3]));
                    if (r3 == 7) {
                        ok = true;
                        break;
                    }
                }
                if (ok) break;
            }
            if (ok) break;
        }
        System.out.println(c[0]+op1+c[1]+op2+c[2]+op3+c[3]+"=7");
    }
    static int calc (String op, int a, int b) {
        if ("+".equals(op)) {
            return a + b;
        } else {
            return a - b;
        }
    }
}



Measured memory_bytes: 23892
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)


int main()
{
int n;
int a[210000];
cin>>n;
rep(i,n)
cin>>a[i];

ll ans=0;
rep(i,n-1)
{
if(a[i]>a[i+1])
{
ans+=a[i]-a[i+1];
a[i+1]=a[i];
}

}
cout <<ans;
    
}

Measured memory_bytes: 4408
n, k = map(int, input().split())
P = list(map(int, input().split()))

maxx = 0
def total(x):
    return int(x*(x+1)/2)

kitai_P = [total(x)/x for x in P]

ans = 0
now = sum(kitai_P[0:k])
for i in range(n-k+1):
    if i >= 1:
        now = now - kitai_P[i-1] + kitai_P[i+k-1]
    ans = max(ans, now)
print(ans)



Measured memory_bytes: 25060
#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_map>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;
typedef pair<pll,pll> P;


ll count(P a){
    return a.F.F+a.S.F;
}


int main(){
    ll n;
    cin>>n;
    ll N=1<<n;
    vector<ll> a;
    vector<P> ans(N);
    vector<vector<pll>> bit(N+100);
    for(int i=0;i<N;i++){
        ll b;
        cin>>b;
        a.push_back(b);
    }
    bit[0].push_back({0,0});
    for(ll i=0;i<N;i++){
        bit[i].push_back({a[i],i});
        sort(bit[i].begin(),bit[i].end(),greater<pll>());
        pll mx=bit[i][0];
        pll sec={-1,-1};
        for(int h=1;h<bit[i].size();h++){
            if(bit[i][0]!=bit[i][h]){sec=bit[i][h]; break;}
        }
        for(ll t=0;t<n;t++){
            ll k=((ll)1<<t)|i;
            if(k>=N){continue;}
            bit[k].push_back(mx);
            bit[k].push_back(sec);
        }
        if(i!=0 && count({mx,sec})<=count(ans[i-1])){
            mx=ans[i-1].F;
            sec=ans[i-1].S;
        }
        ans[i]={mx,sec};
    }
    for(int i=1;i<N;i++){
        assert(ans[i].F.S!=ans[i].S.S);
        cout<<ans[i].F.F+ans[i].S.F<<endl;
    }
    
    
    return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    vector<int> v(3);
    for (int i = 0; i < 3; i++)
    {
        cin>>v[i];
    }
    sort(all(v));
    cout<<v[0]+v[1]<<endl;

    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = []
for i in range(H):
  S.append(list(input()))

dx = [-1, 0, 1, -1, 1, -1, 0, 1]
dy = [-1, -1, -1, 0, 0, 1, 1, 1]

for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      for k in range(8):
        px = i+dx[k]
        py = j+dy[k]
        if 0 <= px and px < H and 0 <= py and py < W:
          if S[px][py] == '#':
            pass
          elif S[px][py] == '.':
            S[px][py] = '1'
          else:
            S[px][py] = str(int(S[px][py])+1)
    elif S[i][j] == '.':
      S[i][j] = '0'

for i in range(H):
  print("".join(S[i]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int mat[3010][3010];
char a[3010], b[3010];
string bt(int i, int j) {
  int mim=12321414;
  bool d=0, ba=0, e=0;
  if (i>0) {
    mim=mat[i-1][j];
    ba=1;
  }
  if (j>0 && mim>mat[i][j-1]) {
    mim=mat[i][j-1];
    e=1;
  }
  if (i>0 && j>0 && mim>mat[i-1][j-1] && mat[i-1][j-1]==mat[i][j]) {
    mim=mat[i-1][j-1];
    d=1;
  }
  if (d==1) {
    return b[j-1] + bt(i-1, j-1);
  } 
  else if (e==1) {
    return bt(i, j-1);
  }
  else if (ba==1) {
    return bt(i-1, j);
  }
  return "";
}
int main() {
  scanf("%s%s", a, b);
  int n, m;
  n = strlen(a);
  m = strlen(b);
  
  for (int i = 0 ; i <= n ; i++) {
    for (int j = 0 ; j <= m ; j++) {
      mat[i][j] = 0;
    }
  }

  for (int i=1; i<=n; i++) {
    mat[i][0]=i;
  }
  for (int j=1; j<=m; j++) {
    mat[0][j]=j;
  }
  char a1, b1;
  for (int i = 1 ; i <= n ; i++) {
    a1 = a[i-1];
    for (int j = 1 ; j <= m ; j++) {
      b1 = b[j-1];
      if (a1 == b1) {
        mat[i][j] = mat[i-1][j-1];
      }
      else {
        mat[i][j]=min(mat[i-1][j]+1, mat[i][j-1]+1);
      }
    }
  }
  int i=n, j=m;
  string batata = bt(i, j);
  
  reverse(batata.begin(), batata.end());
  cout << batata <<endl;
}

Measured memory_bytes: 35968
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=205;
int n;
LL a[Maxn];
char s[Maxn];
LL F[64];
void Ins(LL x){
	for (int i=62;i>=0;i--){
		if (x>>i&1){
			if (F[i]!=-1){
				x^=F[i];
			}
			else{
				F[i]=x;
				return;
			}
		}
	}
}
bool Qr(LL x){
	for (int i=62;i>=0;i--){
		if(x>>i&1){
			if (F[i]==-1) return false;
			x^=F[i];
		}
	}
	return true;
}
void mian(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	scanf("%s",s+1);
	for (int i=0;i<64;i++){
		F[i]=-1;
	}
	for (int i=n;i>=1;i--){
		if(s[i]=='1'){
			if (!Qr(a[i])){
				printf("1\n");
				return ;
			}
		}
		else{
			Ins(a[i]);
		}
	}
	printf("0\n");
}
int main(){
	int t;
	scanf("%d",&t);
	while (t--){
		mian();
	}
}

Measured memory_bytes: 3652
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return ((a%mod)*1ll*b)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}


/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[20][20],b[MAX];


int main()
{
 
  #ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
//cout << setprecision(15) << fixed;
fast

cin >> n >> m >> k;
fr(i,0,n)
{
  cin >> b[i];
  fr(j,0,m)
    cin >> a[i][j];
}
ll ans = inf;
ll mask;
ll cnt[m];
fr(mask,0,(1<<n))
{
  mem(cnt,0);
  ll cost = 0;
  fr(i,0,n)
  {
    if(mask>>i & 1)
    {
      cost += b[i];
      fr(j,0,m)
        cnt[j]+=a[i][j];
    }
  }
  ll flag = 1;
  fr(i,0,m)
    flag &= (cnt[i]>=k);
  if(flag)
      ans = min(ans,cost);
}
bug(ans)
cout << (ans == inf ? -1 : ans);

  #ifndef ONLINE_JUDGE
  cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  #endif
 
  return 0;
 
}

Measured memory_bytes: 3640
# -*- coding: utf-8 -*-

def main():

    S = input()
    listS = list(S)

    if listS[2] == listS[3] and listS[4] == listS[5]:
        ans = 'Yes'

    else:
        ans = 'No'

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }


int main() {
  int n; cin>>n;
  vector<long long> ans(10010, 0);
  REP(x, 1, 101) REP(y, 1, 101) REP(z, 1, 101) {
    long long t = x*x + y*y + z*z + x*y + y*z + z*x;
    if (t < 10010) ++ans[t];
  }
  REP(i, 1, n+1) {
    print(ans[i]);
  }

  return 0;
}

Measured memory_bytes: 3648
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static class Fast {
        BufferedReader br;
        StringTokenizer st;

        public Fast() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[]) throws Exception {
        Fast in = new Fast();
        
       System.out.println((in.nextInt()-in.nextInt())%in.nextInt());
    }
}

Measured memory_bytes: 23124
# https://atcoder.jp/contests/abc150/tasks/abc150_c



N = gets.to_i
Ps = gets.split.map(&:to_i)
Qs = gets.split.map(&:to_i)

perm = (1..N).to_a.permutation.to_a
a = perm.find_index(Ps)
b = perm.find_index(Qs)
puts (a - b).abs


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

const int INF = 50 * 50;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    cin >> N >> M;
    vector<string> mp(N);
    for(int i=0; i<N; i++) cin >> mp[i];

    atcoder::mcf_graph<int, int> graph(N * M + 2);
    int start = N * M;
    int goal = N * M + 1;
    int cnto = 0;
    for(int i=0; i<N; i++) {
        for(int j=0; j<M; j++) {
            if(mp[i][j] == '#') continue;
            if(mp[i][j] == 'o') {
                graph.add_edge(start, i * M + j, 1, 0);
                cnto++;
            }
        }
    }
    for(int i=0; i<N; i++) {
        for(int j=0; j<M; j++) {
            if(mp[i][j] == '#') continue;
            int node = i * M + j;
            if(i != N - 1) graph.add_edge(node, node + M, cnto, 0);
            if(j != M - 1) graph.add_edge(node, node + 1, cnto, 0);
            graph.add_edge(node, goal, 1, INF - i - j);
        }
    }

    graph.flow(start, goal);

    int ans = 0;
    for(auto edge : graph.edges()) {
        if(edge.from == start || edge.to == goal || edge.flow == 0) continue;
        ans += edge.flow;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4228
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int n,k,q;
  cin >> n >> k >> q;
  int a,pnt[n];
  for (int i = 0; i < n; i++){
    pnt[i] = k-q;
  }
  for (int i = 0; i < q; i++){
    cin >> a;
    pnt[a-1] += 1;
  }
  for (int i = 0; i < n; i++){
    if (pnt[i] > 0){
      cout << "Yes\n";
    }
    else{
      cout << "No\n";
    }
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010], par[100010];
int pa(int x){
  if(par[x]==x)
    return x;
  return par[x]=pa(par[x]);
}
int main(){
  int n, m;
  while(cin>>n>>m){
    for(int i=1; i<=n; ++i){
      cin>>a[i];
      par[i]=i;
    }
    int x, y;
    for(int i=0; i<m; ++i){
      cin>>x>>y;
      par[pa(x)]=pa(y);
    }
    int ans=0;
    for(int i=1; i<=n; ++i){
      if(pa(i)==pa(a[i]))
        ++ans;
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s.at(i);
	int cnt=0;
	rep(i,h){
		rep(j,w){
			if(s[i][j]=='#') cnt++;
		}
	}
	if(cnt==h+w-1) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
x,n = map(int,input().split())
l = [int(x) for x in input().split()]
mp = [False]*101
for i in range(n):
    mp[l[i]] = True



queue = [x]
while(len(queue)>0):
    now = queue.pop(0)
    if(now <= 0 or now >=101):
        print(now)
        break
    if(mp[now]==False):
        print(now)
        break
    
    if(now==x):
        queue.append(now-1)
        queue.append(now+1)
    if(now < x):
        queue.append(now-1)
    if(now > x):
        queue.append(now+1)


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

int main() {
  string s;
  cin >> s;
  int ans = 700;
  
  for(auto x : s) if(x == 'o') ans += 100;
  
  cout << ans << endl;
  
  return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

const int limit = 100010;
ll a[limit],b[limit];

int main(void){
	ll n,k;
	cin >> n >> k;

	rep(i,n) cin >> a[i] >> b[i];

	ll ans = 0LL;

	rep(i,-1,40){
		ll can_mask = k;
		if((i!=-1) and (k&(1LL)<<i)==0) continue;
		
		if(i>=0){
			const ll low_bit = ((1LL<<i)-1LL);
			can_mask ^= (1LL << i);
			can_mask |= low_bit;
		}

		//cerr << can_mask << endl;

		ll cur = 0LL;
		rep(j,n){
			if((a[j]|can_mask)!=can_mask) continue;
			cur += b[j];
		}

		chmax(ans,cur);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1920
A, = [s.split() for s in open(0)][0]

a = int(A[:2])
b = int(A[2:])

yymm = 0
mmyy = 0

if a >= 1 and a <= 12:
    mmyy += 1

if b >= 1 and b <= 12:
    yymm += 1
    
if mmyy and yymm:
    print("AMBIGUOUS")
elif mmyy and not yymm:
    print("MMYY")
elif not mmyy and yymm:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int a[100011][3],h[100011][3]; 
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		fill(h[i], h[i] + 3, 0);
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	for (int j = 0; j < 3; j++) {
		h[0][j] = a[0][j];
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (k == j) {
					continue;
				}
				h[i][j] = max(h[i][j], h[i - 1][k] + a[i][j]);
			}
		}
	}
	cout << *max_element(h[n - 1], h[n - 1] + 3)<<endl;
	//for (int i = 0; i < n; i++) {
	//	for (int j = 0; j < 3; j++) {
	//		cout << h[i][j] << " ";
	//	}
	//	cout << endl;
	//}
	return 0;
}

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

int main(){
  int M,N,ans=0;
  cin>>N;
  M=N;
  for(;;){
    ans=ans+(N%10);
    int s=N-(N%10);
    N=s/10;
    if(N==0)
      break;
  }
  if((M%ans)==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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


int main(){
    int N; cin >> N;
    //vector<pair<string, int>> P(N);
    set<string> ST;
    map<string, vector<pair<int, int>>> M;
    for(int i = 0; i < N; i++){
        string temp; int p;
        cin >> temp >> p;
        
        ST.insert(temp);
        M[temp].push_back(make_pair(p, i));
    }
    for(auto S : ST){
        sort(M[S].rbegin(), M[S].rend());
        for(auto x : M[S]) cout << x.second+1 << endl;
    }

}

Measured memory_bytes: 256
*q,E=2,$<.flat_map{|l|u,v,w=l=l.split.map(&:to_i);[l,[v,u,w]]}.group_by{|u,|u};q.map{|i|$*[i]||=(E[i/2]&.map{|_,v,w|v&&q<<=v*2|i+w&1};i&1)};puts$*

Measured memory_bytes: 39676
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

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

    int n;
    cin >> n;

    int p[60] = {};

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

        for (int k = 0; a; k++) {
            p[k] += a & 1;
            a >>= 1;
        }
    }

    ll r = 0;
    for (int k = 0; k < 60; k++) {
        r += (1LL << k) % P * p[k] % P * (n - p[k]) % P;
    }
    r %= P;

    cout << r << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  using P = pair<int, int>;
  map<int, vector<P>> range;
  int N, Q; cin >> N >> Q;
  rep(i, N) {
    int s, t, x;
    cin >> s >> t >> x;
    range[x].emplace_back(max(s - x, 0), max(t - x, 0));
  }
  set<int> ds;
  map<int, int> ans;
  rep(i, Q) {
    int d; cin >> d;
    ds.insert(d);
    ans[d] = -1;
  }
  each(r, range) {
    int x = r.first;
    each(v, r.second) {
      auto it = ds.lower_bound(v.first);
      while (it != ds.end()) {
        if (*it >= v.second) break;
        ans[*it] = x;
        ds.erase(it++);
      }
    }
  }
  each(a, ans) {
    cout << a.second << '\n';
  }
}


Measured memory_bytes: 41856
#include <iostream>
#include <vector>

using namespace std;

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

	return res;
}

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

	vector<int> a = ReadInput(n);
	vector<int> b = ReadInput(n);
	vector<int> c = ReadInput(n - 1);

	int ans = 0; 
	for (int i = 0; i < n; i++)
	{
		ans += b[a[i] - 1];

		if (i > 0)
		{
			if (a[i] - a[i - 1] == 1)
			{
				ans += c[a[i] - 2];
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {
    public static int numDigits(long num){
        int res = 0;
        while(num != 0){
            num /= 10;
            res += 1;
        }
        return res;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
//        boolean[] sieve = new boolean[100001];
//        Arrays.fill(sieve, true);
//        sieve[0] = false;
//        sieve[1] = false;
//        int index = 2;
//        while(index * index <= 100000){
//            if(sieve[index]){
//                for (int i = index * index; i <= 100000; i += index) {
//                    sieve[i] = false;
//                }
//            }
//            index += 1;
//        }
//        ArrayList<Integer> prime = new ArrayList<>();
//        for(int i = 2; i <= 100000; i++){
//            if(sieve[i])
//                prime.add(i);
//        }
        long bound = (int) Math.sqrt(n);
        int res = numDigits(n);
        for(long i = 2; i <= bound; i++){
            if(n % i == 0){
                res = Math.min(res, Math.max(numDigits(i), numDigits(n/i)));
            }
        }
        System.out.println(res);
        
    }
}

Measured memory_bytes: 22996
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class C
{
	public static void Main()
	{	
		string[] args;

		int[,] c = new int[3,3];
		for(int i = 0; i < 3; i++)
		{
			args = Console.ReadLine().Split(' ');
			for(int j = 0; j < 3; j++)
				c[i,j] =  Int32.Parse(args[j]);
		}

		int[] a = new int[3];
		int[] b = new int[3];
		a[0] = 0;
		b[0] = c[0,0];
		b[1] = c[0,1];
		b[2] = c[0,2];
		a[1] = c[1,1] - b[1];
		a[2] = c[2,2] - b[2];

		bool isYes = true;
		for(int i = 0; i < 3; i++)
		{
			for(int j = 0; j < 3; j++)
			{
				if((a[i] + b[j]) != c[i,j])
				{
					isYes = false;
					break;
				}
			}
			if(!isYes)
				break;
		}

		Console.WriteLine(isYes ? "Yes" : "No");
	}	
}





Measured memory_bytes: 11092
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const long long MOD=1000000007;
const long long LMOD=998244353;
//const long long LMOD=1000000007;
#define Fi first
#define Se second
#define P2 pair
#define Pii pair<int,int>
#define Pll pair<long long,long long>
#define Cb make_pair
#define ll long long
#define Ull unsigned long long
#define Sf scanf
#define Pf printf
#define Pb push_back
#define Psh push
#define Stc stack
#define Vct vector
#define Ret return
#define Re0 return 0z
#define Sz size
#define Is insert
#define Que queue
#define Emp empty
#define Fro front
#define Rv reverse
#define Er erase
#define Bg begin
#define Srt sort
#define Pq priority_queue
#define Ite iterator
int main()
{
	ll a,b;
	cin>>a>>b;
	b=a+b;
	a=b/2;
	if(a*2!=b)
	{
		cout<<"IMPOSSIBLE";
	}
	else
	{
		cout<<a;
	}
	return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
    if (ref < value) ref = value;
}

ll dp[1000001];
int n;
vector<ll> a;

void solve() {
    fill(dp, dp + n, INF);
    for (int i = 0; i < n; ++i) {
        *lower_bound(dp, dp + n, a[i]) = a[i];
    }
    cout << lower_bound(dp, dp + n, INF) - dp << endl;
}

int main() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    solve();
}




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

int main(){
    vector<int> a;
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int b;
        cin>>b;
        if(b==0){
            int c;
            cin>>c;
            a.push_back(c);
        }else if(b==1){
            int d;
            cin>>d;
            cout<<a[d]<<endl;
        }else{
            a.pop_back();
        }
    }
    return 0;
}



Measured memory_bytes: 3920
def main():
    mod = 10**9+7
    fact = [1, 1]
    for i in range(2, 5*(10**5)+1):
        fact.append(fact[-1]*i % mod)

    def nPr(n, r, mod=10**9+7):
        return pow(fact[n-r], mod-2, mod)*fact[n] % mod
    n, m = map(int, input().split())
    if m == 1:
        print(0)
        return
    ans = nPr(m, n)
    if m-n == 1:
        a0 = 1
    else:
        a0 = 0
    a1 = 1
    for i in range((m-n-1), m-1):
        a1, a0 = ((i+1)*a1+(i-(m-n-1))*a0) % mod, a1
    print(a1*ans % mod)


main()


Measured memory_bytes: 104336
#include <bits/stdc++.h>
using namespace std;
int main()
{
    using ll = long long;
    ll n;
    cin >> n;
    vector<ll> v(n);
    for(int i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        v[i] = a - (i+1);
    }
    sort(v.begin(), v.end());
    ll cen = v[n/2];
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        ans += abs(v[i] - cen);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {
	if (a > b) a = b;
}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {
	if (a < b) a = b;
}
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353;
constexpr int MAX = 500050;
const double pi = acos(-1);
// constexpr double EPS = 1e-10;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;


void solve() {
	int N; cin >> N;
	vector<int>A(N), B(N);
	REP(i, N) {
		cin >> A[i] >> B[i];
	}
	VSORT(A);
	VSORT(B);
	if (N & 1) {
		print(B[N / 2] - A[N / 2]+1);
	}
	else {
		print(B[N / 2] + B[N / 2 - 1] - A[N / 2] - A[N / 2 - 1]+1);
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 6344
#include<bits/stdc++.h> 
#define AndIamIronMan ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
#define M 1000000007 

#define int128 __int128
using namespace std; 
typedef  long long int lli; 

bool prime(lli );

int main(){
		
    AndIamIronMan;
	lli co=0,g,i,n,y,m,d,j,k,z,t,x=0,a,b,c,l,r;
//	cin>>t;
//	while(t--){
	string s;
	cin>>s;
	x=0,co=0;
	for(i=0;i<s.length();i++){
		if(s[i]=='R'){
			co++;
			x=max(x,co);
		}
		else co=0;
	}	
	cout<<x;
//	}
	return 0;
}

bool prime(lli n){
	bool x=true;
	int i;
	for(i=2;i<=sqrt(n);i++){
		if(n%i==0){
			x=false;
		}	
	}
	return x;
}

Measured memory_bytes: 3644
def main():
    N, Q = map(int, input().split())
    d = {}
    for _ in range(N-1):
        a, b = map(int, input().split())
        if a in d:
            d[a].append(b)
        else:
            d[a] = [b]
        if b in d:
            d[b].append(a)
        else:
            d[b] = [a]
    dc = {}
    for _ in range(Q):
        p, x = map(int, input().split())
        if p in dc:
            dc[p] += x
        else:
            dc[p] = x
    v = set()
    vr = set(range(1,N+1))
    l = [0] * N
    n = [(1,0)]
    c = []
    while v != vr:
        for i, j in n:
            v.add(i)
            if i in dc:
                j += dc[i]
            l[i-1] = j
            for k in d[i]:
                if k not in v:
                    c.append((k, j))
        n = c
        c = []
    return ' '.join(str(i) for i in l)

print(main())


Measured memory_bytes: 128504
# -*- coding: utf-8 -*-
N = int(input())
total = 10 ** N
no_9 = 9 ** N
no_0 = 9 ** N
no_0and9 = 8 ** N
print((total - (no_9 - no_0and9) - (no_0 - no_0and9) - no_0and9)%(10**9 + 7))

Measured memory_bytes: 87472
local N = io.read("n")
local S = {}
for i=1,2^N do
    local s = io.read("n")
    S[i] = s
end
table.sort(S, function(x,y)return x>y end)
local family = {}
family[1] = S[1]
S[1] = -1
for n=1,N do
    local parents = {table.unpack(family)}
    table.sort(parents, function(x,y)return x>y end)
    local todo = 1
    local sidx = 1
    while todo <= #parents and sidx <= #S do
        if S[sidx] ~= -1 and S[sidx] < parents[todo] then
            family[#family + 1] = S[sidx]
            todo = todo + 1
            S[sidx] = -1
        end
        sidx = sidx + 1
    end
    if todo <= #parents then
        print("No")
        return
    end
end
print("Yes")

Measured memory_bytes: 14700
#include <bits/stdc++.h>
#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long

using namespace std;

void solve() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    while (b<=a) {
        b*=2;
        k--;
    }
    while (c<=b) {
        c*=2;
        k--;
    }
    cout << (k>=0?"Yes":"No") << endl;
}

int main() {
    FAST_INPUT;

    solve();

    return 0;
}


Measured memory_bytes: 3636