akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> a(n + 1, vector<int>(n + 1));
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    a[l][r]++;
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      a[i + 1][j + 1] += a[i + 1][j];
    }
  }

  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    int m = 0;
    for (int j = l; j <= r; j++) {
      m += a[j][r];
    }
    cout << m << endl;
  }
}

Measured memory_bytes: 1920
import std.array;
import std.range;
import std.algorithm;
import std.conv;
import std.stdio;
import std.string;
import std.traits;
import std.ascii;


class Solver {
  private int[char] hash;
  private bool firstUpdate = true;

  public this() {
    foreach(c; lowercase) {
      hash[c] = 0;
    }
  }

  public void updateState(string str) {
    if(firstUpdate) {
      foreach(c; str) {
        hash[c]++;
      }
    } else {
      int[char] tempHash;
      foreach(c; lowercase) {
        tempHash[c] = 0;
      }
      foreach(c; str) {
        tempHash[c]++;
      }
      foreach(c; lowercase) {
        hash[c] = min(tempHash[c], hash[c]);
      }      
    }
    firstUpdate = false;
  }

  public string ans() {
    string ans;
    foreach(c; lowercase) {
      ans ~= c.repeat().take(hash[c]).array;
    }
    return ans;
  }
}


void main(string[] args) {
  auto a = new Solver();
  int n = readln.chomp.to!int;
  foreach(i; iota(n)) {
    a.updateState(readln.chomp);
  }
  a.ans.writeln;
}

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

int main(){
    int n,y,m,d;
    cin >> n;
    while(n--){
        int days = 0;
        cin >> y >> m >> d;
        if(y%3 == 0) days += 20 * (11-m) - d;
        else {
            days += 20 * ((10-m)/2) + 19 * (10-m-(10-m)/2);
            days += (m%2 == 0)? 19-d:20-d;
        }
        for(int i=y+1;i<1000;i++) days += (i%3==0)? 200:195;
        days++;
        cout << days<< endl;
    }
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
using namespace std;
//#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100;
//ここまでテンプレ
int main(){
	int N,count=0;
	cin>>N;
	vint ans;
	vint two,three,six;
	for(int i=1;i<=30000;i++){
		if(i%2==0 && i%3)
			two.pb(i);
		if(i%3==0 && i%2)
			three.pb(i);
		if(i%6==0)
			six.pb(i);
	}
	if(N>=15000){
		for(int i:two){
			ans.pb(i);
			count++;
		}
		for(int i:three){
			ans.pb(i);
			count++;
		}
		for(int i:six){
			if(count==N)
				break;
			ans.pb(i);
			count++;
		}
		for(int i=0;i<ans.size()-1;i++)
			cout<<ans[i]<<" ";
		cout<<ans.back()<<endl;
		
		ll sss=0;
		for(int i:ans)
			sss+=i;
		//cout<<ans.size()<<" "<<sss<<endl;
		return 0;
	}
	if(N==3){
		cout<<"2 5 63"<<endl;
		return 0;
	}
	int TWO=0,THREE=0;
	ll STWO=0,STHREE=0;
	while(1){
		for(TWO+=1;1;TWO++){
			ans.pb(two[TWO]);
			count++;
			STWO+=two[TWO];
			if(STWO%6==0)
				break;
		}
		int tend=THREE+2;
		for(THREE;THREE<tend;THREE++){
			ans.pb(three[THREE]);
			count++;
		}
		if(count>=N-5000){
			for(int i=0;i<=5000;i++){
				if(count==N)
					goto next;
				ans.pb(six[i]);
				count++;
			}
		}
	}
	next:
	for(int i=0;i<ans.size()-1;i++)
		cout<<ans[i]<<" ";
	cout<<ans.back()<<endl;

	ll sss=0;
	set<int> tes;
	for(int i:ans){
		sss+=i;
		tes.insert(i);
	}
	//cout<<sss<<" "<<sss%6<<" "<<ans.size()<<" "<<tes.size()<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <cassert>

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)

using namespace std;

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

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ll k;
	cin >> k;
	vll vec;
	ll all = k / 50;
	for (int i = 0; i < 50; i++) vec.push_back(49 + all);	
	ll m = k % 50;
	if (m != 0) {
		for (int i = m; i < 50; i++) vec[i] -= m;
		for (int i = 0; i < m; i++) vec[i] += 50 - (m - 1);
	}
	cout << vec.size() << endl;
	for (int i = 0; i < vec.size(); i++) cout << vec[i] << " ";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
arr=Array.new
loop do
key=gets.chomp
if key=="-" then break end
t=gets.to_i
t.times do
    x=gets.to_i
    if x<key.length && x>0 then
    key=(key[x..key.length-1]+key[0..x-1])
    end
end
arr.push(key)
end
arr.each { |e|
    printf("%s\n",e)
}

Measured memory_bytes: 8644
import Control.Applicative
import Control.Monad
import Data.List
import Data.Vector.Unboxed (Vector, (!), (//))
import qualified Data.Vector.Unboxed as V
import Data.Sequence ((<|), (|>), (><), ViewL(..), ViewR(..), Seq)
import qualified Data.Sequence as Sq

main :: IO ()
main = do
  [t, n] <- f
  unless (t == 0 && n == 0) $ do
    solve t <$> replicateM n (g <$> f) <*> (g <$> f) >>= print
    main
  where
    f = map read <$> words <$> getLine
    g [x, y] = (x, y)

solve :: Int -> [(Int, Int)] -> (Int, Int) -> Int
solve t sps bp = let iv = V.replicate (123 ^ 2) (-1) // ((toIdx bp, 0) : [(i, -2)| i <- map toIdx sps]) :: Vector Int
                     iq = Sq.singleton bp
                 in loop iq iv 0
  where
    loop q v ct = case Sq.viewl q of
      EmptyL -> ct
      (x, y) :< rq -> let bst = v ! (toIdx (x, y))
                          nps = [(nx, ny) | bst < t,
                                            (dx, dy) <- [(1,0),(-1,0),(0,1),(0,-1),(1,1),(-1,-1)],
                                            let (nx, ny) = (x + dx, y + dy),
                                            v ! (toIdx (nx, ny)) == (-1)]
                          nq = foldl' (|>) rq nps
                          nv = v // [(i, bst+1) | i <- map toIdx nps]
                      in loop nq nv (ct + 1)

toIdx (x, y) = let (x', y') = (x + 61, y + 61)
               in x' + 123 * y'



Measured memory_bytes: 16072
#include<cstdio>
#include<cmath>
#define reg register
typedef long long ll;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
static char buf[100000],*p1=buf,*p2=buf;
inline ll read(void){
	reg bool f=false;
	reg char ch=getchar();
	reg ll res=0;
	while(ch<'0'||'9'<ch)f|=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')res=10*res+ch-'0',ch=getchar();
	return f?-res:res;
}

ll n;

int main(void){
	reg ll i;
	n=read();
	for(i=ceil(sqrt(n));i>=1;--i)
		if(n%i==0){
			printf("%lld\n",i-1+(n/i)-1);
			break;
		}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
    }
  }
  bool ans = true;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#'){
        bool u=true,d=true,r=true,l=true;
        if(i>0)if(s[i-1][j]!='#') u=false;
        if(i<h-1)if(s[i+1][j]!='#') d=false;
        if(j>0)if(s[i][j-1]!='#') l=false;
        if(j<w-1)if(s[i][j+1]!='#') r=false;
        if(u+d+l+r==0){
          ans=false;
          break;
        }
      }
    }
  }
  puts(ans?"Yes":"No");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int a;
	long b;
} s;

int compare(const void *x, const void *y)
{
	return ((s*)x)->a - ((s*)y)->a;
}

int main(void)
{
	int N, ans, i;
	long K, sum = 0;
	s array[100000];
	scanf("%d%ld", &N, &K);
	for (i = 0; i < N; ++i) scanf("%d%ld", &array[i].a, &array[i].b);
	qsort(array, N, sizeof(s), compare);
	for (i = 0; sum < K; ++i) {
		sum += array[i].b;
		ans = array[i].a;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 3324
#include <iostream>
int main() {
	int a, b, c, d, e, ans;
	std::cin >> a >> b >> c >> d >> e;
	if (a < 0) {
		ans = (0 - a)*c + b*e + d;
		std::cout << ans << std::endl;
	}
	else {
		ans = (b - a)*e;
		std::cout << ans << std::endl;
	}




}


Measured memory_bytes: 3112
from collections import deque
def solve():
    H,W = map(int,input().split())
    Ch,Cw = map(lambda x:int(x)-1,input().split())
    Dh,Dw = map(lambda x:int(x)-1,input().split())
    A = [list(input()) for _ in range(H)]
    V = [[-1]*W for _ in range(H)]
    d = ((1,0),(0,1),(-1,0),(0,-1))

    def bfs_2d(sy,sx,v):
        que = deque()
        V[sy][sx] = v
        que.append((sy,sx))

        while que:
            uh, uw = que.popleft()
            for dy, dx in d:
                next_h = uh+dy
                next_w = uw+dx
                if 0 <= next_h < H and 0 <= next_w < W \
                    and A[next_h][next_w] == '.' \
                    and V[next_h][next_w] == -1:
                    V[next_h][next_w] = v
                    que.append((next_h,next_w))
    
    vertex = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] == '#' or V[h][w] != -1:
                continue
            bfs_2d(h,w,vertex)
            vertex += 1

    G = [[] for _ in range(vertex)]
    used = [set() for _ in range(vertex)]
    for h in range(H):
        for w in range(W):
            if A[h][w] == '#':
                continue
            for dh in range(-2, 2+1):
                for dw in range(-2, 2+1):
                    if h + dh < 0 or H <= h + dh or w + dw < 0 or W <= w + dw:
                        continue
                    if A[h+dh][w+dw] == "#":
                        continue
                    if V[h][w] == V[h+dh][w+dw]:
                        continue
                    if V[h+dh][w+dw] in used[V[h][w]]:
                        continue
                    G[V[h][w]].append((V[h+dh][w+dw]))
                    used[V[h][w]].add((V[h+dh][w+dw]))
    
    # s = V[Ch][Cw]
    # g = V[Dh][Dw]

    # dist = [-1 for _ in range(vertex)]
    # que = deque()
    # dist[s] = 0
    # que.append(s)
    # while que:
    #     u = que.popleft()
    #     for v in G[u]:
    #         if dist[v] != -1:
    #             continue
    #         dist[v] = dist[u] + 1
    #         que.append(v)
    
    # print(dist[g])

    start_area_num = int(V[Ch][Cw])
    goal_area_num = int(V[Dh][Dw])

    visited = [False] * vertex

    q = deque()
    q.append((start_area_num,0))
    while len(q) > 0:
        cur_area_num, warp_cnt = q.popleft()
        if cur_area_num == goal_area_num:
            print(warp_cnt)
            return
        
        for next_area_num in G[cur_area_num]:
            if not visited[next_area_num]:
                visited[next_area_num] = True
                q.append((next_area_num, warp_cnt+1))
    else:
        print(-1)

if __name__ == '__main__':
    solve()


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

int main() {
  int a,b; cin >> a >> b;
  if(a+b<10)cout << a+b << endl;
  else cout << "error" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
const int M=1e5+5;
int s[M];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(register int i=1;i<=m;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		s[l]++; s[r+1]--;
	}
	int ans=0;
	for(register int i=2;i<=n;i++) s[i]+=s[i-1];
	for(register int i=1;i<=n;i++){
		if(s[i]==m) ans++; 
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define randomINIT mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define ld long double
#define pll pair<ll,ll>
#define vll vector<pll>
#define vl vector<ll>
#define f first
#define s second
#define pb push_back
#define MAP map<ll,ll>
#define MAPs map<<ll,sl>
#define MAPv map<ll,vl>
#define mset1(x,val) foo(i,0,n+5) x[i]=val;
#define mset2(x,val) foo(i,0,n+5) foo(j,0,n+5) x[i][j]=val;
#define mod 1000000007
#define foo(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,a,b) for(ll i=(a);i>=(b);i--)
#define FOR(i,v) for(auto &(i):(v))
#define OUTv(v) for(auto &i:(v)) cout<<i<<" ";
#define deb1(a) cout<<a<<"\n";
#define deb2(a,b) cout<<a<<" "<<b<<"\n";
#define deb3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define deb4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define sl set<ll> 
#define sll set<pll>
#define ub upper_bound
#define lb lower_bound
using namespace std;

const ll   INF = 0x7f7f7f7f7f7f7f7f;
const ll NINF = -INF;
const ll MAXN  = 1e+6+8;

int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll t=1;randomINIT;
//<<-----Declare Variable Here------->>//
ll k,a,b;
 
//<<-----Implement Functions Here---->>//
 
 
//<<-----Start of Main--------------->>//
void MAIN(){
	cin>>k>>a>>b;
	ll x=ceil((long double)a/k);
	if(x*k<=b) cout<<"OK";
	else cout<<"NG";

}

int main(){
	fastio;
	// cin>>t;
	while(t--){
		MAIN();
	}
 
    // #ifndef ONLINE_JUDGE
    // cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    // #endif
}

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

using namespace std;

typedef long long int lli;

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

    lli n, m;
    pair<lli, lli> store[100000];

    cin >> n >> m;
    for (int i=0; i<n; i++) {
        cin >> store[i].first >> store[i].second;
    }

    sort(store, store+n);

    lli ans = 0;
    for (int i=0; m>0; i++) {
        if (store[i].second >= m) {
            ans += store[i].first * m;
            m = 0;
        }
        else {
            ans += store[i].first * store[i].second;
            m -= store[i].second;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1920
import math
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
A=[]
a=b=0
for i in range(1,n+1):
  A.append(i)
B=A.copy()
for i in range(n):
  a=a+A.index(p[i])*math.factorial(n-i-1)
  b=b+B.index(q[i])*math.factorial(n-i-1)
  A.remove(p[i])
  B.remove(q[i]) 
print(abs(a-b))

Measured memory_bytes: 3064
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, C, K): (usize, usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let T: Vec<usize> = (0..N)
        .map(|_| {
                let mut line: String = String::new();
                std::io::stdin().read_line(&mut line).unwrap();
                line.trim().parse().unwrap()
        })
        .collect();

    let S = {
        let mut S = T.clone();
        S.sort();
        S
    };
    let (ans, _, _) = S[1..].iter().fold((1, S[0], 1), |(res, x, y), &t| {
        if t > x + K || y == C { (res + 1, t, 1) } else { (res, x, y + 1) }
    });

    println!("{}", ans);
}

Measured memory_bytes: 6396
using System;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var text = Console.ReadLine();

			var num = int.Parse(text);

			switch(num % 10)
			{
				case 2:
				case 4:
				case 5:
				case 7:
				case 9:
					Console.WriteLine("hon");
					break;
				case 0:
				case 1:
				case 6:
				case 8:
					Console.WriteLine("pon");
					break;
				case 3:
					Console.WriteLine("bon");
					break;
			}
		}
	}
}


Measured memory_bytes: 27548
#include<bits/stdc++.h>
#define Mod 1000000007
#define ll long long
#define reg register
#define ull unsigned ll
#define int ll
#pragma GCC optimize(3)
#pragma GCC optimize("02")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
class complex{
public:
    inline char gc(){
        static const signed IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> _inline complex & operator >> (_Tp &x){
        static char ch,sgn; ch=gc(),sgn=0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}inc;
int mul(int x){
	return x==1?1:mul(x-1)%Mod*x%Mod;
}
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin>>n>>m;
	if(abs(n-m)>1) return puts("0"),0;
	else if(n==m) printf("%lld\n",2*mul(n)%Mod*mul(m)%Mod);
	else printf("%lld\n",mul(n)%Mod*mul(m)%Mod);
	return 0;
}


Measured memory_bytes: 1152
A = Array.new
b = Array.new
n, m = gets.split.map(&:to_i)
n.times {A << gets.split.map(&:to_i)}
m.times {b << gets.to_i}
  
A.each do |is|
  j = sum = 0
  is.each do |i|
    sum += i * b[j]
    j += 1
  end
  puts sum
end

Measured memory_bytes: 6132
#include <iostream>
#include <algorithm>
using namespace std;
int a[300],ans;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=2*n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+2*n+1);
    for(int i=1;i<=2*n;i++)
    {
        if(i%2==1)
        ans+=a[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

int a, b, c, x, ans;


int main(){
    ios::sync_with_stdio(0);
    cin >> a >> b >> c >> x;

    ans = 0;
    forn(i,a+1){
        forn(j,b+1){
            forn(k,c+1){
                if(500*i + 100*j + 50*k == x){
                    ans++;
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){
  int a; cin >>a;
  vector<int>c(a);
  for(int i=0; i<a; i++){c[i]=0;}

  for(int i=0; i<a-1; i++)
  {int b; cin >>b; c[b-1]++;}

  for(int i=0; i<a; i++)
  {cout <<c[i] <<endl;}

return 0;
}

Measured memory_bytes: 4052
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

ll N,K;

cin >> N >> K;

vector<ll> p(N);

for(ll i = 0;i < N;++i) cin >> p[i];


sort(p.begin(),p.end());

ll ans = 0;

for(ll i = 0;i < K;++i) ans += p[i];

cout << ans << endl;

return 0;

}


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

struct edge {int to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const int INf = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
static const int INF = 1000000000;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define int ll

int countDigit(int a){
    if(a<10) return 1;
    else return (countDigit(a/10)+1);
}

int solve(int n){
    int res = INF;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            res = min(res,max(countDigit(i),countDigit(n/i)));
        }
    }
    return res;
}

signed main(){
    int n;
    scanf("%lld",&n);
    printf("%lld\n",solve(n));
    return 0;
}

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

using namespace std;

int main(void){
long long A;
long long B;
long long K;
long long resultA, resultB;
//int N;
cin >> A;
cin >> B;
cin >> K;
//vector<int> P(N), Q(N);
/*int result = 0;

for(int i = 0; i < N; i++){
  cin >> P.data[i];
}
for(int i = 0; i < N; i++){
  cin >> Q.data[i];
}*/

resultA = A - K;
if(resultA >= 0) resultB = B;
if(resultA < 0){
  resultB = B + resultA;
  resultA = 0;
  if (resultB < 0) resultB = 0;
}
cout << resultA << " " << resultB << endl;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
#include <numeric>
using namespace std;
using ll = long long;

#define no "no"
#define No "No"
#define NO "NO"
#define yes "yes"
#define Yes "Yes"
#define YES "YES"
#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define INF 1e+9
#define PI acos(-1)
#define TAU PI * 2
#define EPS 0.00000001
const ll MOD = 998244353;

int main() {
    int n;
    cin >> n;
    map<ll, int> mp;
    ll cnt = 0;
    rep(i, n){
        ll a;
        cin >> a;
        cnt += mp[i - a];
        mp[i + a]++;
    }

    println(cnt);
}

Measured memory_bytes: 26152
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 1000005, inf = 1000000000;
int n, f[N][2];
char str[N];

int main () {
	scanf("%s", str), n = strlen(str);
	f[0][0] = 0, f[0][1] = 1;
	for (int i = 0; i < n; i++) {
		int d = str[i] - '0';
		f[i + 1][0] = min(f[i][0] + d, f[i][1] + 10 - d), f[i + 1][1] = inf;
		if (d < 9) f[i + 1][1] = min(f[i + 1][1], f[i][0] + d + 1);
		if (d) f[i + 1][1] = min(f[i + 1][1], f[i][1] + 9 - d);
	}
	printf("%d\n", f[n][0]);
	return 0;
}

Measured memory_bytes: 9088
import java.util.Scanner;

class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		int n;
		n = scan.nextInt();
		
		Button b[] = new Button[n];
		for(int i = 0; i < n; i++){
			b[i] =  new Button();
			b[i].next = scan.nextInt()-1; 
		}
		
		scan.close();
		int next = 0;
		int count = 0;
		
		while(true){
			b[next].flag = false;
			next = b[next].next;
			count++;
			if(next == 1){
				System.out.print(count);
				break;
			}
			if(!b[next].flag){
				System.out.print("-1");
				break;
			}
		}
	}
}
class Button{
	int next;
	Boolean flag = true;
}

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

int main() {
    int n, x; std::cin >> n >> x;
    std::vector<int> v(n);
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }
    std::sort(v.begin(), v.end());
    int cnt = 0;
    int i = 0;
    for (; i < n; i++) {
        if (x <v[i]) {
            break;
        }
        x -= v[i];
        cnt++;
    }
    if (i >= n && x > 0) {
        cnt--;
    }
    std::cout << cnt << std::endl;
    return 0;
}

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

namespace _2013
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                int[] imos = new int[100000];
                for (int i = 0; i < n; i++)
                {
                    int[] x = Console.ReadLine().Split(' ',':').Select(int.Parse).ToArray();
                    imos[x[0] * 3600 + x[1] * 60 + x[2]]++; imos[x[3] * 3600 + x[4] * 60 + x[5]]--;
                }
                int sum = 0; int ret = 0;
                for (int i = 0; i < 100000; i++)
                {
                    sum += imos[i];
                    ret = Math.Max(ret,sum);
                }
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 10928
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

ll gcd(ll x, ll y) {
  if (x%y == 0) {
    return y;
  }
  else {
    return gcd(y, x%y);
  }
}
ll lcm(ll x, ll y) {
  return x*y/gcd(x, y);
}

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  //BまででCかDで割り切れるやつ
  ll outB = B/C + B/D - B/lcm(C, D);
  ll okB = B - outB;
  ll outA = (A-1)/C + (A-1)/D - (A-1)/lcm(C, D);
  ll okA = A-1 - outA;
  cout << okB-okA << endl;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
alist=list(map(int,input().split()))

max_len = len(format(K, 'b'))
for a in alist:
  max_len = max(max_len, len(format(a, 'b')))

bin_K_str = format(K, '0'+str(max_len)+'b')
#print(bin_K_str)

a0list=[0]*max_len
a1list=[0]*max_len
for a in alist:
  bin_a_str = format(a,  '0'+str(max_len)+'b')
  
  for i in range(max_len):
    a_bit = bin_a_str[i]
    if a_bit == "0":
      a0list[i] += 1
    elif a_bit == "1":
      a1list[i] += 1
#print(a0list)
#print(a1list)

minor_list = ["-1"]*max_len
for i in range(max_len):
  if a0list[i] > a1list[i]:
    minor_list[i] = "1"
  else:
    minor_list[i] = "0"
#print(minor_list)

equal = True
dp_str = ""
for i in range(max_len):
  if not equal:
    dp_str += minor_list[i]
  else:
    if bin_K_str[i] == "1":
      if minor_list[i] == "0":
        dp_str += "0"
        equal = False
      else:
        dp_str += "1"
    else:
      dp_str += "0"
#print(dp_str)

argmax = int(dp_str,2)
#print(argmax)

fmax=0
for a in alist:
  fmax += argmax ^ a
  
print(fmax)


Measured memory_bytes: 14836
#include <iostream>
#include <string>

using namespace std;

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

		int odd_w = 0, odd_b = 0, even_w = 0, even_b =0;
		for (int i = 0; i < S.size(); i++) {
				if (i % 2) {
						if (S[i] == '1') odd_w++;
						else odd_b++;
				} else {
						if (S[i] == '1') even_w++;
						else even_b++;
				}
		}
		
		cout << min(even_b + odd_w, even_w + odd_b) << endl;
		return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  int n;
  cin >> n;
  vector<vector<int>> F(n,vector<int>(10,0));
  // vector<vector<vector<int>>> F(n,vector<vector<int>>(5,vector<int>(2,0)));
  rep(i,n)rep(j,10)cin>>F.at(i).at(j);
  vector<vector<int>> P(n,vector<int>(11));
  rep(i,n)rep(j,11)cin>>P.at(i).at(j);


  ll res = -(1<<30);
  for(int bit = 1; bit < (1<<10); bit++){
    int cc = 0;
    for(int i = 0 ; i < n; i++){
      int c = 0;
      for(int j = 0; j < 10; j++){
        if((bit>>j&1)&&F.at(i).at(j))c++;
      }
      cc+=P.at(i).at(c);
    }
    //cout<<cc<<endl;
    if(res<cc)res=cc;
  }
  cout<<res<<endl;
  return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

template <ll mod>
class modint
{
public:
    constexpr modint(ll value = 0) : _value(value >= 0 ? value % mod : (value % mod) + mod) {}

    constexpr modint operator+() const { return *this; }
    constexpr modint operator-() const { return modint(-_value); }

    constexpr modint &operator+=(const modint &rhs) {
        if ((_value += rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint &rhs) {
        if ((_value += mod - rhs._value) >= mod) _value -= mod;
        return *this;
    }
    constexpr modint &operator*=(const modint &rhs) {
        (_value *= rhs._value) %= mod;
        return *this;
    }
    constexpr modint &operator/=(const modint &rhs) {
        *this *= rhs.inv();
        return *this;
    }
    constexpr modint operator+(const modint &rhs) const { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const { return modint(*this) /= rhs; }

    constexpr modint operator++() { *this += 1; return *this; }
    constexpr modint operator--() { *this -= 1; return *this; }
    constexpr modint operator++(int) { modint tmp = *this; ++*this; return tmp; }
    constexpr modint operator--(int) { modint tmp = *this; --*this; return tmp; }

    constexpr bool operator==(const modint &rhs) const { return _value == rhs._value; }
    constexpr bool operator!=(const modint &rhs) const { return _value != rhs._value; }

    constexpr modint inv() const {
        ll a = _value, b = mod, u = 1LL, v = 0LL;
        while (b > 0) {
            ll tmp = a / b;
            a -= tmp * b; swap(a, b);
            u -= tmp * v; swap(u, v);
        }
        return modint(u);
    }

    constexpr modint pow(ll n) const {
        modint e = *this, res = 1;
        while (n) {
            if (n & 1) res *= e;
            e *= e, n >>= 1;
        }
        return res;
    }

    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m._value;
        return os;
    }

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }

private:
    ll _value;
};
using mint = modint<1000000007>;

int n, k;
vector<int> g[100000];
bool visited[100000];

mint dfs(int i, int choice, int depth)
{
    mint res = choice;
    visited[i] = true;

    int rest = k - min(depth + 1, 2);
    for (auto &j: g[i]) {
        if (visited[j]) continue;
        res *= dfs(j, rest--, depth + 1);
    }
    return res;
}

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

    cin >> n >> k;
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        g[a].emplace_back(b), g[b].emplace_back(a);
    }

    cout << dfs(0, k, 0) << endl;; 
    return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long D, long long N)
{
    if (N != 100)
    {
        cout << (int)pow(100, D) * N << endl;
    }
    else
    {
        cout << (int)pow(100, D) * (N + 1) << endl;
    }
}

int main()
{
    long long D;
    scanf("%lld", &D);
    long long N;
    scanf("%lld", &N);
    solve(D, N);
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(a % 2 != 0 && b % 2 != 0 ? "Yes" : "No");
  }

}


Measured memory_bytes: 21716
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

queue<pair<int,int> > q;
int n,m;
int w[205][205];
int d[205][205];
int f[205][205];
char op;
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0};
int sx,sy;

void bfs(int x,int y)
{
	pair<int,int> now,temp;
	now = make_pair(x,y);
	d[x][y] = 0;
	q.push(now);
	int nx,ny;
	while (!q.empty())
	{
		now = q.front();
		q.pop();
		x = now.first;
		y = now.second;
		for (int i=0;i<4;i++)
		{
			nx = x+dx[i];
			ny = y+dy[i];
			if (d[nx][ny] > d[x][y]+1 && w[nx][ny])
			{
				d[nx][ny] = d[x][y]+1;
				temp = make_pair(nx,ny);
				q.push(temp);
			}
		}
	}
}

bool solve(int x,int y)
{
	pair<int,int> now,temp;
	f[x][y] = 0;
	now = make_pair(x,y);
	q.push(now);
	int nx,ny;
	while (!q.empty())
	{
		now = q.front();
		q.pop();
		x = now.first;
		y = now.second;
		if (w[x][y] == 5) return 1;
		for (int i=0;i<4;i++)
		{
			nx = x+dx[i];
			ny = y+dy[i];
			if (w[nx][ny] == 0 || f[nx][ny] != f[0][0]) continue;
			f[nx][ny] = f[x][y]+1;
			if (f[nx][ny] < d[nx][ny])
			{
				temp = make_pair(nx,ny);
				q.push(temp);
			}
		}
	}
	return 0;
}

int main()
{
	scanf("%d%d",&n,&m);
	memset(w,0,sizeof(w));
	memset(d,0x3f,sizeof(d));
	memset(f,0x3f,sizeof(f));
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			scanf(" %c",&op);
			if (op == '@')
			{
				w[i][j] = 4;
				sx = i;
				sy = j;
			}
			if (op == '%')
			{
				w[i][j] = 5;
			}
			if (op == '$')
			{
				w[i][j] = 2;
			}
			if (op == '.')
			{
				w[i][j] = 1;
			}
		}
	}
/*	printf("n=%d m=%d\n",n,m);
	for (int i=0;i<=n+1;i++)
	{
		for (int j=0;j<=m+1;j++)
			printf("%d",w[i][j]);
		printf("\n");
	}*/

	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			if (w[i][j] == 2)
			{
				bfs(i,j);
			}
		}
	}

	if (solve(sx,sy))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 3728
n = int(input())
x = list(map(int, input().split()))

min_hp = float('inf')

for i in range(min(x), max(x) + 1):
    hp = 0
    for xi in x:
        hp += abs(i - xi) ** 2
    if hp < min_hp:
        min_hp = hp

print(min_hp)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<algorithm>
typedef long long ll;
int main() {
	int n,dig = 0;
	int a = 0, b = 0;
	int ak = 0, bk = 0;
	int sum = 999999999;
	std::cin >> n;
	if (n > 11) {
		for (int i = 1; i < n / 2; i++) {
			dig = 0;
			a = i;
			while (a) {
				dig = a % 10;
				ak = ak + dig;
				a = a / 10;
			}
			b = n - i;
			dig = 0;
			while (b) {
				dig = b % 10;
				bk = bk + dig;
				b = b / 10;
			}
			sum = std::min(ak + bk, sum);
			ak = 0;
			bk = 0;
		}
	}
	else {
		std::cout << n << std::endl;
		return 0;
	}
	std::cout << sum << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    string s;
    cin >> s;
    if (s == "Sunny")
        cout << "Cloudy" << endl;
    else if (s == "Cloudy")
        cout << "Rainy" << endl;
    else if (s == "Rainy")
        cout << "Sunny" << endl;
    return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	rep(i, 0, 3) {
		int h, m, s; cin >> h >> m >> s;
		int in = s + 60 * m + h * 3600;
		cin >> h >> m >> s;
		int out = s + 60 * m + h * 3600;
		int ans = abs(in - out);
		h = ans / 3600;
		ans %= 3600;
		m = ans / 60;
		ans %= 60;
		cout << h << " " << m << " " << ans << endl;
	}
	return 0;
}

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

using namespace std;

typedef pair<int, int> iip;

vector<iip> point;
int D, x, y;

int solve(int idx, int d)
{
  if(d <= 0) return 0;
  if(idx == point.size()) return 0;
  
  if(d >= point[idx].first) 
    return max(solve(idx+1, d), solve(idx+1, d-point[idx].first) + point[idx].second);
  else return solve(idx+1, d);
}

int main()
{
  cin >> D;
  cin >> x;
  for(int i = 0; i < x; i++){
    string a;
    int p;
    cin >> a >> p;
    point.push_back(iip(1, p*(a == "D")));
  }
  cin >> y;
  for(int i = 0; i < y; i++){
    string b;
    int q;
    cin >> b >> q;
    point.push_back(iip(1, 0));
    point.push_back(iip(2, q*(b=="DD")));
  }
  cout << solve(0, D) << endl;
  return 0;
}

Measured memory_bytes: 1216
# AtCoder Beginner Contest 175
# C - Walking Takahashi

X,K,D =map(int,input().split())

X=abs(X)

q=X//D
r=X%D

if K<=q:
    print(X-K*D)
    exit()

else :
    if (K-q)%2==0:
        print(r)
    else :
        print(abs(r-D))

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

using namespace std;

const int dim = (int) (1e5) + 1;

int n, m, p[dim], wa[dim], c, pe;
bool ac[dim];
char s[dim][5];

int main()
{
    cin>>n>>m;
    for(int i = 1;i <= m;i++)
    {
        cin>>p[i]>>s[i];
    }
    for(int i = 1;i <= m;i++)
    {
        if(!ac[p[i]])
        {
            if(strcmp(s[i], "AC") == 0)
            {
                ac[p[i]]++;
            }
            else
            {
                wa[p[i]]++;
            }
        }
    }
    for(int i = 1;i <= n;i++)
    {
        if(ac[i])
        {
            c++;
            pe += wa[i];
        }
    }
    cout<<c<<' '<<pe;
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    ll sum[n+1];
    sum[0] = 0;
    rep(i, n){
        sum[i+1] = sum[i] + a[i];
    }

    map<ll, ll> mp;
    reps(i, 0, n+1){
        mp[ sum[i] ]++;
    }

    ll ans = 0;
    for(auto x: mp){
        if(x.second < 2) continue;

        ans += x.second*(x.second-1)/2;
    }

    cout << ans << endl;

    return 0;
}

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

void Main() {
    string s;
    cin >> s;
    if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}

Measured memory_bytes: 256
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
ans=0
for i in b:
    A=bisect.bisect_left(a,i)
    B=len(b)-bisect.bisect_right(c,i)
    ans+=A*B
print(ans)

Measured memory_bytes: 29316
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  int N, W; cin >> N >> W;
  int w[N], v[N]; rep(i,N) cin >> w[i] >> v[i];

  vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
  
  rep(i,N) rep(j,W+1){  // 配るDP
    if (j+w[i]<=W) chmax(dp[i+1][j+w[i]], dp[i][j]+v[i]);  // 選ぶ場合
    chmax(dp[i+1][j], dp[i][j]);  // 選ばない場合
  }
  cout << dp[N][W] << endl;


 

  // cout << fixed << setprecision(10);
  
  return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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; }

bool temp(pair<ll,int> a, pair<ll,int> b) {
	if(a.fi > b.fi) return true;
	else return false;
}
int main() {
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	vector<pair<ll, int>> p(a);
	ll ta,tb,tc;
	rep(i,a) {
		cin >> ta;
		p.pb(pair<ll,int>(ta, 0));
	}
	rep(i,b) {
		cin >> tb;
		p.pb(pair<ll,int>(tb, 1));
	}
	rep(i,c) {
		cin >> tc;
		p.pb(pair<ll,int>(tc, 2));
	}
	sort(p.begin(), p.end(), temp);

	ll ans=0;
	ll t = x+y;
	auto itr = p.begin();
	while (t > 0) {
		if (itr->second == 0 && x > 0) {
			x--;
		}
		else if(itr->second == 0 && x == 0)  {
			itr++;
			continue;
		}
		if (itr->second == 1 && y > 0) {
			y--;
		}
		else if(itr->second == 1 && y == 0) {
			itr++;
			continue;
		}
		ans += itr->first;
		//cout << itr->first << " ";
		itr++;
		t--;
	}
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8292
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h, w, n; cin >> h >> w >> n;
    int num = max(h,w);
    int cnt = 0;
    int ans = 0;
    while(ans<n) {
        ans += num;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;

const ll inf = 1LL<<50;


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

    int n; scanf("%d", &n);
    vector<int> a(n), b(n);
    for(int i=0; i<n; ++i) scanf("%d", &a[i]);
    for(int i=0; i<n; ++i) scanf("%d", &b[i]);

    int ans = 0;
    for(int k=28; k>=0; --k){
        int T = 1<<k;
        for(int i=0; i<n; ++i) { a[i]%=2*T, b[i]%=2*T; }
        sort(b.begin(), b.end());
        ll cnt = 0;
        for(int i=0; i<n; ++i){
            cnt += lower_bound(b.begin(), b.end(), 2*T-a[i]) - lower_bound(b.begin(), b.end(), T-a[i]);
            cnt += lower_bound(b.begin(), b.end(), 4*T-a[i]) - lower_bound(b.begin(), b.end(), 3*T-a[i]);
        }
        if(cnt%2 == 1) ans += T;
    }
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define R cin>>
#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 INF 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long unsigned int ll;;
int main(){
    string s;
    R s;
    sort(all(s));
    if (s=="abc") printf("%s", &"Yes");
    else printf("%s", &"No");
    return 0;
}


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

using namespace std;

int main(void)
{
	int x, y;
	cin >> x >> y;
	int a, b, c;
	cin >> a >> b >> c;
	vector<pair<long long, int>> apple(a + b + c);
	int i;
	for (i = 0; i < a; i++) {
		cin >> apple[i].first;
		apple[i].second = 0;
	}
	for (; i < a + b; i++) {
		cin >> apple[i].first;
		apple[i].second = 1;
	}
	for (; i < a + b + c; i++) {
		cin >> apple[i].first;
		apple[i].second = 2;
	}
	sort(apple.begin(), apple.end());
	
	long long ans = 0;
	int s = 0, t = 0, u = 0;
	i = apple.size() - 1;
	while (s + t + u < x + y) {
		switch (apple[i].second) {
		case 0:
			if (s < x) {
				ans += apple[i].first;
				s++;
			}
			break;
		case 1:
			if (t < y) {
				ans += apple[i].first;
				t++;
			}
			break;
		case 2:
			ans += apple[i].first;
			u++;
			break;
		}
		i--;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4992