akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	maxBufSize = 1024 * 1024
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, 1)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	out = bufio.NewWriter(os.Stdout)
)

type t struct {
	t int64
	f int64
	c byte
}

func solve(s []byte, q int64, qs []t) []byte {
	edges := make([][]byte, 2)
	edges[0] = make([]byte, 0, q)
	edges[1] = make([]byte, 0, q)
	frontIdx := 0

	reversed := false
	for _, tt := range qs {
		if tt.t == 1 {
			reversed = !reversed
			frontIdx = 1 - frontIdx
			continue
		}
		if tt.f == 1 {
			edges[frontIdx] = append(edges[frontIdx], tt.c)
		} else {
			edges[1 - frontIdx] = append(edges[1 - frontIdx], tt.c)
		}
	}

	ret := make([]byte, 0, len(s) + len(edges[0]) + len(edges[1]))
	for i := len(edges[frontIdx]) - 1; i >= 0; i-- {
		ret = append(ret, edges[frontIdx][i])
	}
	if reversed {
		for i := len(s) - 1; i >= 0; i-- {
			ret = append(ret, s[i])
		}
	} else {
		for _, b := range s  {
			ret = append(ret, b)
		}
	}
	for _, b := range edges[1 - frontIdx] {
		ret = append(ret, b)
	}
	return ret
}

func main() {
	defer out.Flush()

	s := nextStringAsBytes()
	q := nextInt()

	qs := make([]t, q)
	for i := int64(0); i < q; i++ {
		qs[i].t = nextInt()
		if qs[i].t == 2 {
			qs[i].f  = nextInt()
			qs[i].c  = nextStringAsBytes()[0]
		}
	}

	bytes := solve(s, q, qs)
	fmt.Fprintln(out, string(bytes))
}

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

func nextStringAsBytes() []byte {
	sc.Scan()
	return []byte(sc.Text())
}

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 10368
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define re return
#define pb push_back
#define po pop_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define si size
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pi 3.14159265359
#define er erase
#define in insert
#define em empty
#define ft front
#define fo(i,n) for(i = 0; i < n; i++)
#define ro(i,n) for(i = n - 1; i >= 0; i--)
#define fr(i,j,n) for(i = j; i < n; i++)
#define rf(i,j,n) for(i=n-1;i>=j;i--)
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::pair<int,int> ii;
typedef std::vector<ii> vii;
typedef std::vector<std::string> vs;
typedef double dl;
typedef long double ld;
typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> vll;
#define filename ""
using namespace std;
    map<string,int> m;
int main()
{
    /*
	freopen(filename".in","r",stdin);
	freopen(filename".out","w",stdout);
	*/
	/*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    */
    /*
    ios::sync_with_stdio(0);
    */
    int n,i;
    cin>>n;
    string s;
    fo(i,n)
    {
        cin>>s;
        m[s]++;
    }
    cin>>n;
    fo(i,n)
    {
        cin>>s;
        m[s]--;
    }
    int ma=m.begin()->se;
    for(auto j:m)
    {
        ma=max(ma,j.se);
    }
    if (ma>0)
    {
        cout<<ma<<'\n';
    }
    else
    {
        cout<<0<<'\n';
    }
    re 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::min;
fn main() {
    let n = read::<usize>();
    let mut h = vec![0; n+3];
    for i in 0..n {
        h[i] = read::<i64>();
    }

    let mut d :Vec<i64> = vec![100_000_000_000_000; n+3];
    d[0] = 0;
    for i in 0..n {
        let w1 = h[i+1] - h[i];
        let w2 = h[i+2] - h[i];

        d[i+1] = min(d[i+1], d[i]+w1.abs());
        d[i+2] = min(d[i+2], d[i]+w2.abs());
    }

    println!("{}", d[n-1]);
}

Measured memory_bytes: 6396
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int ans = 0;
		ans = a*b - a - b + 1;
		System.out.println(ans);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
INF = float('inf')


def LIST():
    return list(map(int, input().split()))


N = int(input())
h = LIST()

h.extend([0] * 2)

# DP配列を初期化
dp = [INF] * (N + 2)

# 初期条件を入力
dp[0] = 0

# テーブルを更新 くばるDP
for i in range(0, N):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))

print(dp[N - 1])

Measured memory_bytes: 13980
import java.util.*;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.io.*;

class SegmentTree{
    int maxElmNum = 131072;//this must be power of 2
    Integer[] tree;
    //edit here to solve different problems
    Integer initial = 0;
    private Integer op(Integer e1, Integer e2){
        return e1+e2;
    }

    private static int parent(int i){
        return (i-1)/2;
    }
    private static int leftchild(int i){
        return 2*i+1;
    }
    private static int rightchild(int i){
        return 2*i+2;
    }
    //make the empty tree
    public SegmentTree(){
        tree = new Integer[maxElmNum*4];
        for(int i=0;i<tree.length;i++) tree[i]=initial;
    }
    //fix tree[i] and the ancestors
    private void reflesh(int i){
        tree[i] = op(tree[leftchild(i)], tree[rightchild(i)]);
        if(i>0) reflesh(parent(i));
    }
    //
    private void setTree(int i, Integer elm){
        tree[i] = elm;
        reflesh(parent(i));
    }
    //replace array[i] with elm and reflesh the tree
    public void set(int i, Integer elm){
        setTree(maxElmNum+i-1,elm);
    }
    //make new tree which contains the given array
    public void make(Integer[] elements){
        for(int i=0;i<elements.length;i++) tree[i+maxElmNum-1]=elements[i];
        for(int i=maxElmNum-2;i>=0;i--) tree[i]=op(tree[2*i+1],tree[2*i+2]);
    }
    private Integer get(int left, int right, int nodeNum, int nodeStart, int nodeEnd){
        if(nodeEnd<=left || right<=nodeStart) return initial;
        if(left<=nodeStart && nodeEnd<=right) return tree[nodeNum];

        Integer leftValue  = get(left,right,2*nodeNum+1,nodeStart,(nodeStart+nodeEnd)/2);
        Integer rightValue = get(left,right,2*nodeNum+2,(nodeStart+nodeEnd)/2,nodeEnd);
        return op(leftValue,rightValue);
    }
    //calculate the answer in [l,r)
    public Integer get(int left, int right){
        return get(left,right,0,0,maxElmNum);
    }
}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        String S = sc.next();

        ArrayList<Integer> s = new ArrayList<>();

        {
            char cur = S.charAt(0);
            if(cur=='0') s.add(0);
            int cont = 0;
            for(int n=0; n<N; n++){
                if(S.charAt(n)==cur) cont++;
                else {
                    s.add(cont);
                    cont=1;
                    cur = S.charAt(n);
                }
            }
            s.add(cont);
            if(S.charAt(N-1)=='0') s.add(0);
        }


        SegmentTree sTree = new SegmentTree(); sTree.make(s.toArray(new Integer[s.size()]));



        int range = 2*K+1;
        int ans=sTree.get(0,range);
        for(int i=0; i<=s.size()-range; i+=2){
            ans = Math.max(ans, sTree.get(i,i+range));
        }

        System.out.println(ans);



    }
}


Measured memory_bytes: 39988
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int bob=0;
		int Alice=0;
		int b[]=new int[a];
		for(int i=0;i!=a;i++) {
			b[i]=scan.nextInt();
		}
		Arrays.sort(b);
		for(int i=0;i!=a;i++) {
			if(i%2==0) {
				bob+=b[i];
			}
			else {
				Alice+=b[i];
			}
		}
		System.out.println(Math.abs(Alice-bob));
	}
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <map>
#include <set>
#include <vector>
using namespace std;

const long long mod = 1000000007;
long long comb[505][505], phi[505], pw[505], inv[505];

int N, M, K;
vector<int> G[505],I[505];
int par[505], chk[505];
vector<int> k,p;

int find(int x)
{
	if (par[x] != x) par[x] = find(par[x]);
	return par[x];
}

void dfs(int x)
{
	for (int i=0;i<G[x].size();i++){
		int y = G[x][i];
		if (chk[y]){
			bool good = 0;
			for (int j=0;j<k.size();j++) if (k[j] == y) good = 1;
			if (good) for (int j=(int)p.size()-1;j>=0;j--){
				par[(find(p[j]))] = find(I[x][i]);
				if (k[j] == y) break;
			}
		}
		else{
			k.push_back(x);
			p.push_back(I[x][i]);
			chk[x] = 1;
			dfs(y);
			k.pop_back();
			p.pop_back();
		}
	}
}

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

	for (int i=0;i<505;i++){
		comb[i][0] = comb[i][i] = 1;
		for (int j=1;j<i;j++) comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % mod;
	}

	for (int i=1;i<505;i++) phi[i] = i;
	for (int i=1;i<505;i++){
		for (int j=i*2;j<505;j+=i) phi[j] = (phi[j] + mod - phi[i]) % mod;
	}

	pw[0] = 1;
	for (int i=1;i<505;i++) pw[i] = pw[i-1] * K % mod;

	inv[1] = 1;
	for (int i=2;i<505;i++) inv[i] = (mod - mod / i) * inv[mod % i] % mod;

	for (int i=1;i<=M;i++){
		int x, y; scanf("%d %d", &x, &y);
		G[x].push_back(y);
		I[x].push_back(i);
		G[y].push_back(x);
		I[y].push_back(i);
	}

	for (int i=1;i<=M;i++) par[i] = i;

	for (int i=1;i<=N;i++) if (!chk[i])
	{
		dfs(i);
	}

	long long ans = 1;
	map<int, int> sz;
	map<int, set<int> > vt;
	for (int i=1;i<=M;i++){
		sz[find(i)]++;
	}
	for (int i=1;i<=N;i++) for (int j=0;j<I[i].size();j++) vt[find(I[i][j])].insert(G[i][j]);

	for (auto &p : sz){
		if (vt[p.first].size() == p.second){
			long long c = 0;
			for (int d=1;d<=p.second;d++) if (p.second % d == 0){
				c = (c + phi[d] * pw[p.second/d]) % mod;
			}
			c = c * inv[p.second] % mod;
			ans = ans * c % mod;
		}
		else{
			ans = ans * comb[p.second+K-1][K-1] % mod;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2432
import sys
from collections import deque

N=input()
A=map(int, sys.stdin.readline().split())
A=map(lambda x: x*2, A)

a=sum(A)/2

for i in range(1,N):
	if i%2==1:
		a-=A[i]

#a
print a,

prev=a
for x in A[:-1]:
	x-=prev
	print x,
	prev=x

Measured memory_bytes: 43288
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    map<int,int> m;
    REP(i,n) {
        int x; cin >> x;
        m[x]++;
    }

    bool ans = false;

    if (m.size() == 1 && m.begin()->first == 0) ans = true;

    if (n % 3 == 0) {
        if (m.size() == 2 ) {
            for(auto kv : m) {
                if (kv.first == 0) {
                    if (kv.second * 3 == n ) ans = true;
                }
            }
        } else if (m.size() == 3) {
            vector<int> k;
            vector<int> v;
            for(auto kv : m) {
                k.emplace_back(kv.first);
                v.emplace_back(kv.second);
            }
            if (v[0] == v[1] && v[1] == v[2]) {
                if ((k[2] ^ k[1]) == k[0]) ans = true;
                if ((k[2] ^ k[0]) == k[1]) ans = true;
                if ((k[0] ^ k[1]) == k[2]) ans = true;
            }
        }
    }

    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;

const int N = 200000 + 123;

int a[N];

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        ++a[x];
    }
    int diff = 0;
    for (int i = 0; i < N; ++i) {
        diff += a[i] > 0;
    }
    if (diff > k) {
        sort(a, a + N);
        int res = 0;
        int qwe = 0;
        for (int i = 0; qwe < diff - k && i < N; ++i) {
            if (a[i] > 0) ++qwe;
            res += a[i];
        }
        printf("%d\n", res);
    }
    else {
        puts("0");
    }
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long n, res,ans;

 

const long long  mod = 1000000007;
 
long long powmod(long long x, long long y) 
{
     res = 1;
    for (long long i=0; i<y; i++) 
        res = res * x % mod;

    return res;
}
 
 
int main() 
{

 
      
    cin >> n;
 
     ans = powmod(10, n) - powmod(9, n) * 2 + powmod(8, n);
    
    ans = ans%mod;
    ans = (ans+mod)%mod;
 
    cout << ans << endl;    
    
 
   
 
  
}

Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int64 a[N], b[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld%lld", &a[i], &b[i]);
  }
  int64 ret = 0;
  for (int i = n - 1; i >= 0; --i) {
    a[i] += ret;
    ret += (a[i] + b[i] - 1) / b[i] * b[i] - a[i];
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 1792
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
hat = [0, 0, 0]
MOD = 10 ** 9 + 7
answer = 1
for i in range(N):
    x = hat.count(A[i])
    if x == 0:
        answer = 0
    else:
        answer *= x
        j = hat.index(A[i])
        hat[j] += 1
        answer %= MOD

print(answer%MOD)
# 30


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

int main(){
  int n;
  cin >> n;
  char s[n];
  REP(i, n) s[i] = '0';
  REP(i, n) cin >> s[i];
  int ans = 0;
  char comp = s[0];
  
  REP(i,n){
    if(s[i+1] == '0') break;
  	if(comp != s[i+1]){
      comp = s[i+1];
      ans += 1;
    }
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 384
/* Coached by rainboy */
#include <stdio.h>

#define C 30
#define INF 0x3f3f3f3f

int main() {
	static int dd[C][C], kk1[C], kk2[C], kk3[C];
	int n, c, i, j, x, c1, c2, c3, a, cost, ans;

	scanf("%d%d", &n, &c);
	for (i = 0; i < c; i++)
		for (j = 0; j < c; j++)
			scanf("%d", &dd[i][j]);
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++) {
			scanf("%d", &a), a--;
			x = (i + j) % 3;
			if (x == 0)
				kk1[a]++;
			else if (x == 1)
				kk2[a]++;
			else
				kk3[a]++;
		}
	ans = INF;
	for (c1 = 0; c1 < c; c1++)
		for (c2 = 0; c2 < c; c2++)
			for (c3 = 0; c3 < c; c3++)
				if (c1 != c2 && c1 != c3 && c2 != c3) {
					cost = 0;
					for (a = 0; a < c; a++)
						cost += kk1[a] * dd[a][c1] + kk2[a] * dd[a][c2] + kk3[a] * dd[a][c3];
					if (ans > cost)
						ans = cost;
				}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
mod = 10**9+7
def mult(A, B):
    C = [[0 for i in range(len(A))] for i in range(len(A))]

    for i in range(len(A)):
        for j in range(len(A)):
            for k in range(len(A)):
                C[i][j] = (C[i][j]+A[i][k]*B[k][j])%mod
    
    return C

def exp(A, p):
    ans = [[0 for i in range(len(A))] for i in range(len(A))]
    for i in range(len(A)):
        ans[i][i] = 1
    
    while p:
        if p%2 == 0:
            A = mult(A, A)
            p = p//2
        else:
            ans = mult(ans, A)
            p -= 1
    
    return ans

n, k = map(int, input().strip().split())
grid = [list(map(int, input().strip().split())) for i in range(n)]

print(sum([sum(i)%mod for i in exp(grid, k)])%mod)





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

int main() {

int N,k=0; cin>>N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin>>A.at(i);}
  
  sort(A.begin(),A.end(),greater<int>());
  for(int i=0; i<N;i++){
    if(i%2==0)k+=A.at(i);
    else{k-=A.at(i);}
  }
  cout<<k<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long int64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 3e3+5;
struct Edge
{
    int next, to;
    Edge(int next = 0, int to = 0):next(next), to(to) {};
}edge[N<<1];
int tot, head[N];
void _add(int x, int y) { edge[++tot] = Edge(head[x], y), head[x] = tot; }
void add(int x, int y) { _add(x, y), _add(y, x); } 
int n, a[N];
bool dfs(int x, int fa, int d)
{
    if(a[x] >= a[fa]) return true;
    for(int i = head[x]; i; i = edge[i].next)
    {
        int y = edge[i].to; if(y == fa) continue;
        if(!dfs(y, x, d^1)) return true;
    }
    return false;
}
int main()
{
    a[0] = 1e9+1, n = read();
    for(int i = 1; i <= n; ++i) a[i] = read();
    for(int i = 1; i < n; ++i)
    {
        int x = read(), y = read();
        add(x, y);
    }
    for(int x = 1; x <= n; ++x) if(dfs(x, 0, 0)) printf("%d ", x);
    return 0;
}

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

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

int K, T;
int A[100010];

signed main()
{
    cin >> K >> T;
    rep(i, T)cin >> A[i];
    sort(A, A + T);
    reverse(A, A + T);
    if(A[0] <= K / 2)cout << 0 << endl;
    else cout << K - 1 - (K - A[0]) * 2 << endl;
    return 0;
}


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

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;

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

ll modpow(ll x, ll n) {
    ll ret = 1;
    while(n > 0) {
        if((n & 1) == 1) {
            ret = ret * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

ll combine(ll n, ll k) {
    ll ret;
    ll p = 1;
    ll q = 1;
    for(ll i = 0; i < k; i++) {
        p *= n - i;
        p %= MOD;
        q *= k - i;
        q %= MOD;
    }
    ret = p * modpow(q, MOD - 2);
    ret %= MOD;
    return ret;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = modpow(2, n) - 1;
    ans -= combine(n, a);
    if(ans < 0) ans += MOD;
    ans -= combine(n, b);
    if(ans < 0) ans += MOD;
    ans %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 256
while True:
    h,w = map(int, input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        x = ["."]*w
        if i%2==0:
            for i in range(0,w,2):
                x[i] = "#"
        else:
            for i in range(1,w,2):
                x[i] = "#"
        print("".join(x))
    print()


Measured memory_bytes: 5616
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>


using namespace std;

const int MAX	= 1e5 + 5;
const int LIM	= 3e5 + 5;
const int MOD	= 1e9 + 7;
const long double  EPS	= 1e-10;
const double PI = acos(-1.0);

typedef long long LL; 
typedef long double LD;


#define uint64 unsigned long long
#define int64 long long


#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

////////////////////////////////////////////////////////////////

int main()
{
    double  N;
    cin >> N;

    int ans = N / 1.08;

    if (ceil(N/1.08) < ceil((N+1) / 1.08)) {
            cout << ceil(N/1.08) << "\n";
            }
    else {
        	cout << ":(" << "\n";
        }
        return 0;
}




Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
   int n,m;
   cin>>n>>m;

   vector<int> s(m,0);
   vector<int> c(m,0);
   rep(i,m){
      cin>>s[i]>>c[i];
   }

   rep(i,1000){
      string k=to_string(i);
      if(k.size()!=n) {
         continue;
      }

      bool kari=true;
      rep(j,m){
         if(k[s[j]-1]!=to_string(c[j])[0]) {
            kari=false;
         
         }
      }
      if(kari==true){
         cout<<i<<endl;
         return 0;
      }
   }
   

cout<<"-1"<<endl;

return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        if (n < 3) {
            out.println(Math.abs(a[1] - a[0]));
            return;
        }


        int[] dp = new int[n];
        dp[1] = Math.abs(a[1] - a[0]);
        for (int i = 2; i < n; i++) {
            int x = dp[i - 2] + Math.abs(a[i - 2] - a[i]);
            int y = dp[i - 1] + Math.abs(a[i - 1] - a[i]);
            dp[i] = Math.min(x , y);
        }

        out.println(dp[n - 1]);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}


Measured memory_bytes: 35892
import java.util.Scanner;

public class Main {
    static int man[];
    static int ans;

    /**
     * @param args
     */
    public static void main(String[] args) throws java.io.IOException {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            System.out.println((n * n + n + 2) / 2);
        }
    }
}

Measured memory_bytes: 11000
N = int(input())

def count(a1,a2):
    res = 0
    for b in range(1,N+1):
        sb = str(b)
        if sb[0]==a2 and sb[-1]==a1:
            res += 1
    return res

d = {}
for a1 in range(1,10):
    for a2 in range(10):
        d[(str(a1),str(a2))] = count(str(a1),str(a2))

ans = 0
for a in range(1,N+1):
    sa = str(a)
    a1 = sa[0]
    a2 = sa[-1]
    ans += d[(a1,a2)]

print(ans)

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

int main(){

 int N;
 cin >> N;
 
 int sum = 0;
 
 for(int i =0; i < N; i++){
  int li, ri;
  cin >> li >> ri;
 
  sum += ri - li + 1;
   
 }

 cout << sum << endl;
  
}

Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

int main() {
    cin.tie();
    ios::sync_with_stdio(false);
    
    // input
    int x;
    cin >> x;
    
    if (x/100 == x%10) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);
        int num = N / K;
        long ans = (long)Math.Pow(num, 3);
        if (K % 2 == 0)
        {
            num = (N + K / 2) / K;
            ans += (long)Math.Pow(num, 3);
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;

int a[N];
ll Sum[N];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

int main() {

	int n = read(),L = read();
	For(i,1,n) a[i] = read(),Sum[i] = Sum[i - 1] + a[i];

	ll ans = 1e18;
	For(i,1,n) {
		ll tot = 0;int pos = n;
		For(j,1,n / i + 1) {
			tot += 1ll * max(5,2 * j + 1) * (Sum[pos] - Sum[max(0,pos - i)]);
			if(tot > ans) break;
			pos = max(0,pos - i);
		}
		tot = tot + 1ll * (i + n) * L;
		ans = min(ans,tot);
	}

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


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1
#define j0 gray_cat_j0

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 16;
const int INF = 1e9 + 10;
const ll MOD = 998244353;

const int MAXN = 3e3 + 5;

ll dp[MAXN][MAXN];

void solve(){
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	dp[a][b] = 1;
	REPN(i, a + 1, c) {
		dp[i][b] = (dp[i - 1][b] * b) % MOD;
	}
	REPN(j, b + 1, d) {
		dp[a][j] = (dp[a][j - 1] * a) % MOD;
	}
	REPN(i, a + 1, c) {
		REPN(j, b + 1, d) {
			dp[i][j] = (dp[i - 1][j] * j + dp[i][j - 1] * i) % MOD;
			dp[i][j] = ((dp[i][j] - (i - 1) * (j - 1) * dp[i - 1][j - 1]) % MOD + MOD) % MOD;
		}
	}
	cout << dp[c][d] << endl;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 74096
#include <bits/stdc++.h>
#define R cin>>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long unsigned int ll;;
int main(){
    vector<int> v(3);
    cin>>v[0]>>v[1]>>v[2];
    sort(all(v));
    int x = v[2]*2-v[0]-v[1];
    if (x%2==1) x += 3;
    printf("%d", x/2);
    return 0;
}


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

int main(){
    double a,b,S,L,h,C;
    cin>>a>>b>>C;
    double PI=acos(-1);
    S=a*b*sin(C*PI/180)*1/2;
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(C*PI/180));
    h=b*sin(C*PI/180);
    printf("%lf\n%lf\n%lf\n",S,L,h);

    return 0;
}


Measured memory_bytes: 3548
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize a, b, c, d;
    std::cin >> a >> b >> c >> d;
    std::cout << std::max(a*b, c*d) << '\n';
}


Measured memory_bytes: 256
#include<cstdio>
int a[500005];
int maxn[500005][2];

int max(int a,int b){ return a>b?a:b; }

int min(int a,int b){ return a>b?b:a; }

void update(int&a,int&b,int c){
    if(c>a){ 
        if(b<a) b = a;
        a = c;
    }
    else if(c>b) b = c;
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i < (1<<n); i++) scanf("%d",&a[i]);  
    for(int i = 1; i < (1<<n); i++){
        int m0 = 0, m1 = 0;
        for(int j = i; ; j = (j-1)&i){
            update(m0,m1,a[j]);
            if(j==0) break;
        }
        maxn[i][0] = m0, maxn[i][1] = m1;
    }
    int ans = 0;
    for(int i = 1; i < (1<<n); i++){
        ans = max(ans,maxn[i][0]+maxn[i][1]);
        printf("%d\n",ans);
    }
    return 0;
}


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

#define REP(i, n) for(int i=0;i<n;i++)
#define REPR(i, n) for(int i=n;i>0;i--)
#define FOR(i, j, n) for(int i=j;i<n;i++)
#define COUT(n) cout<<(n)<<"\n"

typedef long long ll;
const int INF = 1e9;

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

    int n; cin >> n;
    double x[n], y[n];
    double ans = 0;
    REP(i, n) cin >> x[i] >> y[i];
    REP(i, n){
        FOR(j, i+1, n){
            ans += sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
        }
    }
    ans = ans *  2 / n;

    cout << setprecision(10) << ans << endl;

    return 0;
} 

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

int main(){
  int n;
  cin>>n;
  vector<int> p(n),q(n);

  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  for(int i=0;i<n;i++){
    cin>>q[i];
  }
  vector<int> a(n);
  for(int i=0;i<n;i++){
    a[i]=i+1;
  }
  map<vector<int>, int> mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(a.begin(),a.end()));
  
  int ans=abs(mp[p]-mp[q]);
  cout<<ans<<endl;
  return 0;
}
    
    
    
  
  
  
  
  
  
  
  
  
  
  


Measured memory_bytes: 5248
#1:??¶??°???????\???°??????????????????def??§????????????????\???°?????????/2 +???????????°????????????
=begin
def even
    (h / 2).times do
        puts = "#." * (w / 2)
        puts = ".#" * (w / 2)
    end
end
def odd
    (h / 2).times do
        puts = "#." * w
        puts = ".#" * w
end
=end
def line(w, f, s)
    w.times do |i|
        if i.even?
            print f
        else
            print s
        end
    end
    puts ""
end

loop do
    h, w = gets.chomp.split.map(&:to_i)
    break if h==0 && w==0

    h.times do |i|
        if (i % 2) == 0
            line(w, "#", ".")
        else
            line(w, ".", "#")
        end
    end
    puts ""
end

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

void insert(vector<int> &t, int v) {
  if (t.size() == 0) {
    t.push_back(v);
  } else {
    auto itin = lower_bound(t.begin(), t.end(), v);
    t.insert(itin, v);
  }
}

int main() {
  int N, K;
  cin >> N >> K;
  int V[N];
  for (int i = 0; i < N; i++) cin >> V[i];

  long long ans = 0;
  vector<int> left(0), current(0);
  long long leftValue = 0, currentValue = 0, currentValue2 = 0;
  for (int i = 0; i <= K; i++) {
    if (0 < i && i <= N) {
      leftValue += V[i - 1];
      currentValue = leftValue;
      insert(left, V[i - 1]);
      current.resize(left.size());
      copy(left.begin(), left.end(), current.begin());
    }

    for (int j = 0; j <= K - i; j++) {
      if (0 < j && j <= N - i) {
        insert(current, V[N - j]);
        currentValue += V[N - j];
      }

      ans = max(ans, currentValue);
      currentValue2 = currentValue;
      int removeCount = min(K - i - j, i + j);
      if (removeCount > 0) {
        for (int k = 1; k <= removeCount; k++) {
          if (current[k - 1] >= 0) break;
          currentValue2 -= current[k - 1];
        }
        ans = max(ans, currentValue2);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
 
using namespace std;
 
int main() {
  fast_io;

  ll n, k;

  cout.precision(10);
  cout << fixed;

	cin >> n >> k;
	if (n < k) 
    cout << min(abs(n - k), n) << endl;
	else 
    cout << min(abs(n % k - k), n % k) << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int Digits(llong num){
  int cnt = 0;
  while(num > 0){
    num / 10;
    cnt++;
  }
  return cnt;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T;
    cin >> S >> T;
    sort(S.begin(),S.end());
    sort(T.rbegin(),T.rend());
    if(S < T) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N,Y = map(int,input().split(" "))

t = int(Y/10000)
end=False
for x in range(0,t+1):
    for y in range(0,N+1):
        if x+y>N:
            break
        z = N-x-y
        num = x*10000+y*5000+z*1000
        if num==Y:
            print(str(x)+" "+str(y)+" "+str(z))
            end=True
            break
    if end:
        break
if end==False:
    print("-1 -1 -1")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
class IO {
	private:
		static const int size = 1 << 18;
		char in[size], *bin, *ein, out[size], *pout;
	public:
		IO() { bin = ein = in, pout = out; }
		inline char get() {
			if(bin == ein) ein = (bin = in) + fread(in, 1, size, stdin);
			if(bin != ein) return *(bin++); else return EOF;
		}
		inline void put(char c) {
			if(pout == out + size) fwrite(out, 1, size, stdout);
			*(pout++) = c;
		}
		~IO() { fwrite(out, 1, pout - out, stdout), pout = out; }
} io;
inline int read() {
	int x = 0, op = 1; char ch = 0;
	while(not isdigit(ch = io.get())) if(ch == '-') op = -op;
	do x = (x << 3) + (x << 1) + (ch - '0'); while(isdigit(ch = io.get()));
	return op * x;
}
inline void write(int x) {
	if(x < 0) io.put('-'), x = -x;
	static char str[30], *p = str;
	do *p = (x % 10) + '0', p++; while(x /= 10);
	while(p != str) io.put(*(--p));
}
inline void putstr(const char *p) {
    while(*p) io.put(*p), p++;
}

#define int long long

int bf(int n, int m) {
    if(n<m) return 0;if(n%m==0) return n/m;
    return bf(n-n/m-1, m);
}
int sg(int n, int m) {
    if(n<m) return 0;if(n%m==0) return n/m;
    int x=n/m;int u=x*m;
    int h=(n-u)/(x+1);
    if(n-h*(x+1)==u) return x;
    return sg(n-(h+1)*(x+1), m);
}

signed main() {
    int T = read(), ans = 0;
    while(T--) {
        int n = read(), k = read();
        ans ^= (k <= n / k? bf: sg)(n, k);
    }
    putstr(ans? "Takahashi\n": "Aoki\n");
	return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    string T; cin >> T;
    int N = T.length();
    string ans = "";
    REP(i,N){
        if (T[i] == '?') ans += 'D';
        else ans += T[i];
    }

    cout << ans << endl;
}

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

int main() {
  double D,T,S;
  D=0;T=0;S=0;
  cin >> D >> T >> S;
  
  if ((D/S)<=T) {
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 3720
//問題URL
//

//解き方メモ
//
    
#include<iostream>
using namespace std;

int main(){
  int n;

  cin >> n;

  int prev = n%10;
  int cnt=1;
  n = n/10;
  for (int i = 0; i < 3; i++) {
    if(prev == n%10){
      cnt++;
    } else {
      if(cnt < 3)
	cnt=1;
      else
	break;
    }
    prev = n%10;
    n = n/10;
  }

  if(cnt >= 3)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define repp(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define popcnt __builtin_popcount
#define all(v) v.begin(),v.end()
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?GCD(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/GCD(a,b);}

int main(){
    ll h,w; cin >> h >> w;
    ll ans=0;
    if(h == 1 || w == 1) ans = 1;
    else if(h%2==0 && w%2 == 0) ans = h*w/2;
    else if(h%2==0 && w%2==1) ans = h*(w-1)/2 + h/2;
    else if(h%2==1 && w%2==0) ans = (h-1)*w/2 + w/2;
    else if(h%2==1 && w%2==1) ans = (h-1)*(w-1)/2 + (w-1)/2 + (h-1)/2 + 1;

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


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a int
	fmt.Scan(&a)
	h, hm := divRem(a, 3600)
	m, s := divRem(hm, 60)
	fmt.Printf("%d:%d:%d\n", h, m, s)
}

func divRem(divided int, divisor int) (a int, reminder int) {
	a = divided / divisor
	reminder = divided % divisor
	return
}


Measured memory_bytes: 1128