akhauriyash/Code-Regression huggingface dataset:
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import  java.io.*;
import  java.math.*;
import java.nio.Buffer;
import java.sql.SQLSyntaxErrorException;
import  java.util.*;
import  java.text.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;


public class Main {


    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        long ans=cin.nextLong();
        long c=(long) (ans/500);
        long t=(long)(ans%500)/5;
        System.out.println(c*1000+t*5);
    }
}


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

int main(){
int a, b, c, t;
cin >> a >> b >> c;

if ( a > b ) { t = a; a = b; b = t; }
if ( b > c ) { t = b; b = c; c = t; }
if ( a > b ) { t = a; a = b; b = t; }

cout << a << " " << b << " " << c << endl;

return 0;
} 


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

int main() {

    long long n,k;
    cin >> n >> k;

    long long ans = 0;
    long long div = n / k;
    long long amr = n % k;

    long long ab = abs(amr - k);
    ans = min(ab,amr);

    cout << ans << endl;
}   

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int N, K;
    cin >> N >> K;
    
    string v;
    for (int i = 0; i < K; i++) {
        int x;
        cin >> x;
        v.push_back( x + '0' );
    }

    int size = v.size();
    int s = N;
    while (1) {
        bool f = false;
        string a = to_string(s);
        int len = a.length();

        s++;
        for (int i = 0; i < len; i++) {
            for (int j = 0; j < size; j++) {
                if (a[i] == v[j]) {
                    f = true;
                    break;                   
                }
            }
            if (f) break;
        }

        if (!f) {
            cout << s - 1 << endl;
            return 0;
        }
    }


    return 0;
}

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

typedef long long ll;
const ll MOD = 1000000007;

int main() {
    ll N, A, B, d;
    ll ans = 0;
    cin >> N >> A >> B;
    vector<ll>x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
        if (i > 0) {
            d = x[i] - x[i-1];
            if (A*d <= B) {
                ans += A*d;
            } else {
                ans += B;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import math

N = int(input())
ZL = [[] for _ in range(N)]
ZL[0].append([0])
for i in range(1, N):
    for szl in ZL[i - 1]:
        n1 = max(szl)
        for j in range(n1 + 2):
            ZL[i].append(szl + [j])


def func(i):
    if i == 0:
        return "a"
    if i == 1:
        return "b"
    if i == 2:
        return "c"
    if i == 3:
        return "d"
    if i == 4:
        return "e"
    if i == 5:
        return "f"
    if i == 6:
        return "g"
    if i == 7:
        return "h"
    if i == 8:
        return "i"
    if i == 9:
        return "j"


L = ZL[N - 1]
for sl in L:
    for i in range(N):
        sl[i] = func(sl[i])
L.sort()
for sl in L:
    print("".join(map(str, sl)))


Measured memory_bytes: 94172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
const int maxn = 5e5 + 5;
const int mod = 1e9 + 7;
ll ksm (ll a, ll b)
{
    ll ans = 1 , base = a;
    while (b)
    {
        if (b & 1) ans = ans * base % mod;
        b >>= 1;
        base = base * base % mod;
    }
    return ans;
}
ll inv[maxn] , fact[maxn];
ll C (ll a , ll b)
{
    ll res = fact[a] * inv[b] % mod;
    res = res * inv[a - b] % mod;
    return res;
}
int main()
{
    ios::sync_with_stdio(false);
    ll n , k ; cin >> n >> k;
    fact[0] = 1;
    inv[0] = 1;
    for (int i = 1 ; i <= 2 * n ; i++){
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = ksm(fact[i] , mod - 2) % mod;
    }
    ll ans = C(2 * n - 1 , n - 1);
    ll res = 0;
    for (int i = min(n  , k + 1) ; i <= n - 1 ; i++){
        res = (res + C(n , i) * C(n - 1 , n - i - 1)%mod)%mod;
    }
    cout << (ans - res + mod) % mod << endl;
    return 0;
}


Measured memory_bytes: 9832
#include<stdio.h>
#define MAX 200

int main(void)
{
  int N, M, C, B[MAX], A[MAX][MAX];
  int sum = 0, sumsum = 0;
  int i, j;
  
  scanf("%d %d %d", &N, &M, &C);
  
  for(i = 0 ; i < M ; i++)
  {
    scanf("%d", &B[i]);
  }

  for(i = 0 ; i < N ; i++)
  {
    for(j = 0 ; j < M ; j++)
    {
      scanf("%d", &A[i][j]);
    }
  }
  
  for(i = 0 ; i < N ; i++)
  {
    for(j = 0 ; j < M ; j++)
    {
      sum += A[i][j] * B[j];
    }
    sum = sum + C;
    if(sum > 0)
    {
      sumsum += 1;
    }
    sum = 0;
  }
  
  printf("%d", sumsum);
  
  return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
cir = 1
bsum = 1
hantei=0
asum = [0 for i in range(n+1)]
asum[0] = sum(a)
for i in range(1,n+1):
    asum[i] = asum[i-1]-a[i]
#print(asum)
swi = 0
for i in range(n):
    if swi == 1:
        #print(cir,a[i])
        cir = cir-a[i]
    if swi==0:
        if (cir-a[i])*2 < asum[i]:
            cir = (cir-a[i])*2
        else:
            cir = asum[i]
            swi = 1

    bsum += cir
    if cir<=0:
        hantei=1
        break


#print(cir,a[-1])


if hantei==1 or cir!=a[-1]:
    print(-1)
else:
    print(bsum)


Measured memory_bytes: 84932
package main

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

// go run ./main.go < in

func main() {
	var n int
	fmt.Scan(&n)

	var strInputs []string
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	strInputs = strings.Split(sc.Text(), " ")

	var inputs []int
	for _, v := range strInputs {
		num, _ := strconv.Atoi(v)
		inputs = append(inputs, num)
	}

	// 逆順にsort
	sort.Sort(sort.Reverse(sort.IntSlice(inputs)))

	sumA, sumB := 0, 0
	for i := 0; i < len(inputs); i++ {
		switch i % 2 {
		case 0:
			sumA += inputs[i]
		default:
			sumB += inputs[i]
		}
	}
	fmt.Println(sumA - sumB)
}

Measured memory_bytes: 640
#include <stdio.h>
 
int main(void)
{
 
  int a, b, c, tmp;
 
  scanf("%d%d", &a, &b);
 
 
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  
  c = a % b;
  
  while(c!=0){
    a = b;
    b = c;
    c = a % b;

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

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

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

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

  int maxT = 0;
  for (int i = 0; i <= S.size() - T.size(); i++) {
    int tmp = 0;
    for (int j = 0; j < T.size(); j++) {
      if (S[i + j] == T[j]) {
        tmp++;
      }
    }
    maxT = max(maxT, tmp);
  }

  cout << T.size() - maxT << endl;

  return 0;
}

Measured memory_bytes: 3568
from math import sqrt
q = int(input())
for _ in range(q):
    a, b = map(int, input().split())
    t = a*b
    s = int(sqrt(t))
    an = 2 * s - 2
    if s*s == t:
        an -= 1
    if s*(s+1) < t:
        an += 1
    if a == b:
        an += 1
    print(an)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long 
using namespace std;

signed main() {
	int N,A,B;
	cin >> N >> A >> B;
	if(B * (N - 1) + A - A * (N - 1) - B + 1 < 0) {
		cout << 0 << endl;
	}
	else {
		cout << B * (N - 1) + A - A * (N - 1) - B + 1 << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

template<typename T> class segtree {
private:
    int n,sz,h;
    vector<T> node, lazy;
    void eval(int k) {
        if(lazy[k]){
            node[k] += lazy[k];
            if(k < n) {
                lazy[k*2] += lazy[k] / 2, lazy[k*2+1] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

public:
    segtree(const vector<T>& v) : n(1), sz((int)v.size()), h(0) {
        while(n < sz) n *= 2, h++;
        node.resize(2*n, 0), lazy.resize(2*n, 0);
        for(int i = 0; i < sz; i++) node[i+n] = v[i];
        for(int i = n-1; i >= 1; i--) node[i] = node[2*i] + node[2*i+1];
    }
    void range(int a, int b, T x, int k=1, int l=0, int r=-1){
        if(r < 0) r = n;
        eval(k);
        if(b <= l || r <= a){
            return;
        }
        if(a <= l && r <= b){
            lazy[k] += (r-l)*x;
            eval(k);
        }else{
            range(a, b, x, 2*k, l, (l+r)/2);
            range(a, b, x, 2*k+1, (l+r)/2, r);
            node[k] = node[2*k] + node[2*k+1];
        }
    }
    T query(int a, int b) {
        a += n, b += n - 1;
        for(int i = h; i > 0; i--) eval(a >> i), eval(b >> i);
        b++;
        T res1 = 0, res2 = 0;
        while(a < b) {
            if(a & 1) eval(a), res1 += node[a++];
            if(b & 1) eval(--b), res2 += node[b];
            a >>= 1, b >>= 1;
        }
        return res1 + res2;
    }
    //void print(){for(int i = 0; i < sz; i++) cout<<query(i,i+1)<< " ";cout<<endl;}
};

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, d, a;
	cin >> n >> d >> a;
	ll x, h;
	P xh[n];
	zep(i, 0, n){
		cin >> x >> h;
		xh[i] = P(x, h);
	}
	sort(xh, xh+n);
	
	set<ll> use;
	vector<ll> xhh;
	zep(i, 0, n){
		ll xx = xh[i].first;
		if(use.find(xx) == use.end()){
			xhh.push_back(xx);
			use.insert(xx);
		}
		if(use.find(xx+2*d) == use.end()){
			xhh.push_back(xx+2*d);
			use.insert(xx+2*d);
		}
	}
	sort(xhh.begin(), xhh.end());
	map<ll, ll> mp;
	zep(i, 0, xhh.size()){
		mp[xhh[i]] = i;
	}
	ll m = xhh.size();
	
	vector<ll> v(m+10, 0);
	segtree<ll> sg(v);
	
	ll ans = 0;
	zep(i, 0, n){
		x = xh[i].first;
		h = xh[i].second;
		ll at = mp[x];
		h -= sg.query(at, at+1);
		if(h > 0){
			ll buf = (h+a-1)/a;
			ans += buf;
			sg.range(at, mp[x+2*d]+1, a*buf);
		}
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 69740
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,mod=1e9+7;
map < int,int > mp;
int dfs(int x){
	int ans=0;
	if(x==0) return 1;
	if(x==1) return 2;
	if(mp[x/2]) ans+=mp[x/2];
	else mp[x/2]=dfs(x/2),ans+=mp[x/2]%mod;
	if(mp[(x-1)/2]) ans+=mp[(x-1)/2];
	else mp[(x-1)/2]=dfs((x-1)/2),ans+=mp[(x-1)/2]%mod;
	if(mp[x/2-1]) ans+=mp[x/2-1];
	else mp[x/2-1]=dfs(x/2-1),ans+=mp[x/2-1]%mod;
	return ans%mod;
}
main(){
	cin>>n;
	cout<<dfs(n)%mod;
	return 0;
}

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

int main(){
  int N; cin >> N;
  int a[100000];
  for(int i=0; i<N; i++) cin >> a[i];
  sort(a,a+N);
  
  int result=0;
  int repeat=0;
  int current=0;
  for(int i=0; i<N; i++){
    if(current==a[i]){
      repeat++;
    }else{
      result+=(repeat%2);
      repeat=1;
      current=a[i];
    }
  }
  cout << result+repeat%2 << endl;
}

Measured memory_bytes: 640
<?php

$L1 = explode(" ",fgets(STDIN));
$L2 = explode(" ",fgets(STDIN));


foreach ($L1 as $key => $value) {
  $L1[$key] = intval($value);
}
foreach ($L2 as $key => $value) {
  $L2[$key] = intval($value);
}

//var_dump($L2);
sort($L2);
/*
foreach ($L2 as $key => $value) {
  echo $value+" ";
}
*/

for ($i=1; $i < $L1[1]; $i++) {
  $way[] = $L2[$i]-$L2[$i-1];
}
$way[] = $L2[0] + $L1[0] - $L2[$L1[1]-1];
//var_dump($way);


$max_way = max($way);

$long = 0;
foreach ($way as $key => $value) {
  $long = $long + $value;
}
$long = $long - $max_way;
echo $long;

/*
if($L1[0]-$L2[$L1[1]-1]-$L2[0] <= $L2[1]-$L2[0]){

  echo $L2[$L1[1]-1] - $L2[1];

}else{

  echo $L2[$L1[1]-1] - $L2[0];

}
*/


 ?>


Measured memory_bytes: 27248
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long idx=0;
    long N, M;
    cin >> N >> M;
    // 問題番号の正解数、不正解数を記録する必要
    std::vector<pair<long, long>> mat(N, pair<long, long>(0, 0));
    long num;
    string ans;

    for(size_t i = 0; i < M; i++)
    {
        cin >> num >> ans;
        pair<long, long> current_state = mat[num-1];
        //cerr << "pre:" << current_state.first << ":" << current_state.second << endl;
        if(ans == "AC")
        {
            if(current_state.first == 1) continue;
            mat[num-1] = make_pair(1, current_state.second);
        }
        else
        {
            if(current_state.first == 1) continue;
            mat[num-1] = make_pair(0, current_state.second + 1);
        }
        //cerr << "post:" << mat[num-1].first << ":" << mat[num-1].second << endl;
    }
    long correct = 0, wrong = 0;
    for(size_t i = 0; i< N; i++)
    {
        correct += mat[i].first;
        if(mat[i].first == 1)
            wrong += mat[i].second;
    }
    cout << correct << " " << wrong << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;vector<ll>arr;
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    map<string,ll>m;
    in(n);
    while(n--){
        string s;cin>>s;
        if(m[s])
            m[s]++;
        else
            m[s]=1;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
    return 0;
}

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


void solve(long long N, std::string S){
    stack<ll> stk;
    ll numl=0, numr=0;
    for(ll i=0; i< S.length(); i++){
        if(stk.empty())
            stk.push(S[i]);
        else{
            if(stk.top()=='(' && S[i]==')') 
                stk.pop();
            else
                stk.push(S[i]);
        }
    }
    while(!stk.empty()){
        if(stk.top()=='(')
            numl++;
        else
            numr++;
        stk.pop();
    }
    for(ll i=0; i< numr; i++){
        cout << '(';
    }
    cout << S;
    for(ll i=0; i< numl; i++){
        cout << ')';
    }
    cout << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List
import Data.Ord

inputList 0 _ = []
inputList n (a:b:c:rest) =
    [a, b, c] : inputList (n-1) rest

parent [] n = -1
parent ([x, y, z]:xs) n =
    if y == n || z == n then x
    else parent xs n
    
findNode [] n = [-1, -1, -1] -- fxxking node
findNode ([x, y, z]:xs) n
    | x == n = [x, y, z]
    | otherwise = findNode xs n

sibling xs n = sibling_ xs n (parent xs n)
sibling_ xs n p
    | p == -1 = -1
    | otherwise = sibling__ xs n (findNode xs p)
sibling__ xs n [_, q, r]
    | q == n = r
    | otherwise = q

degree [x, y, z] = (zeroOrOne (y /= -1)) + (zeroOrOne (z /= -1))
    where zeroOrOne bl = if bl then 1 else 0

depth xs n = depth_ $ parent xs n
    where depth_ p = if p == -1 then 0 else (depth xs p) + 1

height xs (-1) = -1
height xs n = (max (height xs y) (height xs z)) + 1
    where [x, y, z] = findNode xs n
    
printType xs [x, y, z]
    | parent xs x == -1 = "root"
    | degree [x, y, z] == 0 = "leaf"
    | otherwise = "internal node"

printNode xs node =
    "node " ++ (show id) ++ ": parent = " ++ (show $ parent xs id)
    ++ ", sibling = " ++ (show $ sibling xs id)
    ++ ", degree = " ++ (show $ degree node)
    ++ ", depth = " ++ (show $ depth xs id)
    ++ ", height = " ++ (show $ height xs id)
    ++ ", " ++ (printType xs node)
    where [id, left, right] = node

main = do
    str <- getContents
    let xs1 = map (\x -> read x :: Int) (words str)
    let xs2 = inputList (head xs1) (tail xs1)
    let xs3 = sortBy (comparing head) xs2
    let res = foldl (\acc x -> acc ++ (printNode xs3 x) ++ "\n") "" xs3
    putStr res



Measured memory_bytes: 4204
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string S;
    cin >> S;
    
    vector<int> LR;
    int k = 0;
    int l = 0;
    while (k < S.size()) {
        ++l;
        if (k == S.size() - 1) LR.push_back(l);
        else {
            if (S[k] != S[k + 1]) {
                LR.push_back(l);
                l = 0;
            }
        }
        ++k;
    }
    vector<int> X(LR.size());
    rep(i, LR.size()) {
        if (i % 2 == 0) X[i] = (LR[i] + 1) / 2 + LR[i + 1] / 2;
        else X[i] = LR[i - 1] / 2 + (LR[i] + 1) / 2;
    }
    
    vector<int> ans(S.size(), 0);
    int cnt = 0;
    rep(i, S.size() - 1) {
        if (S[i] == 'R' && S[i + 1] == 'L') {
            ans[i] = X[cnt];
            ++cnt;
        }
        if (S[i] == 'L' && S[i + 1] == 'R') ++cnt;
    }
    cnt = 0;
    REP(i, S.size()) {
        if (S[i - 1] == 'R' && S[i] == 'L') {
            ans[i] = X[cnt + 1];
            ++cnt;
        }
        if (S[i - 1] == 'L' && S[i] == 'R') ++cnt;
    }
    
    rep(i, S.size() - 1) cout << ans[i] << " ";
    cout << ans[S.size() - 1] << endl;
    return 0;
}


Measured memory_bytes: 1912
#!/usr/bin/env python3
import sys
import math


def solve(H: int, W: int):
    if W == 1 or H == 1:
        # coner case
        print(1)
    else:
        print(math.ceil(W * H / 2))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(H, W)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String X = sc.next();
    Deque<Character> stack = new ArrayDeque<>(); // スタック
    for (int i = 0; i < X.length(); i++) {
      if (X.charAt(i) == 'S') { // i番目がS
        stack.push(X.charAt(i));
      } else { // i番目がT
        if (stack.size() == 0) { // スタックが空
          stack.push(X.charAt(i));
        } else if (stack.peek() == 'S') { // i-1番目がS
          stack.pop();
        } else if (stack.peek() == 'T') { // i-1番目がT
          stack.push(X.charAt(i));
        }
      }
    }
    System.out.println(stack.size());
  }
}

Measured memory_bytes: 26528
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans[ohara],a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll uke[ohara];
ll pa;
bool mem[ohara]; 
V g[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>m;
    rep(i,n-1+m)cin>>a[i]>>b[i];

    rep(i,n-1+m){
        uke[b[i]-1]++;
        mem[b[i]-1]=true;
    }
    rep(i,n){
        if(mem[i])continue;
        pa=i;
    }
    rep(i,n-1+m){
        a[i]--;b[i]--;
        g[a[i]].push_back(b[i]);
    }
    queue<ll> que;
    que.push(pa);
    while(!que.empty()){
        ll moto=que.front();
        que.pop();
        rep(i,Size(g[moto])){
            ll ri=g[moto][i];
            if(uke[ri]==1){
                que.push(ri);
                ans[ri]=moto;
            }
            else{
                uke[ri]--;
            }
        }
    }
    rep(i,n){
        if(pa==i)Cout(0);
        else Cout(ans[i]+1);
    }
    return 0;
}


Measured memory_bytes: 38784
n = int(input())
a = [0]*((10**4)+1)
for i in range(1,101):
    for j in range(1,101):
        for  k in range(1,101):
            try:
                a[i*i+j*j+k*k+i*j+j*k+i*k]+=1
            except:
                continue
for i in range(1, n+1):
    print(a[i])

Measured memory_bytes: 9300
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N=int(input())
l = prime_factorize(N)
m = collections.Counter([])
m[1]=1
x=1
cnt=0
y=list()
for i in range(len(l)):
    if x!=1 and x%l[i]!=0:
        x=1
    x*=l[i]
    #print(x)
    if m[x]==0:
        y.append(x)
        m[x]=1
        cnt+=1
        x=1
#print(l)
#print(m)
#print(x,y)
print(cnt)


Measured memory_bytes: 9500
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

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

    if(A[N-1]-A[0]>1){
        cout << "No" << endl;
        return 0;
    }

    if(A[N-1]-A[0]==1){
        int mx = A[N-1];
        int mn = A[0];
        int x=0,y=0;
        rep(i,N) if(A[i]==mn) x++; else y++;

        int C = mx;
        if(x>=C){
            cout << "No" << endl;
            return 0;
        }
        int rem = C-x;
        if(y < 2*rem){
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
    }else{
        if(A[0] == N-1){
            cout << "Yes" << endl;
            return 0;
        }
        if(N >= 2*A[0]){
            cout << "Yes" << endl;
            return 0;
        }
        cout << "No" << endl;
    }
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARounding solver = new ARounding();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARounding {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt(), a = in.nextInt();

            out.println(x < a ? 0 : 10);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 20820
import sys

n = int(input())
a = list(map(int, input().split()))

if 0 in a:
    print(0)
    sys.exit()

hg = 10 ** 18
ans = 1
for i in a:
    ans *= i
    if ans > hg:
        print(-1)
        sys.exit()

print(ans)

Measured memory_bytes: 21636
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

ll N;
long long MOD = 1000000007;

int main(void){

    cin >> N;
    ll ans = 0;

    ll ten = 1;
    ll nine = 1;
    ll eight = 1;

    for (int i = 1;i <= N;i++){
        ten = (ten * 10) % MOD;
        nine = (nine * 9) % MOD;
        eight = (eight * 8) % MOD;
    }

    ll teei = (ten + eight) % MOD;
    ll nitw = (nine * 2) % MOD;
    if (nitw > teei) ans = teei + MOD - nitw;
    else ans = teei - nitw;

    ans = ans % MOD;

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

Measured memory_bytes: 3568
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

bool visited[111];
int d[111];
vector<vector<int> > g(111);
typedef pair<int, int> P;

int main(){
  int n; cin >> n;
  FOR(i,0,n){
    int u, k; cin >> u >> k;
    FOR(j,0,k){
      int v;
      cin >> v;
      g[u].push_back(v);
    }
  }
  FOR(i,0,n+1) visited[i] = false;
  FOR(i,0,n+1) d[i] = -1;
  queue<P> que;
  que.push(P(1,0));
  visited[1] = true;
  while(!que.empty()){
    P p = que.front();que.pop();
    int u = p.first;
    d[u] = p.second;
    for(auto &v : g[u]){
      if(!visited[v]){
        que.push(P(v, p.second + 1));
        visited[v] = true;
      }
    }
  }
  FOR(i,1,n+1){
    cout << i << " " << d[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3108
N, W = map(int, input().split())

MAX_V = N * (10 ** 3)
w, v = [], []
for _ in range(N):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)

dp = [10**9+7 for _ in range(MAX_V + 1)]
dp[0] = 0

for i in range(N):
    for j in range(MAX_V, -1, -1):
        if j - v[i] >= 0:
            dp[j] = min(dp[j],dp[j - v[i]] + w[i])

mv = 0
for i in range(MAX_V + 1):
    if dp[i] <= W:
        mv = i

print(mv)


Measured memory_bytes: 45040
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

int main()
{
	fastio;
	int n,a,b,t,i;
	string s;
	cin>>t;
        cin>>s;
	int x=s.size()/2;
	int f=0;
	if(t & 1){
		cout<<"No"<<"\n";
		return 0;
	}
	else
	{
		for(i=0;i<(s.size()/2) && x<s.size();i++)
			if(s[i]==s[x++])
				f=0;
			else
			{
				cout<<"No"<<"\n";
				return 0;
			}


	}
	if(f==0)
		cout<<"Yes"<<"\n";
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<ll,P>  PP;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;
typedef priority_queue<PP, vector<PP>, greater<PP>> PPQueue;

#define fi          first
#define se          second
#define sfi         se.fi
#define sse         se.se
#define pb          push_back
#define INF         1LL << 50
#define MOD         1000000007
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     (upper_bound(all(x),y)-x.begin())
#define lb(x,y)     (lower_bound(all(x),y)-x.begin())
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)


int main(){
  cin.sync_with_stdio(false);
  ll n,m;
  cin >> n >> m;
  ll nmx = 1000;
  ll mmx = 2000;
  Vector a(mmx), b(mmx), c(mmx),dist(nmx,INF);
  rep(i,m){
    cin >> a[i] >> b[i] >> c[i];
    c[i] = -c[i];
  }
  dist[0] = 0;
  rep(loop,n-1)rep(i,m){
    if(dist[a[i] - 1] == INF)continue;
    if(dist[b[i] - 1] > dist[a[i] - 1] + c[i])dist[b[i] - 1] = dist[a[i] - 1] + c[i];
  }
  ll ans = dist[n - 1];
  vector<bool> negative(nmx,false);
  rep(loop,n)rep(i,m){
    if(dist[a[i] - 1] == INF)continue;
    if(dist[b[i] - 1] > dist[a[i] - 1] + c[i]){
      dist[b[i] - 1] = dist[a[i] - 1] + c[i];
      negative[b[i] - 1] = true;
    }
    if(negative[a[i] - 1] == true)negative[b[i] - 1] = true;
  }

  if(negative[n - 1]) cout << "inf" << endl;
  else                cout << -ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rush() int T;scanf("%d",&T);int kase=1;while(T--)
#define pb(x) push_back(x)
#define pr pair<int,int>
#define mem(a) memset(a,0,sizeof(a))
#define  fi first
#define  se second
using namespace std;
typedef long long ll;
const ll maxn=2e6+5;
const ll mod=1e9+7;
ll quickpow(ll x,ll y,ll mod){ll ans=1;while(y){if(y&1)ans=ans*x%mod;x=x*x%mod;y>>=1;}return ans;}

int a[maxn]={0};

int main()
{
    int n;
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        sum+=x;
        a[x]++;
    }
    int q;
    cin>>q;
    while(q--)
    {
        int b,c;
        cin>>b>>c;
        sum+=(c-b)*a[b];
        a[c]+=a[b];
        a[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 3972
import java.io.*;

public class Main {
	static int[][] grid = null;
	static long[][] dp = null;
	static long mod = 1000000007;
	
	public static long countWays(int i, int j) {
		if(i<0 || j<0) return 0L;
		if(i==0 && j==0) return 1L;
		if(grid[i][j] == 0) return 0L;
		if(dp[i][j]!=0) return dp[i][j];
		return dp[i][j] = (countWays(i-1, j)+countWays(i, j-1))%mod;
	}
	
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str;
		str = br.readLine().split(" ");
		int h = Integer.parseInt(str[0]);
		int w = Integer.parseInt(str[1]);
		grid = new int[h][w];
		//dp = new long[h][w];
		dp = new long[h+1][w+1];
		for(int i=0; i<h; i++) {
			String tmp = br.readLine();
			for(int j=0; j<tmp.length(); j++) {
				if(tmp.charAt(j)=='.')
					grid[i][j] = 1;
			}
		}
		//System.out.println(countWays(h-1, w-1));
		for(int i=1; i<=h; i++) {
			for(int j=1; j<=w; j++) {
				if(i==1 && j==1) {
					dp[i][j] = 1;
					continue;
				}
				if(grid[i-1][j-1]!=0) dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
			}
		}
		System.out.println(dp[h][w]);
	}
}

Measured memory_bytes: 37892
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;

int main()
{
  int w,d,a,b,ans;
  queue<int> A,B;
  while(1){
    cin>>w>>d;
    if(w==0 && d==0)break;
    for(int i=0;i<w;i++){
      cin>>a;
      A.push(a);
    }
    for(int i=0;i<d;i++){
      cin>>b;
      B.push(b);
    }
    ans=0;
    while(!A.empty()){
      int c=A.front();A.pop();
      for(int i=0;i<B.size();i++){
	int d=B.front();B.pop();
	if(c==d)break;
	else B.push(d);
      }
      ans+=c;
    }
    while(!B.empty()){
      int e=B.front();B.pop();
      ans+=e;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
a, b, ab, x, y = map(int, input().split())
ave = (a + b) / 2

if ave > ab:
    amt = ab * min(x, y) * 2
    if x > y:
        if a > ab * 2:
            amt += ab * (x - y) * 2
        else:
            amt += a * (x - y)
    else:
        if b > ab * 2:
            amt += ab * (y - x) * 2
        else:
            amt += b * (y - x)
else:
    amt = a * x + b * y
    
print(amt)

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    ll dsum = 0;
    for (int i = 0;i < n;++i) {
        ll d,c;
        cin >> d >> c;
        ans += c;
        dsum += d*c;
    }
    ans--;
    ans += dsum/9;
    if (dsum%9 == 0) ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;

int main() {
	int N;
	cin >> N;
	unsigned long long int x = 1;
	for (int i = 1; i <= N; i++) {
		x = (i*x) % (int)(pow(10, 9) + 7);
	}
	cout << x << endl;
}

Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		String[] sx=br.readLine().split(" ");
		String[] sy=br.readLine().split(" ");
		double[] x=new double[n];
		double[] y=new double[n];
		for (int i=0;i<n;i++){
			x[i]=Double.parseDouble(sx[i]);
			y[i]=Double.parseDouble(sy[i]);
		}
		System.out.printf("%.6f\n",manDis(x,y,n));
		System.out.printf("%.6f\n",eucDis(x,y,n));
		System.out.printf("%.6f\n",mincoDis(x,y,n));
		System.out.printf("%.6f\n",cheDis(x,y,n));
	}
	public static double manDis(double x[],double y[],int n){
		double manD=0;
		for(int i=0;i<n;i++){
			manD +=Math.abs(x[i]-y[i]);
		}
		return manD;
	}

	public static double eucDis(double x[],double y[],int n){
		double eucD=0;
		for(int i=0;i<n;i++){
			eucD +=(x[i]-y[i])*(x[i]-y[i]);
		}
		return Math.sqrt(eucD);
	}

	public static double mincoDis(double x[],double y[],int n){
		double mincoD=0;
		for(int i=0;i<n;i++){
			mincoD +=Math.pow(Math.abs(x[i]-y[i]),3);
		}
		return Math.cbrt(mincoD);
	}

	

	public static double cheDis(double x[],double y[],int n){
		double cheD,maxD=0;
		for(int i=0;i<n;i++){
			cheD =Math.abs(x[i]-y[i]);
			if(cheD>maxD) maxD=cheD;
		}
		return maxD;
	}
	
}

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

int main() {
  int n;
  cin >> n;
  
  int m = n / 111;
  
  if(n % 111 == 0) {
    cout << m * 111 << endl;
  } else {
    cout << (m + 1) * 111 << endl;
  }
}

Measured memory_bytes: 256
def counter(a,n):
    big = max(a)
    check = True
    counter = 0
    while big > n-1:
        for i in range(n):
            if a[i] == big and check:
                check = False
                a[i] -= n
            else:
                a[i] += 1
        counter += 1
        big = max(a)
        check = True
    return counter

k = int(input())
n = 50
print(n)
temp = k//50
a = [49+temp for i in range(n)]
k = k - 50*(k//50)
for i in range(k):
    big = min(a)
    check = True
    for j in range(n):
        if a[j] == big and check:
            check = False
            a[j] += 50
        else:
            a[j] -= 1
for i in range(n):
    if i != n-1:
        print(a[i],end = " ")
    else:
        print(a[i])

Measured memory_bytes: 3064
#include<stdio.h>

typedef long long int ll;
ll n,ans=0;

int dfs(ll a,ll n3,ll n5,ll n7){
    if(a>n)return ans;
    if(n3+n5+n7==3)ans++;
    dfs(a*10+7,1,n5,n7);
    dfs(a*10+5,n3,1,n7);
    dfs(a*10+3,n3,n5,1);
}

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

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

typedef long long W;

const W INF = 1LL << 50;

struct edge {
	int to;
	W cost;
};
typedef pair<W, int> P;
typedef vector<vector <edge > > Graph;

ll H[100000];
ll dist[100000];

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

	int N, M;
	ll X;
	cin >> N >> M >> X;
	for(int i = 0; i < N; i++) {
		cin >> H[i];
	}

	Graph G(N);
	for(int i = 0; i < M; i++) {
		int a, b;
		ll t;
		cin >> a >> b >> t;
		a--, b--;
		G[a].push_back({ b, t });
		G[b].push_back({ a, t });
	}

	fill((ll*)begin(dist), (ll*)end(dist), INF);
	dist[0] = 0;
	priority_queue<P, vector<P>, greater<P>> q;
	q.push({ 0, 0 });

	ll ans = INF;
	while(q.size()) {
		int v = q.top().second;
		ll d = q.top().first;
		q.pop();
		if(dist[v] < d) continue;

		ll h = max(X - dist[v], 0LL);

		if(v == N - 1) {
			ans = min(ans, d + H[N - 1] - h);
			continue;
		}

		for(auto e : G[v]) {
			ll nd = d;
			if(H[v] < e.cost) continue;
			if(h - e.cost >= 0) {
				if(h - e.cost > H[e.to]) nd += h - e.cost - H[e.to];
				nd += e.cost;
			}
			else nd += e.cost - h + e.cost;

			if(dist[e.to] > nd) {
				dist[e.to] = nd;
				q.push({ nd, e.to });
			}
		}
	}

	if(ans == INF) ans = -1;
	cout << ans << endl;
}

Measured memory_bytes: 23192
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9012337203685477580
using ll = long long;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    ll ans = 0;
    vector<vector<ll>> score(8,vector<ll>(N));
    for (int i = 0; i < N; i++)
    {
        ll x[3];
        cin >> x[0] >> x[1] >> x[2];
        for (int j = 0; j < 8; j++)
        {
            ll n = 0;
            for (int k = 0; k < 3; k++)
            {
                if (1 & (j >> k)) {
                    n -= x[k];
                }
                else {
                    n += x[k];
                }
            }
            score[j][i] = n;
        }
    }
    for (int i = 0; i < 8; i++)
    {
        ll tmp = 0;
        sort(RALL(score[i]));
        for (int j = 0; j < M; j++)
        {
            tmp += score[i][j];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    getchar(); getchar();
}

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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;
        public static string s = Console.ReadLine();
        public static bool[]sss=new bool[5];
            
    static void Main(string[] args)
        {
            
            int[] ss = new int[10];
            for (int i = 0; i < s.Length; i++)
            {
                string a = "" + s[i];
                ss[i] = int.Parse(a);
            }

            string ans = ""+ss[0]; ;


            if (Dfs(0, ss, ss[0]))
            {
                for (int i = 1; i < s.Length; i++)
                {
                    if (sss[i-1]) ans += "+";
                    else ans += "-";
                    ans += ss[i];
                }
            }

            ans += "=7";

            //foreach (var ssss in sss) Console.WriteLine(ssss);
            Console.WriteLine(ans);
                
                

            



        }

        static public bool Dfs(int i,int[] ss,long sum)
        {
            if (i == s.Length-1) return sum==7;

            if (Dfs(i + 1, ss, sum + ss[i+1]))
            {
                sss[i] = true;
                return true;
            }

            if (Dfs(i + 1, ss, sum - ss[i+1])) 
            {
                sss[i] = false;
                return true;
            }

            return false;
        }

       
        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }

        
       
    }
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

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

  int mi = max(-1000000, x-k+1);
  int ma = min(1000000, x+k-1);

  for(int i=mi; i<=ma; i++){
    cout << i << " ";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

VI p(32);
vector<P> range(32);
VI ans(32, 0);

int main(){
	int n;
    cin >> n;
    string s="";

    if(n==0){
        cout << 0 << endl;
        return 0;
    }

    int x = 1;
    rep(i,32){
        p[i] = x;
        x *= -2;
    }

    int left=0, right=0;
    rep(i,32){
        // Exception handling to prevent overflow
        if(i==31){
            left = p[i];
        }else if(i%2 == 0){
            right += p[i];
        }else{
            left += p[i];
        }
        range[i] = P(left,right);
    }

    while(n != 0){
        int top;
        rep(i,32){
            int l = range[i].first;
            int r = range[i].second;
            if(l <= n && n <= r){
                top = i;
                break;
            }
        }
        ans[top] = 1;
        n -= p[top];
    }

    bool flag=false;
    rep(i,32){
        int j = 31-i;
        if(ans[j] == 1) flag = true;
        if(flag) cout << ans[j];
    }

    cout << endl;

    // rep(i,32){
    //     cout << range[i].first <<" "<< range[i].second << " ";
    //     cout << p[i] << endl;
    // }

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;

int main()
{
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    int res = 0;

    for (int i = 0; i <= 200; i++)
    {
        if (a <= i && i < b && c <= i && i < d)
            res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    
    int a,b ;
    
    
    scanf( "%d%d"  , &a ,&b);
    
    
if (a>b) {
        printf("a > b\n");
}
else if(a==b){ printf("a == b\n");
}
  else{printf("a < b\n");}
    
    return 0;
    
}



Measured memory_bytes: 2100
/*
    Don't practice until you get it right. Practice until you can't get it wrong.
*/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vl>
#define vb vector<bool>
#define vs vector<string>
#define vp vector<pii>
#define pb push_back
#define mp make_pair
#define sc(a) scanf("%lld",&a);
#define sd(a) scanf("%lf",&a);
#define test() ll tt;cin>>tt;for(ll testcase=1;testcase<=tt;testcase++)
#define all(v) v.begin(),v.end()
#define vivek_ghosh ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second

const int MAX = 1000055;
const int mod = 1000000007;
// const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ll INF = LLONG_MAX;

ll power(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

ll modinv(ll a,ll m)
{
    ll g =__gcd(a, m);
    ll res=power(a, m-2, m);
    return res;
}

vb prime(MAX,true);
vl prm;
void sieve()
{
	prime[0] = prime[1] = false;
	for(ll p=2;p*p<MAX;p++)
	{
		if(prime[p])
		{
			for(ll i=p*p;i<MAX;i+=p)
				prime[i] = false;
		}
	}

	for(ll p=2;p<MAX;p++)
	{
		if(prime[p])
			prm.pb(p);
	}
}

ll n,m,t,i,j,k,q,x,y,ans=0,cnt=0,sum=0,mx=INT_MIN,mn=INT_MAX;
string s;

int main()
{
	vivek_ghosh;

	cin>>s;
	n = int(s.size());

	for(i=0;i<n;i++)
	{
		if(s[i] == '?')
		{
			if(i)
			{
				if(s[i-1] == 'P')
				{
					s[i] = 'D';
				}
			}
			if(s[i] == '?')
			{
				if(i<n-1)
				{
					if(s[i+1] == 'D')
					{
						s[i] = 'P';
					}
					else if(s[i+1] == '?')
					{
						s[i] = 'P';
					}
					else
						s[i] = 'D';
				}
				else
				{
					s[i] = 'D';
				}
			}
			else
			{
				s[i] = 'D';
			}
		}
	}

	cout<<s<<endl;

	return 0;
}



















Measured memory_bytes: 3864
import Control.Applicative
import Control.Monad
import Data.List
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M
import Data.Set (Set)
import qualified Data.Set as S

main :: IO ()
main = do
  [t, p, r] <- g
  unless (t == 0 && p == 0 && r == 0) $ do
    solve t <$> replicateM r f >>= mapM_ putStrLn
    main
  where
    f = words <$> getLine
    g = map read <$> f

solve :: Int -> [[String]] -> [String]
solve t xss = let idb = V.replicate t (0, 0) :: Vector (Int, Int)
                  ice = M.empty :: Map (Int, Int) Int
                  isc = S.empty :: Set (Int, Int)
                  (db, _, _) = foldl' f (idb, ice, isc) xss
              in map (\((a,b),c) -> (unwords . map show) [c, a, b]) $ sortBy g $ zip (V.toList db) [1..]
  where
    f (db, ce, sc) [sti, spi, stm, mes] =
      let (ti, pi, tm) = (read sti - 1, read spi, read stm) :: (Int, Int, Int)
      in if mes == "CORRECT"
           then
             if S.member (ti, pi) sc
               then (db, ce, sc)
               else let (c, p) = db ! ti
                        e = M.findWithDefault 0 (ti, pi) ce
                    in (db // [(ti, (c + 1, p + tm + 1200 * e))], ce, S.insert (ti, pi) sc)
           else
             let e = M.findWithDefault 0 (ti, pi) ce
             in (db, M.insert (ti, pi) (e + 1) ce, sc)
    g ((ca, pa), ia) ((cb, pb), ib)
      | ca == cb && pa == pb = compare ia ib
      | ca == cb = compare pa pb
      | otherwise = compare cb ca



Measured memory_bytes: 6428