akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std; 
using lint =                            long long int;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD 1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                     bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }

/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

//Mean of an uniformly distributed variable is = (a + b)/2;
//Variance = (b-a)^2/2;

void solve(){
  int N;
  cin>>N;
  int K;
  cin>>K;   
  vector<double> p(N);
  cin>>p;
  REP(i,N){
      p[i]=(p[i]+1)/2.0;
  }
  vector<double> acc(N+1);
  REP(i,N)  acc[i+1]=acc[i]+p[i];
  
  double ans = 0.0;
  REP(i,N-K+1){
      mmax(ans,acc[i+K] - acc[i]);
  }
  cout<<ans<<endl;
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 3456
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args) throws Exception{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] wh = reader.readLine().split(" ",0);
		int w = Integer.parseInt(wh[0]);
		int h = Integer.parseInt(wh[1]);

		int[] costX = new int[w];
		int[] costY = new int[h];

		for(int i = 0; i < w; i++) {
			costX[i] = Integer.parseInt(reader.readLine());
		}
		for(int i = 0; i < h; i++) {
			costY[i] = Integer.parseInt(reader.readLine());
		}

		Arrays.sort(costX);
		Arrays.sort(costY);

		int wIndex = 0;
		int hIndex = 0;

		long result = 0;

		for(;;) {
			if(wIndex>=costX.length && hIndex>=costY.length) break;
			if(hIndex<costY.length && (wIndex>=costX.length || costX[wIndex] > costY[hIndex])) {
				result += (long)costY[hIndex] * (long)(w-wIndex+1);
				hIndex++;
			}else {
				result += (long)costX[wIndex] * (long)(h-hIndex+1);
				wIndex++;
			}
			//System.out.println(result);
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 26896
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x);
int pop(void);

int main(){
  int a,b;
  top = 0;
  char s[100];

  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }
    else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a*b);
    }
    else{
      push(atoi(s));
    }
  }

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

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

int pop(){
  top--;
  
  return S[top+1];
}




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

int main(){
    int x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    int ans = 0;
    ans -= x1 - 1;
    ans -= x2 - 2;
    ans -= x3 - 3;
    ans -= x4 - 4;
    ans -= x5 - 5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
////////////////////////////////////////////////
//                                            //
//  Author: Muhammad Faishol Amirul Mukminin  //
//                                            //
////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef pair<ll,ll> pl;
typedef pair<pl,ll> pll;
typedef pair<double,double> pd;
typedef pair<pd,double> pdd;

#define fi first
#define se second
#define PUB push_back
#define POB pop_back
#define PUF push_front
#define POF pop_front
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"

const double EPS = 1e-9;
const double PI = acos(-1);

const ll MOD = 1e9+7;

const int dCol[] = {0,+1,0,-1,+1,+1,-1,-1};
const int dRow[] = {-1,0,+1,0,-1,+1,+1,-1};

ll A, B, N=1, ans=0;

bool valid(ll ang){
	ll res=0;
	while(ang>0){
		res += ang%10;
		ang /= 10;
	}

	if(A <= res && res <= B) return 1;
	else return 0;
}

// ^r log Un/a = ^(n-1)

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> A >> B;
	for(int i=1;i<62;i++){
		N <<= 1;

		if(A*N > B){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
w, h, x, y = map(int, input().split())

cent_x = w / 2
cent_y = h / 2

unique_flag = 0
if (cent_x == float(x)) & (cent_y == float(y)):
    unique_flag = 1

area = w * h / 2
print(str(area) + " " + str(unique_flag))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

ll dist(ll i, ll j, ll n, ll x, ll y) {
  ll a = j - i;
  ll b = abs(i - x) + abs(j - y) + 1;
  return min(a, b);
}

int main() {
  ll n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  vll ans(n, 0);
  for (ll i = 0; i < n - 1; i++) {
    for (ll j = i + 1; j < n; j++) {
      ans[dist(i, j, n, x, y)]++;
    }
  }
  for (ll i = 1; i < n; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		String s= sc.next();
		if(Character.isUpperCase(s.charAt(0))) {
			System.out.println("A");
		}else {
			System.out.println("a");
		}
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

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

	        return tokenizer.nextToken("\n");
	    }

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

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

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

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 32576
class UnionFind:

  def __init__(self, n):
    self.par = [i for i in range(n)]
    self.rank = [0] * n
    self.sizes = [1] * n

  def find(self, x):
    if self.par[x] != x:
      self.par[x] = self.find(self.par[x])
    return self.par[x]

  def union(self, x, y):
    x, y = self.find(x), self.find(y)
    if x == y:
      return False
    elif self.rank[x] < self.rank[y]:
      self.par[x] = y
      self.sizes[y] += self.sizes[x]
    elif self.rank[x] > self.rank[y]:
      self.par[y] = x
      self.sizes[x] += self.sizes[y]
    else:
      self.par[y] = x
      self.rank[x] += 1
      self.sizes[x] += self.sizes[y]
    return True

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def size(self, x):
    return self.sizes[self.find(x)]


n, m = list(map(int, input().split()))
edge = []
for i in range(m):
  a, b = list(map(int, input().split()))
  edge.append((a-1, b-1))
ans = 0

for i in range(m):
  uf = UnionFind(n)
  for j in range(m):
    if i==j:
      continue
    uf.union(edge[j][0], edge[j][1])
  ans += uf.union(edge[i][0], edge[i][1])
print(ans)

Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let s = get!(String);
    println!("{}", s.chars().filter(|&x| x == '2').count());
}


Measured memory_bytes: 4352
n=int(input())
s=[]
for _ in range(n):
    x=int(input())
    s.append(x)
sums=sum(s)
if sums%10!=0:
    print(sums)
    exit()
s.sort()
for i in range(n):
    if s[i]%10!=0:
        print(sums-s[i])
        exit()
print(0)

Measured memory_bytes: 9116
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String line = sc.nextLine();
        Set<String> sList = new HashSet<>(Arrays.asList(line.split(" ")));
        if(sList.size() == 4) {
            System.out.println("Four");
        } else {
            System.out.println("Three");
        }
    }
}

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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnPreOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnInOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnInsert(StNode*& rpoRoot, StNode* poNewNod)
{
  StNode* poParnt = nullptr;
  StNode* poNode = rpoRoot;

  while (poNode != nullptr)
  {
    poParnt = poNode;
    if (poNewNod->m_nKey < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;
  }

  poNewNod->m_poParnt = poParnt;
  if (poParnt == nullptr)
    rpoRoot = poNewNod;
  else if (poNewNod->m_nKey < poParnt->m_nKey)
    poParnt->m_poLeft = poNewNod;
  else
    poParnt->m_poRigt = poNewNod;
}

void fnBinSchTree(StNode*& poRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(poRoot, poNewNod);
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(poRoot);
      cout << endl;
      fnPreOrder(poRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
  fnPstOrder(poRoot);
}

Measured memory_bytes: 26688
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, si = 0; cin >> n;
	vector<int> x(n), y(n), h(n);
	rep(i, 0, n - 1)
	{
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] > 0) si = i;
	}
	rep(i, 0, 100)rep(j, 0, 100)
	{
		int H = h[si] + abs(x[si] - i) + abs(y[si] - j);
		bool flag = true;
		rep(k, 0, n - 1)
		{
			if(h[k] != max(H - abs(x[k] - i) - abs(y[k] - j), 0)) flag = false;
		}
		if (flag)
		{
			cout << i << " " << j << " " << H << endl;
			return 0;
		}
	}
}

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


struct Person {
  string name;
  Person *parent;
};

const int MAXN = 1005;
int N, M;
map<string, Person*> conv;
Person root, person[MAXN];

void init() {
  conv.clear();
  root.name = "root";
  root.parent = NULL;
}

bool child(Person *a, Person *b) { // a is child of b
  return a->parent == b;
}

bool sibling(Person *a, Person *b) {
  return a->parent == b->parent;
}

bool descendant(Person *a, Person *b) { // a is descendant of b
  while(a != NULL) {
    if(a->parent == b) return true;
    a = a->parent;
  }
  return false;
}

int main() {
  while(cin >> N >> M && (N|M)) {
    cin.ignore();
    init();
    Person *cp = &root;
    int depth = -1;
    for(int i = 0; i < N; ++i) {
      string line;
      getline(cin, line);
      int sp = 0;
      for(int j = 0; j < line.size() && line[j] == ' '; ++j, ++sp);

      Person &c = person[i];
      c.name = line.substr(sp);
      conv[c.name] = &person[i];

      if(sp > depth) {
        c.parent = cp;
      } else {
        for(int j = 0; j < depth-sp; ++j) {
          cp = cp->parent;
        }
        c.parent = cp->parent;
      }
      cp = &c;
      depth = sp;
    }

    while(M--) {
      string x, y, type;
      string dumy;
      cin >> x >> dumy >> dumy >> type >> dumy >> y;
      y = y.substr(0, y.size()-1);
      bool output = false;
      if(0) {
      } else if(type == "child") {
        output = child(conv[x], conv[y]);
      } else if(type == "parent") {
        output = child(conv[y], conv[x]);
      } else if(type == "sibling") {
        output = sibling(conv[x], conv[y]);
      } else if(type == "descendant") {
        output = descendant(conv[x], conv[y]);
      } else if(type == "ancestor") {
        output = descendant(conv[y], conv[x]);
      }
      cout << (output ? "True" : "False") << endl;
    }
    cout << endl;
  }
  return 0;
}

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

#define pu push_back
#define fi first
#define se second
#define mp make_pair
#define int long long
#define pii pair<int,int>
#define mm (s+e)/2
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define sz 1000100
int A[sz],B[sz],C[sz];
signed main()
{
	

		int n;
		cin>>n;
		for(int i=0;i<n;i++)
		{
			int a;
			cin>>a;
			A[a]++;
		}
		int sum=0;
		for(int i=1;i<=1000000;i++)
		{
			if(A[i]!=0)
			{
               if(A[i]==1 && B[i]==0) sum++;
               for(int j=i*2;j<=1000000;j+=i)
               {
               	B[j]=1;
               } 
			}
		}
	     cout<<sum<<endl;
}

Measured memory_bytes: 19264
#include<bits/stdc++.h>
#define ll long long

const ll mod = 1000000007 ;

bool isInteger(double n)
{
	if(floor(n)==ceil(n))
		return true ;
	return false ;
}

using namespace std ;

int main()
{
	int x;
	cin>>x;
	if(x>=30)
		cout<<"Yes";
	else
		cout<<"No";
}


Measured memory_bytes: 3600
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>

using namespace std;
const int maxN=1e5+100;

map <pair<int,int>, bool> iscut;
int dfs_num;
vector<int> g[maxN];
vector<pair<int,int> > ans;
bool mark[maxN];
int high[maxN];
int n,m;

#define mp make_pair


void input()
{
  cin>>n>>m;
  for(int i=1;i<=m;i++)
    {
      int k1,k2;
      cin>>k1>>k2;
      g[k1+1].push_back(k2+1);
      g[k2+1].push_back(k1+1);
    }
	
}
void dfs(int v,int parent)
{
  int copydfsnum=dfs_num;
  high[v]=dfs_num++;
  mark[v]=true;
  
  
  for(int i=0;i<g[v].size();i++){
    if(!mark[g[v][i]])
      dfs(g[v][i],v);
    if(g[v][i]!=parent)
    high[v]=min(high[v],high[g[v][i]]);
    if(high[g[v][i]]>copydfsnum){
      //if(v<g[v][i])
      ans.push_back(mp(min(v,g[v][i]),max(v,g[v][i])));
      //      iscut[mp(v,g[v][i])]=true;
      //iscut[mp(g[v][i],v)]=true; // age jahat dar hast graph ino comment kon

    }
    // cout<<v<<" "<<g[v][i]<<" "<<high[g[v][i]]<<" "<<copydfsnum<<endl;
  }
}

void show()
{
  sort(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++)
    cout<<ans[i].first-1<<" "<<ans[i].second-1<<endl;
}
int main()
{
  input();
  dfs(1,0);
  show(); 
} 

Measured memory_bytes: 5304
N,M=map(int,input().split())
AB=[]
for n in range(N):
	AB.append(list(map(int,input().split())))
AB.sort(key=lambda x:x[0])
m=0
ans=0
i=0
while m<M:
	buy=min(M-m,AB[i][1])
	m+=buy
	ans+=AB[i][0]*buy
	i+=1
print(ans)

Measured memory_bytes: 29020
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int n, x, maxx; string s; cin >> n >> s;
    x = maxx = 0;;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'I')
        {
            x++;
        }
        else
        {
            x--;
        }
        if (maxx < x)
        {
            maxx = x;
        }
    }
    cout << maxx << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(a>b){
cout<<"a > b"<<endl;
}else if(a<b){
cout<<"a < b"<<endl;
}else if(a==b){
cout<<"a == b"<<endl;
}
return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> h(N);
	vector<int> dp(N,0);
	for(int i=0;i<N;i++){
		cin >> h.at(i);
	}

	dp.at(N-2)=abs(h.at(N-1)-h.at(N-2));
/*	if(dp.at(N-2)+abs(h.at(N-2)-h.at(N-3))<abs(h.at(N-1)-h.at(N-3))){
		dp.at(N-3)=dp.at(N-2)+abs(h.at(N-2)-h.at(N-3));
	}else{
		dp.at(N-3)=abs(h.at(N-1)-h.at(N-3));
	}
*/
	for(int i=N-3;i>=0;i--){
		if(dp.at(i+2)+abs(h.at(i+2)-h.at(i))<dp.at(i+1)+abs(h.at(i+1)-h.at(i))){
			dp.at(i)=dp.at(i+2)+abs(h.at(i+2)-h.at(i));
		}else{
			dp.at(i)=dp.at(i+1)+abs(h.at(i+1)-h.at(i));
		}
	}

	cout << dp.at(0) << endl;
	return 0;
}

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

using namespace std;

int main(){
    long long a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    if(k<=a){
        ans=k;
    }
    else if(k>a && k<=a+b){
        ans=a;
    }
    else{
        ans=a-(k-(a+b));
    }
    cout<<ans;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep (i, n) {
        cin >> a[i];
    }

    vi left(n), right(n);
    rep (_, k) {
        bool is_n = true;
        rep (i, n) {
            if (a[i] != n) {
                is_n = false;
                break;
            }
        }
        if (is_n) break;
        fill(all(left), 0);
        fill(all(right), 0);
        vi b(n, 1);
        int num = 0;

        rep (i, n) {
            b[i] += num;
            int j = min(i + a[i], n - 1);
            num++;
            left[j]++;
            num -= left[i];
        }

        num = 0;
        rrep (i, n) {
            b[i] += num;
            int j = max(i - a[i], 0ll);
            num++;
            right[j]++;
            num -= right[i];
        }
        swap(a, b);
    }

    rep (i, n) {
        cout << a[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 9516
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
tmp1,tmp2=0,0
for i in range(1,len(a)):
  if a[i]==a[i-1]:
    tmp1=a[i]
    break
a=a[i+1:]
for i in range(1,len(a)):
  if a[i]==a[i-1]:
    tmp2=a[i]
    break
print(tmp1*tmp2)

Measured memory_bytes: 14252
import math
import sys
sys.setrecursionlimit(10**9)


def comb(n, r):  # 普通のcombination計算
    if r < 0 or r > n:
        return 0
    else:
        n1 = math.factorial(n)
        n21 = math.factorial(n - r)
        n22 = math.factorial(r)
        ans = n1 // (n21 * n22)
        return ans


"""
solve(i, k, smaller)
:= i桁目以降について、0以外の値を残りk個使用可能という状況を考える。
このときi桁目までの部分が「等しい」か「strictに小さくなっている」かを
smallerフラグによって分岐する。
"""


def solve(i, k, smaller):  # 再帰

    # print(i, k, smaller)

    if i == N:
        if k == 0:
            return 1
        else:
            return 0

    if k == 0:
        return 1

    if smaller == True:
        return comb(N - i, k) * pow(9, k)

    else:
        if S[i] == "0":
            return solve(i + 1, k, False)
        else:
            """
            ex. S = 314159　の場合
            000000〜099999 := a
            100000〜299999 := b
            300000〜314159 := c　のように場合分け
            """
            a = solve(i + 1, k, True)
            b = solve(i + 1, k - 1, True) * (int(S[i]) - 1)
            c = solve(i + 1, k - 1, False)
            return a + b + c


# 問題文ではNだが、文字列として扱うのでSと名付ける
S = input()
# Sの桁数、問題文のNとは違う
N = len(S)
K = int(input())

ans = solve(0, K, False)
print(ans)


Measured memory_bytes: 62312
''' ===========================================
from collections import deque
    appendleft() = push_front(), append = push_back()
    popfleft() = pop_front(), pop() = pop_back()
import heapq #heappush(trgt, val) heappop(trgt) trgt[0] __lt__<
=========================================== '''
##======================================python3
import sys
import collections
from sys import stdin #read(), readline()
sys.setrecursionlimit(10**6)
INF = 1<<50
MINI = 100005

class gv:
    input = None;
    
def build():
    gv.str = stdin.readline().rstrip()

def solve():
    slen = len(gv.str)
    if (slen&1) == 1:
        print("No")
        return
    
    for i in range(0,slen,2):
        if (gv.str[i:i+2] == "hi") :
            pass
        else :
            print("No")
            return
    
    print("Yes")
    
    

if __name__ == '__main__':
    build()
    solve()



Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

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

	ll cnt = 0;
	REP(i, n){
		cnt += (ll)(s[i] - '0');
	}
	if(cnt % 9 == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3672
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool inG(ll x,ll n){return 0<=x && x<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  int n;
  cin>>n;

  vi v(n),c(n);
  cin>>v>>c;

  REP(i,n) v[i]-=c[i],v[i]*=v[i]>0;

  cout<<accumulate(ALL(v),0)<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    vector<vector<ll>> a(51, vector<ll>(51, 0));

    rep(j, 0, 3) 
        rep(i, 0, n) 
            cin >> a[j][i];

    rep(i, 0, n) 
        a[0][i]--;

    ll sum(0);
    ll prev(a[0][0]);

    rep(i,0,n)
    {
        sum += a[1][a[0][i]];
        if (prev+1 == a[0][i]) sum += a[2][a[0][i-1]];
        prev = a[0][i];
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
N=int(input())
t=[0]*N
r=set(range(N))
for _ in[0]*N:
 e=list(map(int,input().split()))
 t[e[0]]=e[1:]+[0]*5
 r-=set(e[1:])
def f(i,p,s,d):
 if i<0:return-1
 l,r=t[i][:2]
 t[i][2:]=[p,s,(l!=-1)+(r!=-1),d,max(f(l,i,r,d+1),f(r,i,l,d+1))+1]
 return t[i][-1]
f(r.pop(),-1,-1,0)
for i in range(N):
 print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(i,*t[i][2:],'root'if not t[i][5]else'internal node'if t[i][4]else'leaf'))


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

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

 if(a > b){
  tmp = a;
  a = b;
  b = tmp;
 }

 if(a > c){
  tmp = a;
  a = c;
  c = tmp;
 }

 if(b > c){
  tmp = b;
  b = c;
  c = tmp;
 }
/*
 if(a > b){
  tmp = a;
  a = b;
  b = tmp;
 }*/

 cout << a << " " << b << " " <<  c << endl;

 return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

class ParseError{};
struct Result{
    int p, val;
    Result(int a, int b) : p(a), val(b) {}
};
struct Parser{
    int order_dict[256];
    Parser(){
        memset(order_dict, 0, sizeof(order_dict));
        order_dict['*'] = 5;
        order_dict['+'] = 4;
        order_dict['-'] = 4;
        order_dict['&'] = 3;
        order_dict['^'] = 2;
        order_dict['|'] = 1;
    }
    int eval(const string& s){
        Result r = expr(s, 0, 0);
        if(r.p != s.size()) throw ParseError();
        return r.val;
    }
    int calc(int a, int b, char c){
        //printf("%d%c%d\n", a, c, b);
        if(c == '*') return a * b;
        if(c == '+') return a + b;
        if(c == '-') return a - b;
        if(c == '&') return a & b;
        if(c == '^') return a ^ b;
        if(c == '|') return a | b;
        assert(false);
    }
    Result expr(const string& s, int k, int order){
        if(order == 5) return term(s, k);
        Result r = expr(s, k, order + 1);
        while(order_dict[ s[r.p] ] == order + 1){
            Result t = expr(s, r.p + 1, order + 1);
            r.val = calc(r.val, t.val, s[r.p]);
            r.p = t.p;
        }
        return r;
    }
    Result term(const string& s, int k){
        if(s[k] == '('){
            Result r = expr(s, k + 1, 0);
            if(s[r.p++] != ')') throw ParseError();
            return r;
        }else if(isdigit(s[k])){
            if(s[k] == '0') throw ParseError();
            int val = 0;
            while(isdigit(s[k])){
                val = val * 10 + s[k++] - '0';
            }
            return Result(k, val);
        }else {
            throw ParseError();
        }
    }
    bool valid(const string& s){
        try{
            eval(s);
            return true;
        }catch(...){
            return false;
        }
    }
};
Parser P;

int dfs(const string& s, int n, int type){
    if(n == 0){
        try{
            return P.eval(s);
        }catch(...){
            return (type == 0 ? INT_MAX : INT_MIN);
        }
    }
    string cs = "()*+-&^|0123456789";
    vector<string> next;
    int res = (type == 0 ? INT_MIN : INT_MAX);
    // add 
    for(int i = 0; i <= s.size(); i++){
        for(char c : cs) {
            string ns = s.substr(0, i) + string(1, c) + s.substr(i);
            next.push_back(ns);
        }
    }
    // delete
    for(int i = 0; i < s.size(); i++){
        string ns = s.substr(0, i) + s.substr(i + 1);
        next.push_back(ns);
    }
    for(const string& ns : next) if(P.valid(ns)) {
        //cout << s << "->" << ns << endl;
        if(type == 0){
            res = max(res, dfs(ns, n - 1, type ^ 1));
        }else{
            res = min(res, dfs(ns, n - 1, type ^ 1));
        }
    }
    return res;
}

int main(){
    int N;
    while(cin >> N && N > 0){
        if(N % 2 == 0) N = 2;
        else N = 1;
        string s;
        cin >> s;
        cout << dfs(s, N, 0) << endl;
    }
    return 0;
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;

int main(){
    int n, h; cin >>n >>h;
    vector<P> vec(n);
    ll max_ = 0;
    for(int i = 0; i < n; ++i){
        cin >>vec[i].second >> vec[i].first ; 
        max_ = max(max_ , vec[i].second);
    }
    sort(vec.begin(), vec.end(), greater<P>());
   
    ll ans = 0;
    for(int i = 0; i < n; ++i){
    	if(vec[i].first < max_ ){break;}
    	h -= vec[i].first ;
        ++ans;
        if(h <= 0){h = 0;break;}
    }
    ans += (h/max_ );
    if(h%max_ !=0){++ans;}
    cout << ans << endl;
    return 0;
}

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

int main()
{
	double PI = 3.14159265359;
	double a,b,C,S,L,h;

	cin >> a >> b >> C;

	h = b*sin(C/180.0*PI);
	S = a*h/2.0;
	L = sqrt(pow(h,2.0)+pow(a-b*cos(C/180.0*PI),2.0))+a+b;

	printf("%.08lf %.08lf %.08lf",S,L,h);

	return 0;
}

Measured memory_bytes: 1268
using System;

class AOJ
{
	public static void Main()
	{
		int num = 1;
		while(true)
		{
			int test = int.Parse(Console.ReadLine().Trim());
			if(test == 0){ break; }
			else
			{
				Console.WriteLine(string.Format("Case {0}: {1}", num, test));
				num++;
			}
		}
	}
}

Measured memory_bytes: 5844
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <algorithm>
#define pll pair<ll,ll>
#define NMAX 200001

using namespace std;
typedef long long ll;
typedef long double ld;
int dist[NMAX];
bool win[NMAX];
vector<int>v[NMAX];
void DFS(int nod)
{
    for(auto &vec:v[nod])
    {
        if(dist[vec]==0)
        {
            dist[vec]=dist[nod]+1;
            DFS(vec);
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    int x,y,i,n;
    cin>>n;
    for(i=1;i<n;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dist[1]=1;
    DFS(1);
    x=1;
    for(i=1;i<=n;i++)
    {
        if(dist[i]>dist[x])
        {
            dist[x]=0;
            x=i;
            continue;
        }
        dist[i]=0;
    }
    dist[x]=1;
    DFS(x);
    int ma=0;
    for(int i=1;i<=n;i++)
    {
        ma=max(ma,dist[i]);
    }
    win[0]=0;
    win[1]=1;
    win[2]=0;
    for(int i=3;i<=ma;i++)
    {
        if(!win[i-1] || !win[i-2])
            win[i]=1;
        else
            win[i]=0;
    }
    if(win[ma]==1)
    {
        cout<<"First"<<'\n';
    }
    else
    {
        cout<<"Second"<<'\n';
    }
    
    return 0;
}

Measured memory_bytes: 18432
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MOD = 1e9+7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int c[3] = {};
  ll ans = 1;
  rep(i, n) {
    int cnt = 0;
    rep(j, 3) {
      if (c[j] == a[i]) {
        if (!cnt) c[j]++;
        cnt++;
      }
    }
    ans = ans*cnt%MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main() {
  int n;
  cin >> n;
  int a[n];
  ll ans = 0;
  rep(i,n)cin >> a[i];
  rep(i,n-1){
    if(a[i+1] < a[i]){
      ans += a[i] - a[i+1];
      a[i+1] = a[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4412
while True:
    h,w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for j in range(h):
        if j == 0 or j == h-1:
            for i in range(w):
                print("#", end="")
            print()
        else :
            print("#"+"."*(w-2)+"#")
    print()


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map<int, vector<int>> pos;
    forn(i, 0, n) {
        int a;
        cin >> a;
        pos[a].eb(i);
    }
    vector<ll> ans(n);
    auto it = pos.end();
    --it;
    int prv = it->fs;
    int min_cur = it->sn[0];
    int cnt = it->sn.size();
    if (pos.size() > 1)  {
        do {
            --it;
            ans[min_cur] += 1ll * (prv - it->fs) * cnt;
            min_cur = min(min_cur, it->sn[0]);
            prv = it->fs;
            cnt += it->sn.size();
        } while (it != pos.begin());
    }
    ans[0] += 1ll * prv * cnt;
    forn(i, 0, n) cout << ans[i] << '\n';
}


Measured memory_bytes: 14064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var nd = Arrays.stream(br.readLine().split(" "))
        .mapToLong(Long::parseLong)
        .toArray();

      int count = 0;
      for (int i = 0; i < nd[0]; i++) {
        final var line = br.readLine().split(" ");
        final var x = Long.parseLong(line[0]);
        final var y = Long.parseLong(line[1]);

        final var len2 = x * x + y * y;
        if (len2 <= nd[1] * nd[1]) {
          count++;
        }
      }

      System.out.println(count);
    }
  }
}


Measured memory_bytes: 56284
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

int n,m;
int h[100],b[100];
bool bad[10][10];
vector<int> t[100],val,ans;

bool check(bool *used){
	for(int i=0;i<m;i++){
		int hit=0, blow=0;
		for(int j=0;j<n;j++){
			if(val[j] == t[i][j]){
				hit++;
			}
			else if(used[t[i][j]]){
				blow++;
			}
		}
		if(hit!=h[i] || blow!=b[i]) return false;
	}
	return true;
}

bool solve(int idx,bool *used){
	if(idx == n){
		if(!check(used)) return true;
		if(!ans.empty()) return false;
		ans = val;
		return true;
	}

	for(int i=0;i<10;i++){
		if(used[i] || bad[idx][i]) continue;
		used[i] = true;
		val[idx] = i;
		if(!solve(idx+1,used)) return false;
		used[i] = false;
	}

	return true;
}

int main(void){
	while(cin>>n>>m,n||m){
		memset(bad,0,sizeof(bad));
		for(int i=0;i<m;i++){
			string s;
			cin>>s>>h[i]>>b[i];
			t[i].clear();
			for(int j=0;j<n;j++){
				t[i].push_back(s[j]-'0');
				if(h[i] == 0) bad[j][t[i][j]] = true;
			}
		}

		bool used[10];
		memset(used,0,sizeof(used));
		ans.clear();
		val = vector<int>(n);
		bool flg = solve(0,used);

		if(flg && !ans.empty()){
			for(int i=0;i<n;i++) cout<<ans[i];
			cout<<endl;
		}
		else{
			cout<<"NO\n";
		}
	}

	return 0;
}

Measured memory_bytes: 928
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			int N = Integer.parseInt(br.readLine());
			Dice dice[] = new Dice[N];
			for(int i = 0; i < dice.length; i++)dice[i] = new Dice(); //★★クラス型配列は、入れ物を作った後に、それぞれnewする必要がある★★

			//String str[] = new String[6];
			int array[] = new int[6];

			//N個のDice情報を取得
			for(int i = 0; i < N; i++){
				String str[] = br.readLine().split("\\s+");

				for(int k = 0; k < str.length; k++){
					array[k] = Integer.parseInt(str[k]);
				}

				dice[i].setNumber(array[0], array[1], array[2], array[3], array[4], array[5]);
			}

			boolean FLG = true;

			for(int i = 0; i < N-1; i++){
				for(int k = i+1; k < N; k++){
					if(dice[i].equals(dice[k])){
						FLG = false;
						break;
					}
				}
				if(!FLG)break;
			}

			if(FLG){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

//0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice{

	private int number[];
	private int work[];
	private final String order = "NNNNWNNNWNNNENNNENNNWNNN";

	Dice(){
		number = new int[6];
		work = new int[6];
	}


	public void roll(char dst){
		for(int i = 0; i < 6; i++) work[i] = number[i];
		switch(dst){
		case 'E':
			setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
			break;
		case 'N':
			setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
			break;
		case 'S':
			setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
			break;
		case 'W':
			setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
			break;
		}
	};

	public int getTop(){
		return number[0];
	}

	public void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

	public boolean equals(Object object){

		if(object == this)return true;
		if(object == null)return false;
		if(!(object instanceof Dice))return false;

		Dice another = (Dice)object;

		boolean FLG;

		for(int i = 0; i < order.length(); i++){
			roll(order.charAt(i));
			FLG = true;
			for(int k = 0; k < 6; k++){
				if(this.number[k] != another.number[k]){
					FLG = false;
					break;
				}
			}
			if(FLG)return true;
		}

		return false;
	}
};



Measured memory_bytes: 26608
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n,x,y; 
		
		while(true){
			n = sc.nextInt();
			if(n == 0)break;
			
			int[] z = new int[2];
			
			for(int i = 0; i < n; i++){
				x = sc.nextInt();
				y = sc.nextInt();
				
				if(x == y){
					z[0] += x;
					z[1] += y;
				}
				else{
				if(x < y)z[1] += x + y;
				else z[0] += x + y;
				}
			}
			
			System.out.println(z[0] + " " + z[1]);
		}
		sc.close();
	}
}

Measured memory_bytes: 51640
#include <stdio.h>
#include <queue>

int main(){

    std::priority_queue <int>Q;
    int n;
    int a;

    scanf("%d", &n);

    for (int i = 0; i < n; i++){
        scanf("%d", &a);
        Q.push(a);
    }

    int big = 0;
    int ans = 0;
    while( 1 ){
        ans++;
        big = Q.top();
        while(Q.top() == big){
            Q.pop();
            if(Q.empty()) break;
        }
        if(Q.empty()) break;
    }

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

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<algorithm>
#define maxn 100005
using namespace std;
int n,a[maxn],b[maxn],fa[maxn],siz[maxn],x,ans,cnt;
map<int,int> mp,val;
int find(int x)
{
	if(fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) fa[i]=i,siz[i]=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		x^=a[i]; mp[a[i]]++;
		if(!val[a[i]]) val[a[i]]=++cnt;
	}
	mp[x]++;
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	for(int i=1;i<=n;i++)
	{
		if(!mp[b[i]]) { printf("-1\n"); return 0; }
		mp[b[i]]--;
		if(!val[b[i]]) val[b[i]]=++cnt;
		if(b[i]!=a[i])
		{
			int r1=find(val[a[i]]),r2=find(val[b[i]]);
			if(r1!=r2) fa[r2]=r1,siz[r1]+=siz[r2];
			ans++;
		}
	}
	bool f=true;
	for(int i=1;i<=n;i++) 
		if(a[i]!=b[i]) { f=false; break; }
	if(f) { printf("0\n"); return 0; }
	if(!val[x]) ans++;
	for(int i=1;i<=cnt;i++)
		if(find(i)==i&&siz[i]>1) ans++;
	printf("%d\n",ans-1);
}

Measured memory_bytes: 11136
n,m,Q = map(int, input().split())
train = []
for i in range(n):
  a = []
  for j in range(n):
    a.append(0)
  train.append(a)
  
for i in range(m):
  l,r = map(int, input().split())
  train[l-1][r-1] += 1
cumsum = []
list1 = []
for i in range(n+1):
  list1.append(0)
cumsum.append(list1)
for i in range(n):
  lst = [0,cumsum[i][1]+train[i][0]]
  for j in range(1,n):
    lst.append(lst[j]+train[i][j]+(cumsum[i][j+1]-cumsum[i][j]))
  cumsum.append(lst)
for i in range(Q):
  p,q = map(int, input().split())
  print(cumsum[q][q]-cumsum[p-1][q]-cumsum[q][p-1]+cumsum[p-1][p-1])

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

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

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

    ll H,W; cin >> H >> W;

    ll ans = LLONG_MAX;

    if(H%3 == 0){
        ans = min(ans,0LL);
    }else{
        ans = min(ans,W);
    }

    for (ll i = 0;i < H;i++){
        ll a = W*i;
        ll h2 = H-i;
        if(W%2 == 0){
            ans = min(abs(W/2LL*h2-a),ans);
        }else{
            ans = min(max({abs((W/2LL)*h2-a),h2,abs((W/2LL+1)*h2-a)}),ans);
        }
    }

    swap(H,W);

    if(H%3 == 0){
        ans = min(ans,0LL);
    }else{
        ans = min(ans,W);
    }

    for (ll i = 0;i < H;i++){
        ll a = W*i;
        ll h2 = H-i;
        if(W%2 == 0){
            ans = min(abs(W/2LL*h2-a),ans);
        }else{
            ans = min(max({abs((W/2LL)*h2-a),h2,abs((W/2LL+1)*h2-a)}),ans);            
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256