akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();

        out.println(n % 2 == 0 ? n : n * 2);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 21332
S = list(input())
N = len(S)
flg = True
for i in range((N-1)//2):
  if S[i] != S[N-1-i]:
    flg = False
for i in range((N-1)//4):
  if S[i+((N+3)//2)-1] != S[N-1-i]:
    flg = False
    
if flg:
  print("Yes")
else:
  print("No")


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

using namespace std;

int main(){
    int N, M, C, sum,ans=0;
    cin >> N >> M >> C;
    vector<int> B(M),A(M);
    for(int i=0; i<M; i++){
        cin >> B[i];
    }
    for(int i=0;i<N; i++){
        sum = 0;
        for(int j=0; j<M; j++){
            cin >> A[j];
            sum += A[j]*B[j];
        }
        sum += C;
        if(sum > 0){
            ans++;
        }
    }

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

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

	char c;

	char s[101] = { 0 };
	char p[101] = { 0 };

	int sn = 0;

	while ( (c = getchar()) != EOF) {
		if (c == '\n') {
			break;
		}
		s[sn++] = c;
	}

	int pn = 0;
	while ((c = getchar()) != EOF) {
		if (c == '\n') {
			break;
		}
		p[pn++] = c;
	}

	// 文字数 == pn or sn

	int i = 0;
	int counter = 0;

	int j = 0;


	for (i = 0; i < sn; i++) {
		counter = 1;
		for (j = 0; j < pn; j++)
			if (s[(i + j) % sn] != p[j]) counter = 0;
		if (counter) break;
	}



	if (counter)
		puts("Yes");
	else
		puts("No");

	return 0;
}


Measured memory_bytes: 2144
#include <iostream>
#include <string>
#include <bitset>
#include <algorithm>

int main() {
    std::string s;
    std::cin >> s;
    std::reverse(s.begin(), s.end());
    const auto len = s.length();
    int64_t result{};
    for (uint64_t pattern = 0; pattern < (1ULL << (len - 1)); pattern++) {
        int64_t digit = 1;
        std::bitset<32> bits(pattern);
        for (size_t i = 0; i < len; i++) {
            result += digit * (s[i] - '0');
            digit = (bits[i]) ? 1 : digit * 10;
        }
    }
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 3572
#include<cstdio>
using namespace std;
const int maxn=2e5+5;
int b[maxn],a[maxn],n;
inline void init(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]); 
}
inline void solve(){
	int cur=0,l=1,r=n;
	for (int i=n;i;i--){
		if (!cur) b[l++]=a[i];
			else b[r--]=a[i];
		cur^=1;
	}
	for (int i=1;i<=n;i++){
		printf("%d ",b[i]);
	}
}
int main(){
	init();
	solve();
	return 0;
}

Measured memory_bytes: 3712
import sys
input = sys.stdin.readline

INF = float('inf')


def number2digits(number):
    return list(map(int, str(number)))

def main():
    N, A, B = map(int, input().split())
    ans = 0
    for number in range(1, N+1):
        num_digits_list = number2digits(number)
        total = 0
        for i in num_digits_list:
            total += int(i)
        if A <= total <= B:
            ans += number

    print(ans)


if __name__ == '__main__':
    main()


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define minit(a,b) memset(a,b,sizeof(a))

typedef long long lint;

struct UnionFind {
private:
	vector< int > data;
	
public:
	UnionFind(int _size) : data(_size, -1) {}
	
	bool unite(int _x, int _y) {
		_x = root(_x); _y = root(_y);
		if (_x != _y) data[_x] += data[_y]; data[_y] = _x;
		return _x != _y;
	}
	
	bool same(int _x, int _y) { return root(_x) == root(_y); }
	
	int root(int _x) { return data[_x] < 0 ? _x : data[_x] = root(data[_x]); }
	
	int size(int _x) { return -data[root(_x)]; }
};

int N, Q, p[100010];
char q[100010];
int mark[100010], v[100010];
lint anc[100010];

void solve() {
	UnionFind uf(N+1);
	
	for_(i,1,N+1) if (!mark[i]) uf.unite(p[i], i);
	
	lint ans = 0;
	
	for_rev(i,Q-1,0) {
		if (q[i] == 'M') {
			--mark[ v[i] ];
			if (!mark[ v[i] ]) uf.unite(p[ v[i] ], v[i]);
		} else {
			ans += uf.root(v[i]);
		}
	}
	
	cout << ans << endl;
}

int main() {
	while (scanf("%d %d", &N, &Q), N) {
		for_(i,2,N+1) {
			scanf("%d", &p[i]);
		}
		
		minit(mark, 0);
		mark[1] = 1;
		
		for_(i,0,Q) {
			scanf("%s %d", &q[i], &v[i]);
			if (q[i] == 'M') ++mark[ v[i] ];
		}
		
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 2888
#include <iostream>
#include <cmath>

long long sum(long long n){
  return n*(n+1)/2;
}

int main(){
 long long N;
 std::cin>>N;

 long long ans=0;

/*O(N)
 for(long long i=1;i<=N;i++){
  ans+=i*(N/i)*(N/i+1)/2;
 }
//*/
  
//O(\sqrt(N))
 long long sqN=std::sqrt(N);

 for(long long i=1;i<=sqN;i++){
  ans+=i*sum(N/i);
 }
 for(long long i=1;i<sqN;i++){
  ans+=sum(i)*(sum(N/i)-sum(N/(i+1)));
 }
 ans+=sum(sqN)*(sum(N/sqN)-sum(sqN));
 
 std::cout<<ans<<std::endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) {
	return b?gcd(b,a%b):a;
}
int main() {
	ll sum,x;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) {
		cin>>x;
		if(i==1)
			sum=x;
		else {
			sum=sum/gcd(sum,x)*x;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int X = sc.nextInt();
			int Y = sc.nextInt();
			int Z = sc.nextInt();
			System.out.println(Z + " " + X + " " + Y);

		} finally

		{
			sc.close();
		}
	}

}


Measured memory_bytes: 21716
using System;

namespace ConsoleApp3
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var a = Console.ReadLine();
            if (a.Contains("RRR"))
            {
                Console.WriteLine("3");
            }
            else if (a.Contains("RR"))
            {
                Console.WriteLine("2");
            }
            else if (a.Contains("R"))
            {
                Console.WriteLine("1");
            }
            else
            {
                Console.WriteLine("0");
            }
        }

    }
}


Measured memory_bytes: 25880
class Dice:
    def __init__(self,labels):
       self.stat =  labels
    
    def roll_E(self):
        self.stat[0],self.stat[2],self.stat[3],self.stat[5] = self.stat[3],self.stat[0],self.stat[5],self.stat[2]
        
    def roll_N(self):
        self.stat[0],self.stat[1],self.stat[5],self.stat[4] = self.stat[1],self.stat[5],self.stat[4],self.stat[0]
        
    def roll_S(self):
        self.stat[0],self.stat[1],self.stat[5],self.stat[4] = self.stat[4],self.stat[0],self.stat[1],self.stat[5]
        
    def roll_W(self):
        self.stat[0],self.stat[2],self.stat[5],self.stat[3] = self.stat[2],self.stat[5],self.stat[3],self.stat[0]
        
    def get_top(self):
        return self.stat[0]
        
dice = Dice(input().split())
commands = input()

for command in commands:
    if command == "E":
        dice.roll_E()
    elif command == "N":
        dice.roll_N()
    elif command == "S":
        dice.roll_S()
    elif command == "W":
        dice.roll_W()

print(dice.get_top())


Measured memory_bytes: 5572
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N,K;
  cin>>N>>K;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  sort(A.rbegin(),A.rend());

  ll sum=0;
  for(int i=K;i<N;i++) sum+=A[i];
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 1792
from collections import deque

def solve():
    N = int(input())
    Ss = list(map(int, input().split()))

    Ss.sort(reverse=True)

    Qs = [deque() for _ in range(N+1)]
    Qs[0].append(10**10)

    for S in Ss:
        for day in range(N+1):
            if not Qs[day]: continue
            if Qs[day][0] > S:
                Qs[day].popleft()
                for d in range(day+1, N+1):
                    Qs[d].append(S)
                break
        else:
            return False

    return True


if solve():
    print('Yes')
else:
    print('No')


Measured memory_bytes: 106316
import java.util.*;

public class Main{

    int w,h;
    char[][] map;
    int[][] map2;
    boolean B,W;
    int[] dx = {0,0,1,-1};
    int[] dy = {1,-1,0,0};
    int idx;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            w = sc.nextInt();
            h = sc.nextInt();
            if(w==0 && h==0) break;

            map = new char[h][w];
            for(int i=0; i<h; i++){
                String line = sc.next();
                map[i] = line.toCharArray();
            }
        
            ArrayList<Integer> black = new ArrayList<Integer>();
            ArrayList<Integer> white = new ArrayList<Integer>();
            map2 = new int[h][w];
            idx = 1;
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    if(map[i][j]=='.'){
                        B = false;
                        W = false;
                        bfs(j,i);
                        if(B && !W) black.add(idx);
                        if(!B && W) white.add(idx);
                        idx++; 
                    }
                }
            }

            int bsum = 0, wsum = 0;
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    if(black.contains(map2[i][j])) bsum++;
                    if(white.contains(map2[i][j])) wsum++;
                }
            }

            System.out.println(bsum+" "+wsum);
        }
    }

    void bfs(int sx, int sy){
        LinkedList<int[]> list = new LinkedList<int[]>();
        list.add(new int[]{sx,sy});
        boolean[][] v = new boolean[h][w];

        while(list.size()>0){
            int[] xy = list.poll();
            int x = xy[0], y = xy[1];

            if(v[y][x]) continue;
            v[y][x] = true;

            map2[y][x] = idx;
            map[y][x] = 'x';

            for(int i=0; i<4; i++){
                int nx = x+dx[i], ny = y+dy[i];
                if(nx<0 || nx>=w || ny<0 || ny>=h) continue;
                if(map[ny][nx]=='.'){
                    list.add(new int[]{nx,ny});
                }else if(map[ny][nx]=='B') B = true;
                else if(map[ny][nx]=='W') W = true;
            }
        }
    }

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

Measured memory_bytes: 13000
import itertools
N,M,Q = list(map(int,input().split()))
list1 = [None for i in range(Q)]
for i in range(Q):
  list1[i] = list(map(int,input().split()))

ans = 0
for x in itertools.combinations_with_replacement(range(1,M+1),N):
  score = 0
  x1 = sorted(x)
  score = sum(y[3] for y in list1 if x1[y[1]-1]-x1[y[0]-1] == y[2])
  if score > ans:
    ans = score

print(ans)

Measured memory_bytes: 69572
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a;
    cin>>n;
    while (cin>>a) {
        if (cin.fail()) {
            break;
        } else {
            int b,c,d;
            cin>>b>>c>>d;
            int sum=a+b+c+d;
            int min_num=10000;
            std::deque<int> deq(4,0);
            for (int i=0;i<=a;i++) {
                for (int j=0;j<=b;j++) {
                    for (int k=0;k<=c;k++) {
                        for (int l=0;l<=d;l++) {
                            int tmp=sum;
                            if (10*i+50*j+100*k+500*l>=n) {
                                tmp-=(i+j+k+l);
                                int rest=(10*i+50*j+100*k+500*l)-n;
                                if (rest/500!=0) {
                                    tmp+=rest/500;
                                    rest-=500*(rest/500);
                                }
                                if (rest/100!=0) {
                                    tmp+=rest/100;
                                    rest-=100*(rest/100);
                                }
                                if (rest/50!=0) {
                                    tmp+=rest/50;
                                    rest-=50*(rest/50);
                                }
                                if (rest/10!=0) {
                                    tmp+=rest/10;
                                    rest-=10*(rest/10);
                                }
                                if (tmp<min_num) {
                                    min_num=tmp;
                                    deq[0]=i;
                                    deq[1]=j;
                                    deq[2]=k;
                                    deq[3]=l;
                                }
                            }
                        }
                    }
                }
            }
            for (int i=0;i<4;i++) {
                if (deq[i]!=0) {
                    if (i==0) {
                        cout<<10<<" "<<deq[i]<<endl;
                    } else if (i==1) {
                        cout<<50<<" "<<deq[i]<<endl;
                    } else if (i==2) {
                        cout<<100<<" "<<deq[i]<<endl;
                    } else if (i==3) {
                        cout<<500<<" "<<deq[i]<<endl;
                    }
                }
            }
            cin>>n;
            if (n!=0) {
                cout<<endl;
            } else {
                break;
            }
        }
    }
}


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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<ll,ll>
#define pii pair<int,pi>
#define pb push_back
#define mxn 200005

int main(){
sp;

ll n,p;
cin>>n>>p;
if(n==1){
    cout<<p;
    return 0;
}
vector<pi> v;
ll ans=1LL;
ll z=0;
while(p%2==0){
    p>>=1;
    ++z;
}
if(z>=n)v.pb({2LL,z});
for(ll i=3LL; i*i<=p;i+=2){
    if(p%i==0){
        ll z=0;
        while(p%i==0){
            ++z;
            p/=i;
        }
        if(z>=n)
        v.pb({i,z});

    }
}
if(n==1&&p>1)v.pb({p,1LL});
for(auto &it:v)
if(it.s>=n){
    ll temp=it.s/n;
    ll t1=it.f;
    t1=pow(1LL*t1,1LL*temp);
    ans=(1LL*ans*t1);
}
cout<<ans;
return 0;}


Measured memory_bytes: 256
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
import math


def add(i):
    return math.floor(i * 1.01)


x = int(input())
s = 100
ans = 0
while True:
    s = add(s)
    ans += 1
    if (s >= x):
        print(ans)
        break


Measured memory_bytes: 9160
// created_by  Rishi_Mohan

#include<bits/stdc++.h>

#define    ll           long long int
#define    db1(x)       cout<<#x<<"="<<x<<'\n'
#define    db2(x,y)     cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define    db3(x,y,z)   cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

using namespace std;

void solve()
{
   ll x;
   cin >> x;
   ll ans = 100,temp=0;
   while(ans<x)
   {
     ans = ans + ans*0.01 ;
     temp++;
   }
   cout << temp ;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}


Measured memory_bytes: 3612
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	string s;
	long long int k;
	cin >> s >> k;
	int n[s.length()];
	int ans = 1, c = 1;;
	REP(i, s.length()){
		n[i] = s[i] - '0';
		if(n[i] == 1 && c == k){
			break;
		}
		if(n[i] != 1){
			ans = n[i];
			break;
		}
		c++;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int h, w;
  cin >> h >> w;
  rep(i, 0, h) {
    string s;
    cin >> s;
    cout << s << endl;
    cout << s << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N, M, K;
  cin >> N >> M >> K;
  vector<ll> A(N + 1, 0), B(M + 1, 0);
  for (ll i = 1; i <= N; ++i) {
    cin >> A.at(i);
  }
  for (ll i = 1; i <= M; ++i) {
    cin >> B.at(i);
  }
  for (ll i = 0; i < N; ++i) {
    A.at(i + 1) += A.at(i);
  }
  for (ll i = 0; i < M; ++i) {
    B.at(i + 1) += B.at(i);
  }
  ll ans = 0;
  for (ll i = 0; i <= N; ++i) {
    ll left = K - A.at(i);
    if (left < 0) {
      break;
    }
    ll b = upper_bound(B.begin(), B.end(), left) - B.begin() - 1;
    ans = max(ans, b + i);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 6368
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //input
        Scanner sc = new Scanner(System.in);
        //int n = sc.nextInt();
        int m1 = sc.nextInt();
        int d1 = sc.nextInt();
        int m2 = sc.nextInt();
        int d2 = sc.nextInt();

        if (m2 != m1 && d1>d2)
        {
            System.out.println(1);
        }else
        {
            System.out.println(0);
        }

        sc.close();
    }

    public class Pair<F,S>
    {
        private final F first;
        private final S second;

        Pair(F first,S second)
        {
            this.first = first;
            this.second = second;
        }

        public void print() { System.out.println("("+this.first+","+this.second+")"); }

        //get
        public F first() {return this.first;}
        public S second() {return this.second;}

        @Override
        public boolean equals(Object object)
        {
            if (object instanceof Pair)
            {
                Pair pair = (Pair)object;
                return this.first==pair.first && this.second==pair.second;
            }else
            {
                return false;
            }
        }

        @Override
        public int hashCode()
        {
            return Objects.hash(first,second);
        }
    }
}

Measured memory_bytes: 22612
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n+1);
    for(int i = 0 ; i < n ; ++i){
        cin>>a[i+1];
        --a[i+1];
    }
    for(int i = 0 ; i < n ; ++i){
        a[i+1] += a[i];
        a[i+1] %= k;
    }
    map<int,int> mp;
    long long ans = 0;
    for(int i = 0 ; i < n+1 ; ++i){
        if(i>=k)--mp[a[i-k]];
        ans += mp[a[i]];
        ++mp[a[i]];
    }
    cout << ans << endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
struct TreeNode {
	int val;
	TreeNode *left, *right;
	TreeNode(int x) :val(x), left(NULL), right(NULL) {}
};
#define rep(i,n) for(int i=0;i<n;i++)
const int  mod = 1e9 + 7;
int main()
{
	//freopen("data_in.txt", "rb", stdin);
	int N, M;
	cin >> N >> M;
	vector<int> A(N), B(M);
	set<int> sa, sb;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		if (sa.count(A[i])) {
			cout << 0;
			return 0;
		}
		sa.insert(A[i]);
	}
	for (int i = 0; i < M; ++i) {
		cin >> B[i];
		if (sb.count(B[i])) {
			cout << 0;
			return 0;
		}
		sb.insert(B[i]);
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	long long res = 1;
	for (int i = N * M; i >= 1; --i) {
		if (!sa.count(i) || !sb.count(i)) {
			if (sa.count(i)) {
				res *= M - (lower_bound(B.begin(), B.end(), i) - B.begin());
			}
			else if (sb.count(i)) {
				res *= N - (lower_bound(A.begin(), A.end(), i) - A.begin());
			}
			else {
				res *= (long long)(M - (lower_bound(B.begin(), B.end(), i) - B.begin()))*
					(N - (lower_bound(A.begin(), A.end(), i) - A.begin())) - (N*M - i);
			}
		}
		res %= mod;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;
const ll INF = ll(1e18)+1;

int main(){
   int n, m;
   cin >> n >> m;
   vector<int> a(n);
   int sum = 0;
   for(int i = 0; i < n; i++){
      cin >> a[i];
      sum += a[i];
   }
   int cnt = 0;
   for(int i = 0; i < n; i++){
      if(a[i] >= (sum+4*m-1)/(4*m)) cnt++;
   }
   if(cnt >= m) cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m;
	while(cin >> n >> m, n){
		vi p(n, -1);
		vi deg(n);
		function<int(int)> root = [&](int x){
			if(p[x] < 0) return x;
			return p[x] = root(p[x]);
		};
		bool ans = 1;
		rep(i, m){
			int a, b; cin >> a >> b; a--; b--;
			deg[a]++;
			deg[b]++;
			a = root(a); b = root(b);
			if(a == b) ans = 0;
			else p[b] = a;
		}
		rep(i, n) if(deg[i] > 2) ans = 0;
		cout << (ans ? "yes" : "no") << endl;
	}
	return 0;
}


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

int main() {
  string N;
  cin >> N;

  char a = N[0],
       b = N[1],
       c = N[2],
       d = N[3];

  if ( b!=c ) {
  cout << "No" << endl;
  }
  else if ( ( a==b ) || ( c==d ) ) {
      cout << "Yes" << endl;
  }
    else {
      cout << "No" << endl;
    }
}

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

int solve (string & s) {
    string s1;
    for (char c : s) {
        if (c != 'x') s1.push_back(c);
    }
    string s2 = s1;
    reverse(s2.begin(), s2.end());
    if (s1 != s2) return -1;
    int n1 = s1.size();
    if (n1 == 0) return 0;
    int tmpj = n1 / 2;
    int tmpi = tmpj;
    if (n1 % 2 == 0) tmpi--;
    int j = 0, i = 0;
    while (tmpi) {
        if (s[i] != 'x') tmpi--;
        i++;
    }
    int n = s.size();
    while (i < n && s[i] == 'x') i++;
    while (tmpj) {
        if (s[j] != 'x') tmpj--;
        j++;
    }
    while (j < n && s[j] == 'x') j++;
    int cnt = 0;
    while (i >= 0 && j < n) {
        if (s[i] == s[j]) {
            i--;
            j++;
        }
        else {
            while (i >= 0 && s[i]=='x') {
                i--;
                cnt++;
            }
            while (j < n && s[j] =='x') {
                j++;
                cnt++;
            }
        }
    }
    while (j < n && s[j] =='x') {
        j++;
        cnt++;
    }
    while (i >= 0 && s[i]=='x') {
        i--;
        cnt++;
    }
    return cnt;
}

int main() {
//    freopen("test.txt", "r", stdin);
    string s;
    cin >> s;
    cout << solve(s) << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<bitset>
#include<vector>

using namespace std;

#define N 1001
#define MIN 1440
#define INV (-1)

typedef pair< int, pair<int,int> > lgtime;
typedef vector< lgtime > PC;

int main(){
	while(true){
		int n,m,r,q;
		vector< PC > PCs;
		
		PCs.resize(N);
		cin>>n>>m;
		if(n==0&&m==0)break;
		cin>>r;
		for(int i=0;i<r;++i){
			int t,n,m,s;

			cin>>t>>n>>m>>s;
			if(s==1){
				lgtime a;
				a.first=m;
				a.second.first=t;
				a.second.second=INV;
				PCs[n].push_back(a);
			}else if(s==0){
				PCs[n][PCs[n].size()-1].second.second=t;
			}
		}
		cin>>q;
		for(int i=0;i<q;++i){
			int ts,te,m;
			cin>>ts>>te>>m;
			bitset<MIN> b;
			bitset<MIN> filt;
			for(int j=ts;j<te;++j)
				filt.set(j);
			for(int k=0;k<PCs.size();++k){
				for(int l=0;l<PCs[k].size();++l){
					if( PCs[k][l].first==m ){
						for(int o=PCs[k][l].second.first; o<PCs[k][l].second.second;++o){
							b.set(o);
						}
					}
				}
			}
			b=b&filt;
			cout<<b.count()<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())


ress = []

for i in range(N):
    inputs = input().split()
    s = str(inputs[0])
    p = int(inputs[1])

    ress.append([s, -p, i + 1])
ans = sorted(ress, key=lambda x: (x[0], x[1]), reverse=False)
for i in ans:
    print(i[2])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = n - 1; i >= 0; --i)
#define INF 100000000
#define pb push_back
#define all(x) (x).begin(),(x).end()

typedef long long ll;

int main() {
	int N, Q; cin >> N >> Q;
	string S; cin >> S;
	int R[N+1];
	
	R[0] = 0;
	
	FOR(i, 1, N){
		if (S[i-1] == 'A' && S[i] == 'C'){
			R[i + 1] = R[i] + 1;
		} else {
			R[i + 1] = R[i];
		}
	}
	//0 1 2 3 4 5 6
	// A C A C A C
	// 0 1 2 3 4 5

	REP(i, Q){
		int l, r; cin >> l >> r;
		cout << R[r] - R[l] << endl;
	}

	return 0;
}

Measured memory_bytes: 1408
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

  static int N;
  static int K;
  static long Q;
  static int A;
  static int B;
  static long C;
  static double min = 9999999;
  static long ans = 0;





  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);


    System.out.println(getAns());





  }

  static public int getAns(){
    Scanner scanner = new Scanner(System.in);
    int H = scanner.nextInt();
    int W = scanner.nextInt();

    int h = scanner.nextInt();
    int w = scanner.nextInt();




    return (H - h) * (W - w);
  }

}


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

int main(){
  int n,t;
  int a[100006];
  ll minv = 100100100100;
  ll maxv = -100100100100;
  int i;

  scanf("%d %d", &n, &t);
  for(i = 0;i < n;i++) scanf("%d", &a[i]);

  int cnt = 0;
  minv = a[0];
  for(i = 1;i < n;i++){
    if(a[i] - minv >= maxv){
      if(a[i] - minv == maxv) cnt++;

      else {
        maxv = a[i] - minv;
        cnt = 1;
      }
    }

    if(minv > a[i]) minv = a[i];
  }

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

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    int a,b;
    cin >> a >> b;
    cout << (a-1)*(b-1) <<endl;
    return 0;
}


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

int main()
{
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double x;
    long double y = abs(((h * 60 + m) * 0.5) - m * 6);
    x = pow(a, 2) + pow(b, 2) - (2 * a * b) * cos(y * (M_PI / 180));
    x = sqrtl(x);
    cout << fixed << setprecision(20) << x << endl;
}

Measured memory_bytes: 4184
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair <long long,long long> ii;
// typedef complex<long double> point;

ll mod = 998244353;

ll power(ll x,ll y){
    ll ans = 1;
    while (y > 0){
        if (y & 1) ans *= x;
        ans %= mod;
        y /= 2;
        x = (x*x)%mod;
    }
    return ans%mod;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector <ll> arr(n);
    map <ll,ll> mapp;
    for (int z=0;z<n;z++){
        cin >> arr[z];
        mapp[arr[z]]++;
        if (arr[z] == 0 && z != 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll i = 1;
    auto it = mapp.begin();
    if (it->first != 0 && it->second != 1){
        cout << 0 << endl;
        return 0;
    }
    ll prev = 1;
    ll ans = 1;
    it++;
    for (;it != mapp.end();it++){
        if (it->first != i){
            cout << 0 << endl;
            return 0;
        }
        ans *= power(prev,it->second);
        prev = it->second;
        ans %= mod;
        i++;
    }
    cout << ans << endl;
}

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

using namespace std;

namespace Solver {

    int N;
    vector<int> m1, m2;
    inline bool Read() {
        cin >> N;
        return N != 0;
    }

    inline void PreWork() {
        m1.resize(1000000, 1000000);
        m2.resize(1000000, 1000000);
        m1[0] = m2[0] = 0;
        for (int i = 1; i < 1000000; i++) {
            for (int j = 0;; j++) {
                int vol = vol = ((j * (j + 1) * (j + 2)) / 6);
                if (i < vol) break;
                m1[i] = min(m1[i], m1[i - vol] + 1);
                if (vol % 2 == 1) {
                    m2[i] = min(m2[i], m2[i - vol] + 1);
                }
            }
        }
    }

    inline void Work() {
        cout << m1[N] << " " << m2[N] << endl;
    }

    inline void Solve() {
        PreWork();
        while (Read()) Work();
    }
}

int main() {
    Solver::Solve();
}

Measured memory_bytes: 8784
#include<bits/stdc++.h>
#define L long long
using namespace std;
const int q=1000000007;
int n,m,a[4000010],b[4000010],f[2010][2010];
inline L C(int n,int m)
{
	return (L)a[n]*b[m]%q*b[n-m]%q;
}
int main()
{
	//freopen(".in","r",stdin);
	//fre,jopen(".out","w",stdout);
	int i,j;
	scanf("%d%d",&n,&m);
	if(m==1)
	  {
	   printf("1\n");
	   return 0;
	  }
	b[0]=b[1]=1;
	for(i=2;i<=n*m;i++)
	  b[i]=q-(L)q/i*b[q%i]%q;
	a[0]=1;
	for(i=1;i<=n*m;i++)
	  {
	   a[i]=(L)a[i-1]*i%q;
	   b[i]=(L)b[i-1]*b[i]%q;
	  }
	f[0][0]=1;
	for(i=0;i<=n;i++)
	  for(j=0;j<=i;j++)
	    {
		 if(i<n)
		   f[i+1][j]=(f[i+1][j]+f[i][j])%q;
		 if(j<i)
		   f[i][j+1]=(f[i][j+1]+f[i][j]*C(n*m-i-j*(m-1)-1,m-2))%q;
		}
	printf("%d\n",int((L)f[n][n]*a[n]%q));
	return 0;
}


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

int main(){
    int M, N;
    cin >> N >> M;
    char A[N][N], B[M][M], C[M][M];

    //scanf("%c",&A[0][0]);
    for(int i=0; i<N; i++){
        char s[50];
        cin >> s;
        for(int j=0; j<N; j++){
            A[i][j]=s[j];
        }
    }
    for(int i=0; i<M; i++){
        char s[50];
        cin >> s;
        for(int j=0; j<M; j++){
            B[i][j]=s[j];            
        }
    }

    bool flag;
    flag=false;

    for(int is=0; is<=N-M; is++){
        for(int js=0; js<=N-M; js++){
            //cout << is << " " << " " << js << endl;
            flag=false;
            for(int i=0; i<M; i++){
                for(int j=0; j<M; j++){
                    //cout << "before" << " " << is+i << " " << js+j << " " << i << " " << j << endl;
                    if( A[is+i][js+j]==B[i][j] ){
                        //cout  << "if" << is+i << " " << js+j << " " << i << " " << j << endl;
                        flag=true;
                    }else{
                        flag=false;
                        break;
                    }
                }
                if(!flag) break;
            }
            if(flag){
                cout << "Yes" << endl;
                return 0;
            }
        }
    } 

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);i++)
#define FORE(x,arr) for(auto &x:arr)
#define FOR(i,a,n) for(int i=a;i<(int)(n);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;

ll fact[200001];
ll fact_inv[200001];
ll bin_pow(ll a,ll b,ll mod) {
    if(a==0) return 1;
    a%=mod;
    ll product=1;
    while(b>0) {
        if(b&1) {
            product *= a;
            product %= mod;
        }
        a *= a;
        a %= mod;
        b >>= 1;
    }
    return product%mod;
}
void init_fact(ll max,ll mod) {
    fact[0]=1, fact_inv[0]=1;
    FOR(i,1,max) {
        fact[i]=(fact[i-1]*i)%mod;
        fact_inv[i]=bin_pow(fact[i],mod-2,mod);
    }
}
inline ll nCr_mod(ll n,ll r,ll mod) {
    ll ret = fact[n] * fact_inv[r] % mod*fact_inv[n-r] % mod;
    return ret;
}

int main(int argc, char const *argv[]) {
    const int MOD=1e9+7;
    ll H,W,A,B;
    cin>>H>>W>>A>>B;
    init_fact(H+W,MOD);

    ll ans = 0;
    FOR(x,B,W) {
        // a = (x+H-A-1)C(x)
        // b = (A-1+W-x-1)C(A-1)
        ans += (nCr_mod(x+H-A-1,x,MOD)*nCr_mod(A+W-x-2,A-1,MOD))%MOD;
        ans %= MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using ll = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
     
int main() {
    ll H;
    cin >> H;
    ll i = 0LL, s = 0LL;
    while ( H > 0LL ) {
        s += pow(2LL, i++);
        H = H / 2LL;
    }
    cout << s << endl;
    return 0;
}

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

int main(){
    int x, y;
    
    while(scanf("%d %d", &x, &y), x > 0 || y > 0){
        printf("%d %d\n", min(x, y), max(x, y));
    }
    
    return 0;
}


Measured memory_bytes: 2564
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Segtree<T>
{
    int n;
    T[] tree;
    Func<T, T, T> f;
    T exnum;
    public Segtree(int m, Func<T, T, T> f, T ex)
    {
        this.f = f;
        this.exnum = ex;
        n = 1;
        while (n < m) n <<= 1;

        tree = new T[(n << 1) - 1];
        for (int i = 0; i < tree.Length; i++) tree[i] = ex;
    }
    public Segtree(int m, T ini, Func<T, T, T> f, T ex)
    {
        this.f = f;
        this.exnum = ex;
        n = 1;
        while (n < m) n <<= 1;

        tree = new T[(n << 1) - 1];
        for (int i = 0; i < tree.Length; i++) tree[i] = ini;
        for (int i = 0; i < m; ++i) update(i, ini);
    }
    public void update(int j, T x)
    {
        int i = j + n - 1;
        tree[i] = x;
        while (i > 0)
        {
            i = (i - 1) >> 1;
            tree[i] = f(tree[(i << 1) + 1], tree[(i << 1) + 2]);
        }
    }
    public T look(int i) { return tree[i + n - 1]; }

    // [s, t]
    public T run(int s, int t) { return query(s, t + 1, 0, 0, n); }
    T query(int s, int t, int k, int l, int r)
    {
        if (r <= s || t <= l) return exnum;
        if (s <= l && r <= t) return tree[k];

        return f(query(s, t, (k << 1) + 1, l, (l + r) >> 1), query(s, t, (k + 1) << 1, (l + r) >> 1, r));
    }
}

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int result = 0;

            int[] arr = new int[n];
            string[] input_arr = Console.ReadLine().Split(' ');

            for(int i = 0; i<n; i++)
            {
                arr[i] = int.Parse(input_arr[i]);
            }

            for(int i = 0; i<n; i++)
            {
                if (i == arr[arr[i] - 1] - 1) result++;
            }

            Console.WriteLine(result / 2);
        }
    }
}

Measured memory_bytes: 9688
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
     arr[0]=2;
    arr[1]=1;
    for(int i=2;i<=86;i++)
        arr[i]=arr[i-1]+arr[i-2];
    int n;
    cin>>n;
    cout<<arr[n]<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)

int n, m, x;
int c[15], a[15][15];
int min, nowa[15];

void dfs(int i, int summ){
	//printf("i:%d, summ:%d, min:%d\n", i, summ, min);
	if(i==n){
		int chk=1;
		for(int j=0; j<m; j++){
			if(nowa[j]<x) chk=-1;
		}
		if((chk>0) && (min>summ)){
			min = summ;
		}
	}
	else{
		dfs(i+1, summ);
		for(int j=0; j<m; j++){
			nowa[j] += a[i][j];
		}
		dfs(i+1, summ+c[i]);
		for(int j=0; j<m; j++){
			nowa[j] -= a[i][j];
		}
	}
	
}

int main(){
	scanf("%d%d%d", &n, &m, &x);
	for(int i=0; i<n; i++){
		scanf("%d", &c[i]);
		for(int j=0; j<m; j++){
			scanf("%d", &a[i][j]);
		}
	}

	min = 10000000;
	for(int i=0; i<n; i++){
		nowa[i] = 0;
	}
	dfs(0, 0);
	if(min == 10000000) printf("-1\n");
	else printf("%d\n", min);
	
	return 0;
}

Measured memory_bytes: 1728
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min =  1000000;
        int max = -1000000;
        long sum =  0;
        for(int i=0; i<n; i++){
            int a = sc.nextInt();
            if(min > a) min = a;
            if(max < a) max = a;
            sum += a;
        }
        
        System.out.printf("%d %d %d\n", min, max, sum);
    }
}



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

int main()
{
	string a;
	cin >> a;

	int hai = 700;

	for (int i = 0; i < a.size(); ++i) {
		if (a[i] == 'o') {
			hai += 100;
		}
	}

	cout << hai;



	return 0;
}

Measured memory_bytes: 888
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int n = sc.nextInt();
    int[] arrA = new int[n];
    int[] arrB = new int[n];
    for (int i = 0; i < n; i++) {
      arrA[i] = sc.nextInt();
      arrB[i] = sc.nextInt();
    }
    sc.close();

    HashMap<String, Integer> result = new HashMap<>();
    for (int i = 0; i < n; i++) {
      int a = arrA[i];
      int b = arrB[i];
      putBlack(result, a, b, h, w);
    }
    long[] count = new long[10];
    Arrays.fill(count, 0);
    count[0] = (long) (h - 2) * (long) (w - 2);
    for (int val : result.values()) {
      count[val] += 1;
      count[0] -= 1;
    }
    for (int i = 0; i <= 9; i++) {
      System.out.println(count[i]);
    }
  }

  private static void putBlack(HashMap<String, Integer> result, int a, int b, int h, int w) {
    for (int x = a - 2; x <= a; x++) {
      if (x < 1 || x > h - 2) {
        continue;
      }
      for (int y = b - 2; y <= b; y++) {
        if (y < 1 || y > w - 2) {
          continue;
        }
        String point = x + " " + y;
        if (!result.containsKey(point)) {
          result.put(point, Integer.valueOf(1));
        } else {
          int count = result.get(point);
          result.put(point, count + 1);
        }
      }
    }
  }
}


Measured memory_bytes: 189664
#include<stdio.h>
int n, m, s[200][10], t [1000] [100],i,x,y,i2,i3;
int main()
{
	
	for (; scanf("%d", &m), m;){
		for (i = 0; i < m; i++)
			scanf("%d %d", &s[i][0],&s[i][1]);
		
		scanf("%d", &n);
		for (i = 0; i < n; i++)
			scanf("%d %d", &t[i][0], &t[i][1]);
		
		for (i = 0; i < n; i++){
			x = t[i][0] - s[0][0], y = t[i][1] - s[0][1];
			for (i2 = 1; i2 < m; i2++){
				for (i3 = 0; i3 < n; i3++)
					if (s[i2][0] + x == t[i3][0] && s[i2][1] + y == t[i3][1])
						break;
					if (i3 == n)
						break;

				}
				if (i2 == m){
					printf("%d %d\n", x, y);
					break;
				}
			}
		}

	
	return 0;
}

Measured memory_bytes: 996
while True:
    try:
        n,x = map(int,raw_input().split())
        if n == x == 0:
            break
    except EOFError:
        break
    
    total = 0
    for k in range(1,n+1):
        for j in range(1,n+1):
            for l in range(1,n+1):
                if k!=j!=l and k + j + l == x and k<j<l:
                    total +=1
    print total                

Measured memory_bytes: 4216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC172A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine(a + a * a + a * a * a);
        }
    }
}


Measured memory_bytes: 27528
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
//stack<int> st;
// cout << << endl;
// cin >> ;
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    
 
int main(){
    ll x=-10,y=-10,d=0,n,m,h,w,k,max=-100000,min=10000000,ans=0,count=1,sum=0;
    string s;
    cin >> n >> k;
    VI a(n);
    rep(i,n){
        cin >> a[i];
	}
    sort(ALL(a));
    int i=0;
    while(a[n-1] != 1){
        m = k;
        while(m > 0 && n>i){
            a[i] = 1;
            i++;
            m--; 
        }
        ans++;
        i--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


Measured memory_bytes: 11840
count = 0
n = int(input())
p = [int(i) for i in input().split()]
for i in range(1,n-1):
    lower = min(p[i-1],p[i+1])
    upper = max(p[i-1],p[i+1])
    if lower < p[i] and p[i] < upper:
        count += 1

print(count)


Measured memory_bytes: 3060
import java.io.File

import java.io.FileInputStream


fun main(args: Array<String>) {


    val T = readLine()!!.toString()



    for (i in 0.until(T.length)) {
        if (T[i] == '?') {
            print('D')
            continue
        }
        print(T[i])
    }


}


Measured memory_bytes: 57668