akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <sstream>
#include <cctype>
#include <climits>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <vector>
#include <iterator>
#include <algorithm>
#include <stack>
#define _clr(x,y) memset(x,y,sizeof(x))
#define _inf(x) memset(x,0x3f,sizeof(x))
#define pb push_back
#define mp make_pair
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
typedef long long LL;
const int maxn=1000000+5;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	#ifndef ONLINE_JUDGE
		//freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
	
	int n;
	cin>>n;
	if(n<1200)cout<<"ABC"<<endl;
	else cout<<"ARC";
	
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	for {
		var H, W int
		fmt.Scanf("%d %d", &H, &W)
		if H == 0 && W == 0{
			break
		}
		for i := 0; i < H; i++ {
			for j := 0; j < W; j++ {
				if (i+j)%2 == 0{
					fmt.Print("#")
				}else {
					fmt.Print(".")
				}
			}
			fmt.Print("\n")
		}
		fmt.Print("\n")
	}
}



Measured memory_bytes: 1160
//Har Har Mahadev
using namespace std;
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
#define pb push_back
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " -> " << a << endl;
	err(++it, args...);
}

void testcase(){
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for(int i{0};i <= n-3;i++){
		if(s.substr(i,3) == "ABC")ans++;
	}
	cout << ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


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

using namespace std;

int main() {
  int a,b,c,d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  if(a+b>c+d){
   printf("Left\n");
  }else if(a+b<c+d){
    printf("Right\n");
  }else{
    printf("Balanced\n");
  }
  return 0;
}

Measured memory_bytes: 256
h,w,k = map(int, input().split())
board = [list(map(int, input())) for i in range(h)]

bitcnt = [0]*(1<<h)
for i in range(1<<(h-1)):
    bitcnt[2*i] = bitcnt[i]
    bitcnt[2*i+1] = bitcnt[i]+1

ans = float("inf")
for state in range(1<<(h-1)):
    s = [0]*h
    ans_tmp = 0
    can = True
    for i in range(w):
        cnt = 0
        tmp = [0]*h
        for j in range(h):
            tmp[cnt] += board[j][i]
            if state&(1<<j) or j==h-1:
                cnt += 1
        if any(tmp[j]>k for j in range(cnt)):
            can = False
            break
        if all(s[j]+tmp[j]<=k for j in range(cnt)):
            for j in range(cnt):
                s[j] += tmp[j]
        else:
            s = tmp
            ans_tmp += 1
    if can:
        ans = min(ans, ans_tmp+bitcnt[state])

print(ans)


Measured memory_bytes: 51416
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;
typedef vector<int> vi;
typedef vector<vi> vvi;

int dfs(vvi& g, vector<pi>& res, int v, int& count, int from, vi& low, vi& pre)
{
	pre[v] = count++;
	low[v] = pre[v];
	for (vi::iterator it = g[v].begin(); it != g[v].end(); it++) {
		int to = *it;
		if (pre[to] == -1) {
		
			low[v] = min(low[v], dfs(g, res, to, count, v, low, pre));
			if (low[to] == pre[to]) {
				res.push_back(make_pair(min(to,v), max(to,v)));
			}
		}
		else {
			if (from == to) {
				continue;
			}
			low[v] = min(low[v], low[to]);
		}
	}
	return low[v];
}

// g: adjacency list
// v:number of nodes

vector<pi> bridges(vvi& g, int v) {
	vector<pi> res;
	if (v > 0) {
		
		vi low(v, -1); 
		vi pre(v, -1); 
		int count = 0; 
		dfs(g, res, 0, count, -1, low, pre); 
	}
	return res;
}

vvi G;
vector<pi> ans;

int main()
{
	int v, e;
	cin >> v >> e;
	G.resize(v);

	rep(i, e) {
		int s, t;
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}

	ans = bridges(G, v);
	sort(ans.begin(), ans.end());
	
	rep(i, ans.size())
		cout << ans[i].first << " " << ans[i].second << endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> h(N);
  vector<int> cost(N);
  for(int i=0;i<N;i++){
    cin >> h.at(i);
    cost.at(i) = -1;
  }
  
  cost.at(0) = 0;
  cost.at(1) = abs(h.at(1) - h.at(0));
  for(int i=2;i<N;i++){
    cost.at(i) = min((cost.at(i-2) + abs(h.at(i)-h.at(i-2))),
                  (cost.at(i-1) + abs(h.at(i)-h.at(i-1))));
  }
  cout << cost.at(N-1) << endl;
}

Measured memory_bytes: 1024
using System;

class Program
{
    static void Main(string[] args) {
        string[] a = Console.ReadLine().Split(' ');
        int x = int.Parse(a[0]);
        int y = int.Parse(a[1]);

        Console.WriteLine(gcd(x, y));
    }

    static int gcd(int x, int y) {
        if (y < 1) { return x; }
        return gcd(y, x % y);
    }
}



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

using namespace std;

long long h[200001];
long long rh[200001];
long long q[200001];
long long ct[256];
long long n;

long long gt(int l, int r){
    return h[r] - h[l] * q[r - l];
}

long long rgt(int l, int r){
    return rh[l] - rh[r] * q[r - l];
}

int main()
{
    #ifdef DEBUG
    freopen("input.txt", "r", stdin);
    #endif
    string s;
    cin >> s;
    n = s.size();
    long long ans = n * (n + 1) / 2 + 1;
    /*q[0] = 1;
    for (int i = 0; i < n; i++){
        h[i + 1] = h[i] * 23467ll + s[i];
        q[i + 1] = q[i] * 23467ll;
    }
    for (int i = n - 1; i >= 0; i--){
        rh[i] = rh[i + 1] * 23467ll + s[i];
    }
    for (int i = 0; i < n; i++){
        int len = min(i, n - i - 1);
        long long l = 0;
        long long r = len + 1;
        while (l < r - 1){
            int m = (l + r) / 2;
            if (gt(i, i + m + 1) == rgt(i - m, i + 1)){
                l = m;
            } else {
                r = m;
            }
        }
        ans -= r;
        len = min(i, n - i);
        l = 0;
        r = len + 1;
        while (l < r - 1){
            int m = (l + r) / 2;
            if (gt(i, i + m) == rgt(i - m, i)){
                l = m;
            } else {
                r = m;
            }
        }
        ans -= l;
    }
    cout << ans;*/
    for (int i = 0; i < n; i++){
        ct[s[i]]++;
    }
    for (int i = 'a'; i <= 'z'; i++){
        ans -= (ct[i] * (ct[i] + 1)) / 2;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx - sx;
    int y = ty - sy;
    for(int i=0;i<x;i++) cout << 'R';
    for(int i=0;i<y;i++) cout << 'U';
    for(int i=0;i<x;i++) cout << 'L';
    for(int i=0;i<y;i++) cout << 'D';
    cout << 'D';
    for(int i=0;i<x+1;i++) cout << 'R';
    for(int i=0;i<y+1;i++) cout << 'U';
    cout << 'L';
    cout << 'U';
    for(int i=0;i<x+1;i++) cout << 'L';
    for(int i=0;i<y+1;i++) cout << 'D';
    cout << 'R';
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String buffer;
		try {
			while ((buffer = reader.readLine())  != null) {
				int a = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ")));
				int b = Integer.valueOf(buffer.substring(buffer.indexOf(" ") + 1));
				if (a == b) {
					System.out.println("a == b");
				}
				if (a < b) {
					System.out.println("a < b");
				}
				if (a > b) {
					System.out.println("a > b");
				}
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}

Measured memory_bytes: 24436
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
signed main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (min(a, b) <= c && c <= max(a, b))puts("Yes");
	else puts("No");
	ggr
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define per(i,b,a) for(int i=b; i>=a; i--)
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pi ;
typedef vector<pair<int,int> > vpi ;
typedef vector<int> vi ;
typedef long long ll ;
const int mod = 998244353 ;
const int inf = 1e9 + 5;
ll powmod(ll a, ll b) { ll ret = 1 ; while(b) { if(b&1) ret = (ret*a)%mod ;  a = (a*a)%mod ; b >>= 1 ; }  return ret ; }
const int maxn = 1e5 + 5 ;
int n, m ;
vi gph[maxn] ;
bool vis[maxn] ;
int dp[maxn] ;
vi ts ;
void dfs(int v)
{
    for(auto u : gph[v])
    {
        if(!vis[u])
        {
            vis[u] = true ;
            dfs(u) ;
        }
    }
    ts.pb(v) ;
}
int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cin >> n >> m ;
    rep(i,1,m)
    {
        int u, v ;
        cin >> u >> v ;
        gph[u].pb(v) ;
    }
    rep(i,1,n)
    {
        if(!vis[i])
        {
            vis[i] = true ;
            dfs(i) ;
        }
    }
     reverse(ts.begin(), ts.end()) ;
     rep(j,0,(int)ts.size()-1)
     {
         for(auto u : gph[ts[j]])
           dp[u] = max(dp[u], dp[ts[j]]+1) ;
     }
    int res = -63 ;
    rep(i,1,n)
     res = max(res, dp[i]) ;
    cout << res << "\n" ;
    return 0 ;
}


Measured memory_bytes: 8824
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

type Point struct {
	h, w int
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	H, W, K := sc.nextInt(), sc.nextInt(), sc.nextInt()
	dp := make([][]int, H+1)
	for i := 0; i < H+1; i++ {
		dp[i] = make([]int, W)
	}
	dp[0][0] = 1
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			var X, Y, Z int
			for bit := 0; bit < 1<<uint(W-1); bit++ {
				ok := true
				for k := 0; k < W-2; k++ {
					// 横棒が並んでいる場合
					if 1<<uint(k)&bit > 0 && 1<<uint(k+1)&bit > 0 {
						ok = false
					}
				}
				if !ok {
					continue
				}
				if j >= 1 && 1<<uint(j-1)&bit > 0 {
					X++
				}
				if 1<<uint(j-1)&bit == 0 && 1<<uint(j)&bit == 0 {
					Y++
				}
				if 1<<uint(j)&bit > 0 {
					Z++
				}
			}
			//fmt.Fprintln(wtr, i, j, X, Y, Z)
			if j >= 1 {
				dp[i+1][j-1] += X * dp[i][j] % MOD
				dp[i+1][j-1] %= MOD
			}
			dp[i+1][j] += Y * dp[i][j] % MOD
			dp[i+1][j] %= MOD
			if j+1 < W {
				dp[i+1][j+1] += Z * dp[i][j] % MOD
				dp[i+1][j+1] %= MOD
			}
		}
	}
	fmt.Fprintln(wtr, dp[H][K-1])
}


Measured memory_bytes: 640
# Problem C - Marks
# input
N, K = map(int, input().split())
a_nums = list(map(int, input().split()))

# initialization
cumulative_sum = 1
for i in range(K):
    cumulative_sum += a_nums[i]
cumulative_list = [0] * N
cumulative_list[K-1] = cumulative_sum

# cumulative sum calc
for i in range(K, N):
    cumulative_sum = cumulative_sum - a_nums[i-K]
    cumulative_sum = cumulative_sum + a_nums[i]
    cumulative_list[i] = cumulative_sum
    if cumulative_list[i]>cumulative_list[i-1]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 31672
#include <iostream>
using namespace std;
int main() {
	int x1, x2, x3, x4, x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;
	if (x1 == 0) cout << 1 << endl;
	if (x2 == 0) cout << 2 << endl;
	if (x3 == 0) cout << 3 << endl;
	if (x4 == 0) cout << 4 << endl;
	if (x5 == 0) cout << 5 << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)

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

struct Point {
  int x, y, dist;
  Point(int x, int y, int dist) : x(x), y(y), dist(dist) {}
};

int main() {

  string kabe = "";
  rep(i, 2*MAX_W+4) kabe += "1";

  int w, h;
  while(cin >> w >> h, w || h) {
    vector<string> maze;
    maze.push_back(kabe); // 利便のため、迷路の周り(ここでは上側)を壁で囲う
    string s;
    getline(cin, s);
    rep(i, 2*h - 1) {
      getline(cin, s);
      if (s.size() < 2*w - 1) s += " "; // 入力の末尾の空白を補う
      s = "1" + s + "1"; // 左右に壁
      maze.push_back(s);
    }
    maze.push_back(kabe); // 下側に壁

    queue<Point> que;
    que.push(Point(1,1, 1));
    vector<vector<bool> > visited(2*h, vector<bool>(2*w, false));
    int ans = 0;
    while (!que.empty()) {
      Point p = que.front();
      que.pop();
      if (p.x == 2*w-1 && p.y == 2*h-1) {
        ans = p.dist;
        break;
      }
      if (visited[p.y][p.x]) continue;
      visited[p.y][p.x] = true;
      rep(i, 4) {
        int nx = p.x + dx[i];
        int ny = p.y + dy[i];
        if (maze[ny][nx] == '0') {
          // 一つ飛ばしで移動する
          que.push(Point(nx + dx[i], ny + dy[i], p.dist + 1));
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 948
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();



int main(){
  ll n,k;
  cin >> n>>k;
  ll a[200001], b[200001];
  REP(i,200001)b[i]=0;
  
  REP(i,n){
    cin>>a[i];
    b[a[i]-1] ++;
  }
  

  
  sort(b, b+200001,greater<ll>());

  ll res = 0;

  
  FOR(i, k,n)
  {
    res += b[i];
  }

  cout << res << endl;
}

Measured memory_bytes: 3328
using System;
using System.Linq;
namespace AtCoder_Begginer_Contest1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NM = Console.ReadLine().Split();
            int N = int.Parse(NM[0]);
            int M = int.Parse(NM[1]);
            int[] board = new int[N+1];
            int[] penaltyp = new int[N + 1];
            int penalty = 0;
            int seito = 0;
            int[] p = new int[M];
            string[] S = new string[M];
            int[] hantei= new int[M];
            for (int i = M-1; i >-1 ; i--)
            {
                string[] pS = Console.ReadLine().Split();
                p[i] = int.Parse(pS[0]);
                S[i] = pS[1];
            }
            for (int i = M - 1; i > -1; i--)
            {
                if (S[i] == "WA")
                 {
                    penaltyp[p[i]]++;
                 }
                 else if (S[i] == "AC")
                 {
                    if (board[p[i]] == 0)
                    {
                        seito++;
                        penalty += penaltyp[p[i]];
                        board[p[i]]++;
                    }
                    else board[p[i]]++;
                 }
            }
            Console.WriteLine(seito + " " + penalty);
        }
    }
}

Measured memory_bytes: 24272
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int n, double w) {
    VI v(n);
    for_each(ALL(v), [](int &e){cin >> e;});
    SORT(v);
    double ans = 0.0;
    VI g;
    int cnt = 0;
    int mi = 0, ma = w - 1;
    int id = 0;
    while (id < n) {
        if (mi <= v[id] && v[id] <= ma) {
            cnt++; id++;
        } else {
            //cout << mi << " " <<ma << endl;
            g.EB(cnt); cnt = 0;
            mi = ma + 1; ma += w;
        }
    }
    g.EB(cnt);
    int sz = g.size();
    ma = *max_element(ALL(g));
    REP(i, sz) {
        ans += (1. * g[i] / ma) * 1. * ((sz - i - 1) / (1. * (sz - 1)));
    }
    cout << fixed << setprecision(10) << ans + 0.01 << endl;
    return;
}

signed main(void) {
    LL n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n >> m, n) {
        solve(n, m);
        //return 0;
    }
}

Measured memory_bytes: 3212
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,n,m,j;
	cin>>n;
	int t[n];
	for(i=0;i<n;i++)cin>>t[i];
	cin>>m;
	int p,x;
	for(i=0;i<m;i++){
		int ans=0;
		cin>>p>>x;
		for(j=0;j<n;j++){
			if(p-1==j)ans+=x;
			else ans+=t[j];
		}
		cout<<ans<<endl;
	}
	
	
	
	return 0;
}

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

using namespace std;

int main() {
	double v;
	while (cin >> v){
		double t = v/9.8;
		double y = 4.9*pow(t,2);
		int N;
		for (N=1;;N++) {
			if (5*N-5>=y) break;
		}
		cout << N << endl;
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cstring>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

void tc()
{
	long double a,b;
	cin >> a >> b;
	unsigned long long int ans = a*b;
	cout << ans << endl;
}

int main()
{
	fastio;
	int t; t=1;
	while(t--)
	{
		tc();
	}
	return 0;
}


Measured memory_bytes: 3744
#include<cstdio>
#include<cstring>
static const int MAX_T = 100000;

int N, T;
int t[MAX_T + 1];

int main(){
	memset(t, 0, sizeof(t));
	int l, r;
	scanf("%d %d", &N, &T);
	for(int i = 1; i <= N; i++){
		scanf("%d %d", &l, &r);
		t[l]++; t[r]--;
	}
	int num = 0, max_num = 0;
	for(int i = 0; i < T; i++){
		num += t[i];
		if(num > max_num) max_num = num;
	}
	printf("%d\n", max_num);
	return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k,m; string s,t;
char maze[60][60];
int dis[101][101]; int graph[50][50]; bool vis[50];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
int main() {
	ll r, g, b; ll cnt = 0;
	cin >> r >> g >> b >> n;
	for (int i = 0; i <= n; i+=r) {
		for (int j = 0; j <= n; j+=g) {
			if ((n - i - j)%b == 0&&(n-i-j)<=n&&(n-i-j)>=0) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}



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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int cnt[1000];
char s[MAXN];

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	scanf("%s", s);
	n = strlen(s);
	for (int i = 0; i < n; i++)
		cnt[s[i]]++;
	ll ans = 1ll * n * (n - 1) / 2;
	for (int i = 'a'; i <= 'z'; i++)
		ans -= (1ll * cnt[i] * (cnt[i] - 1) / 2);
	printf("%lld\n", ans + 1);
}

void printans(){

}


int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}



Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

type Entry struct{
  name string
  score int
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)

  var res int

  n := iScan()
  if n % 1000 == 0 {
    res = 0
  } else {
    res = 1000 - (n % 1000)
  }
  fmt.Println(res)

}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
typedef pair<int, int> ii;
typedef vector<ii> vii;

int lgt, wth, pm, nPt;
vii rg;

bool onEdge (int r, int c) {
  bool ote = false;
  ote |= r == 0;
  ote |= c == 0;
  ote |= r == lgt;
  ote |= c == wth;
  return ote;
}

int unID (int r, int c) {
  if (r == 0) return c;
  if (c == 0) return pm - r;
  if (r == lgt) return pm - (lgt) - c;
  if (c == wth) return (wth - 1) + r;
  return 10000;
}

int main() {
  scanf("%d%d%d", &lgt, &wth, &nPt);
  pm = 2 * (lgt + wth);
  int nCE = 0;
  for (int i = 0; i < nPt; i++) {
    int a, b, p, q;
    scanf("%d%d%d%d", &a, &b, &p, &q);

    if (onEdge(a, b) && onEdge(p, q)) {
      nCE++;
      int s = unID(a, b);
      int t = unID(p, q);
      if (s > t) swap(s, t);
      rg.eb(s, nCE);
      rg.eb(t, -nCE);
      // printf(">>%d %d\n", s, t);
    }
  }
  sort(rg.begin(), rg.end());
  stack<int> st;
  st.push(0);
  for (ii el : rg) {
    // printf("%d %d\n", el.fi, el.se);
    if (el.se > 0) st.push(el.se);
    if (el.se + st.top() == 0) {
      st.pop();
    }
  }
  st.pop();
  if (st.empty()) printf("YES\n");
  if (!st.empty()) printf("NO\n");
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);

const int MAX=200010;


int main() {
    ios_base::sync_with_stdio(false); 

    int n;
    cin >> n;
    vector<pair<ll,ll>> pp(n),pm(n);
    rep(i,n) {
        int x,y;
        cin >> x >> y;
        pp[i]={x+y,y};
        pm[i]={x-y,y};
    }
    sort(pp.begin(),pp.end());
    sort(pm.begin(),pm.end());
    ll ansx=abs(pp[0].first-pp[n-1].first);
    ll ansy=abs(pm[0].first-pm[n-1].first);
    ll ans=(ansx>ansy)?ansx:ansy;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9508
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=1010, inf=1e9, mod=1e9+7;
int n, N;
int h[maxn], b[maxn], f[maxn][maxn];

template<typename T>
inline void read(T &k)
{
	int f=1; k=0; char c=getchar();
	while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
	while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
	k*=f;	
}

inline int power(int a, int b)
{
	if(b<0) return 1;
	int ans=1;
	for(;b;b>>=1, a=1ll*a*a%mod)
	if(b&1) ans=1ll*a*ans%mod;
	return ans;
}
 
int main()
{
	read(n);
	for(int i=1;i<=n;i++) read(h[i]), b[++N]=h[i];
	sort(b+1, b+1+N); N=unique(b+1, b+1+N)-b-1;
	for(int i=1;i<=n;i++) h[i]=lower_bound(b+1, b+1+N, h[i])-b;
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		f[i][0]=2ll*f[i-1][0]%mod;
		for(int j=h[i]+1;j<=h[i-1];j++) f[i][0]=(f[i][0]+2ll*f[i-1][j])%mod;
		for(int j=1;j<=h[i];j++)
		{
			f[i][j]=1ll*f[i-1][j]*power(2, b[h[i]]-b[h[i-1]])%mod;
			if(j>h[i-1])
			{
				if(j>1) f[i][j]=(f[i][j]+1ll*f[i-1][0]*(power(2, b[j]-b[j-1])-1+mod)*2%mod*power(2, b[h[i]]-b[j]))%mod;
				else f[i][j]=(f[i][j]+1ll*f[i-1][0]*(power(2, b[j]-1)-1)*2%mod*power(2, b[h[i]]-b[j]))%mod;
			}
		}
	}
	int ans=0;
	for(int i=0;i<=N;i++) ans=(ans+f[n][i])%mod;
	printf("%d\n", ans);
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


// xiが0 => i-th bitの1の個数
// xiが1 => i-th bitの0の個数
// 最上位桁から決めていく

#define MAX_BIT 40
i64 dp[MAX_BIT + 1][2];

#define INF 1152921504606846976

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

    REP(i, MAX_BIT + 1) REP(j, 2) dp[i][j] = -INF;
    dp[0][0] = 0;

    i64 p = 1LL << 40;
    REP(l, MAX_BIT) {
        p /= 2;

        i64 Ki = K / p;
        K %= p;

        i64 n1 = 0;
        REP(j, N) {
            n1 += A[j] / p;
            A[j] %= p;
        }

        REP(smaller, 2) {
            for (i64 i = 0; i <= (smaller ? 1 : Ki); i++) {
                chmax(dp[l + 1][smaller || i < Ki], dp[l][smaller] + (i == 1 ? (N - n1) : n1) * p);
            }
        }
    }

    cout << max(dp[MAX_BIT][0], dp[MAX_BIT][1]) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    ll r, D, x;
    cin >> r >> D >> x;
    REP(i, 10) {
        x = r * x - D;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>


int main(void) {

	char str[1000],mark[1000];
	int i,count=0;
	scanf("%s",mark);
	for(i=0; ;i++){
		if(mark[i] == '\0')break;
		mark[i] = toupper(mark[i]);
	}
	while(1){
		scanf("%s",str);
		if(strcmp(str,"END_OF_TEXT")== 0)break;
		for(i=0; ;i++){
			if(str[i] == '\0')break;
			str[i] = toupper(str[i]);
		}
		if(strcmp(str,mark) == 0)count++;
	}
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 1860
#include <stdio.h>
#include <inttypes.h>
#include <stdint.h>
#include <algorithm>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n] = { 0 };
	for (int i = 0; i < n; i++) {
		int x = ri();
		a[i] += x;
		a[n - 1 - i] += x;
	}
	int64_t res = 0;
	for (int i = 1; i < n; i++) {
		int64_t sum = 0;
		for (int cur = i; cur < n; cur += i) {
			sum += a[cur];
			int forward = n - 1 - cur;
			if (forward <= i) continue;
			int back = forward - i;
			if (back % i == 0 && n - 1 >= forward * 2) continue;
			res = std::max(res, sum);
		}
	}
	printf("%" PRId64 "\n", res);
	return 0;
}


Measured memory_bytes: 512
n, m = map(int, input().split())
P = [0]*(m+1)
Y = [0]*(m+1)
for i in range(1, m+1):
    P[i], Y[i] = map(int, input().split())
PP = [[] for i in range(n+1)]
#print(PP)
for i in range(1, m+1):
    p = P[i]
    y = Y[i]
    PP[p].append((i, y))

C = []
for i in range(1, n+1):
    if len(PP[i]) == 0:
        continue
    if len(PP[i]) > 1:
        PP[i].sort(key=lambda x: x[1])
    for j, pp in enumerate(PP[i]):
        num = '%06d%06d' % (P[pp[0]], j+1)
        C.append((pp[0], num))
#print(C)
C.sort(key=lambda x: x[0])
for i, num in C:
    print(num)

Measured memory_bytes: 47324
use std::cmp;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::HashSet;
use std::fmt;
use std::io::stdin;
use std::io::Error;
use std::io::ErrorKind;
use std::io::Read;

#[derive(Debug)]
struct Input {
    n: usize,
    a: Vec<i64>,
}

fn handle_input(input_str: String) -> Result<Input, Error> {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut a = Vec::new();
    for _ in 0..n {
        let v: i64 = iter.next().unwrap().parse().unwrap();
        a.push(v)
    }
    let input = Input { n: n, a: a };
    Ok(input)
}

fn gcd(a: u32, b: u32) -> u32 {
    if a == 0 {
        return b;
    }
    gcd(b % a, a)
}

fn handle_output(input: Input) -> Result<String, Error> {
    let mut b_not_flipped = input.a[0];
    let mut b_flipped = -input.a[0];
    for i in 1..input.n - 1 {
        let tmp = max(b_not_flipped + input.a[i], b_flipped - input.a[i]);
        b_flipped = max(b_not_flipped - input.a[i], b_flipped + input.a[i]);
        b_not_flipped = tmp;
    }
    let last = input.a.last().unwrap();
    Ok(format!("{}", max(b_not_flipped + last, b_flipped - last)))
}

fn main() {
    let mut input_str = String::new();
    let stdin = stdin();
    stdin.lock().read_to_string(&mut input_str).unwrap();
    let input = handle_input(input_str).unwrap();
    let output = handle_output(input).unwrap();
    println!("{}", output);
}

Measured memory_bytes: 8444
s = list(input())
t = list(input())

s_d = {}
t_d = {}

ans = 'Yes'

for i in range(len(s)):
    a = s[i]
    b = t[i]
    if a in s_d.keys() and b in t_d.keys():
        if s_d[a] != t_d[b]:
            ans = 'No'
            break

    elif a in s_d.keys() and b not in t_d.keys():
        ans = 'No'
        break

    elif a not in s_d.keys() and b in t_d.keys():
        ans = 'No'
        break

    else:
        s_d[a] = i
        t_d[b] = i

print(ans)



Measured memory_bytes: 6704
n, m, x = map(int, input().split())
cost = [ 0 for _ in range(n+1) ]
a = [ int(x) for x in input().split() ]
for aa in a:
    cost[aa] = 1

ans = float("inf")
# x -> n
t = 0
for i in range(x+1, n+1):
    t += cost[i]
ans = min(ans, t)

# x -> 0
t = 0
for i in range(x-1, -1, -1):
    t += cost[i]

ans = min(ans, t)

print(ans)

Measured memory_bytes: 3188
n = int(input())

all_ord_list = [ None for i in range(n) ] 
def listing(inlist):
	ord_list = [0 for i in range(26)]
	for i in inlist:
		ord_list[ord(i)-97] += 1
	return ord_list

for i in range(n):
	all_ord_list[i] = listing(input())

ans = ""
for i in range(26):
	ans += (min([ all_ord_list[j][i] for j in range(n)])*chr(97+i))
	
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<map>
#include<queue>
#include<functional>
using namespace std;

const int MAX = 100;
const int INF = 1000;

bool check(int n) {
	string s = to_string(n);
	int b = 0;
	int e = 4;

	while (b < e) {
		if (s[b] != s[e])return false;
		b++;
		e--;
	}
	return true;
}

int main() {
	int A, B;
	int ans = 0;

	cin >> A >> B;

	for (int i = A; i <= B; i++) {
		if (check(i))ans++;
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define read(x) scanf("%d",&x)
int n;
int dis[505][505];
int occ[505][505];
pii p[250005];
queue<pii> q;
int ans=0;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	REP(i,n) REP(j,n) dis[i][j]=min(min(i-1,n-i),min(j-1,n-j)),occ[i][j]=1;
	rep(TMP,n*n){
		int X;cin>>X;--X;
		int x=X/n+1,y=X%n+1;
		ans+=dis[x][y];
		//cout<<"After "<<x<<','<<y<<" leaves, ans added by "<<dis[x][y]<<"\n";
		occ[x][y]=0;
	int nd=min(min(dis[x-1][y]+occ[x-1][y],dis[x+1][y]+occ[x+1][y]),min(dis[x][y+1]+occ[x][y+1],dis[x][y-1]+occ[x][y-1]));
		dis[x][y]=nd;
		q.push(mp(x,y));
		while(!q.empty()){
			pii cur=q.front();q.pop();
			int i=cur.F,j=cur.S;
			int nd=dis[i][j]+occ[i][j];
			if (nd<dis[i][j+1]) dis[i][j+1]=nd,q.push(mp(i,j+1));
			if (nd<dis[i][j-1]) dis[i][j-1]=nd,q.push(mp(i,j-1));
			if (nd<dis[i+1][j]) dis[i+1][j]=nd,q.push(mp(i+1,j));
			if (nd<dis[i-1][j]) dis[i-1][j]=nd,q.push(mp(i-1,j));
		}
	}
	cout<<ans<<endl;
	
	return 0; 
}

Measured memory_bytes: 5636
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)
const long double PI = (acos(-1));

int main() {

	int n, q;
	string s;
	cin >> n >> q >> s;

	vector<int> l(q), r(q);
	rep(i, 0, q) cin >> l[i] >> r[i];

	map<int, int> m;
	int cnt = 0;

	rep(i, 0, n - 1) {
		if (s[i] == 'A' && s[i + 1] == 'C') {
			cnt++;
		}
		m[i + 1] = cnt;
	}

	int ans = 0;
	rep(i, 0, q) {
		ans = m[r[i] - 1] - m[l[i] - 1];
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 6400
n = gets.to_i
A = gets.split.map(&:to_i)
q = gets.to_i
M = gets.split.map(&:to_i)

def solve(i, m)
  return true if m == 0
  return false if i >= A.size

  solve(i + 1, m) || solve(i + 1, m - A[i])
end

M.each do |target|
  puts solve(0, target) ? 'yes' : 'no'
end

Measured memory_bytes: 8668
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;
using P = pair<int, int>;
const int undefined = -1;

int main() {
  int H, W;
  cin >> H >> W;

  int Ch, Cw, Dh, Dw;
  cin >> Ch >> Cw >> Dh >> Dw;
  Ch--; Cw--; Dh--; Dw--;

  vector<vector<char>> S(H, vector<char>(W));
  rep(i,0,H-1) {
    rep(j,0,W-1) {
      cin >> S[i][j];
    }
  }

  vector<vector<int>> answers(H, vector<int>(W, undefined));
  deque<P> q, visited;
  q.push_back(P(Ch, Cw));
  answers[Ch][Cw] = 0;

  while (!q.empty() || !visited.empty()) {
    if (!q.empty()) {
      P current = q.front(); q.pop_front();
      visited.push_back(current);

      int dx[4] = {1, 0, -1, 0};
      int dy[4] = {0, 1, 0, -1};
      rep(i,0,3) {
        int next_x = current.first + dx[i];
        int next_y = current.second + dy[i];
        if (0 <= next_x && next_x < H && 0 <= next_y && next_y < W) {
          if (S[next_x][next_y] == '#') continue;
          if (answers[next_x][next_y] == undefined) {
            answers[next_x][next_y] = answers[current.first][current.second];
            q.push_back(P(next_x, next_y));
          }
        }
      }
    } else {
      P point = visited.front(); visited.pop_front();
      for (int i = -2; i <= 2; ++i) {
        for (int j = -2; j <= 2; ++j) {
          int next_x = point.first + i;
          int next_y = point.second + j;
          if (0 <= next_x && next_x < H && 0 <= next_y && next_y < W) {
            if (S[next_x][next_y] == '#') continue;
            if (answers[next_x][next_y] == undefined) {
              answers[next_x][next_y] = answers[point.first][point.second] + 1;
              q.push_back(P(next_x, next_y));
            }
          }
        }
      }
    }
  }

  cout << answers[Dh][Dw] << endl;
  return 0;
}


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

#define each(i, c) for (auto& i : c)

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9+7;

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

  ll sn = 0;
  for (ll i = n; i > 0; i /= 10) {
    sn += (i % 10);
  }

  cout << ((n % sn) == 0 ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author indy256
 */

#include <bits/stdc++.h>

using namespace std;

int f(int x) {
    if (x == 0)
        return 0;
    return 1 + f(x % __builtin_popcount(x));
}

void solve(istream &in, ostream &out) {
    int n;
    in >> n;

    string s;
    in >> s;

    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '1')++cnt;
    }

    vector<int> r1(n), r2(n);
    for (int i = 0, cur1 = 1, cur2 = 1; i < n; ++i) {
        r1[i] = cur1;
        r2[i] = cur2;
        cur1 *= 2;
        cur2 *= 2;
        if (cnt > 1)
            cur1 %= cnt - 1;
        cur2 %= cnt + 1;
    }

    int rem1 = 0, rem2 = 0;
    for (int i = 0; i < n; ++i) {
        if (cnt > 1) {
            rem1 = rem1 * 2 + (s[i] == '1' ? 1 : 0);
            rem1 %= cnt - 1;
        }
        rem2 = rem2 * 2 + (s[i] == '1' ? 1 : 0);
        rem2 %= cnt + 1;
    }

    for (int i = 0; i < n; ++i) {
        int res;
        if (s[i] == '1') {
            if (cnt == 1)
                res = 0;
            else
                res = f((rem1 - r1[n - 1 - i] + (cnt - 1)) % (cnt - 1)) + 1;
        } else {
            res = f((rem2 + r2[n - 1 - i]) % (cnt + 1)) + 1;
        }
        out << res << '\n';
    }
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solve(in, out);
}


Measured memory_bytes: 5192
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		for(int i=0;i<n;i++){
			BigInteger a = new BigInteger(scan.next());
			BigInteger b = new BigInteger(scan.next());
			if(a.add(b).toString().length()>80)
				System.out.println("overflow");
			else
				System.out.println(a.add(b));
		}
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdio>
#include <vector>
#define N 100005
using namespace std;

int n, k, mx;
string a;
vector<int> ve, vc;
int main()
{
	int i;
	cin >> n >> k >> a;
	ve.push_back('0'), vc.push_back(-1);
	for (i = 0; i < n; i++) {
        if (a[i] != a[i + 1]) ve.push_back(a[i]), vc.push_back(i);
	}
    for (i = 1; i < ve.size(); i++) {
		if (ve[i] == '1') {
			if (i + k * 2 >= vc.size()) mx = max(mx, n - 1 - vc[i - 1]);
			else mx = max(mx, vc[i + k * 2] - vc[i - 1]);
		} else {
			if (i + k * 2 - 1 >= vc.size()) mx = max(mx, n - 1 - vc[i - 1]);
			else mx = max(mx, vc[i + k * 2 - 1] - vc[i - 1]);
		}
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 1404
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>
#include <numeric>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

int n;
vector<int> up;
vector<int> bt;


int main(int argc, char *argv[])
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        int val;
        scanf("%d", &val);
        up.push_back(val);
    }
    for (int i = 0; i < n; ++i)
    {
        int val;
        scanf("%d", &val);
        bt.push_back(val);
    }

    int max_val = 0;
    for (int i = 0; i < n; ++i)
    {
        int sum = accumulate(up.begin(), up.begin() + i + 1, 0);
        sum += accumulate(bt.begin() + i, bt.end(), 0);
        if (sum > max_val)
        {
            max_val = sum;
        }
    }

    printf("%d\n", max_val);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
long long m;
string n;

int main() {
	cin >> n >> m;
	int tmp = 0;
	for (int i = 0; i <= n.size()-1; i++) {
		if (n[i] == '1') tmp++;
		if (n[i] != '1') break;
	}
	if (tmp >= m) {
		cout << "1"; return 0;
	}
	if (tmp == 0) {
		cout << n[0]; return 0;
	}
	if (tmp < m) {
		cout << n[tmp]; return 0;
	}
}


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

typedef long long int llint;

int main()
{
  int mas[4][4];
  bool flg = false;

  for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) cin>> mas[i][j];

  for(int i = 0; i <= mas[0][0]; i++) {

    int j = mas[0][0] - i;
    int jj = mas[0][1] - i;
    int jjj = mas[0][2] - i;
    int ii = mas[1][0] - j;
    int iii = mas[2][0] - j;

    if(ii + jj == mas[1][1] && ii + jjj == mas[1][2] &&
       iii + jj == mas[2][1] && iii + jjj == mas[2][2]) flg = true;

    if(flg) break;

  }

  cout<< (flg ? "Yes" : "No") <<endl;

  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    
    if(N==1){
    	cout << 1 << endl;
    	cout << 1 << endl;
    }else if(N==2){
    	cout << 2 << endl;
    	cout << 0 << endl;
    	cout << 11 << endl;
    }else{
    	cout << N-1 << endl;
    	REP(i, N-1){
    		cout << 1;
    		REP(j, i) cout << 0;
    		cout << 1 << endl;
    	}
    }
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
ll a[3];
ll k;
cin >>a[0]>>a[1]>>a[2]>>k;
sort(a,a+3);
ll sum=0;
sum=a[0]+a[1];
ll ave=a[2];
for(ll i=0;i<k;i++){
ave=ave*2;
}
cout<<ave+sum;
return 0;

}

Measured memory_bytes: 256
#include <iostream>

int main() {
    int W, H, N;
    std::cin >> W >> H >> N;
    int x1 = 0, x2 = W, y3 = 0, y4 = H;
    for (int i = 0; i < N; i++) {
        int x, y, a;
        std::cin >> x >> y >> a;
        if (a == 1) x1 = std::max(x1, x);
        if (a == 2) x2 = std::min(x2, x);
        if (a == 3) y3 = std::max(y3, y);
        if (a == 4) y4 = std::min(y4, y);
    }

    if (x2 < x1 || y4 < y3)
        std::cout << "0\n";
    else
        std::cout << (x2 - x1) * (y4 - y3) << "\n";

    return 0;
}


Measured memory_bytes: 3580