akhauriyash/Code-Regression huggingface dataset:
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var M = one[1];
  var s = next();
  var output = [];
  var now = N;
  while(true){
  	myerr(now);
  	var isOK = false;
  	var nextMove = 0;
  	var count = 0;
  	for(var i = now - 1; i > (now - M - 1) && i >= 0; i--){
  		count++;
  		if(s[i] == "0"){
  			isOK = true;
  			nextMove = count;
  		}
  	}
  	now -= nextMove;
  	if(!isOK){
  		myout(-1);
  		return;
  	}else{
  		output.push(nextMove);
  	}
  	if(now == 0){
  		break;
  	}
  }
  output.sort(function(){return -1});
  myout(myconv(output, 8));
}

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

using namespace std;

int main()
{
  int64_t N, M, P;
  cin >> N >> M >> P;
  
  vector<multimap<int64_t, int64_t>> edges(N);
  for (int64_t m = 0; m < M; ++m) {
    int64_t A, B, C;
    cin >> A >> B >> C;
    
    edges[A - 1].emplace(B - 1, P - C);
  }
  
  vector<bool> negative_loop(N, false);
  vector<int64_t> dist(N, 1e+9);
  dist[0] = 0;
  for (int64_t i = 0; i < 2 * N; ++i) {
    for (int64_t src = 0; src < N; ++src) {
      if (dist[src] >= 1e+9) { continue; }
      
      for (const pair<int64_t, int64_t> &p : edges[src]) {
        int64_t dst = p.first, cost = p.second;
        
        if (dist[dst] > dist[src] + cost) {
          dist[dst] = dist[src] + cost;
          
          if (i >= N - 1) {
            negative_loop[dst] = true;
          }
        }
        
        if (i >= N - 1 && negative_loop[src]) {
          negative_loop[dst] = true;
        }
      }
    }
  }
  
  if (negative_loop[N - 1]) {
    cout << -1 << endl;
  } else {
    cout << max(static_cast<int64_t>(0), -dist[N - 1]) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 640
function Main(s) {
	s = s.split(" ").map(a => parseInt(a));
	var a, b, c, d;
	if(s[0] > s[1]){
		a = s[0];
		b = s[1];
		c = ".";
		d = "#";
	}else{
		b = s[0];
		a = s[1];
		d = ".";
		c = "#";
	}
	const h = Math.ceil(Math.sqrt(a)) * 4;
	const a1 = [c, c, c, d];
	const ab = [c, d, c, d];
	const a0 = [d, d, d, d];
	var ans = [];
	var aa = 1, bb = 1;
	for(var i = 0; i < h; i += 4){
		ans[i] = [];
		ans[i+1] = [];
		ans[i+2] = [];
		ans[i+3] = [];
		for(var j = 0; j < h; j += 4){
			if(i === 0 && j === 0){
				ans[i].push(...a1);
				ans[i+1].push(...a1);
				ans[i+2].push(...a1);
				ans[i+3].push(...a0);
			}else if(aa === a){
				ans[i].push(...a0);
				ans[i+1].push(...a0);
				ans[i+2].push(...a0);
				ans[i+3].push(...a0);
			}else if(bb === b){
				ans[i].push(...a1);
				ans[i+1].push(...a1);
				ans[i+2].push(...a1);
				ans[i+3].push(...a0);
				aa++;
			}else{
				ans[i].push(...a1);
				ans[i+1].push(...ab);
				ans[i+2].push(...a1);
				ans[i+3].push(...a0);
				aa++;
				bb++;
			}
		}
	}
	for(i = 0; i < h; i++){
		ans[i] = ans[i].join("");
	}
	console.log("%d %d\n%s", h, h, ans.join("\n"));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 8880
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int D, T, S; cin >> D >> T >> S;
    if ((D + S - 1) / S > T) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

typedef vector<int> vec;
typedef vector<vec> mat;

void solve(mat &M, int H, int W) {
	int NOW = 0;
	for (int i = 0; i < W; i++) {
		bool check = false;
		for (int j = NOW; j < H; j++) {
			if (M[j][i] != 0) {
				swap(M[j], M[NOW]);
				check = true;
				break;
			}
		}
		if (!check) continue;
		for (int j = 0; j < H; j++) {
			if (j != NOW && M[j][i] != 0) {
				for (int k = 0; k < W; k++) {
					M[j][k] = M[j][k] ^ M[NOW][k];
				}
			}
		}
		NOW++;
	}
}

int main() {
	long long N, XOR = 0, ANS = 0;
	static long long A[100000], V[60] = {};
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i], XOR = XOR ^ A[i];
	mat M(N, vec(60));
	ANS = XOR;
	for (int i = 1; i <= 60; i++) {
		V[60 - i] = XOR % 2;
		XOR /= 2;
	}
	for (int i = 0; i < N; i++) {
		long long X = A[i];
		for (int j = 1; j <= 60; j++) {
			if (V[60 - j] == 0) M[i][60 - j] = X % 2;
			else M[i][60 - j] = 0;
			X /= 2;
		}
	}
	solve(M, N, 60);
	long long Cur = 2;
	for (int i = 59; i >= 0; i--) {
		long long COUNT = 0;
		for (int j = 0; j < N; j++) {
			COUNT += M[j][i];
		}
		ANS += Cur * (COUNT % 2);
		Cur *= 2;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 28416
let rec f x=function|(0,0)->1|(n,_)when n<=0->0|(n,m)->(let rec(^)i a=if i>m||i>9then a else(i+1)^(a+f(i+1)(n-1,m-i))in x^0)and q()=Scanf.scanf"%d %d
"(fun n s->if n<>0||s<>0then q(Printf.printf"%d
"(f 0(n,s))));;try q()with _->()

Measured memory_bytes: 2672
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a[] = new int[m];
        int b[] = new int[m];

        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
        }

        long[] ans = new long[m];   // 答え
        // 一番最後は最悪の場合
        ans[m - 1] = (long) n * (n - 1) / 2;

        UnionFind uni = new UnionFind(n);
        // 全て破壊された場合から残ってる数を引くことでポイントを計算
        for (int i = m - 1; i >= 1; i--) {
            if (uni.root(a[i]) != uni.root(b[i])) {
                ans[i - 1] = (long) ans[i] - uni.size(a[i]) * uni.size(b[i]);
                uni.unite(a[i], b[i]);
            } else {
                ans[i - 1] = ans[i];
            }
        }

        // 出力
        for (long i : ans){
            System.out.println(i);
        }
    }

    static class UnionFind {
        // Parents[i]:iの親の番号 or 根だった場合、ついているノードの数N(-N)
        static List<Integer> Parents = new ArrayList<>();

        // 最初はすべてが根であるとして初期化
        public UnionFind(int N) {
            for (int i = 0; i < N; i++) {
                Parents.add(-1);
            }
        }

        // データが属する木の根を再帰で得る
        public int root(int x) {
            if (Parents.get(x) < 0)
                return x;
            Parents.set(x, root(Parents.get(x)));
            return Parents.get(x);
        }

        // xとyの木を併合
        public void unite(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            if (rx == ry)
                return;

            // yの方が大きい場合は入れ替える
            if (size(rx) < size(ry)) {
                int tmp = rx;
                rx = ry;
                ry = tmp;
            }

            Parents.set(rx, Parents.get(rx) + Parents.get(ry));
            Parents.set(ry, rx);
        }

        // 2つのデータx, yが属する木が同じならtrueを返す
        public boolean same(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            return rx == ry;
        }

        // 頂点の数を返す
        public int size(int x) {
            if (x >= 0)
                x = root(x);
            return Parents.get(x);
        }
    }
}


Measured memory_bytes: 108168
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())

using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define INF 10101010

int main()
{
    string T;
    cin >> T;
    bool d;
    ll count=0;
    rep(i,T.size()){
        if(T[i]=='D'){
            count++;
            if(d){
                count++;
            }
            d=false;
        }else if(T[i]=='P'){
            d=true;
        }else if(T[i]=='?'){
            if(d){
                T[i]='D';
                count+=2;
                d=false;
            }else if(i<T.size()-1){
                if(T[i+1]=='D'||T[i+1]=='?'){
                    d=true;T[i]='P';
                }else{
                    T[i]='D';
                    count++;d=false;
                }
            }else{
                if(d){
                    T[i]='D';
                    count+=2;
                }else{
                    T[i]='D';
                }
            }
        }
    }
    cout << T << endl;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
static const int MAX=100;
static const long long INF=(1LL<<32);
int main()
{
  int e,u,v,c;
  int n;
  long long d[MAX][MAX];
  scanf("%d %d",&n,&e);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      d[i][j]=((i==j)?0:INF);
    }
  }
  for(int i=0;i<e;i++){
    scanf("%d %d %d",&u,&v,&c);
    d[u][v]=c;
  }
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      if(d[i][k]==INF) continue;
      for(int j=0;j<n;j++){
	if(d[k][j]==INF) continue;
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  int judge=0;
  for(int i=0;i<n;i++) if(d[i][i]<0) judge=1;
  if(judge) printf("NEGATIVE CYCLE\n");
  else{
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(j) printf(" ");
	if(d[i][j]==INF) printf("INF");
	else printf("%d",d[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}
	



Measured memory_bytes: 3308
#include <iostream>
#include <algorithm>

void fastin(int &num) {
    bool neg = false;
    int c;
    num = 0;
    c = getchar_unlocked();
    if (c == '-') {
        neg = true;
        c = getchar_unlocked();
    }
    for (; (c > 47 && c < 58); c = getchar_unlocked()) num = num * 10 + c - 48;
    if (neg) num *= -1;
}

void fastout(int n) {
    int N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { ++count; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar_unlocked('0');
}

int main(){
    int n, c, k; fastin(n); fastin(c); fastin(k);
    int t[n];
    for (int i = 0; i < n; ++i) fastin(t[i]);

    std::sort(t, t + n);

    int ans = 0;
    int beg = 0;
    while (beg < n){
        int end = beg;
        while (end - beg + 1 < c && t[end + 1] - t[beg] <= k){
            ++end;
            if (end == n - 1) break;
        }
        ++ans; beg = end + 1;
        if (beg == n - 1){
            ++ans; break;
        }
    }
    fastout(ans);
    
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<map>
#include<cstring>
using namespace std;
map<string,int>f;
const int p=998244353;
inline int Jia(int x){return x>=p?x-p:x;}
void merge(string &s1,string s2,int len){
	for(int i=0;i<len;++i)if(s2[i]=='0')s1[i]='0';
}
int dp(string s){
	if(s.empty())return 1;
	if(f.count(s))return f[s];
	int ans=(s[0]=='1'?2LL:1LL)*dp(s.substr(1,s.length()))%p;
	for(int i=1;2*i<=s.length();++i){
		string tmp=s.substr(0,i);
		for(int j=2;j*i<=s.length();++j){
			merge(tmp,s.substr(i*(j-1),i*j),i);
			ans=Jia(ans+1LL*dp(tmp)*dp(s.substr(i*j,s.length()))%p);
		}
	}
	f[s]=ans;
	return ans;
}
int main(){
	string s;
	cin>>s;
	cout<<dp(s)<<'\n';
	return 0;
}

Measured memory_bytes: 8024
N,M = map(int,input().split())
ps = list(map(lambda x:int(x)-1,input().split()))
xys = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1

uf = UnionFind(N)
for x,y in xys:
    if uf.is_same(x,y): continue
    uf.unite(x,y)

ans = 0
for i,p in enumerate(ps):
    if i==p or uf.is_same(i,p):
        ans += 1
print(ans)


Measured memory_bytes: 25184
n = int(input())
casies = [str(input()) for i in range(n)]
import collections
d = collections.Counter(casies)
print("AC x "+str(d["AC"]))
print("WA x "+str(d["WA"]))
print("TLE x "+str(d["TLE"]))
print("RE x "+str(d["RE"]))

Measured memory_bytes: 16532
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int N = in.nextInt();
			int[] an = in.nextIntArray(N);
			int[] bn = in.nextIntArray(N);

			int ans = 0;
			for (int k = 0; k < 32; k++) {
				int count = 0;
				int[] sa = new int[N];
				int[] sb = new int[N];
				int mask = (1 << (k + 1)) - 1;
				for (int i = 0; i < N; i++) {
					sa[i] = an[i] & mask;
					sb[i] = bn[i] & mask;
				}
				Arrays.sort(sb);

				int T = 1 << k;
				for (int i = 0; i < N; i++) {
					int f1 = lowerBound(sb, 1 * T - sa[i]);
					int t1 = lowerBound(sb, 2 * T - sa[i]);
					int f2 = lowerBound(sb, 3 * T - sa[i]);
					int t2 = lowerBound(sb, 4 * T - sa[i]);
					count += t1 - f1;
					count %= 2;
					count += t2 - f2;
					count %= 2;
				}

				if (count == 1) {
					ans |= 1 << k;
				}

			}

			out.println(ans);

		}
	}

	public static int lowerBound(int[] a, int obj) {
		int l = 0,r = a.length - 1;
		while (r - l >= 0) {
			int c = (l + r) / 2;
			if (obj <= a[c]) {
				r = c - 1;
			} else {
				l = c + 1;
			}
		}
		return l;
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 74652
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iomanip>
#define ll long long
using namespace std;
ll num,q,h,s,d,n,ans;
int main()
{
	scanf("%lld%lld%lld%lld",&q,&h,&s,&d);
	s=min(s,4*q);
	s=min(s,2*h);
	scanf("%lld",&n);
	if(s*2<=d) ans=n*s;
	if(s*2>d) ans=n/2*d+(n%2)*s;
	cout<<ans;
	return 0;
}


 

Measured memory_bytes: 384
import std.stdio;
import core.stdc.stdio;
import std.algorithm;

struct cube{
	int x1;
	int x2;
	int y1;
	int y2;
	int z1;
	int z2;
}

int find(int[] d,int t){
	for(int i=0;i<d.length;i++)
		if(d[i] == t)
			return i;
	return -1;
}

void main(){
	int n,k;
	int[] xs,ys,zs;
	cube[] cs;
	scanf("%d%d",&n,&k);
	xs = new int[n*2];
	ys = new int[n*2];
	zs = new int[n*2];
	cs = new cube[n];
	for(int i=0;i<n;i++){
		scanf("%d%d%d%d%d%d",&cs[i].x1,&cs[i].y1,&cs[i].z1,&cs[i].x2,&cs[i].y2,&cs[i].z2);
		xs[i*2] = cs[i].x1;
		xs[i*2+1] = cs[i].x2;
		ys[i*2] = cs[i].y1;
		ys[i*2+1] = cs[i].y2;
		zs[i*2] = cs[i].z1;
		zs[i*2+1] = cs[i].z2;
	}
	sort(xs);
	sort(ys);
	sort(zs);
	//xs.writeln;
	//ys.writeln;
	//zs.writeln;
	int[] count =  new int[n*n*n*8];
	for(int i=0;i<n;i++){
		int xl = xs.find(cs[i].x1);
		int xr = xs.find(cs[i].x2);
		int yl = ys.find(cs[i].y1);
		int yr = ys.find(cs[i].y2);
		int zl = zs.find(cs[i].z1);
		int zr = zs.find(cs[i].z2);
		for(int x=xl;x<xr;x++){
			for(int y=yl;y<yr;y++){
				for(int z=zl;z<zr;z++){
					count[(x*n*2+y)*n*2+z]++;
				}
			}
		}
	}
	long ans=0;
	for(int x=0;x<n*2-1;x++){
		long xd = xs[x+1]-xs[x];
		for(int y=0;y<n*2-1;y++){
			long yd = ys[y+1]-ys[y];
			for(int z=0;z<n*2-1;z++){
				long zd = zs[z+1]-zs[z];
				if(count[(x*n*2+y)*n*2+z]>=k){
				//	writeln(x," ",y," ",z," ",xd," ",yd," ",zd);
					ans += xd*yd*zd;
				}
			}
		}
	}
	printf("%lld\n",ans);
}

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

int main() {
  vector<int> a(4);
  for (int i = 0; i < 4; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long

using namespace std;

map<int, int> memory;

// int f(string s, int x) {
//   int ret = 0;
//   for (int i = 0; i < x - 1; ++i) {
//     if (s[i] == 'A' && s[i + 1] == 'C') ++ret;
//   }
//   return ret;
// }

int f(string s, int x) {

  if (x < 1) return 0;

  if (memory.count(x)) {
    return memory.at(x);
  } else {
    int key = x;
    int value = f(s, x - 1);
    if (s[x - 1] == 'C' && s[x - 2] == 'A') {
      value += 1;
    }
    memory.insert(make_pair(key, value));
    return value;
  }
}

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

  int num = 0;
  int n; cin >> n;
  int q; cin >> q;
  string s; cin >> s;

  vector<int> l(q);
  vector<int> r(q);
  for (int i = 0; i < q; ++i) cin >> l[i] >> r[i];

  vector<int> a(q);
  for (int i = 0; i < q; ++i) {
    string t = s.substr(l[i] - 1, r[i] - l[i] + 1);
    // a[i] = f(t); 
    a[i] = f(s, r[i]) - f(s, l[i]);
  }

  for (int i = 0; i < q; ++i) cout << a[i] << endl;


  return 0;
}


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

using namespace std;
const int MAXN=30;
const long long int MOD=1e9+7;
const long long int MAXK=2500000;

vector<int> combinazioni[MAXN];
long long int dp[MAXN][MAXK];
int N;

long long int solve(int index, bitset<MAXN> b){
	int disponibili = b.to_ulong();
	if(index==N)
		dp[index][disponibili]=1;
	if(dp[index][disponibili]!=-1)
		return dp[index][disponibili];	
	dp[index][disponibili]=0;
	for(auto elem : combinazioni[index])
		if(!b[elem]){
			b[elem]=true;
			dp[index][disponibili]=(dp[index][disponibili]+solve(index+1,b))%MOD;
			b[elem]=false;
		}
	return dp[index][disponibili];
}

int main(){
	cin>>N;
	int valore;
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++){
			cin>>valore;
			if(valore)
				combinazioni[i].push_back(j);
		}
	int numColumns=0;
	for(int i=0;i<N;i++)
		numColumns=(numColumns*2)+1;
	for(int i=0;i<=N;i++)
		for(int j=0;j<=numColumns;j++)
			dp[i][j]=-1;
	bitset<MAXN> b;
	b.reset();
	cout<<solve(0,b);
}

Measured memory_bytes: 405760
K = gets.to_i
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
puts array[K-1]

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int main()
{
    int n, m;
    cin >> n >> m;
    
    if(n == m)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,v,p,a[100010],lbound,ubound,ans;
bool check(long long mid){
	long long x=m+mid,num=0;
	if (a[p-1]>x) return 0;
	for (long long i=0;i<n;i++){
		if (a[i]<x||p-1==i){
			for (;i<p-1;i++) num+=m;
			for (;i<n;i++) num+=min(m,max((long long)0,x-a[i]));
			break;
		}
		num+=m;
	}
	return (num>=m*v);
}
int main(){
	cin>>n>>m>>v>>p;
	for (int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);reverse(a,a+n);
	lbound=a[n-1];ubound=a[p];
	while (lbound<ubound){
		long long mid=(lbound+ubound)/2;
		if (check(mid)==1)
			ubound=mid;
		else
			lbound=mid+1;
	}
	for (int i=lbound+100;i>=lbound-100;i--)
		if (check(i)==0){
			lbound=i+1;
			break;
		}
	for (int i=0;i<n;i++) if (a[i]>=lbound) ans++;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

signed main()
{
    double ans = 0;
    ll n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        ll j = i;
        double v = 1 / (double)n;
        while (j < k)
        {
            j = j * 2;
            v = v / 2;
        }
        ans += v;
    }
    printf("%.10f", ans);
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	char c;
	int h,w,a[53][53]={0};
	cin>>h>>w;
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)
	{
		cin>>c;
		a[i][j]=c=='#';
	}
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)
	{
		if(a[i][j]==1&&a[i+1][j]+a[i-1][j]+a[i][j+1]+a[i][j-1]==0)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

#define int long long

#define sqr(x) ((x) * (x))

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(0);
    int n, c;
    cin >> n >> c;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    vector<int> d(n);
    d[0] = 0;
    vector<pair<int, int>> a;
    a.push_back({0, 0});
    for (int i = 1; i < n; i++) {
        int ind = upper_bound(a.begin(), a.end(), make_pair(x[i], (int)(2e18))) - a.begin() - 1;
        int j = a[ind].second;
        d[i] = d[j] + sqr(x[i] - x[j]) + c;
        while (a.size()) {
            j = a.back().second;
            int cur_x = a.back().first;
            if (
                    d[i] + sqr(x[i] - cur_x) + c >
                    d[j] + sqr(x[j] - cur_x) + c
                )
            {
                break;
            }
            a.pop_back();
        }
        if (a.size() == 0) {
            a.push_back({0, i});
        } else {
            j = a.back().second;
            int inter = (d[i] + sqr(x[i]) - d[j] - sqr(x[j]) + 2 * x[i] - 2 * x[j] - 1)
                                                                / (2 * x[i] - 2 * x[j]);
            a.push_back({inter, i});
        }
    }
    cout << d.back() << endl;
}


Measured memory_bytes: 10572
using System;
using System.Linq;

class A
{
	static double[] Read() => Console.ReadLine().Split().Select(double.Parse).ToArray();
	static void Main()
	{
		var h = Read();

		// Vector2 は float のため、精度が足りません。
		var p1 = new V(h[0], h[1]);
		var p2 = new V(h[2], h[3]);
		var p0 = p2 - p1;
		var e = p0 / p0.Norm;

		var q = int.Parse(Console.ReadLine());
		var r = new int[q].Select(_ => Read())
			.Select(x => new V(x[0], x[1]) - p1)
			.Select(p => p1 + V.Dot(p, e) * e);
		Console.WriteLine(string.Join("\n", r));
	}
}

struct V : IEquatable<V>
{
	public double X, Y;
	public V(double x, double y) { X = x; Y = y; }
	public override string ToString() => $"{X:F9} {Y:F9}";

	public double Norm => Math.Sqrt(X * X + Y * Y);
	public double Angle => Math.Atan2(Y, X);

	public bool Equals(V other) => X == other.X && Y == other.Y;
	public static bool operator ==(V v1, V v2) => v1.Equals(v2);
	public static bool operator !=(V v1, V v2) => !v1.Equals(v2);
	public override bool Equals(object obj) => obj is V && Equals((V)obj);
	public override int GetHashCode() => X.GetHashCode() ^ Y.GetHashCode();

	public static V operator -(V v) => new V(-v.X, -v.Y);
	public static V operator +(V v1, V v2) => new V(v1.X + v2.X, v1.Y + v2.Y);
	public static V operator -(V v1, V v2) => new V(v1.X - v2.X, v1.Y - v2.Y);
	public static V operator *(double c, V v) => v * c;
	public static V operator *(V v, double c) => new V(v.X * c, v.Y * c);
	public static V operator /(V v, double c) => new V(v.X / c, v.Y / c);

	public static double Dot(V v1, V v2) => v1.X * v2.X + v1.Y * v2.Y;
	public static double Area(V v1, V v2) => Math.Abs(v1.X * v2.Y - v2.X * v1.Y) / 2;
}



Measured memory_bytes: 20580
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()


 ll mod_pow(ll x,ll n,ll mod) {
ll res=1;
  while(n>0) {
if(n&1) {
res=res*x%mod;
}
  x=x*x%mod;
    n>>=1;
  }
  return res;
}


int main() {
  ll mod=1000000007;
 ll S;
  cin>>S;
  if(S<3) {
cout<<0<<endl;
    return 0;
  }
  ll ans=1;
  
  ll km=S/3;
  vector<ll> f(km);
  for(ll i=2;i<km;i++) {
f[i]=mod_pow(i,mod-2,mod);
  }
  
  
  
  for(ll i=km;i>=2;i--) {
ll am=S-3*i;
    if(am==0) {
      ans++;
continue;
    }
    ll u=1;
    for(ll j=0;j<i-1;j++) {
u*=i+am-1-j;
      u%=mod;
    }
    for(ll h=i-1;h>=2;h--) {
u*=f[h];
      u%=mod;
    }
    ans+=u;
    ans%=mod;
    
  }
  
  cout<<ans<<endl;
}
  
  
  
    
    
    
    
  
  

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

int main(){
	int a, b;
	cin >> a >> b;
	int d = a / b;
	int r = a % b;
	double f = 1.0 * a / b;
	printf("%d %d %.8f", d, r, f);

	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)


char s[100001];

int main() {
  scanf("%s", s);
  int n = strlen(s);

  int ans = n;
  for (int i = (n+1)>>1; i < n; ++i) {
    if (s[i-1] != s[i] || s[n-i-1] != s[n-i]) {
      ans = i;
      break;
    }
  }

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-(x)))
#define re register
#define ll long long
#define int ll
#define ull unsigned long long
#define rep(i,a,b) for(re int i=a;i<=b;++i)
#define per(i,a,b) for(re int i=a;i>=b;--i)
template<typename T>
inline void read(T&x)
{
	x=0;
	char s=(char)getchar();
	bool f=false;
	while(!(s>='0'&&s<='9'))
	{
		if(s=='-')
			f=true;
		s=(char)getchar();
	}
	while(s>='0'&&s<='9')
	{
		x=(x<<1)+(x<<3)+s-'0';
		s=(char)getchar();
	}
	if(f)
		x=(~x)+1;
}
template<typename T>
inline void clear(T*a,int l,int r,int val)
{
	memset(&a[l],val,sizeof(T)*(r-l+1));
}
const int N=1e6+5;
int n;
ll a[N];
signed main()
{
	int n;
	int sum = 1;
	read(n);
	int x = 1e18;
	int flag = 0;
	rep(i , 1 , n)
		read(a[i]);
	std::sort(a+1,a+1+n);
	if(a[1]==0)
	{
		printf("0\n");
		return 0;
	}
	rep(i , 1 , n)
	{
		if(x / sum < a[i]) return printf("-1\n"),0;
		sum *= a[i];
	}
	printf("%lld\n",sum);
	return 0;
}



Measured memory_bytes: 4548
import java.util.Scanner;

public class Main {

	static int a,b;
	static int[][] field;

	public static void main(String args[]){

		Scanner s=new Scanner(System.in);

		while(true){
			b=s.nextInt();
			a=s.nextInt();
			if(a==0)System.exit(0);

			field = new int[a][b];

			for(int i=0; i<a; i++) {
				for(int j=0; j<b; j++) {
					field[i][j] = s.nextInt();
				}
			}
			int count =0;
			for(int i=0; i<a; i++) {
				for(int j=0; j<b; j++) {
					if(field[i][j]==1) {
						count++;
						check(i,j);
					}
				}
			}

			System.out.println(count);
		}
	}

	static void check ( int x, int y) {

		field[x][y] = 0;

		if(x>0) {
			if(field[x-1][y]==1) check(x-1,y);
			if(y>0)if(field[x-1][y-1]==1)check(x-1,y-1);
			if(y<b-1)if(field[x-1][y+1]==1)check(x-1,y+1);
		}

		if(x<a-1) {
			if(field[x+1][y]==1) check(x+1,y);
			if(y>0)if(field[x+1][y-1]==1)check(x+1,y-1);
			if(y<b-1)if(field[x+1][y+1]==1)check(x+1,y+1);
		}
		if(y>0) if(field[x][y-1]==1) check(x,y-1);
		if(y<b-1) if(field[x][y+1]==1) check(x,y+1);


		return;
	}

}



Measured memory_bytes: 45288
//クラス名は必ずMainにする必要があります。

import java.util.*;

public class Main {
  	public static void main(String args[] ) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[] ary = new int[3];
		for(int i = 0; i < 3; i++){
			ary[i] = Integer.parseInt(sc.next());
		}
		int j = 0;
		int num = 0;
		int n = Integer.parseInt(sc.next());
		while(true){
			if(ary[j] >= ary[j+1]){
				ary[j+1] *= 2;
				num++;
			}else{
				j++;
			}
			if(j == 2){
				break;
			}
		}
		if(num <= n){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
	
}


Measured memory_bytes: 35528
#include<iostream>
#include<cstdio>

using namespace std;

const int maxn = 100 + 10;

int main()
{
    int A[maxn];
    int n;
    while (scanf("%d",&n)!= EOF){
        int cot = 0;
        for (int i = 1 ; i <= n ; i ++){
            cin >> A[i];
        }

        for (int i = 1 ; i <= n ; i ++){
            for (int j = n ; j >= i + 1 ; j --){
                if (A[j] < A[j - 1]){
                    int t = A[j];
                    A[j] = A[j - 1];
                    A[j - 1] = t;
                    cot ++;
                }
            }
        }

        for (int i = 1 ; i <= n ; i ++){
            cout << A[i] ;
            if (i != n){
                cout << " ";
            }
        }
        cout << endl;
        cout << cot << endl;

    }
    return 0;
}



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

#define int long long

int32_t main(){
	string a , b ;
	cin >> a >> b ;
	int ans = INT_MAX ;
	for(int i = 0 ; i < a.size() ; i++){
		int cnt = 0 ;
		if(i + b.size() > a.size()) break ;
		for(int j = i ; j < i + (int)b.size() ; j++){
			cnt += a[j] != b[j - i] ;
		}
		ans = min(cnt , ans) ;
	}
	cout << ans ;
	return 0 ;
}



Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define ld long double
int const M=2e5+10,M2=1e6+10,mod=1e9+7,mod2=1e9+9,inf=1e18+30;
int mn[M],cnt[M],x[M],y[M];
int32_t main()
{
	int n,m;
	cin>>n>>m;
	int l=0,r=0,sum=0;
	for(int i=1;i<=n;i++)cin>>x[i];
	for(int i=1;i<=m;i++)cin>>y[i];
	sort(x+1,x+n+1);
	sort(y+1,y+m+1);
	for(int i=1;i<=n;i++)
	{
		int tmp=x[i];
		l+=tmp*(i-1);
		l-=sum;
		sum+=tmp;
	}
	sum=0;
	for(int i=1;i<=m;i++)
	{
		int tmp=y[i];
		r+=tmp*(i-1);
		r-=sum;
		sum+=tmp;
	}
	l%=mod,r%=mod;
	cout<<(l*r)%mod;
}	

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    long N,ans=100000000000000L;
    cin>>N;
    long X[N];
    for(long i=0;i<N;i++)cin>>X[i];
    sort(X,X+N);
    for(long i=0;i<=X[N-1];i++){
        long sum=0L;
        for(long j=0;j<N;j++){
            sum+=(i-X[j])*(i-X[j]);
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e3 + 9, M = 2e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int primes[N];

void factorize(int n){
    for(int i = 2;i * i <= n;i++){
        if(n % i == 0){
            while(n % i == 0){
                primes[i]++;
                n /= i;
            }
        }
    }

    if(n != 1)  primes[n]++;
}

int main(){
    init();

    int n;  cin >> n;

    for(int i = 1;i <= n;i++)
        factorize(i);

    ll ans = 1;
    for(int i = 1;i <= n;i++){
        if(!primes[i])  continue;
        ans *= (primes[i] + 1);
        ans %= modulo;
    }

    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include "atcoder/dsu"
#include "atcoder/fenwicktree"
typedef long long int ll;
using namespace std;
using namespace atcoder;
int main() {
    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> f(n);
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        f.add(i, a);
    }
    vector<ll> ans;
    for (int i = 0; i < q; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        if (x == 0) {
            f.add(y, z);
        }
        else {
            ans.push_back(f.sum(y, z));
        }
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 10264
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n, m;
    cin >> n >> m;
    ll s = 0;
    for (int i = 1; i <= m; i++)
    {
        ll tmp;
        cin >> tmp;
        s += tmp;
    }
    if (n - s < 0)
        cout << -1;
    else
        cout << n - s;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		long [] in = new long [a];      
        for(int i=0;i<a;i++){
                             in[i] = sc.nextLong();
                            }		
        long max = in[0];
		long ans = 0;
        for(int i=0;i<a;i++){if(max>in[i]){ans+=max-in[i];}
                             max=Math.max(in[i],max);
                            }       
		System.out.println(ans);
	}
}

Measured memory_bytes: 60464
"use strict";

const App8 = (arg: any) => {
  const value: string = arg.trim().split("\n");
  const A: number = parseInt(value[0].split(" ")[0], 10);
  const B: number = parseInt(value[0].split(" ")[1], 10);
  if (A > B) {
    console.log(`${B}`.repeat(A));
  } else {
    console.log(`${A}`.repeat(B));
  }
}

App8(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11468
#include <stdio.h>

int main(void){
  int N;
  scanf("%d", &N);

  int A[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    while(A[i] == A[i+1]){
      i++;
      continue;
    }
    if(A[i] < A[i+1]){
      while(A[i] <= A[i+1] && i+1 < N){
        i++;
      }
    }else{
      while(A[i] >= A[i+1] && i+1 < N){
        i++;
      }
    }
    ans++;
  }

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

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k;
    cin >> k;

    int even = k / 2;
    int odd = k - even;
    
    cout << even * odd << endl;
}


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

int main(void)
{
    int N, K;

    cin >> N >> K;

    long long int ans = K;

    for(int i = 1; i < N; ++i)
    {   
        ans *= K-1;
    }

    cout << ans << endl;

    return 0;
}



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

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

  ll ans = 1;
  while(1){
    if (ans * x % 360 == 0) {
      cout << ans << endl;
      return 0;
    }
    ans++;
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  string s;
  cin >> s;
  for (int i=0; i<19; i++) {
    if (s[i] == ',') {
      s[i] = ' ';
    }
    else {
      s[i] = s[i];
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }


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

  ll h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, 0, h) cin >> s[i];

  ll ans = 0;
  rep(i, 0, 1<<h) rep(j, 0, 1<<w){
    ll cnt = 0;
    rep(y, 0, h) rep(x, 0, w) if(s[y][x] == '#' && i >> y & 1 && j >> x & 1) cnt++;
    ans += (cnt == k);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n,m;
  cin >> n >> m;
  priority_queue<ll,vector<ll>,less<ll>> q;
  for(int i=0;i<n;i++){
    ll a;
    cin >> a;
    q.push(a);
  }

  for(int i=0;i<m;i++){
    ll b=q.top();
    q.pop();
    b/=2;
    q.push(b);
  }

  ll s=0;
  for(int i=0;i<n;i++){
    ll c=q.top();
    q.pop();
    s+=c;
  }

  cout << s << endl;

  

}

Measured memory_bytes: 4260
n = int(input())
P =[]
s = 0
for _ in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for j in range(n):s += P[j][1]*P[j+1][0] - P[j+1][1] * P[j][0]
print(s*-0.5)

Measured memory_bytes: 7728
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        while (sc.hasNext()) {
            char[] n = sc.next().toCharArray();
            for (int i = 0; i < n.length / 2; i++) {
                if (n[i] != n[n.length - i - 1]) {
                    count--;
                    break;
                }
            }
            count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26020
/******************************************
* AUTHOR : AMAN SAXENA *
* "There's some good in this world, and it's worth fighting for." *
* INSTITUTION : KIET Group of Institutions *
******************************************/
#include <bits/stdc++.h>

const long long MODULO=1000000007;
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define FOR1(i,a,n) for(int i=a;i<=n;i++)
#define FOR2(i,a,n) for(int i=a;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pi 3.14159265359

using namespace std;

template <typename TYPE> void in(TYPE &x){cin>>x;}

void solve()
{
    char ch ;
    cin >> ch;
    if(ch>='a' && ch<='z')
        cout << 'a' << '\n';
    else
        cout << 'A' << '\n';
}

void test()
{
    int t;
    cin>>t;
    while(t--) //for(int j=1;j<=t;j++) cout << "Case #" << j << ": ";
    {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    // test();
    solve();
    
    return 0;
}

Measured memory_bytes: 3632
// Problem: B - Product Max
// Contest: AtCoder - AtCoder Beginner Contest 178
// URL: https://atcoder.jp/contests/abc178/tasks/abc178_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long int
#define ii int
#define du double
#define jmp "\n"
#define vl vector<ll>
#define vvl vector<vl>
#define pb push_back
#define printv(v)     \
  for (auto x : v)    \
    cout << x << " "; \
  cout << jmp;
#define vi vector<int>
#define vb vector<bool>
#define ump unordered_map
#define SORT(v) sort(v.begin(), v.end())
#define REV(x) reverse(x.begin(), x.end())
#define all(x) x.begin(), x.end()
#define SET(x, a) memset(x, a, sizeof(x))
#define si(x) x.size()
#define ff first
#define ss second
#define iin insert
#define deb(x) cout << "test " << #x << "=" << x << jmp
#define deb2(x, y) cout << "test " << #x << "=" << x << "," << #y << "=" << y << jmp
using namespace std;
const ll nax = 1e5 + 5;
void solve()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max({a*c,a*d,b*c,b*d});
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while (t--)
    solve();
  return 0;
}

Measured memory_bytes: 3688
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n,m;
int mt[611];
int pre[611];
ll f[611][611],g[611][611];
ll dp[611];
int main()
{
	getii(n,m);
	dp[0]=1;
	for(int i=1;i<=600;i++)
	{
		dp[i]=dp[i-1]*(2*i-1)%mod;
	}
	for(int i=1;i<=m;i++)
	{
		int x,y;
		getii(x,y);
		mt[x]=y;
		mt[y]=x;
	}
	for(int i=1;i<=n+n;i++)pre[i]=pre[i-1]+(mt[i]==0);
	ll ans=0;
	for(int i=n+n-1;i>=1;i--)
	{
		int mn=n+n+1,mx=0;
		for(int j=i+1;j<=n+n;j+=2)
		{
			if(mt[j])mn=min(mn,mt[j]),mx=max(mx,mt[j]);
			if(mt[j-1])mn=min(mn,mt[j-1]),mx=max(mx,mt[j-1]);
			if(mn<i||mx>j)continue;
			if(j==i+1)
			{
				if(mt[i]!=0&&mt[i]!=j||mt[j]!=0&&mt[j]!=i)f[i][j]=g[i][j]=0;
				else f[i][j]=1,g[i][j]=0;
			}
			else
			{
				for(int k=i+1;k<j;k+=2)
				{
					g[i][j]=(g[i][j]+f[i][k]*(f[k+1][j]+g[k+1][j]))%mod;
				}
				f[i][j]=(dp[(pre[j]-pre[i-1])/2]-g[i][j]+mod)%mod;
			}
//			cerr<<i<<","<<j<<" "<<f[i][j]<<" "<<g[i][j]<<" "<<dp[(pre[n+n]-(pre[j]-pre[i-1]))/2]<<endl;
			ans=(ans+f[i][j]*dp[(pre[n+n]-(pre[j]-pre[i-1]))/2])%mod;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6016
# 整数1個だけ
N = int(input().strip())

# 別変数の整数複数個
A = [int(x) for x in input().strip().split(" ")]

cnt = 0

for j in range(1, len(A)):
    i = j - 1
    if A[i] > A[j]:
        s = A[i] - A[j]
        cnt += s
        A[j] += s
print(cnt)

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	string s;
	cin >> s;
	FOR(i, 0, 2) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3596
for e in iter(input,'0'):
 R=[[]for _ in[0]*-~int(e)]
 for _ in[0]*int(input()):
  a,b=map(int,input().split())
  R[a]+=[b];R[b]+=[a]
 for m in R[1][:]:R[1]+=R[m]
 print(len({*R[1]}-{1}))


Measured memory_bytes: 6292