akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <complex>
#include <cstring>
#include <cassert>
#include <bitset>

using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, a, b) for(int i = (a); i > (b); i--)
#define forIt(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define ft(a) __typeof((a).begin())
#define ll long long
#define ld long double
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define bitcount(n) __builtin_popcountll(n)
#define randchar() ((rand() % 26) + 'a')


typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int N = 200000 + 7;
const int M = 1000000;
const ll MM = 1ll * M * M;
const int inf = 1e9 + 7;
const long long linf = 1ll * inf * inf;
const double pi = acos(-1);
const double eps = 1e-7;
const bool multipleTest = 0;

int n, m;
vi adj[N];
int depth[N];
int q[N], top;

void solve() {
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1; i <= n; ++i) depth[i] = -1;
	depth[1] = 0;
	q[top++] = 1;
	for (int i = 0; i < top; ++i) {
		int u = q[i];
		if (depth[u] >= 2) continue;
		for (int v : adj[u]) {
			if (depth[v] == -1) {
				depth[v] = depth[u] + 1;
				q[top++] = v;
			}
		}
	}
//	for (int i = 1; i <= n; ++i) cout << i << ' ' << depth[i] << '\n';
	if (depth[n] != -1) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	
}

int main() {
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin);
	//	freopen("out.txt", "w", stdout);
#endif
	int Test = 1;
	if (multipleTest)
		cin >> Test;
	for(int i = 0; i < Test; ++i) {
		solve();
	}
	
#ifdef _LOCAL_
	cout<<"\n" << 1.0 * clock() / CLOCKS_PER_SEC<<endl;
#endif
}

Measured memory_bytes: 13168
/*input
5 3 7
1
3
6
9
12
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N 100005
// const int INF = 1e18;
const int mod = 1e9 + 7;
#define c(x) ((x)&1)
int n, A, B;
int a[N];
vector<int> updx, updy;
int Tx = 0, Ty = 0;

struct BITsum {
	int tree[N];
	int cur[N];
	BITsum() {
		memset(tree, 0, sizeof(tree));
	}
	void upd(int p, int val) {
		p++; val %= mod;
		int org = cur[p];
		for (int i = p; i <= N - 2; i += i & -i) tree[i] -= org, tree[i] = ((tree[i] % mod) + mod) % mod;
		cur[p] = val;
		for (int i = p; i <= N - 2; i += i & -i) tree[i] += val, tree[i] %= mod;
	}
	void plus(int i, int val) {
		i++;
		cur[i] += val; cur[i] %= mod;
		for (; i <= N - 2; i += i & -i) tree[i] += val, tree[i] %= mod;
	}
	int get(int i) {
		i++;
		int ret = 0;
		for (; i; i -= i & -i) ret += tree[i], ret %= mod;
		return ret;
	}
} dpx, dpy;

void solve1(int i) {
	int l = 0, r = i - 1;
	while (l != r) {
		int mid = (l + r + 1) / 2;
		if (a[i + 1] - a[mid] < B) r = mid - 1;
		else l = mid;
	}
	Ty = dpx.get(l),
	updy.push_back(i);
	if (a[i + 1] - a[i] < A) {
		for (int i = 0; i < updx.size(); i++) dpx.upd(updx[i], 0);
		updx.clear();
	}
}

void solve2(int i) {
	int l = 0, r = i - 1;
	while (l != r) {
		int mid = (l + r + 1) / 2;
		if (a[i + 1] - a[mid] < A) r = mid - 1;
		else l = mid;
	}
	Tx = dpy.get(l);
	updx.push_back(i);
	if (a[i + 1] - a[i] < B) {
		for (int i = 0; i < updy.size(); i++) dpy.upd(updy[i], 0);
		updy.clear();
	}
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> A >> B;
	for (int i = 1; i <= n; i++) cin >> a[i];
	a[0] = -1e9;
	updx.push_back(0); updy.push_back(0);
	dpx.upd(0, 1);
	dpy.upd(0, 1);
	for (int i = 1; i < n; i++) {
		solve1(i);
		solve2(i);
		dpx.upd(i, Tx);
		dpy.upd(i, Ty);
		Tx = 0; Ty = 0;
		updy.push_back(i); updx.push_back(i);
	}
	int ans = dpx.get(N - 2) + dpy.get(N - 2);
	ans %= mod;
	cout << ans << endl;
}

Measured memory_bytes: 7524
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

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

	void solver() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long[] A = new long[N];
		PriorityQueue<Long> pq = new PriorityQueue<>();
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextLong();
			pq.add(-A[i]);
		}
		while (M > 0) {
			long v = -pq.poll();
			v /= 2;
			--M;
			pq.add(-v);
		}
		long ans = 0;
		while (!pq.isEmpty()) {
			long v = -pq.poll();
			ans += v;
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 63080
<?php
fscanf(STDIN, "%d %d %d", $n, $x, $y);
$res=[];
$short = $y - $x - 1;
for ($i=1;$i<$n;$i++) {
  if (!isset($res[$i])) $res[$i]=0;
  for ($j=$i+1;$j<=$n;$j++) {
    $dist = $j - $i;
    if ($i <= $x && $j >= $y) {
      $dist = $dist - $short;
    } else if ($i > $x && $i < $y || $j > $x && $j < $y) {
      $dist_b = abs($x - $i) + 1 + abs($y - $j);
      $dist = min($dist, $dist_b);
    }
    if (!isset($res[$dist])) $res[$dist]=0;
    $res[$dist]++;
  }
}
echo implode("\n", $res);

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

int main(){
string a,b;
cin>>a>>b;
  int c;
  c=a.size();
  vector<char>A(c+1),B(c+1);
  for(int i=0;i<c;i++){
    A[i]=a[i];
    B[i]=b[i];
  }
  A[c]='0';
  B[c]='0';
  for(int i=0;i<c;i++){
    if(A==B){
      cout<<"Yes"<<endl; 
      break;
    }
    for(int j=0;j<c;j++){
    A[c-j]=A[c-j-1];
    }
    A[0]=A[c];
    A[c]='0';
    if(i==c-1){
      cout<<"No"<<endl;
    }
  }
 
 

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if (a * b == 15) System.out.println("*");
        else if (a + b == 15) System.out.println("+");
        else System.out.println("x");
    }
}


Measured memory_bytes: 21844
package main

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

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func solve(grid [][]byte) int {
    H := len(grid)
    W := len(grid[0])
    dp := make([][]int, H)
    for i := range dp {
        dp[i] = make([]int, W)
    }
    dp[0][0] = 1

    hoff := []int{-1,  0}
    woff := []int{ 0, -1}
    for h:=0; h<H; h++ {
        for w:=0; w<W; w++ {
            if grid[h][w] == '#' {
                continue
            }
            for k:=0; k<len(hoff); k++ {
                ph, pw :=h+hoff[k], w+woff[k]
                if ph < 0 || pw < 0 {
                    continue
                }
                dp[h][w] += dp[ph][pw]
                dp[h][w] %= 1000000007
            }
        }
    }

    return dp[H-1][W-1]
}

func readLineNum(bf *bufio.Reader) int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	N, _ := strconv.Atoi(line)
	return N
}

func readLineNums(bf *bufio.Reader) []int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int{}
	for _, field := range fields {
		num, _ := strconv.Atoi(field)
		nums = append(nums, num)
	}
	return nums
}

func readLineStrs(bf *bufio.Reader) []string {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	return strings.Split(line, " ")
}

func main() {
	bf := bufio.NewReader(os.Stdin)
	hw := readLineNums(bf)
    H, _ := hw[0], hw[1]
    grid := make([][]byte, H)
    for h:=0; h<H; h++ {
        strs := readLineStrs(bf)
        grid[h] = []byte(strs[0])
    }
    fmt.Println(solve(grid))
}


Measured memory_bytes: 13332
# include "iostream"
# include "cstdio"
# include "queue"

using namespace std;

const int maxm=1e5+10;
const long long Inf=1ll<<50;

int head[maxm],tot=1,N,Cnt,S,T;
int Deep[maxm];
long long A[maxm];

struct edge{
	int To;
	int Next;
	long long Value;
	# define To(x) Edge[x].To
	# define Next(x) Edge[x].Next
	# define Value(x) Edge[x].Value
}Edge[maxm<<1];

inline void Add_Edge(int From,int To,long long Value){Edge[++tot]=(edge){To,head[From],Value},head[From]=tot;return;}
inline void Insert_Edge(int From,int To,long long Value){Add_Edge(From,To,Value);Add_Edge(To,From,0);return;}

inline bool Bfs(int S,int T){
    register int i,x;
    for(i=1;i<=N+2;i++) Deep[i]=0;
    queue<int> q;
    q.push(S);
    Deep[S]=1;
    while(q.size()){
        x=q.front(),q.pop();
        for(i=head[x];i;i=Next(i)){
            if(Value(i) && !Deep[To(i)]){
                q.push(To(i));
                Deep[To(i)]=Deep[x]+1;
                if(To(i)==T) return true;
            }
        }
    }
    return false;
}

long long Dfs(int now,long long Now){
    if(now==T) return Now;
    long long Rest=Now,Reduce;
    for(int i=head[now];i && Rest;i=Next(i)){
        if(Value(i) && Deep[To(i)]==Deep[now]+1){
            Reduce=Dfs(To(i),min(Rest,Value(i)));
            if(!Reduce) Deep[To(i)]=0;
            Value(i)-=Reduce;
            Value(i^1)+=Reduce;
            Rest-=Reduce;
        }
    }
    return Now-Rest;
}

int main(){
	register int i,j;
	register long long Ans=0,Now,Max=0;
	scanf("%d",&N);
	for(i=1;i<=N;i++)	scanf("%lld",A+i);
	S=N+1;
	T=N+2;
	for(i=1;i<=N;i++){
		if(A[i]>0){
			Insert_Edge(S,i,A[i]);
			Ans+=A[i];
		}else{
			Insert_Edge(i,T,-A[i]);
		}
	}
	for(i=1;i<=N;i++){
		for(j=i<<1;j<=N;j+=i){
			Insert_Edge(j,i,Inf);
		}
	}
	while(Bfs(S,T)){
		while(Now=Dfs(S,Inf)){
			Max+=Now;
		}
	}
	cout<<Ans-Max<<endl;
	return 0;
}


Measured memory_bytes: 2304
#!/usr/bin/python3
# vim: set fileencoding=utf-8:
import sys
from collections import Counter
input = sys.stdin.readline

"""
H = int(input())
h = [int(ele) for ele in input().split()]
h = [0] + h
"""


def main():
    N = input()
    ct = Counter(N)
    s = 0
    for num, count in zip(ct.keys(), ct.values()):
        if str(num) in '123456789':
            s += int(num) * int(count)

    print("Yes" if int(N) % s == 0 else "No")


def bfs(queue):
    global yet, graph
    if len(queue) == 0:
        return
    yet.remove(queue[-1])

    for i, adjacency in enumerate(graph[queue[-1]]):
        if adjacency == 1 and (i in yet) and (i not in queue):  # 隣接かつ未探索であれば、stackにpush
            queue.appendleft(i)
    else:
        queue.pop()
        bfs(queue)


def dfs(stack):
    global yet, graph
    yet.remove(stack[-1])

    for i, adjacency in enumerate(graph[stack[-1]]):
        if adjacency == 1 and i in yet:  # 隣接かつ未探索であれば、stackにpush
            stack.append(i)
            dfs(stack)
    else:
        stack.pop()


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
        if i != n // i:
            divisors.append(n//i)
    return divisors


class Node():

    def __init__(self):
        self.idx = None
        self.left = None
        self.right = None
        self.parent = None
        return

    def pre_order(self):
        global pre_order_str
        pre_order_str += str(self.idx) + " "
        if self.left:
            self.left.pre_order()

        if self.right:
            self.right.pre_order()

    def in_order(self):
        global in_order_str

        if self.left:
            self.left.in_order()

        in_order_str += str(self.idx) + " "

        if self.right:
            self.right.in_order()

    def post_order(self):
        global post_order_str
        if self.left:
            self.left.post_order()

        if self.right:
            self.right.post_order()

        post_order_str += str(self.idx) + " "


class HeapHelper():
    """HeapContrler.
    完全二分木を二分ヒープで表現した配列 A に対して、
    HeapHelper.parent(idx) とするとそのノードの親の添字を返す
    存在しない場合は Falseを返す

    Returns:
        [type] -- [description]
    """

    def __init__(self):
        return

    @staticmethod
    def parent(i):
        if i == 1:
            return False

        return int(i/2)

    @staticmethod
    def left(i):
        l_idx = 2*i
        if H < l_idx:
            return False

        return l_idx

    @staticmethod
    def right(i):
        r_idx = 2*i + 1
        if H < r_idx:
            return False

        return r_idx


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#define INF 1e9
#define MOD 1000000007
#define ll long long
using namespace std;
typedef unsigned long long ull;
typedef pair<int, int> pr;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n,p;
    cin>>n>>p;
    map<ll,ll>mp;
    for(ll i=2;i*i<=p;i++){
        while(p%i==0){
            mp[i]++;
            p/=i;
        }
    }
    if(p!=1){
        mp[p]++;
    }
    ll ans=1;
    for(auto &itr:mp){
        const ll k=itr.second/n;
        for(ll i=0;i<k;i++){
            ans*=itr.first;
        }
    }
    cout<<ans;
    return 0;
}

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

using namespace std;


int main() {

    int x;
    int happy = 0;
    cin >> x;


    happy = 1000 * (x / 500);
    x = x % 500;

    happy += 5 * (x / 5);

    cout << happy;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define ordered_set tree<int , null_type,less<int , rb_tree_tag,tree_order_statistics_node_update>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 100000000
// order_of_key and *find_by_order

int32_t main() {
	fast;
	int n, m, k;
	cin >> n >> m >> k;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i) {
			a[i] += a[i - 1];
		}
	}
	int b[m];
	for (int i = 0; i < m; i++) {
		cin >> b[i];
		if (i) {
			b[i] += b[i - 1];
		}
	}
	int ans = 0;
	ans = max(ans, upper_bound(b, b + m, k) - b);
	for (int i = 0; i < n; i++) {
		if (k - a[i] > 0) {
			int u = upper_bound(b, b + m, k - a[i]) - b;
			ans = max(ans, u + i + 1);
		}
	}
	ans = max(ans, upper_bound(a, a + n, k) - a);
	for (int i = 0; i < m; i++) {
		if (k - b[i] > 0) {
			int u = upper_bound(a, a + n, k - b[i]) - a;
			ans = max(ans, u + i + 1);
		}
	}
	cout << ans;









}

Measured memory_bytes: 6732
# ABC132D - Blue and Red Balls
def get_fact_and_inv(lim: int) -> tuple:
    # compute tables of factorials and inverse factorials (1-idx)
    fact = [1] * (lim + 1)
    x = 1
    for i in range(1, lim + 1):
        x = (x * i) % MOD
        fact[i] = x

    inv = [1] * (lim + 1)
    inv[-1] = pow(fact[-1], MOD - 2, MOD)
    x = inv[-1]
    for i in range(lim - 1, 0, -1):
        x = (x * (i + 1)) % MOD
        inv[i] = x
    return fact, inv


def comb(n: int, r: int) -> int:
    # compute nCr (n! / r!(n - r)!)
    return (fact[n] * inv[r] * inv[n - r]) % MOD


def main():
    global MOD, fact, inv
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7
    fact, inv = get_fact_and_inv(N)
    ans = []
    for i in range(1, K + 1):
        if N - K - i + 1 >= 0:
            x = (comb(N - K + 1, i) * comb(K - 1, i - 1)) % MOD
        else:
            x = 0
        ans.append(x)
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

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

using namespace std;

void nmSeq(int n, int m, vector<int> &seq, vector< vector<int> > &a) {
  if (n == 0) { a.push_back(seq); return; }
  for (int i = 1; i <= m; i++) {
    seq.push_back(i);
    nmSeq(n - 1, m, seq, a);
    seq.pop_back();
  }
}

int calc1(int x[], vector<int> op) {
  int A = x[0];
  switch (op[0]) {
    case 1: A += x[1]; break;
    case 2: A -= x[1]; break;
    case 3: A *= x[1]; break;
  }
  int B = x[2];
  switch (op[2])  {
    case 1: B += x[3]; break;
    case 2: B -= x[3]; break;
    case 3: B *= x[3]; break;
  }
  switch (op[1]) {
    case 1: return A + B;
    case 2: return A - B;
    case 3: return A * B;
  }
}

int calc2(int x[], vector<int> op) {
  int A = x[0];
  switch (op[0]) {
    case 1: A += x[1]; break;
    case 2: A -= x[1]; break;
    case 3: A *= x[1]; break;
  }
  switch (op[1]) {
    case 1: A += x[2]; break;
    case 2: A -= x[2]; break;
    case 3: A *= x[2]; break;
  }
  switch (op[2]) {
    case 1: return A + x[3];
    case 2: return A - x[3];
    case 3: return A * x[3];
  }
}

int main(void) {
  int x[4];
  string ord = "+-*";
  while (true) {
    for (int i = 0; i < 4; i++) {
      cin >> x[i];
    }
    if (x[0] == 0) break;

    vector<int> a;
    vector< vector<int> > op;
    nmSeq(3, 3, a, op);

    bool none = true;
    sort(x, x + 4);
    do {
      for (int i = 0; i < op.size(); i++) {
        if (!none) break;
        if (calc1(x, op[i]) == 10) {
          printf("((%d %c %d) %c (%d %c %d))\n", x[0], ord[op[i][0] - 1], x[1], ord[op[i][1] - 1], x[2], ord[op[i][2] - 1], x[3]);
          none = false;
        } else if (calc2(x, op[i]) == 10) {
          printf("(((%d %c %d) %c %d) %c %d)\n", x[0], ord[op[i][0] - 1], x[1], ord[op[i][1] - 1], x[2], ord[op[i][2] - 1], x[3]);          
          none = false;          
        }
      }
    } while (next_permutation(x, x + 4));

    if (none) cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <set>

int main(){
    int k;
    std::cin >> k;

    int x = 7 % k;
    for (int i = 1; i <= k; i++)
    {
        if (x == 0)
        {
            std::cout << i << std::endl;
            return 0;
        }
        x = (x * 10 + 7) % k;
    }
    std::cout << -1 << std::endl;

    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N, Y;
	cin >> N >> Y;

	rep(a, 0, N + 1) rep(b, 0, N - a + 1) {
		int c = N - a - b;
		if(10000 * a + 5000 * b + 1000 * c == Y) {
			cout << a << " " << b << " " << c << endl;
			return 0;
		}
	}
	cout << "-1 -1 -1" << endl;

}


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

#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define PH push
#define ll long long

const int MOD=1e9+7;

int n;
int b[2010],w[2010];
int f[2010][2010];
int addb[2010][2010],addw[2010][2010];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)
	{
		char c;
		int a;
		scanf("%s%d",&c,&a);
		if(c=='B') b[a]=i;
		else w[a]=i;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			addb[i][j]=addb[i][j-1]+(w[j]>b[i]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			addw[i][j]=addw[i][j-1]+(b[j]>w[i]);
	for(int i=0;i<=n;i++) 
		for(int j=0;j<=n;j++)
			f[i][j]=1e9+7;
	for(int i=0;i<=n;i++)
		f[0][i]=f[i][0]=0;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
		{
			if(i!=n)
			{
				f[i+1][j]=min(f[i+1][j],f[i][j]+addb[i+1][j]);
			}
			if(j!=n)
			{
				f[i][j+1]=min(f[i][j+1],f[i][j]+addw[j+1][i]);
			}
		}
	int res=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=i-1;j++)
			res+=(b[i]<b[j]),res+=(w[i]<w[j]);
//	printf("res=%d\n",res);
	printf("%d",f[n][n]+res);
	return 0;
	
}


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

int m[3][101], dt[3][101];

int f(int i, int j){
    if(i<1 || j<1) return 0;
    if(i==1 && j==1) return dt[1][1]=m[1][1];
    if(dt[i][j])
        return dt[i][j];
    return dt[i][j] = max(f(i-1, j), f(i, j-1)) + m[i][j];
}
int main(){
    int n;
    scanf("%d", &n);
    for(int i=1; i<=2; i++)
        for(int j=1; j<=n; j++)
            scanf("%d", &m[i][j]);
    f(2, n);
    printf("%d", dt[2][n]);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> a;

i64 f(int s) {
  i64 sum = 0, res = 0;
  for (int i = 0; i < n; ++i) {
    bool f = i % 2 == s;
    sum += a[i];
    i64 old_sum = sum;
    if (f && sum <= 0) {
      sum = 1;
    }
    if (!f && sum >= 0) {
      sum = -1;
    }
    res += abs(sum - old_sum);
  }
  return res;
}

int main() {
  cin >> n;
  read_n(a, n);
  i64 ans = min(f(0), f(1));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
void tmp(int *, int *);
int main(void)
{
	int a, b, c;
	scanf("%d %d %d",&a,&b,&c);
	tmp(&a, &b);
	tmp(&a,&c);
	printf("%d %d %d",a,b,c);
}

void tmp(int* x,int* y) {
	int tmp;
	tmp = *x;
	*x=*y;
	*y = tmp;

}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
    int n, n1, n2, n3, n4;

    cin >> n;

    n1 = n / 1000;
    n2 = (n % 1000) / 100;
    n3 = ((n % 1000) % 100) / 10;
    n4 = (((n % 1000) % 100) % 10) / 1;

    if ((n1 == n2) && (n2 == n3)) {
        cout << "Yes" << endl;
    }
    else if ((n2 == n3) && (n3 == n4)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int A,B,C ;
    scanf("%d%d%d",&A,&B,&C);
    if(A==B){
        printf("%d",C);
    }else if(A==C){
        printf("%d",B);
    }
    else if(B==C){
        printf("%d",A);
    }
}


Measured memory_bytes: 128
void main() {
	auto N = ri;
	generate_prime_list(2000);
	auto res = prime_list.filter!(a => a % 5 == 1).array;
	foreach(i; 0..N) {
		if(i != N-1)
			"%d ".writef(res[i]);
		else
			res[i].writeln;
	}
	
	foreach(i; 0..55-5) {
		if(prime_list.canFind(res[i]+res[i+1]+res[i+2]+res[i+3]+res[i+4])){
			"bad".writeln;
		}
	}
	
}

int[] prime_list;

void generate_prime_list(int N) {
	prime_list = [2];
	bool not_prime = false;
	foreach(i; 3..N+1) {
		foreach(j; prime_list) {
			if(i % j == 0) {
				not_prime = true;
				break;
			}
		}
		if(!not_prime) prime_list ~= i;
		not_prime = false;
	}
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

T[] deepcopy(T)(T[] a) {
	static if(isArray!T) {
		T[] res;
		foreach(i; a) {
			res ~= deepcopy(i);
		}
		return res;
	} else {
		return a.dup;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

using Item = tuple<int,int,int,int>;
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    vector<vector<int>> a(H,vector<int>(W));
    for(auto& vec:a) for(auto& in:vec) cin >> in;
    vector<Item> ans;
    for(int i = 0; i < H-1; i++){
        for(int j = 0; j < W; j++){
            if(a[i][j]%2 == 0) continue;
            ans.push_back(Item(i+1,j+1,i+2,j+1));
            
            a[i+1][j]++;
        }
    }
    
    int i = H-1;
    for(int j = 0; j < W-1; j++){
        if(a[i][j]%2 == 0) continue;
        ans.push_back(Item(i+1,j+1,i+1,j+2));
        
        a[i][j+1]++;
    }
    
    cout << ans.size() << endl;
    for(int i = 0; i < (int)ans.size();i++){
        int a,b,c,d; tie(a,b,c,d) = ans[i];
        cout << a << " " << b << " " << c << " " << d << endl;
    }
    return 0;
}


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

int main(){
	int N; cin>>N;
	map<char,ll> S;
	string T{"MARCH"};
	while(N--){
		string s; cin>>s;
		for(auto c:T) if(s[0]==c) S[c]++;
	}

	map<string,ll> C;
	for(auto a:S){
		for(auto b:S){
			if(a==b)continue;
			for(auto c:S){
				if(a==c || b==c)continue;
				string s{a.first, b.first, c.first};
				sort(s.begin(), s.end());
				if(C.find(s)==C.end()) C[s] += a.second * b.second * c.second;
			}
		}
	}

	ll ans = 0;
	for(auto e:C) ans += e.second;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
def main():
    from math import gcd
    MINFact = [-1] * (10**6 + 10)
    MINFact[0] = 0
    MINFact[1] = 1

    def Eratosthenes(sup: int) -> set:
        primes = [True for i in range(sup+1)]
        primes[0] = False
        primes[1] = False
        for i in range(2, sup+1):
            if primes[i]:
                MINFact[i] = i
                mul = 2
                while i*mul <= sup:
                    primes[i*mul] = False
                    if MINFact[i*mul] == -1:
                        MINFact[i*mul] = i
                    mul += 1

    def prime_factor(n):
        while n != 1:
            prime = MINFact[n]
            while MINFact[n] == prime:
                n //= prime
            B[prime] += 1

    _ = int(input())
    A = [int(i) for i in input().split()]
    g = A[0]
    for a in A:
        g = gcd(g, a)
    Eratosthenes(10**6 + 5)
    B = [0]*(10**6 + 5)
    for a in A:
        prime_factor(a)
    # 素因数分解したのをBにいれる
    # 1より大きいのがあったら gcd != 1 のペアが存在する
    if g != 1:
        print("not coprime")
    elif max(B) <= 1:
        print("pairwise coprime")
    else:
        print("setwise coprime")


if __name__ == '__main__':
    main()


Measured memory_bytes: 210860
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
typedef long long ll;

int main()
{
    ll X, K, D;
    cin >> X >> K >> D;
    if (X < 0)
        X *= -1;

    ll p_X = 0;
    ll kr = X / D;
    if (kr < K)
    {
        K -= kr;
        p_X = X % D;
        if (K % 2 == 1)
        {
            p_X -= D;
        }
    }else{
        p_X =  X - K * D;
    }

    cout << abs(p_X) << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll dp[125][2][4];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  string n;
  int K;
  cin>>n>>K;
  int m=n.size();
  REP(i, m+1){
    REP(j, 2){
      REP(k, K){
        dp[i][j][k]=0;
      }
    }
  }
  dp[0][0][0]=1;
  REP(i, m){
    int D=n[i]-'0';
    REP(j, 2){
      REP(k, K+1){
        for(int d=0; d<=(j ? 9 : D); ++d){
          if(k==K && (d!=0)){
            continue;
          }
          dp[i+1][j||(d<D)][k+(d!=0)]+=dp[i][j][k];
        }
      }
    }
  }
  cout<<dp[m][0][K]+dp[m][1][K]<<'\n';
  return 0;
}


Measured memory_bytes: 256
try:
  while 1:
    c=[0,1,1]+[0]*98
    while 1:
      a, b = map(int, raw_input().split())
      if a==0==b:break
      c[a] = -c[a]+1
      c[b] = -c[b]+1
    if c.count(1): print "NG"
    else: print "OK"
except:exit

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

int main(){
  int n;
  cin >> n;
  
  map<string, int>mp;
  string s;
  for(int i=0;i<n;i++){
    cin >> s;
    mp[s]++;
  }
  multimap<int, string, greater<int>> mps;
  for(auto it : mp)
    mps.insert({it.second, it.first});
  
  int m=mps.begin()->first;
  set<string> ans;
  for(auto it : mps){
      if(m == it.first)ans.insert(it.second);
      else break;
  }
  set<string>:: iterator it = ans.begin();
  for(;it!=ans.end();++it)cout << *it << endl;
}


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

int main() {
	int N,K;
	cin >> N >> K;
	
	vector<int> Nuk(N);
	
	for(int i=0;i<N;i++){
		int d,e;
		cin >> d;
		for(int j=0;j<d;j++){
			cin >> e;
			Nuk.at(e-1)=1;
		}
	}
	
	int c =0;
	
	for(int l=0;l<N;l++){
		int f;
		f=Nuk.at(l);
		if(f==0)
			c++;
	}
	
	cout << c << endl;
}


Measured memory_bytes: 3640
import sys
import itertools

input = sys.stdin.readline


def main():
    H, W, D = [int(x) for x in input().split()]
    A = [[int(x) for x in input().split()] for _ in range(H)]
    Q = int(input())
    LR = [[int(x) for x in input().split()] for _ in range(Q)]

    d = {}
    for j in range(H):
        for i in range(W):
            d[A[j][i]] = (i, j)

    A = [[0] for j in range(D)]

    for i in range(D):
        accumu = 0
        for j in range(i, H * W + 1, D):
            if j <= D:
                continue
            accumu += abs(d[j][0] - d[j - D][0]) + abs(d[j][1] - d[j - D][1])
            A[i].append(accumu)


    for l, r in LR:
        if l % D == 0:
            print(A[l % D][r // D - 1] - A[l % D][l // D - 1])
        else:
            print(A[l % D][r // D] - A[l % D][l // D])


if __name__ == '__main__':
    main()


Measured memory_bytes: 47488
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
// #include <bits/stdc++.h> 
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;
#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define int long long
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

int32_t main(){
    fast
    int t;
    cin >> t;
    vector<int> x;
    while(t--){
        int n;
        cin >> n;
        x.pb(n);
    }
    int res = 0;
    for(int i =1; i < x.size(); i++){
        if (x[i] < x[i-1]){
            res += (x[i-1]-x[i]);
            x[i] = x[i-1];
        }
    }
    cout << res;
    return 0;
}

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

const int DIM = 2005;
const int MOD = 924844033;

int dp1[DIM][DIM], dp2[DIM], fct[DIM];

void add( int l, int n ) {
    
    for( int i = n; i >= 0; i -- )
    for( int j = min( l / 2, n - i ); j >= 1; j -- )
        dp2[i + j] = ( 1LL * dp2[i] * dp1[l][j] + dp2[i + j] ) % MOD;
    
    return;
}

int main( void ) {
    
    int n, k;
    cin >> n >> k;
    
    dp1[0][0] = dp2[0] = fct[0] = 1;
    for( int i = 1; i <= n; i ++ ) {
        fct[i] = ( fct[i - 1] * 1LL * i ) % MOD;
        
        for( int j = 0; j <= i / 2; j ++ ) {
            dp1[i][j] = dp1[i - 1][j];
            
            if( i >= 2 && j >= 1 )
                dp1[i][j] = ( dp1[i][j] + dp1[i - 2][j - 1] ) % MOD;
        }
    }
    
    for( int i = 1; i <= k; i ++ ) {
        int sz = ceil( (n - i + 1) * 1.0 / k );
        add( sz, n ); add( sz, n );
    }
    
    int ans = 0;
    for( int i = 0; i <= n; i ++ ) {
        if( i % 2 == 0 )
            ans = ( +1LL * dp2[i] * fct[n - i] % MOD + ans ) % MOD;
        else
            ans = ( -1LL * dp2[i] * fct[n - i] % MOD + ans + MOD ) % MOD;
    }
    
    cout << ans << endl;
    return 0;
}

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int x;

int main()
{
    cin>>x;
    int d=x/100;
    int mod=x%100;
    if (d*5>=mod)
        cout<<1;
    else cout<<0;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <utility>
#include <queue>
#include <list>

using namespace std;

#define N 100

typedef pair<int,int> arw;

int
main (
  int   argc,
  char *argv[ ]
  )
{
  list<arw>::iterator it;
  int i;

  for ( ; ; )
  {
    priority_queue<arw, vector<arw>, greater<arw> > lis;
    list<arw> d[ N ];
    int mk[ N ] = { };
    int res = 0;
    int n, m;

    scanf ( "%d%d", &n, &m );
    if ( n == 0 && m == 0 ) break ;
    for ( i = 0; i < m; ++i )
    {
      int a, b, cost;

      scanf ( "%d%d%d", &a, &b, &cost );
      d[ a ].push_back ( make_pair ( cost, b ) );
      d[ b ].push_back ( make_pair ( cost, a ) );
    }

    /* Prim's Algorithm */
    lis.push ( make_pair ( 0, 0 ) );
    while ( !lis.empty ( ) )
    {
      const arw c = lis.top ( );
      lis.pop ( );

      if ( mk[ c.second ] )
        continue ;

      res += c.first;
      for ( it = d[ c.second ].begin ( ); it != d[ c.second ].end ( ); ++it )
      {
        lis.push ( *it );
      }

      mk[ c.second ] = 1;
    }

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

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 1048
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 n;
    cin >> n;

    s64 keta = 1;
    s64 num = 26;
    s64 sum = 1;
    while (sum + num <= n)
    {
        ++keta;
        sum += num;
        num *= 26;
    }

    n -= sum;
    string ans = "";
    rep (i, keta)
    {
        ans = string(1, 'a' + n % 26) + ans;
        n /= 26;
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 /*temp*/

int main(){
    int a[10];
    REP(i,10){
        cin >> a[i];
    }
    sort(a, a+10);
    cout << a[9] << '\n'
         << a[8] << '\n'
         << a[7] << '\n';
}

Measured memory_bytes: 3080
#include<stdio.h>
 
long max(long a,long b){
	if(a>b){
    	return a;
    }else{
    	return b;
    }
}
 
long min(long a,long b){
	if(a<b){
    	return a;
    }else{
    	return b;
    }
}
 
int f(long a,long b){
  long c=max(a,b);
  int keta=1;
  for(int i=0;i<10;++i){
  	if(c/10>0){
    	keta++;
      	c/=10;
    }
  }
  return keta;
}
 
 
 
int main(void){
  
  long N;
  int minnum=11;
  scanf("%ld",&N);
  
  for(long a=1;a*a<=N;++a){
    long b=0;
  	if(N%a == 0){
      b=N/a;
      b=f(a,b);
      minnum=min(minnum,b);
    }
  }
  
  printf("%ld",minnum);
  
 
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    long n,k;
    cin >> n >> k;
    vector<long> h(n);
    rep(i,n) cin >> h.at(i);
    sort(all(h),greater<long>());
    if(k >= n){
        cout << 0 << endl;
        return 0;
    }
    long ans = 0;
    for(long i = k;i<n;i++){
        ans += h.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func main() {
	var x, k, d int64
	fmt.Scan(&x, &k, &d)
	if x < 0 {
		x = -x
	}
	b := x / d
	if k <= b {
		fmt.Println(x - k*d)
		return
	}
	if k%2 == b%2 {
		fmt.Println(x - b*d)
		return
	}
	fmt.Println((b+1)*d - x)
}


Measured memory_bytes: 1768
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;

const int MOD = 1e9 + 7;
int n, cnt[26];
string s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		cnt[s[i] - 'a']++;
	}
	int res = 1;
	for (int i = 0; i < 26; i++) {
		res = (ll)res * (cnt[i] + 1) % MOD;
	}
	res -= 1;
	if (res < 0) {
		res += MOD;
	}
	cout << res;
}


Measured memory_bytes: 512
<?php
list($a, $b, $k) = ints();
for ($i = 0; $i < $k; ++$i) {
    if ($i % 2) {
        $b = intdiv($b, 2);
        $a += $b;
    } else {
        $a = intdiv($a, 2);
        $b += $a;
    }
}
echo implode(' ', [$a, $b]);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16208
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[n];
		for(int i=0;i<n+1;i++){
			a[i]=scanner.nextInt();
		}
		for(int i=0;i<n;i++){
			b[i]=scanner.nextInt();
		}
		long cnt=0;
		for(int i=0;i<n;i++){
			int at=b[i];
			if(a[i]>at){
				cnt+=at;
				a[i]-=at;
				at=0;
			}else{
				cnt+=a[i];
				at-=a[i];
				a[i]=0;
			}
			if(a[i+1]>at){
				cnt+=at;
				a[i+1]-=at;
				at=0;
			}else{
				cnt+=a[i+1];
				at-=a[i+1];
				a[i+1]=0;
			}
		}
		System.out.println(cnt);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 24380
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == '+':
        print(a+b)
    if op == '-':
        print(a-b)
    if op == '*':
        print(a*b)
    if op == '/':
        print(a//b)
    if op == '?':
        break



Measured memory_bytes: 5596
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

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

#define mp make_pair
#define pb push_back
#define all(u) (u).begin(),(u).end()

struct rect
{
  int t, x, y, w, h;
  rect () {}
  rect(int t, int x, int y, int w, int h)
    : t(t), x(x), y(y), w(w), h(h) {}
  int area() const {
    return w * h;
  }
  bool operator <(const rect& o) const {
    return mp(t, area()) < mp(o.t, o.area());
  }
};

int n, w, h;

pair<rect, rect> cut(int time, rect cake, int pos)
{
  int x = cake.x;
  int y = cake.y;
  int w = cake.w;
  int h = cake.h;
  pos %= w + h + w + h;
  rect a, b;
  if (pos < w) {
    int c = pos;
    a = rect(time, x, y, c, h);
    b = rect(time, x + c, y, w - c, h);
  } else if (pos < w + h) {
    int c = pos - w;
    a = rect(time, x, y, w, c);
    b = rect(time, x, y + c, w, h - c);
  } else if (pos < w + h + w) {
    int c = w + h + w - pos;
    a = rect(time, x, y, c, h);
    b = rect(time, x + c, y, w - c, h);
  } else {
    int c = w + h + w + h - pos;
    a = rect(time, x, y, w, c);
    b = rect(time, x, y + c, w, h - c);
  }
  return mp(a, b);
}

int main()
{
  while (cin >> n >> w >> h and w) {
    vector<rect> cakes;
    cakes.pb(rect(-1, 0, 0, w, h));
    rep(i, n) {
      sort(all(cakes));
      int p, s;
      cin >> p >> s;
      pair<rect, rect> nw = cut(i, cakes[p - 1], s);
      cakes[p - 1] = nw.first;
      cakes.pb(nw.second);
    }
    int m = cakes.size();
    vector<int> ans;
    rep(i, m) ans.pb(cakes[i].area());
    sort(all(ans));
    rep(i, m - 1) cout << ans[i] << ' ';
    cout << ans.back() << endl;
  }

  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N;
    scan(N);
    REP(i, N) {
        vector<int> v(3);
        scan(v);
        SORT(v);
        if (v[0] * v[0] + v[1] * v[1] == v[2] * v[2])
            print("YES");
        else
            print("NO");
    }

    return 0;
}


Measured memory_bytes: 3140
n,m=map(int,input().split())
for i in range(n+1):
    for j in range(n+1):
        z=n-i-j
        if 0<=z:
            if 10000*i+5000*j+1000*z==m:
                print(i,j,z)
                exit()
print(-1,-1,-1)


Measured memory_bytes: 2940
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]

ab = sorted(ab, key=lambda x:(x[1], -x[0]))
count = 0
for i in range(n):
    count += ab[i][0]
    if count > ab[i][1]:
        print("No")
        break
else:
    print("Yes")    

Measured memory_bytes: 67444