akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		int ans=0;
		for(int i = 0;i<s[0];i++) {
			var e=sc.La;
			if(Sqrt(e[0]*e[0]+e[1]*e[1])<=s[1]){ans++;}
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 40624
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = read.to!int;
	int k = read.to!int;
	P[] ps;
	foreach(i; 0 .. n) ps ~= P(read.to!long, read.to!long);
	log("ps:", ps);
	
	P[][long] x2p, y2p;
	foreach(p; ps){
		if(p.x !in x2p) x2p[p.x] = [];
		x2p[p.x] ~= p;
		if(p.y !in y2p) y2p[p.y] = [];
		y2p[p.y] ~= p;
	}
	log("x2p:", x2p, "y2p:", y2p);
	
	long[] xs = x2p.keys;
	xs.sort();
	long[] ys = y2p.keys;
	ys.sort();
	log("xs:", xs, "ys:", ys);
	
	const long infty = 1_000_000_999;
	
	int[][] cf = new int[][](xs.length + 1, ys.length + 1);
	foreach(i; 0 .. xs.length) cf[i][0] = 0;
	foreach(j; 0 .. ys.length) cf[0][j] = 0;
	foreach(i, x; xs){
		long yold = -infty;
		foreach(j, y; ys){
			int c = (j > 0)? cf[i + 1][j]: 0;
			foreach(p; y2p[y]) if(p.x <= x) c += 1; 
			foreach(p; x2p[x]) if(p.y > yold && p.y <= y && p.x != x) c += 1;
			cf[i + 1][j + 1] = c;
			yold = y;
		}
	}
	log("cf:", cf);
	
	long ans = infty * infty * 6;
	
	foreach(i1, x1; xs) foreach(i0, x0; xs[0 .. i1 + 1]){
		foreach(j1, y1; ys) foreach(j0, y0; ys[0 .. j1 + 1]){
			int c = cf[i1 + 1][j1 + 1] - cf[i1 + 1][j0] - cf[i0][j1 + 1] + cf[i0][j0];
			if(c >= k) ans = min(ans, (x1 - x0) * (y1 - y0));
			log("i0:", i0, "i1:", i1, "j0:", j0, "j1:", j1, "c:", c, "k:", k, "ans:", ans);
		}
	}
	
	ans.writeln;
}
struct P{
	long x, y;
}


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

int a[100005];
int d[100005];

long long int sumup(long long int n){
	return (n * (n + 1)) / 2;
}

int main(){
  int n;
  cin >> n;
  long long sum=0;
  for(int i=0;i<n;i++){ cin >> a[i]; sum+=a[i];}
  if(sum % sumup(n) != 0){
  	cout << "NO" << endl;
    return 0;
  }
  int t = sum / sumup(n);
  //d[i] denote a[i]-a[i-1];
  for(int i=0;i<n;i++) d[i] = a[(i+n) % n] - a[(i+n-1) % n] - t + 1;
  bool flag = true;
  for(int i=0;i<n;i++){
    if(d[i]>1){flag = false; break;}
    if(d[i]!=1){
      if((1 - d[i]) % n != 0){flag = false; break;}
      int tem = (1 - d[i]) / n;
      if(t < tem){flag = false; break;}
      d[i] = 1;
      t -= tem;
    }
  }
  if(t!=0||!flag) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

ll N;
std::vector<ll> v;

bool is753Number(ll n){
    int count[10];
    memset(count, 0, sizeof(count));

    while(n > 0){
        count[n % 10] += 1;
        n /= 10;
    }

    return count[7] > 0 && count[5] > 0 && count[3] > 0;
}

void enumerate(ll n){
    int tails[] = {7, 5, 3};
    for(int i=0;i<3;++i){
        ll m = n * 10 + tails[i];
        if(m <= N){
            v.emplace_back(m);
            enumerate(m);
        }
    }
}

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

    std::cin >> N;

    enumerate(0);

    int res = 0;
    for(ll i : v){
        if(is753Number(i)){
            res += 1;
        }
    }

    std::cout << res << std::endl;
}


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

using namespace std;

int *b;

int n;
int a;

int main() {
	while (true) {
		cin >> n;
		if (n == 0)
			break;

		b = new int[n / 4];
		int res = 0;

		for (int i = 0; i < n/4; i++) {
			cin >> a;
			res += a;
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3056
def Main(N, A):
    d1 = {}
    for a in A:
        if a not in d1:
            d1[a] = 1
        else:
            d1[a] += 1
    full = 0
    for k in d1:
        full += d1[k]*(d1[k]-1)//2
    ans = []
    for a in A:
        ans.append(full-d1[a]+1)
    return ans 
    

def main():
    N = int(input())
    A = list(map(int, input().split()))
    out = Main(N, A)
    for i in out:
        print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 24992
#include <iostream>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    ll N; cin >> N;
    cout << (N*(N-1))/2 << endl;

    return 0;
}

//cikisir



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

int main()
{
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  vector<vector<int>> p(n, vector<int>(11));
  int i, j;
  vector<int> open(10, 0);
  for(i = 0; i < n; i++)
  {
	for(j = 0; j < 10; j++)
    {
		cin >> f.at(i).at(j);
    }
  }
  for(i = 0; i < n; i++)
  {
	for(j = 0; j < 11; j++)
	{
		cin >> p.at(i).at(j);
    }
  }
  int count = 0;
  int sum = 0;
  int max = -1000000000;
  for(i = 1; i < (1 << 10); i++)
  {
	for(int k = 0; k < 10; k++)
    {
      open.at(k) = 0;
		if(i & (1 << k))
        {
          open.at(k) = 1;
        }
    }
    sum = 0;
    for(j = 0; j < n; j++)
    {
      count = 0;
		for(int k = 0; k < 10; k++)
        {
			if(open.at(k) == 1 && f.at(j).at(k) == 1)
            {
				count++;
            }
        }
      sum += p.at(j).at(count);
    }
    if(sum > max) max = sum;
  }
  cout << max << endl;
}

Measured memory_bytes: 256
n = int(input())
al = list(map(int, input().split()))

if n == 0:
    if al[0] == 1:
        print(1)
    else:
        print(-1)
    exit()

if al[0] != 0:
    print(-1)
    exit()

lim = [0]*(n+1)
lim[0] = 1

for i in range(1, n):
    lim[i] = lim[i-1]*2 - al[i]
    if lim[i] <= 0:
        print(-1)
        exit()
lim[-1] = lim[-2]*2

ansl = [0]*(n+1)
# print(al, lim)

for i in range(n+1):
    if i == 0:
        if lim[n-i] >= al[n-i]:
            ansl[i] = al[n-i]
        else:
            print(-1)
            exit()
    else:
        ansl[i] = min(ansl[i-1]+al[n-i], lim[n-i]+al[n-i])

if sum(ansl) <= 0:
    print(-1)
    exit()

print(sum(ansl))


Measured memory_bytes: 700712
#include <stdio.h>
int main(){
    int r;
    int n;
    int i;
    int max,min;
    
    scanf("%d",&n);
    
    scanf("%d",&min);
    scanf("%d",&r);
    max=r-min;
    if(r<min)min=r;
    for(i=2;i<n;i++){
        scanf("%d",&r);
        if(r-min>max)max=r-min;
        if(r<min){
            min=r;
        }
    }
    printf("%d\n",max);
    return 0;
}



Measured memory_bytes: 1968
function Main(input) {
    var N = parseInt(input[0], 10);
    var P = input.slice(1).map(w => parseInt(w, 10));

    var result = 0;

    for (var i = 1; i < N - 1; i++) {
        if (P[i - 1] > P[i] && P[i] > P[i + 1]) {
            result++;
        } else if (P[i - 1] < P[i] && P[i] < P[i + 1]) {
            result++;
        }
    }
    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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

#define int long long

const int mod = 1e9+7;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> dp(n+1,0);
    dp[1] = 1;
    for(int i = 2; i<= n; i++){
        vector<int> t(n+1,0);
        for(int b = 1; b <= i-1; b++){
            if(s[i-2] == '>'){
                t[1]+=dp[b];
                t[1]%=mod;
                if(b+1 <= n){
                    t[b+1]-=dp[b];
                    if(t[b+1] < 0) t[b+1]+=mod;
                    t[b+1]%=mod;
                }
            }else{
                t[b+1]+=dp[b];
                t[b+1]%=mod;
                if(i+1 <= n){
                    t[i+1]-=dp[b];
                    if(t[i+1] < 0){
                        t[i+1]+=mod;
                    }
                    t[i+1]%=mod;
                }
            }
        }
        int tempo = 0;
        for(int i = 1; i <= n; i++){
            tempo+=t[i];
            tempo%=mod;
            dp[i] = tempo;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans+=dp[i];
        ans%=mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    std::string a, res;
    std::cin >> a;

    if (a.find('a') != std::string::npos ||
        a.find('i') != std::string::npos ||
        a.find('u') != std::string::npos ||
        a.find('e') != std::string::npos ||
        a.find('o') != std::string::npos)           {
        res = "vowel";
    } else {
        res = "consonant";
    }

    std::cout << res << std::endl;
    return 0;
}

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

#define MAX 21
#define int long long

const int MOD = (int) (1e9) + 7;

int count_ways(vector<int> &v, int idx, int n, int mask, vector<int> &dp) {
    if (idx == n) return 1;
    if (dp[mask] != -1) return dp[mask];
    int total = 0, bit = 1;
    for (int i = 0; i < n; ++i) {
        if (!(bit & mask) && (bit & v[idx])) {
            total += count_ways(v, idx + 1, n, mask | bit, dp);
            total %= MOD;
        }
        bit <<= 1;
    }
    dp[mask] = total;
    return total;
}

signed main()
{
    int n;
    cin >> n;
    vector<int> dp(1<<n, -1);
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        int mask = 0, base = 1;
        for (int j = 0; j < n; ++j) {
            int a;
            cin >> a;
            if (a) mask |= base;
            base <<= 1;
        }
        v[i] = mask;
    }
    cout << count_ways(v, 0, n, 0, dp) << endl;
    return 0;
}

Measured memory_bytes: 16640
N=int(input())
*p, = map(float,input().split())

dp = [[0]*(N+1) for _ in range(N+1)]

for i in range(1,N+1):
  if i == 1:
    dp[i][0] = 1-p[0]
    dp[i][1] = p[0]
    continue
  for j in range(i+1):
    if j == 0:
      dp[i][j] = dp[i-1][j]*(1-p[i-1])
      continue
    dp[i][j] = dp[i-1][j]*(1-p[i-1]) + dp[i-1][j-1]*p[i-1]
    
ans=0
for j in range(N//2+1,N+1):
  ans += dp[-1][j]
  
print(ans)

Measured memory_bytes: 203540
#[allow(unused_imports)]
use std::cmp;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use itertools::Itertools;

#[fastout]
fn main() {
  input! {
    n: i64,
    m: usize,
    a: [i64; m],
  }
  let d: i64 = a.iter().sum();

  println!("{}", if d <= n { n - d } else { -1 });
}


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

using namespace std;
using ll = long long;
using P = pair<char, int>;

int main() {
  string s;
  cin >> s;
  vector<P> v;
  rep(i, s.size()) {
    int count = 1;
    while (i < (int)s.size() - 1 && s[i] == s[i + 1]) {
      count++;
      i++;
    }
    v.emplace_back(P(s[i], count));
  }

  vector<int> counts(s.size(), 0);
  int index = 0;
  for (auto p : v) {
    int odd = (p.second + 1) / 2;
    int even = p.second - odd;
    if (p.first == 'R') {
      counts[index + p.second - 1] += odd;
      counts[index + p.second] += even;
    } else {
      counts[index] += odd;
      counts[index - 1] += even;
    }
    index += p.second;
  }
  rep(i, s.size()) {
    if (i != s.size() - 1) {
      cout << counts[i] << " ";
    } else {
      cout << counts[i] << endl;
    }
  }
  return 0;
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    int T, P, R;
    while (cin >> T >> P >> R, T|P|R) {
        vvi wrong(T, vi(P));
        vector<pair<pii, int>> score(T);
        REP(i, T) {
            score[i] = {{0, 0}, -(i+1)};
        }

        REP(i, R) {
            int tid, pid, time;
            string message;
            cin >> tid >> pid >> time >> message;
            tid--;
            pid--;
            if (message == "WRONG") {
                wrong[tid][pid]++;
            } else {
                score[tid].first.first++;
                score[tid].first.second -= time + wrong[tid][pid]*1200;
            }
        }

        RSORT(score);
        REP(i, T) {
            printf("%d %d %d\n", -score[i].second, score[i].first.first, -score[i].first.second);
        }
    }
}

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

void bubblesort(int A[], int N){
 bool flag = true;
 while(flag){
  flag = false;
  for(int i=N-1; i>=1; i--){
   if(A[i]<A[i-1]){
    swap(A[i], A[i-1]);
    flag = true;
   }
  }
 }
}

int main(){
 
 int N;
 cin >> N;
 int h[100];
 int m[100];
 for(int i=0; i<N; i++){
  cin >> h[i] >> m[i];
 }
 
 int M;
 cin >> M;
 int k[100];
 int g[100];
 for(int i=0; i<M; i++){
  cin >> k[i] >> g[i];
 }

 int A[200];
 int t=0;
 for(int i=0; i<N; i++){
  A[t] = h[i]*60 + m[i];
  t++;
 }
 for(int i=0; i<M; i++){
  A[t] = k[i]*60 + g[i];
  t++;
 } 

 bubblesort(A, N+M);

 for(int t=0; t<N+M; t++){
  if(A[t]==A[t+1])  t++;
  if(A[t]%60<10){
   cout << A[t]/60 << ':' << '0' << A[t]%60;
  }else{ 
   cout << A[t]/60 << ':' << A[t]%60;
  }
  if(t==N+M-1){
   cout << endl;
  }else{
   cout << ' ';
  }
 }

 return 0;
}
 

Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Virtual
{
    class ABC094_C
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            int[][] array2 = new int[n][];
            for(int i = 0; i < n; i++)
            {
                array2[i] = new int[3] { array[i], i, 0 };
            }
            Array.Sort(array2, (a, b) => a[0] - b[0]);
            for(int i = 0; i < n; i++)
            {
                if (i < n / 2) array2[i][2] = array2[n / 2][0];
                else array2[i][2] = array2[n / 2 - 1][0];
            }
            Array.Sort(array2, (a, b) => a[1] - b[1]);
            for(int i =0; i < n; i++)
            {
                WriteLine(array2[i][2]);
            }
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 45116
require 'prime'

n = $stdin.gets.chomp.to_i
ans = 0
soin = Prime.prime_division(n)

soin.each do |k|
  cou = 1
  while k[1] >= cou
    k[1] -= cou
    cou += 1
    ans += 1
  end
end

puts ans


Measured memory_bytes: 14476
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		for(int i=0;;i++) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			if(n==0 && x==0)break;
			int j,k,l;
			int count = 0;
			for(j=1;j<=n;j++) {
				for(k=1;k<=n;k++) {
					for(l=1;l<=n;l++) {
						if(j<k&&k<l) {
							if(x==j+k+l) {
								count++;
							}
						}
					}
				}
			}
			System.out.println(count);
		}
	}

}



Measured memory_bytes: 26616
#include<stdio.h>

int main(){
  int n,a[100],flag,i,j,r,cnt=0;

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

    flag=1;
    i=0;
    while(flag){
      flag=0;
      for(j=n-1; j>=i+1; j--){
	if(a[j]<a[j-1]){
	  r=a[j];
	  a[j]=a[j-1];
	  a[j-1]=r;
	  cnt++;
	  flag=1;
	}
      }
      i++;
    }
  
  for(i=0; i<n; i++){
    if(i)printf(" ");
    printf("%d",a[i]);
  }
  printf("\n%d\n",cnt);
  
  return 0;
}



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

int wa(int sum,int N){
  while(N>0){
    sum += N%10 ;
    N=(int)N/10;
   }
  return sum;
}  

  
int main(){
  int N; cin>>N;
  int sum=0;

  
  if(N%wa(sum,N)==0){
  cout<<"Yes"<<endl;
  }else{
  cout<<"No"<<endl;
  }
  
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000

int partition(int *,int,int);

int main(void){

  int i,n,a,S[N];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  a=partition(S,0,n-1);

  for(i=0;i<n;i++){
    if(i==a) printf("[%d]",S[i]);
    else printf("%d",S[i]);
    if(i != n-1) printf(" ");
    

  }
  printf("\n");
  
  return 0;

}

int partition(int *S,int p,int r){
  int x,i,j,temp;

  x=S[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(S[j]<=x){
      i=i+1;
      temp=S[i];
      S[i]=S[j];
      S[j]=temp;

    }
  }
  temp=S[i+1];
  S[i+1]=S[r];
  S[r]=temp;

  return i+1;

}



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

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }
    ll ans = 1;
    ll d = 0;
    for(ll i = 1; i < n; ++i){
        if(d >= 0 && a.at(i) > a.at(i - 1)){
            d = 1;
        }else if(d <= 0 && a.at(i) < a.at(i - 1)){
            d = -1;
        }else if(a.at(i) != a.at(i - 1)){
            d = 0;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>  
#include <stdlib.h> 
#include <string.h> 


int check() {
	char a[105];
	int len;

	scanf("%s", &a);
	len = strlen(a);

	// i 文字目と len-i-1文字目 が違ったら回文ではない
	for (int i = 0; i < len; i++)
	{
		if (a[i] != a[len - i - 1]) return 0;
	}
	// 前半部について、i文字目と(len/2)-i-1文字目が違ったら強い回文ではない
	for (int i = 0; i < len / 2; i++)
	{
		if (a[i] != a[len / 2 - i - 1]) return 0;
	}
	// 後半部について、回文だったら前半部と同じ文字なので調べないで良い
	//強い回文だったらtrueを返す
	return 1;
}

int main()
{
	if (check()) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

void WriteArray(int* nums, int length) {
    for (int i = 0; i < length; i++) {
        cout << nums[i];
        if (i < length - 1) cout << " ";
    }
    cout << endl;
}

int main() {
    int n;
    int nums[100];
    string s;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> nums[i];
    
    WriteArray(nums, n);

    for (int i = 1; i < n; i++) {
        int v = nums[i];
        int j = i - 1;
        for (; j >= 0 && nums[j] > v; j--) {
            nums[j + 1] = nums[j];
        }
        nums[j + 1] = v;

        WriteArray(nums, n);
    }

    return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmin(x,y) x = min(x,y)


int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll c = n % (a + b);

  if (a > c) {
    cout << a * (n / (a + b)) + c << endl;
  } else {
    cout << a * (n / (a + b)) + a << endl;
  }

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int a, b, c, N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d %d %d", &a, &b, &c);
		if (a > b&&a > c) {
			if (a*a == b * b + c * c)printf("YES\n");
			else printf("NO\n");
		}
		else if (b > a&&b > c) {
			if (b*b == a * a + c * c)printf("YES\n");
			else printf("NO\n");
		}
		else if (c*c == a * a + b * b)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 1980
#include <stdio.h>

int main(void)
{
  int A, B, K, i, temp, count = 0, num[10000] = {0};
  scanf("%d %d %d", &A, &B, &K);
  
  if(B > A){
    temp = B;
    B = A;
    A = temp;
  }
  
  for(i = B; 1 <= i; i--){
   if((A % i == 0)&&(B % i == 0)){
     num[count] = i;
     count++;
   }
  }

  printf("%d", num[K-1]);
         
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define rt0 return 0
using namespace std;
int main()
{
	int b=3;
	vector <int> a(b,0);
	cin>>a[0]>>a[1]>>a[2];
	sort(a.begin(),a.end());
	if(((a[2]-a[0])+(a[2]-a[1]))%2==0) cout<<((a[2]-a[0])+(a[2]-a[1]))/2;
	else cout<<((a[2]-a[0])+(a[2]-a[1])+3)/2;
    rt0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(),k = sc.nextInt(),c = sc.nextInt();sc.nextLine();
    String str = sc.nextLine();
    int syu[]=new int[n];
    for(int i=0;i<n;i++){
      if(str.charAt(i)=='o'){
        syu[i]=1;
      }else{
        syu[i]=0;
      }
    }
    int l1[]=new int[k],l2[]=new int[k];
    int d=0;
    for(int i=0;d<k;i++){
      if(syu[i]==1){
        l1[d]=i;
        d++;
        i+=c;
      }
    }
    d=k-1;
    for(int i=n-1;d>=0;i--){
      if(syu[i]==1){
        l2[d]=i;
        d--;
        i-=c;
      }
    }
    for(int i=0;i<k;i++){
      if(l1[i]==l2[i]){
        pl((l1[i]+1)+"");
      }
    }
  }

  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
}


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

int main() {
  int N;
  bool x = false;
  cin >> N;

  // ここにプログラムを追記
  rep (i, N) {
    string S = "";
    cin >> S;
    if (S == "Y") {
      x = true;
      break;
    }
  }
  if (x) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 3540
# B - Multiplication 2

import sys
readline = sys.stdin.readline

N = int(readline())
A = list(int(x) for x in readline().split())
A.sort()

ans = 1
for a in A:
    ans *= a
    if ans == 0:
        break
    if ans > 10**18:
        break

if ans > 10**18:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 21832
import java.util.*;

public class Main {
    public static boolean[] booleans=new boolean[2000*20];
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        final int n=scanner.nextInt();

        rec(0,n,new Position(0,0),new Position(100,0));
        System.out.println(new Position(100,0));
    }
    public static void rec(int currentIndex,int endIndex,Position start,Position end){
        if(currentIndex==endIndex){
            System.out.println(start);
            return;
        }
        double r=Math.sqrt(3)/6.0*(end.x-start.x);
        Position position1=new Position(start.x,start.y);
        Position position2=new Position(start.x+(end.x-start.x)/3.0,start.y+(end.y-start.y)/3.0);
        Position position3=new Position((start.x+end.x)/2.0+r*((start.y-end.y)/(end.x-start.x)),(start.y+end.y)/2.0+r);
        Position position4=new Position(start.x+(end.x-start.x)*2.0/3.0,start.y+(end.y-start.y)*2.0/3.0);
        Position position5=new Position(end.x,end.y);
        rec(currentIndex+1,endIndex,position1,position2);
        rec(currentIndex+1,endIndex,position2,position3);
        rec(currentIndex+1,endIndex,position3,position4);
        rec(currentIndex+1,endIndex,position4,position5);
    }

}

class Position{
    public  double x,y;
    private Position(){}
    public Position(double x,double y){
        this.x=x;
        this.y=y;
    }
    @Override
    public String toString(){
        return String.format("%f %f",x,y);
    }
}


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int place;
	int cost;

	bool operator<(const data &ri) const{
		return cost < ri.cost;
	}
	bool operator>(const data &ri) const{
		return cost > ri.cost;
	}
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};



int main(){
	int N, W;
	int v[100], w[100];
	int dp[10001] = {};
	cin >> N >> W;
	for(int i = 0; i < N; i++){
		cin >> v[i] >> w[i];
	}

	for(int i = 0; i < N; i++){
		for(int j = W; j >= w[i]; j--){
			dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
		}
	}

	cout << dp[W] << endl;

	return 0;
}


Measured memory_bytes: 3172
#include <stdio.h>

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

     scanf("%d %d",&a,&b);
     
     c=a+b;

     if(c>=10)
     {
          printf("error\n");
     }
     else
     {
          printf("%d\n",c);
     }

     return 0;
}



Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int a[1299710]={};
  a[2]=1;
  int fl;
  for(int i=3;i<1299710;i++){
    fl=0;
    for(int j=2;j*j<=i;j++){
      if(i%j==0){
	fl=1;
	break;
      }
    }
    if(fl==0){
      a[i]=1;
    }
  }
  int n,h,t;
  while(1){
    cin >> n;
    if(n==0)break;
    for(int i=n;i>=0;i--){
      if(a[i]==1){
	h=i;
	break;
      }
    }
    for(int i=n;i<=1299709;i++){
      if(a[i]==1){
	t=i;
	break;
      }
    }
    cout << t-h<< endl;
  }
  return 0;
}

Measured memory_bytes: 8064
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    vector<int> s(n);
    rep(i, n) cin >> s[i];

    int ans = 0;
    for(int i = 1; i < n; i++){
        int tmp = 0;
        set<int> ss;
        for(int x = i; n - 1 - x > i; x += i){
            if(ss.find(x) != ss.end()){
                break;
            }
            ss.insert(x);
            if(ss.find(n - 1 - x) != ss.end()){
                break;
            }
            ss.insert(n - 1 - x);

            tmp += s[x] + s[n-1-x];
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7808
import os

def main():
	count = int(input())
	num_p = list(map(int, input().split()))
	ans_list = []
	ans_list.append(num_p[0])
	min_num = ans_list[0]
	for i in range(1,len(num_p)):
		if min_num > num_p[i]:
			ans_list.append(num_p[i])
			min_num = num_p[i]
		else:
			pass
	print(len(ans_list))


if __name__ == '__main__':
	main()


Measured memory_bytes: 24744
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        boolean[][] g = input();
        Boolean[] visited = new Boolean[g[0].length];
        Arrays.fill(visited,false);
        visited[0] = true;
        System.out.println(dfs(g,0,visited));
    }

    private static boolean[][] input(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[][] ret = new boolean[n][n];
        for(int i = 0; i < m;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            ret[a-1][b-1] = ret[b-1][a-1] = true;
        }
        sc.close();
        return ret;
    }

    private static int dfs(boolean[][] g, int s, Boolean[] bools){
        if(!Arrays.asList(bools).contains(false)){
            return 1;
        }
        int ans = 0;
        for(int i = 0; i < bools.length; i++){
            if(!g[s][i] || bools[i]) continue;
                bools[i] = true;
                ans += dfs(g,i,bools);
                bools[i] = false;
        }
        return ans;
    }
}

Measured memory_bytes: 25044
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n, x, y = i_map()
    ans = [0] * n

    for fr in range(1, n+1):
        for to in range(fr+1, n+1):
            cost = min(to - fr, abs(x-fr) + abs(to - y) + 1)
            ans[cost] += 1
    print(*ans[1:], sep="\n")

if __name__=="__main__":
    main()


Measured memory_bytes: 9600
Scanf.(scanf " %d %d %d" @@ fun n a b -> Array.(
  init n (fun _ -> scanf " %d" @@ fun v -> v)
  |> fold_left (fun (p,q,r) v ->
    if v<=a then (p+1,q,r)
    else if v<=b then (p,q+1,r)
    else (p,q,r+1)) (0,0,0)
  |> (fun (p,q,r) -> print_int @@ min p (min q r))))

Measured memory_bytes: 384
#include<stdio.h>

#define n 1001

void print(long long int arr[][n],int c,int r){

    int i,j;
    for(i = 0;i < c;i++){
        for(j = 0;j < r;j++){
            printf("%9lld",arr[i][j]);
        }
        printf("\n");
    }
}

void edge(char arr[][n],long long int map[][n],int c,int r){

    int i,j;
    for(i = 0;i < c;i++)
        for(j = 0;j < r ;j++)
        if(arr[i][j] == '#'){
            map[i][j] = -1;
        }
}

int reset(long long int arr[][n],int c,int r){

    int i,j;
    for(i = 0;i < c ;i++)
        for(j = 0;j < r;j++)
            arr[i][j] = 0;
}

int add(long long int map[][n],int c,int r){

    int i,j;
    for(i = 0;i < c;i++){
        for(j = 0;j < r;j++){

            if(i == 0&& j == 0)
                continue;
            if(map[i][j] == -1){
                continue;
            }else if(i == 0){//edge
                if(map[i][j-1] != -1)
                    map[i][j]++;
                else
                    map[i][j] = -1;
            }else if(j == 0){
                if(map[i-1][j] != -1)
                    map[i][j]++;
                else
                    map[i][j] = -1;
            }else{
                if(map[i - 1][j] != -1 && map[i][j-1] != -1){
                    map[i][j] = (map[i - 1][j] + map[i][j - 1])% (1000000000 + 7);
                }else{
                    map[i][j] = (map[i - 1][j] > map[i][j - 1])?
                                map[i - 1][j]:map[i][j-1];
                }
            }
        }
    }
}
int main(){

    int row, col;
    int i,j;
    char arr[n][n];
    long long int map[n][n];

    //freopen("testdata.in","r",stdin);

    while(scanf("%d %d",&col, &row) != EOF){

        for(i = 0;i < col;i++){
            getchar();
            for(j = 0;j < row;j++){
                scanf("%c",&arr[i][j]);
            }
        }

        reset(map,col,row);
        edge(arr,map,col,row);
        add(map,col,row);
        if(map[col-1][row-1] <= 0)
            printf("0\n");
        else{
            printf("%lld\n",map[col-1][row-1]);
        }
    }
    return 0;
}


Measured memory_bytes: 8960
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue> 
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
int sq[505][505],sum[505][505];
int n,m,q,l,r,a,b;
int main()
{
    scanf("%d%d",&a,&b);
    printf("%d\n",a*b-a-b+1);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

const ll INF = 1<<30;
const ll LINF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void) {
    int n; cin >> n;
    ll sum = 0;
    REP(i, n - 1) sum += i + 1;
    cout << sum << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for(int x = 0; x < K+1; x++){
    for(int y = 0; y < K+1; y++){
      if(S-x-y >= 0 && S-x-y < K+1){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

int main()
{
    int N, Y;
    int array[] = {0, 7, 5, 3, 1, 8, 6, 4, 2};
    cin >> N >> Y; Y /= 1000;
    Y -= N;
    int b = array[Y % 9], a = (Y - b * 4) / 9;
    if(Y < 0 || a + b > N || a < 0) cout << "-1 -1 -1" << endl;
    else cout << a << " " << b << " " << N - a - b << endl;
    return (0);
}

Measured memory_bytes: 256
//import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        // 捜査の範囲
        int start = 1;
        int end = n - 1;
        
        System.out.println(0);
        System.out.flush();
        
        String chairZero = sc.next();
        if (chairZero.equals("Vacant")) {
            return;
        }
        
//        PrintWriter out = new PrintWriter(System.out);
        int query;
        for (int i = 0; i < 20; i++) {
            
            query = (end + start) / 2;
            System.out.println(query);
            System.out.flush();
            
            String response = sc.next();
            if (response.equals("Vacant")) {
                return;
            }
            
            if (end - start == 1) {
                System.out.println(end);
                System.out.flush();
                response = sc.next();
                if (response.equals("Vacant")) {
                    return;
                }
            }
            
            boolean isSame = response.equals(chairZero);
            boolean isDiffEven = (query - start) % 2 == 0;
            
            if (isSame && isDiffEven)
                end = query - 1;
            else if (isSame && !isDiffEven)
                start = query + 1;
            else if (!isSame && isDiffEven)
                start = query;
            else if (!isSame && !isDiffEven)
                end = query;
        }
    }
}

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

using namespace std;

const int maxn = 1e5 + 5;

int f[30][maxn];
bool v[maxn];


int main() {
	string s , t;
	ios::sync_with_stdio(0);
	cin >> s >> t;
	int cnt = 0;
	for(int j = 0 ; j < 26 ; j++) {
		cnt = 0;
		for(int i = s.length() - 1 ; i >= 0 ; i--) { 
			f[j][i] = cnt;
			if(s[i] - 'a' == j) {
				cnt = i;
				if(!v[j])v[j] = 1;
			}
		}
	}
	cnt = 0;
	bool flag = 0;
	for(int i = 0 ; i < t.length() ; i++)if(!v[t[i] - 'a']) {
		flag = 1;
		break;
	}
	if(!flag) {
		while(s[cnt] != t[0])
			cnt = f[t[0] - 'a'][cnt];
		long long ans = 0;
		if(t.length() == 1)ans += cnt + 1;
		for(int i = 1 ; i < t.length() ; i++) {
			int tmp = cnt;
			cnt = f[t[i] - 'a'][cnt];
			while(s[cnt] != t[i])
				cnt = f[t[i] - 'a'][cnt];
			if(cnt <= tmp)ans += s.length();
			if(i == t.length() - 1)ans += cnt + 1;
		}
	 	cout << ans << "\n"; 
	}
	else cout << -1 << "\n"; 
	return 0;
}

Measured memory_bytes: 10704
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 1
s = [0] * 3

for i in range(n):
    ans *= len([0 for x in s if x == a[i]])
    if ans == 0: break
    ans %= MOD
    for j in range(3):
        if s[j] == a[i]:
            s[j] += 1
            break

print(ans % MOD)


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

int main() {
    vector<int> a(3);
    rep (i, 3) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    if (a.at(0) + a.at(1) == a.at(2)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

n,k=map(int, input().split())
p=list(map(int, input().split()))

acc=list(accumulate(p))
# print(acc)
ans=0
if n==k:
    print(sum(p)/2+0.5*k)
    exit()
for i in range(k,n):
    ans=max(ans,acc[i]-acc[i-k])
print(ans/2+0.5*k)


Measured memory_bytes: 25152
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")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let a: i64 = read();
    let b: i64 = read();

    if a < b {
        for _ in 0..b {
            print!("{}", a);
        }
    } else {
        for _ in 0..a {
            print!("{}", b);
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

class Graph{
	private:
	vvi Gpro,Gd;
	vvp Glist;
	int GV,GE;
	public:
	Graph(int x,int y,bool z){
		GV=x;
		GE=y;
		Gd=vvi(x,vi(x,inf));
		if(z) Gpro=vvi(x,vi(x,inf));
		else Glist=vvp(x);
	}
	void Gpro_add(int x,int y,int z){
		Gpro[x][y]=z;
	}
	void Glist_add(int x,int y,int z){
		Glist[x].push_back(P(y,z));
	}
	int open(int x,int y){
		return Gd[x][y];
	}
	void DIJplus(int x){
		priority_queue<P> que;
		Gd[x][x]=0;
		que.push(P(0,x));
		while(!que.empty()){
			P p=que.top();
			p.first*=-1;
			que.pop();
			int v=p.second;
			if(Gd[x][v]<p.first) continue;
			for(int i=0;i<Glist[v].size();i++){
				P e=Glist[v][i];
				if(Gd[x][e.first]>Gd[x][v]+e.second){
					Gd[x][e.first]=Gd[x][v]+e.second;
					que.push(P(-1*Gd[x][e.first],e.first));
				}
			}
		}
	}
	void BELLMAN(int x){
		Gd[x][x]=0;
		while(1){
			bool update=1;
			for(int i=0;i<GV;i++){
				for(int j=0;j<Glist[i].size();j++){
					P e=P(Glist[i][j].first,Glist[i][j].second);
					if(Gd[x][i]!=inf&&Gd[x][e.first]>Gd[x][i]+e.second){
						Gd[x][e.first]=Gd[x][i]+e.second;
						update=0;
					}
				}
			}
			if(update) break;
		}
	}
	bool FNL(int x){
		Gd[x][x]=0;
		for(int i=0;i<GV;i++){
			for(int j=0;j<GV;j++){
				for(int k=0;k<Glist[j].size();k++){
					P e=P(Glist[j][k].first,Glist[j][k].second);
					if(Gd[x][j]!=inf&&Gd[x][e.first]>Gd[x][j]+e.second){
						Gd[x][e.first]=Gd[x][j]+e.second;
						if(i==GV-1) return 1;
					}
				}
			}
		}
		Gd=vvi(GV,vi(GV,inf));
		return 0;
	}
	void WARSHALL(){
		for(int i=0;i<GV;i++){
			for(int j=0;j<GV;j++){
				for(int k=0;k<GV;k++) Gd[i][j]=min(Gd[i][j],Gd[i][k]+Gd[k][j]);
			}
		}
	}
	int PRIM(){
		int Gans=0;
		vi mincost(GV,inf);
		vector<bool> used(GV,1);
		mincost[0]=0;
		while(1){
			int v=-1;
			for(int i=0;i<GV;i++){
				if(used[i]&&(v==-1||mincost[i]<mincost[v])) v=i;
			}
			if(v==-1) break;
			used[v]=0;
			Gans+=mincost[v];
			for(int i=0;i<GV;i++){
				mincost[i]=min(mincost[i],Gpro[v][i]);
			}
		}
		return Gans;
	}
};

int V,E,r;

int main(){
	cin>>V>>E>>r;
	Graph graph(V,E,0);
	for(int i=0;i<E;i++){
		int s,t,d;
		cin>>s>>t>>d;
		graph.Glist_add(s,t,d);
	}
	if(graph.FNL(r)){
		cout<<"NEGATIVE CYCLE"<<endl;
		return 0;
	}
	graph.BELLMAN(r);
	for(int i=0;i<V;i++){
		if(graph.open(r,i)==inf) cout<<"INF"<<endl;
		else cout<<graph.open(r,i)<<endl;
	}
}

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll a,c;
  string b;
  cin>>a>>b;
  c=b.size();
  if(c<=a){
    cout<<b<<endl;
  }
  else{
    string d;
    for(ll i=0;i<a;i++){
      d+=b.at(i);
    }
    d+="...";
    cout<<d<<endl;
  }
}

Measured memory_bytes: 3600
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#include <boost/sort/spreadsort/spreadsort.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
//#include <boost/graph/graph_utility.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
//using namespace boost::multiprecision;
//using namespace boost::math;

typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS,
        boost::no_property, boost::property<boost::edge_weight_t, int> > Graph;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define bsort boost::sort::spreadsort::spreadsort
#define int int_fast64_t
using pii = pair<int,int>;

constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
template <class Func>

class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}
 
    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};
 
template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;

template <typename T> using Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using Umap = gp_hash_table<K, V>;
using Trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

struct negrightshift {
    inline int operator() (const int &x, const unsigned offset) {
        return -(x >> offset);
    }
};
//}}}


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int x, k, d;
    cin >> x >> k >> d;

    x = abs(x);

    int n = min(x / d, k);
    k -= n;
    x -= n * d;

    if(k & 1){
        cout << abs(x - d) << '\n';
    }else{
        cout << x << '\n';
    }

    
    return 0;
}

Measured memory_bytes: 3588