akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.StringTokenizer;
import java.util.function.IntPredicate;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int x = scanner.nextInt();

        if (x == 1 || x == 2 * n - 1) {
            System.out.println("No");
            return;
        }

        System.out.println("Yes");
        if (x == n) {
            final String answer = IntStream.rangeClosed(1, 2 * n - 1)
                    .mapToObj(Integer::toString)
                    .collect(Collectors.joining(" "));
            System.out.println(answer);
            return;
        }

        final IntPredicate predicate = x >= 3 ? i -> !(i >= x - 2 && i <= x + 1) : i -> !(i >= x - 1 && i <= x + 2);
        final int[] array = x >= 3 ? new int[]{x - 1, x + 1, x, x - 2} : new int[]{x + 1, x, x - 1, x + 2};
        final List<Integer> list = createList(n, predicate, array);
        final String answer = createAnswer(list);
        System.out.println(answer);
    }

    private static List<Integer> createList(final int n, final IntPredicate predicate, final int[] array) {
        final List<Integer> list = IntStream.rangeClosed(1, 2 * n - 1)
                .filter(predicate)
                .boxed()
                .collect(Collectors.toList());
        for (int i = 0; i < array.length; i++) {
            list.add(n + i - 3, array[i]);
        }
        return list;
    }

    private static String createAnswer(final List<Integer> list) {
        return list.stream()
                .map(i -> Integer.toString(i))
                .collect(Collectors.joining(" "));
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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


Measured memory_bytes: 54508
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip> //cout << fixed << setprecision(12) << ans << endl;
using namespace std;
 
#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 loop(i, l, r) for(int i = l; i < r; i++)
#define rloop(i, l, r) for(int i = l; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;

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

	int ans = 0;
	for(int i=1;i<n;i++){
		int cnt = 0;
		for(int j=0;j<n-i;j++){
			if(str[j] == str[j + i])
				cnt++;
			else
				cnt = 0;
			ans = max(ans, min(cnt, i));
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

import itertools

a = [i + 1 for i in range(n)]

b = list(itertools.permutations(a))

b = list(map(list, b))

for i in range(len(b)):
    if b[i] == p:
        buf1 = i

    if b[i] == q:
        buf2 = i


print(abs(buf1 - buf2))

Measured memory_bytes: 15092
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<queue>
#include<tuple>
#include<utility>
#include<functional>
#include<algorithm>

#define LL long long

using namespace std;

int a,b,c;
bool d;

int main() {
	cin>>a>>b>>c;
	if(a==b&&b==c)d=false;
	else if(a==b||b==c||c==a)d=true;
	else d=false;
	cout<<(d?"Yes":"No")<<endl;
	return 0;
}


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

b=[0]*n
b[0]=a[0]
for i in range(1,n):
    b[i]=a[i]+b[i-1]
suma=sum(a)

import bisect
ncut = bisect.bisect(b,suma//2)

ans1=abs( sum(a[:ncut])-sum(a[ncut:]) )
if ncut<n:
    ans2=abs( sum(a[:ncut+1])-sum(a[ncut+1:]) )
else:
    ans2=10**12
print(min(ans1,ans2))

Measured memory_bytes: 91468
#include <stdio.h>

int main() {
    int n, b, f, r, v;
    int flo[4][3][10] = {};
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        flo[b-1][f-1][r-1] += v;
    }
    for (int j=0; j<4; j++) {
        for (int k=0; k<3; k++) {
            for (int l=0; l<10; l++) {
                printf(" %d", flo[j][k][l]);
            }
            putchar('\n');
        }
        if (j == 3) {break;}
        printf("####################\n");
    }
    return 0;
}


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

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

using namespace std;

struct Data {
  int id,solve,time;
  bool operator < ( const Data &data ) const {
    if( solve != data.solve ) return solve > data.solve;
    if( time  != data.time  ) return time  < data.time;
    return id > data.id;
  }
};

typedef pair<int,int> ii;

int main(){
  int M,T,P,R;
  while( cin >> M >> T >> P >> R, M|T|P|R ){
    vector<Data> team(T);
    rep(i,T) { team[i].id = i; team[i].solve = team[i].time = 0; }
    map<ii,int> pena;
    rep(_,R){
      int m,t,p,j;
      cin >> m >> t >> p >> j;
      --t, --p;
      if( j ) {
	++pena[ii(t,p)];
      } else {
	++team[t].solve;
	team[t].time += m + pena[ii(t,p)] * 20;
      }
    }
    sort(team.begin(),team.end());
    rep(i,T) {
      if( i ) {
	if( team[i].solve == team[i-1].solve && team[i].time == team[i-1].time ) printf("=");
	else printf(",");
      }
      printf("%d",team[i].id+1);
    } puts("");
  }
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
/*
#include <iostream>
#include <queue>
#include <vector>
#include <utility>
*/

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

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

const double PI = 3.14159265358979;

int dist[8][8];

struct Edge{ ll cost, to; };
void solve()
{
  int n, m, r;
  cin >> n >> m >> r;
  vector<int> ri(r);
  for(int i = 0; i < r; ++i)
  {
    cin >> ri[i];
    ri[i]--;
  }

  int a, b, c;
  vector< vector<Edge> > G(n, vector<Edge>());
  for(int i = 0; i < m; ++i)
  {
    cin >> a >> b >> c;
    a--; b--;
    G[a].emplace_back(Edge{c, b});
    G[b].emplace_back(Edge{c, a});
  }

  const ll INF = 1LL << 60;
  priority_queue<P, vector<P>, greater<P>> que;
  for(int i = 0; i < r; ++i)
  {
    vector<ll> d(n, INF);
    d[ri[i]] = 0;
    que.push(P(0, ri[i])); // P(cost, start)
    while (!que.empty())
    {
      P p = que.top();
      que.pop();
      ll node = p.second;
      if (d[node] < p.first) continue;
      for (const auto& edge : G[node])
      {
          if (d[edge.to] > d[node] + edge.cost)
          {
              d[edge.to] = d[node] + edge.cost;
              que.push(P(d[edge.to], edge.to));
          }
      }
    }
    for(int j = 0; j < r; ++j)
    {
      dist[i][j] = d[ri[j]];
    }
  }

  vector<int> indices(r);
  for(int i = 0; i < r; ++i) indices[i] = i;

  ll ans = INF;
  do {
    ll distance = 0;
    for(int i = 0; i < r - 1; ++i) distance += dist[indices[i]][indices[i + 1]];
    ans = min(ans, distance);
  } while(next_permutation(ALL(indices)));
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4232
a, b, c, x, y = map(int, input().split())

ans = float("inf")
for i in range(0, max(2*x, 2*y)+1, 2):
    na = 0 if x-i//2 < 0 else x-i//2
    nb = 0 if y-i//2 < 0 else y-i//2
    ans = min(ans, c*i + a*na + b*nb)

print(ans)


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

ll lx[256], rx[256], ly[256], ry[256];
int h,w;
char g[55][55];

int main(){
    int n; cin >> n;
    while(n--){
        cin >> h >> w;
        rep(i,h) cin >> g[i];
        loop(i,'A','Z'+1){
            lx[i] = ly[i] = 1000;
            rx[i] = ry[i] = -1;
        }
        rep(i,h)rep(j,w){
            lx[g[i][j]] = min(j, lx[g[i][j]]);
            ly[g[i][j]] = min(i, ly[g[i][j]]);
            rx[g[i][j]] = max(j, rx[g[i][j]]);
            ry[g[i][j]] = max(i, ry[g[i][j]]);
        }
        while(1){
            bool update = false;
            loop(c,'A','Z'+1){
                if(lx[c]==1000) continue;
                bool rect = true;
                loop(i,ly[c],ry[c]+1){
                    loop(j,lx[c],rx[c]+1){
                        if(g[i][j]!=c && g[i][j]!='-'){
                            rect = false;
                            goto OUT;
                        }
                    }
                }
            OUT:;
                if(!rect) continue;
                loop(i,ly[c],ry[c]+1){
                    loop(j,lx[c],rx[c]+1){
                        g[i][j] = '-';
                    }
                }
                update = true;
                lx[c] = 1000;
            }
            if(!update) break;
        }
        bool ok = true;
        loop(i,'A','Z'+1) if(lx[i]!=1000) ok = false;
        puts(ok ? "SAFE" : "SUSPICIOUS");
    }
}

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

int find_set(int x,int *parent){
    if(parent[x] == x)
        return x;
    else{
        parent[x] = find_set(parent[x],parent);
        return (parent[x]);
    }
}


void make_union(int x,int y,int *parent,int *rank,int *size){
    
    int temp1 = find_set(x,parent);
    int temp2 = find_set(y,parent);
    
    if(temp1 ==  temp2)
        return;
    
    if(rank[temp1] > rank[temp2]){
        parent[temp2] = temp1;
        size[temp1] += size[temp2];
    }
    else if(rank[temp1] < rank[temp2]){
        parent[temp1] = temp2;
        size[temp2] += size[temp1];
    }
    else{
        parent[temp1] = temp2;
        rank[temp2]++;
        size[temp2] += size[temp1];
    }
    
}




int main(){
    
    int n,m;
    cin>>n>>m;
    
    int parent[n];
    int rank[n];
    int size[n];
    for(int i=0;i<n;i++){
        parent[i] = i;
        rank[i] = 0;
        size[i] = 1;
    }
    
    int x,y;
    for(int i=0;i<m;i++){
        cin>>x>>y;
        x--;
        y--;
        make_union(x,y,parent,rank,size);   
    }
    
    int max = 0;
    for(int i=0;i<n;i++){
        if((parent[i]==i) && (size[i]>max)){
            max = size[i];   
        }
    }
    
    cout<<max<<endl;
    
    return 0;
}


Measured memory_bytes: 5916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MAX(type)   std::numeric_limits<type>::max()
#define MIN(type) std::numeric_limits<type>::min()
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
ll inf = 1e18;
vector<ll> a,b,c;

int main(){
	fast;
	ll n;cin>>n;
	a.push_back(0);b.push_back(0);c.push_back(0);
	for(ll i=0;i<n;++i){
		ll x,y,z;cin>>x>>y>>z;a.push_back(x);b.push_back(y);c.push_back(z);
	}
	ll ans[n+1][3];
	memset(ans,0,sizeof(ans));
	for(ll i=1;i<=n;++i){
		ans[i][0] = a[i] + max(ans[i-1][1],ans[i-1][2]);
		ans[i][1] = b[i] + max(ans[i-1][0],ans[i-1][2]);
		ans[i][2] = c[i] + max(ans[i-1][0],ans[i-1][1]);
	}
	cout<<max(ans[n][0],max(ans[n][1],ans[n][2]));

	return 0;
}

Measured memory_bytes: 5216
#include<algorithm>
#include<cmath>
#include<iostream>
#include<numeric>
#include<vector>

using namespace std;

int main()
{
    int N; cin >> N;
    vector<int> h(N+1, 0);
    for(int i = 0; i < N; i++) cin >> h[i];

    int ans = 0;
    while( accumulate(h.begin(), h.end(), 0) > 0 )
    {
        int flag = h[0] ? true : false;
        int counter = 0;
        for(auto item : h)
        {
            if(item == 0 && flag)
            {
                counter++;
            }
            flag = item ? true : false;
        }
        ans += counter;
        for_each( h.begin(), h.end(), [](int &x){ x = max(x-1, 0); } );
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 2000005
#define INF 2000000010
int n = 0;
int a[N];
void swap(int *a, int *b){
    int t;
    t = *a;
    *a= *b;
    *b = t;
}
void maxHeapify(int i){
    int l = 2*i;
    int r = 2*i+1;
    int maxi = i;
    if(l <= n && a[l] > a[maxi]){
        maxi = l;
    }
    if(r <= n && a[r] > a[maxi]){
        maxi = r;
    }
    if(maxi != i){
        swap(&a[i], &a[maxi]);
        maxHeapify(maxi);
    }
}
void insert(int key){
    a[++n] = key;
    int temp = n;
    while(temp > 1 && a[temp/2] < key){
        swap(&a[temp], &a[temp/2]);
        temp /= 2;
    }
}
int extract(){
    if(n < 1) return 0;
    int res = a[1];
    a[1] = a[n--];
    maxHeapify(1);
    return res;
}
int main(){
    char s[10];
    int k;
    while(scanf("%s", s), strcmp(s, "end")){
        if(s[0] == 'i'){
            scanf("%d", &k);
            insert(k);
        }else if(s[0] == 'e'){
            int p = extract();
            printf("%d\n", p);
        }
    }
    return 0;
}


Measured memory_bytes: 6500
#include<iostream>
using namespace std;
int main(){
    int num;
    long long a;
    long long sum = 1 ,res =1e18;
    cin >> num;
    for(int i =0;i<num;i++){
        cin >> a;
        if(a !=0){
            res =res/a;
            sum = sum*a;
        }else{
            sum = 0;
            break;
        }
    }
    if(res ==0 && sum!=0){
        sum = -1;
    }    
        cout << sum;
    return 0;
}

Measured memory_bytes: 3600
/*
 * @Author: Kaizyn
 * @Date: 2020-08-22 21:22:54
 * @LastEditTime: 2020-08-22 21:43:32
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const int N = 1e3+7;
const int dir[] = {0, -1, 0, 1, 0};

struct Node {
  int x, y, z;
  bool operator <(const Node &nd) const {
    return z > nd.z;
  }
};

int n, m, bx, by, ex, ey;
char a[N][N];
int d[N][N];
priority_queue<Node> q;

void bfs() {
  memset(d, -1, sizeof d);
  q.push(Node{bx, by, 0});
  d[bx][by] = 0;
  while (q.size()) {
    int x = q.top().x;
    int y = q.top().y;
    int z = q.top().z;
    q.pop();
    if (z > d[x][y]) continue;
    for (int i = 0, nx, ny; i < 4; ++i) {
      nx = x+dir[i];
      ny = y+dir[i+1];
      if (nx < 1 || ny < 1 || nx > n || ny > m) continue;
      if (a[nx][ny] == '#') continue;
      if (d[nx][ny] == -1 || d[nx][ny] > z) {
        d[nx][ny] = z;
        q.push(Node{nx, ny, z});
      }
    }
    for (int i = -2; i <= 2; ++i) {
      for (int j = -2, nx, ny; j <= 2; ++j) {
        nx = x+i;
        ny = y+j;
        if (nx < 1 || ny < 1 || nx > n || ny > m) continue;
        if (a[nx][ny] == '#') continue;
        if (d[nx][ny] == -1 || d[nx][ny] > z+1) {
          d[nx][ny] = z+1;
          q.push(Node{nx, ny, z+1});
        }
      }
    }
  }
}

inline void solve() {
  cin >> n >> m >> bx >> by >> ex >> ey;
  for (int i = 1; i <= n; ++i) {
    cin >> (a[i]+1);
  }
  bfs();
  cout << d[ex][ey] << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 8584
//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)

#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) (ll)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0

typedef double db;
typedef long long ll;

const ll ary=2e5+5;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
using namespace __gnu_pbds;
ll n,a[ary],k,p[ary];
map<ll,ll> mp;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		p[i]=p[i-1]+a[i];
	}
	ll ans=0;
	mp[0]++;
	for(int i=1;i<=n;i++){
		if(i>=k){
			mp[(p[i-k]-(i-k))%k]--;
		}
		ans+=mp[(p[i]-i)%k];
		mp[(p[i]-i)%k]++;
	}
	cout<<ans;
}

Measured memory_bytes: 15872
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <iomanip>

using namespace std;


int main(void)
{
    while(1){
        int x,h;
        cin>>x>>h;
        if(x==0&&h==0)break;
        double h2,x2;
        x2=(double)x;
        h2=sqrt(((double)x/2.0)*((double)x/2.0)+((double)h)*((double)h));
        cout<<fixed<<setprecision(6)<<x2*h2*2.0+x2*x2<<endl;
    }
    
}

Measured memory_bytes: 1232
n = int(input())
s = str(input())
ans = 0
for i in range(1,len(s)):
    A = s[:i]
    B = s[i:]
    a = 0
    for l in range(len(A)):
        if A.find(A[l], l+1, ) != -1:
            continue
        for k in range(len(B)):
            if A[l] == B[k]:
                a += 1
                break
    if a > ans:
        ans = a
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  ll k;
  cin>>n>>k;
  ll aa[100010]={};
  for(int i=1;i<=n;i++){
    int a,b;
    cin>>a>>b;
    aa[a]+=b;
  }
  int cnt=1;
  while(k>0){
    k-=aa[cnt];
    cnt++;
  }
  cout<<cnt-1<<endl;
  return 0;
}


Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;
fn main() {
    input!{
        n: u64,
        a: u64,
    }
    println!("{}", n * n - a);
}


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

int main() {
  int N;
  string S, T, ans;
  cin >> N >> S >> T;
  for(int i=0;i<N;i++){
    cout << S.at(i) << T.at(i);;
  }  
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
a2,b2,k2=input().split()
a2=int(a2)
b2=int(b2)
k2=int(k2)
if a2-k2 >0:
    print(a2-k2,b2)
elif a2+b2-k2>0:
    print("0",a2+b2-k2)
else:
    print("0 0")

Measured memory_bytes: 38256
#include<cstdio>
#include<cmath>

using namespace std;

int main()
{
	long int n;
	scanf("%ld", &n);

	double ceilodd = sqrt(n*1.0);

	bool divisable = false;

	printf("%ld:", n);

	while (n % 2 == 0)
	{
		printf(" 2");
		n /= 2;
	}
	if (n == 1)goto goal;

	while (n % 3 == 0)
	{
		printf(" 3");
		n /= 3;
	}
	if (n == 1)goto goal;

	double tmp;

	for (long int i = 5; i <= ceilodd; i += 2)
	{
		divisable = false;
		
		tmp = sqrt(1.0*i);
		for (long int j = 3; j <= tmp; j += 2)
		{
			if (i%j == 0)
			{
				divisable = true;
				break;
			}
		}

		if (divisable == false)
		{
			while (n%i == 0)
			{
				printf(" %ld", i);
				n /= i;
			}
			if (n == 1)goto goal;
		}

	}
	
	if (n != 1)
		printf(" %ld", n);

	goal:

		printf("\n");
	
	return 0;
}

Measured memory_bytes: 1004
T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    S = input().strip()

    ignore = []

    win = True

    for i in range(N - 1, -1 ,-1):
        startLen = len(ignore)
        #Do Stuff
        curr = A[i]
        for v in ignore:
            if curr ^ v < curr:
                curr = curr ^ v
        if curr != 0:
            ignore.append(curr)
            ignore.sort(reverse = True)
        #End
        endLen = len(ignore)
        if S[i] == '1' and startLen != endLen:
            win = False
            break
            

    if win:
        print(0)
    else:
        print(1)


Measured memory_bytes: 68348
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();

		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextLong();
		MathContext mc = new MathContext(25, RoundingMode.HALF_EVEN);

		int[] p = new int[n];
		for (int i = 0; i < n; i++)
			p[i] = sc.nextInt();

		long[] cnt = new long[1 << n];
		for (int i = 1; i < (1 << n); i++) {
			long l = 1;
			for (int j = 0; j < n; j++) {
				if (((i >> j) & 1) == 1) {
					l = lcm(l, a[j]);
					if (l == 0)
						break;
				}
			}
			if (l != 0)
				cnt[i] += (m / l)*(Math.pow(-1, 1+Integer.bitCount(i)));
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < (1 << n); j++) {
				if (((j >> i) & 1) == 1) {
					cnt[j] += cnt[j ^ (1 << i)];
				}
			}
		}
		double ans = 0;
		for (int i = 0; i < (1 << n); i++) {
			double pro = Math.abs(cnt[i]);
			for (int j = 0; j < n; j++) {
				if (((i >> j) & 1) == 1) {
					pro *= p[j] / 100.0;
				} else {
					pro *= (100 - p[j]) / 100.0;
				}
			}
			ans += pro;

		}
		System.out.printf("%.10f\n", ans);
	}

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

	long lcm(long a, long b) {
		a /= gcd(a, b);
		if (a * b / b != a)
			return 0;
		else
			return a * b;
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 36160
#include <iostream>
#include <vector>
#include <queue>
#include <set>

using namespace std;
struct state {
    state(vector<int> vec, int z, int c, int n) : board {vec}, zero {z}, correct {c}, num {n} {};
    vector<int> board;
    int zero;
    int correct;
    int num;
    void print(){
        cout << "board" << endl;
        for(int i = 0; i < 9; ++i){
            cout << board[i] << ' ';
            if(i%3 == 2){
                cout << endl;
            }
        }
        cout << "correct = " << correct << ", zero = " << zero << ", n = " << num << endl;
    }
};

multiset<vector<int>> memo {};

bool correct_pos(vector<int>& vec, int id){
    return (id+1)%9 == vec[id];
}

void push_queue(queue<state>& states, state now, int pos){
    if(pos >= 0 && pos < 9){
        int nc = now.correct;
        if(correct_pos(now.board, pos)){
            --nc;
        }
        if(correct_pos(now.board, now.zero)){
            --nc;
        }
        swap(now.board[pos], now.board[now.zero]);
        if(correct_pos(now.board, pos)){
            ++nc;
        }
        if(correct_pos(now.board, now.zero)){
            ++nc;
        }
        bool pushed = memo.find(now.board) != memo.end();
        if(pushed){
        //    cout << "already searched, pos = " << pos << endl;
            return;
        } else {
            memo.insert(now.board);
        }
        state next_st = state(vector<int>(now.board), pos, nc, now.num+1);
        //cout << "pushing" << endl;
        //next_st.print();
        states.push(next_st);
        swap(now.board[pos], now.board[now.zero]);
    }
}

int bfs(queue<state>& states){
    int ret = 0;
    while(states.size()){
        state s = states.front();
        states.pop();
        if(s.correct == 9){
            ret = s.num;
            break;
        }
        int up = s.zero - 3;
        int down = s.zero + 3;
        int left = s.zero%3 ? s.zero - 1 : -1;
        int right = s.zero%3 != 2 ? s.zero + 1 : -1;
        //cout << up << " " << down << " " << left << " " << right << endl;
        push_queue(states, s, up);
        push_queue(states, s, down);
        push_queue(states, s, left);
        push_queue(states, s, right);
    }
    return ret;
}

int find_minimum(vector<int>& vec){
    int zero = 0;
    int correct = 0;
    for(auto it = vec.begin(); it != vec.end(); ++it){
        int i = it - vec.begin();
        if(*it == 0){
            zero = i;
        }
        if(correct_pos(vec, i)){
            ++correct;
        }
    }
    auto st = queue<state>();
    st.push(state(vec, zero, correct, 0));
    return bfs(st);
}

int main(){
    vector<int> board {};
    for(int i = 0; i < 9; ++i){
        int v;
        cin >> v;
        board.push_back(v);
    }
    cout << find_minimum(board) << endl;
}

Measured memory_bytes: 21508
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define MAPFOR(it,m) for( auto it = (m).begin(); it != (m).end() ; ++it )
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int x, n;
    cin >> x >> n;
    vi p(n);
    REP(i, n) cin >> p[i];
    if(n==0) {
        cout << x << endl;
        return 0;
    }
    
    FOR(i, 0, 110) {
        auto minus_itr = find(ALL(p), x-i);
        size_t index = distance( p.begin(), minus_itr );
        if (index == p.size()) {
            cout << x-i << endl;
            return 0;
        }
        
        auto plus_itr = find(ALL(p), x+i);
        index = distance( p.begin(), plus_itr );
        if (index == p.size()) {
            cout << x+i << endl;
            return 0;
        }
        
    }
    
    return 0;
}


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

void put(li fr, li to) {
    cout << fr << " " << to << endl;
}

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

    li n;
    cin >> n;

    if (__builtin_popcountll(n) == 1) {
        cout << "No" << endl;
    } else if (n % 4 == 3) {
        cout << "Yes" << endl;
        for (int i = 0; i < 2 * n - 1; ++i) {
            put(i + 1, i + 2);
        }
    } else if (n % 4 == 1) {
        cout << "Yes" << endl;
        for (int i = 1; i < n - 2; ++i) {
            put(i, i + 1);
            put(n + i, n + i + 1);
        }
        put(n - 2, n + 1);

        put(n - 1, n);
        put(n, 1);
        put(1, n - 1 + n);
        put(n - 1 + n, n + n);
    } else if (n % 4 == 2) {
        cout << "Yes" << endl;
        for (int i = 1; i < n - 3; ++i) {
            put(i, i + 1);
            put(n + i, n + i + 1);
        }
        put(n - 3, n + 1);

        put(n - 2, n - 1);
        put(n - 1, 1);
        put(1, n - 2 + n);
        put(n - 2 + n, n - 1 + n);
        put(n, n - 1);
        put(2, n + n);
    } else { // n % 4 == 0
        cout << "Yes" << endl;
        for (int i = 1; i < n - 1; ++i) {
            put(i, i + 1);
            put(n + i, n + i + 1);
        }
        put(n - 1, n + 1);

        const li shiftv = 1LL << __builtin_ctzll(n);
        const li fr = n - shiftv + 1;
        const li to = shiftv;
        put(n, fr);
        put(to + n, n + n);
    }

    return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int gcd(int a, int b){
    while(b){
        a %= b;
        swap(a, b);
    }
    return a;
}

int main(){
    int N; cin >> N;
    string a, b, c; cin >> a >> b >> c;
    int ans = 0;
    for(int i=0; i<N; i++){
        if(a[i]==b[i] && b[i]==c[i]) continue;
        else if(a[i]!=b[i] && b[i]!=c[i] && c[i]!=a[i]) ans += 2;
        else ans++;
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

// mita
int main() {
  int n, k;
  cin >> n;
  vector<int> h;
  rep(i,n) {
    cin >> k;
    h.push_back(k);
  }
  int target = 0;
  int cnt = 0;
  rep(i,n) {
    if (target > h[i]) {
      target = h[i];
    } else {
      cnt += h[i] - target;
      target = h[i];
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque

h, w = map(int, input().split())
c = []
d = [[-1 for i in range(w)] for j in range(h)]
d[0][0] = 0
white = 0
for i in range(h):
	s = input()
	c.append(s)
	white += s.count('.')

dirr = [[1, 0], [0, 1], [-1, 0], [0, -1]]
q = deque()
q.append([0, 0, 0])

min_dist = -1
while len(q) != 0:
	y, x, z = q[0]
	if y == h - 1 and x == w - 1:
		min_dist = z
		break

	for i in range(4):
		ny, nx = y + dirr[i][0], x + dirr[i][1]
		if 0 <= ny < h and 0 <= nx < w and d[ny][nx] == -1 and c[ny][nx] != "#":
			q.append([ny, nx, z + 1])
			d[ny][nx] = z + 1

	q.popleft()

if min_dist == -1:
	print(-1)
else:
	print(white - min_dist - 1)



Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll R;
    cin >> R;
    double res = R * 2 * PI;
    PRINTD(res, 20);
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N, A, counter = 0;
  cin >> N;
  rep(i, N) {    
    cin >> A;

    int power = 0;
    while (A % 2 == 0) {
      A /= 2;
      power++;
    }

    if (counter > power || i == 0) {
      counter = power;
    }
  }

  cout << counter << endl;
}

Measured memory_bytes: 256
/** 
 *  Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s[2] == s[3] && s[4] == s[5])    cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n;
ll arr[3001], dp[3001][3001];

ll solve(int i = 0, int j = n-1, int t = 0) {
    if (i == n | j < 0 || i > j) {
        return 0;
    }
    ll& ret = dp[i][j];
    if (~ret) {
        return ret;
    }
    if (!t) {
        return ret = max(arr[i] + solve(i+1, j, 1), arr[j] + solve(i, j-1, 1));
    }
    return ret = min(solve(i+1, j, 0)-arr[i], solve(i, j-1, 0)-arr[j]);
}
int main()
{
    IOS
    memset(dp, -1, sizeof dp);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    cout << solve() << endl;


    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;
static const int dx[8] = {-1,0,1,-1,1,-1,0,1}, dy[8] = {-1,-1,-1,0,0,1,1,1};

int main(){
  long N,M;
  cin >> N >> M;
  if(N==1 && M==1){
    cout << 1 << endl;
  }else if(N==1 || M==1){
    cout << N*M-2 << endl;
  }else{
    cout << N*M-2*M-2*N+4 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,s[100] = {},q[100] = {},i,l = 0,k = 0,e = 0;
  while(scanf("%d",&n) != EOF){
      if(n > 0){
        s[k] = n;
        k++;
      }else if(n == 0){
        k = k - 1;
        q[l] = s[k];
        l++;
        s[k] = 0;
      }
  }
  for(i = 0;i < l;i++){
    printf("%d\n",q[i]);
  }
  return 0;
}

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

if N == 1:
  print("Yes")
  exit()

for i in range(N-1, 0, -1):
  if H[i-1] > H[i]:
    if H[i-1] - H[i] == 1:
      H[i-1] -= 1
    else:
      print("No")
      exit()

print("Yes")

Measured memory_bytes: 16320
//テストケースを出力するプログラム
#include <stdio.h>

 
int main()
{
    int x, i;
    i = 0;//初期化
    while (1){
        scanf("%d", &x);//入力
        if (x == 0) break;
        i += 1;
 
        printf("Case %d: %d\n", i, x);//出力
    }
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    string S;
    cin >> S;
    REP(i,S.size()){
        S[i] = 'x';
    }
    cout <<S<< "\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	int N, K;
	cin >> N >> K;
	while(K--)
	{
		int n;
		if(N % 2)
		{
			n = N / 2 + 1;
		}
		else
		{
			n = N / 2;
		}
		int x, y;
		cin >> x >> y;
		if(x > n)
		{
			x = N - x + 1;
		}
		if(y > n)
		{
			y = N - y + 1;
		}
		if(y > x)
		{
			int temp = x;
			x = y;
			y = temp;
		}
		if(y % 3 == 0)
		{
			cout << 3 << endl;
		}
		else if(y % 3 == 1)
		{
			cout << 1 << endl;
		}
		else
		{
			cout << 2 << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1160
import numpy as np
from time import time
start = time()
def scoring(c,s,t):
    score = 0
    from_last = np.zeros(26)
    for i in range(s.shape[0]):
        from_last = from_last+1
        score += s[i,t[i]-1]
        from_last[t[i]-1] = 0
        score = score - (c*from_last).sum()
    return score



D = int(input())
c = list(map(int,input().split()))
s = np.empty((D,26))
for i in range(D):
    s[i,:] = np.array(list(map(int,input().split())))


t = []
for i in range(D):
    chosen = s[i,:].flatten().argmax()+ 1
    t.append(chosen)

freq = np.zeros(26)
for i in t:
    freq[i-1] += 1
w = c*(365-freq)
num = np.arange(1,27)
score = scoring(c,s,t)
while time()-start < 1.85:
    i = np.random.randint(D)
    old = t[i]
    t[i] = np.random.choice(num, p = w/w.sum())
    new_score = scoring(c,s,t)
    if new_score > score:
        score = new_score
        w[t[i]-1] -= c[t[i]-1]
        w[old-1] += c[old-1]
    else:
        t[i] = old


for i in t:
	print(i)


Measured memory_bytes: 27540
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n; cin >> n;
  	int f = 0;
  	int m = n;
  	
  	while (n>0) {
		f += n % 10;
      	n /= 10;
    }
  	if (m % f == 0) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

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

using namespace std;

char c[10][10];

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> c[i][j];
    }
  }

  int ans = 0;
  for (int bith = 0; bith < 1 << h; bith++) {
    for (int bitw = 0; bitw < 1 << w; bitw++) {
      vector<int> useh(h, 0), usew(w, 0);
      for (int i = 0; i < h; i++) {
        if (bith >> i & 1) {
          useh[i] = 1;
        }
      }
      for (int i = 0; i < w; i++) {
        if (bitw >> i & 1) {
          usew[i] = 1;
        }
      }
      int sum = 0;
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          if (useh[i]) continue;
          if (usew[j]) continue;
          if (c[i][j] == '#') sum++;
        }
      }
      if (sum == k) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <set>

using namespace std;
int A[400][400];

int main()
{     int N,M;
        set<int> G;
        cin>>N>>M;
          int d;
           queue<int> MN[320];
         for(int i=0;i<N;i++)
            for(int e=0;e<M;e++)
         {
             scanf("%d",&d);
             MN[i].push(d);
         }
         int maw=1000000;
         int mas=0;
         int K[350];
         int y=0;
         int w;
         memset(K,0,sizeof(K));
       //  cout<<"WWWWWWWWWWWW";
         for(;;)
          {     memset(K,0,sizeof(K));
                  mas=0;
              for(int i=0;i<N;i++)
          {
              int d=MN[i].front();
              K[d]++;
              mas=max(K[d],mas);
              if(mas==K[d])
                w=d;

          }
         // cout<<"QQQQQQQQQQQ";
             //  cout<<w<<"SAAAAAAAAAAA";
          G.insert(w);
          maw=min(maw,mas);
          for(int i=0;i<N;i++)
          {    if(MN[i].empty())
                 {     y=1;
                     break;}
                   //   cout<<"RRRRRRRRRR";
              int ds=MN[i].front();
              while(G.count(ds))
              {
                  MN[i].pop();
                   ds=MN[i].front();
                    if(MN[i].empty())
                 {     y=1;
                     break;}
              }
                if(y==1)
                    break;

          }
          if(y==1)
            break;}
            cout<<maw<<endl;
    return 0;
}


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

int main() {
int n, c, d[30][30], x[3][30], m=1e9;
cin>>n>>c;
for(int i=0;i<c;i++){
    for(int j=0;j<c;j++){
        cin>>d[i][j];
    }
}
for(int i=0;i<3;i++){
    for(int j=0;j<c;j++){
        x[i][j]=0;
    }
}
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        int y;
        cin>>y;
        y--;
        x[(i+j)%3][y]++;
    }
}
for(int i=0;i<c;i++){
    for(int j=0;j<c;j++){
        if(i==j)continue;
        for(int k=0;k<c;k++){
            if(k==i||k==j)continue;
            int t=0;
            for(int l=0;l<c;l++){
                t+=x[0][l]*d[l][i];
                t+=x[1][l]*d[l][j];
                t+=x[2][l]*d[l][k];
            }
            m=min(m, t);
           
        }
    }
}
    cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 5 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    string s;

    cin>>s;

    int z=0 , o=0;

    for(int i=0; i<s.size(); ++i){
        z+=(s[i]=='1');
        o+=(s[i]=='0');
    }

    cout<<min(z, o)*2<<endl;



    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("cin","r",stdin);
    freopen("cout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 512
/*
[abc125] D - Flipping Signs
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;
const int MAX_A = 1e9;

int N;
int A[MAX_N];

ll solve() {
    ll s = 0;
    int m = MAX_A;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        s += abs(A[i]);
        m = min(m, abs(A[i]));
        if (A[i] <= 0) {
            cnt++;
        }
    }

    if (cnt % 2 == 0) {
        return s;
    }
    return s - 2 * m;
}

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

    cout << solve() << endl;

    return 0;
}


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

using namespace std;

#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"
#define trace(x) cerr << #x << ": " << x << " " << endl;

#define sz(a) ( (int) (a).size() )
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for(auto (it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end()) //
#define cpres(c, val) (find(all(c), val) != (c).end()) //

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<int>::iterator vit;

const int N = 1e9 + 7;

bool isPalin(string s, int p, int q) {
    for(int i = p; i <= q; i++) if(s[i]!=s[p+q-i]) return false;
    return true;
}

void solve() {
    string s;
    cin >> s;
    int n = sz(s);
    if(isPalin(s, 0, n-1)&&isPalin(s, 0, ((n-1)/2)-1) && isPalin(s, (n+3)/2 - 1, n-1)) cout << "Yes\n";
    else cout << "No\n";
}

int32_t main(int32_t argc, char** argv) {
    fastio;
    solve();
    return 0;
}

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

#define ff first
#define ss second
#define endl '\n'

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

	int five = 0, seven = 0;
	for (int i = 0, x; i < 3; ++i) {
		cin >> x;
		if (x == 5) {
			++five;
		} else if (x == 7) {
			++seven;
		}
	}

	if (five == 2 && seven == 1) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256