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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

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

	map<string, int> mp;
	rep(i,n){
		mp[s[i]] += 1;
	}
	int ma=0;
	for(auto x:mp){
		ma = max(ma, x.second);
	}
	vector<string> res;
	for(auto x:mp){
		if(x.second==ma)res.push_back(x.first);
	}
	sort(all(res));
	for(auto x:res)cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 28404
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::HashMap;
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::usize;

#[allow(unused_macros)]
macro_rules! read_cols {
    ($($t:ty),+) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let mut it = line.trim()
            .split_whitespace();

        ($(
            it.next().unwrap().parse::<$t>().ok().unwrap()
        ),+)
    }}
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn dfs(adjs: &Vec<Vec<usize>>, g: &mut Vec<bool>, v: usize) -> usize {
    let mut ret = 1;

    g[v] = true;

    for u in &adjs[v] {
        if g[*u] {
            continue
        }

        ret += dfs(adjs, g, *u);
    }

    return ret;
}

fn main() {
    let (n, m) = read_cols!(usize, usize);

    let mut adjs = vec![Vec::new(); n];
    for _ in 0..m {
        let (a, b) = read_cols!(usize, usize);
        adjs[a - 1].push(b - 1);
        adjs[b - 1].push(a - 1);
    }

    let mut ans = 0;
    let mut g = vec![false; n];
    for i in 0..n {
        if !g[i] {
            ans = max(ans, dfs(&adjs, &mut g, i));
        }
    }

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

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

using namespace std;

#define forn(i, s, f) for(int i = (s); i <= (f); ++i)
#define for1(i, f, s) for(int i = (f); i >= (s); --i)
#define fora(i, x) for (auto i : x)
#define show(x) cout << #x << " = " << x << " ";
#define skip continue;
#define pb push_back
#define _1 first
#define _2 second

typedef long long ll;

const int N3 = 1e3 + 5;
const int N4 = 1e4 + 5;
const int N5 = 1e5 + 5;
const int N6 = 1e6 + 5;
const int N7 = 1e7 + 5;
const int N8 = 1e8 + 5;
const int N9 = 1e9 + 5;
const int mod = N9 + 2;

char a[10][10];

int lt_x, lt_y, n, m, now[10][10];

int cnt;

int main()
{
    cin >> n >> m;
    forn (i, 1, n)
        forn (j, 1, m)
            cin >> a[i][j];

    if (a[n][m] != '#')
        return !(cout << "Impossible");
    forn (i, 1, n)
    {
        forn (j, 1, m)
        {
            if (a[i][j] == '#' && a[i + 1][j] == '#' && a[i][j + 1] == '#' && a[i + 1][j + 1])
                return !(cout << "Impossible");
            if (i != 1 && j != 1)
            {
                if (a[i][j] == '#' && a[i - 1][j] != '#' && a[i][j - 1] != '#')
                    return !(cout << "Impossible");
            }
        }
    }
    cout << "Possible";

}


Measured memory_bytes: 256
package main

import "fmt"

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

	a := make([]int, n)
	cn := 0
	for i := range a {
		fmt.Scan(&a[i])
		if a[i] < 0 {
			cn++
		}
	}

	ans := 0
	if cn%2 == 0 {
		for _, v := range a {
			ans += abs(v)
		}
	} else {
		var min int = 10e9
		for _, v := range a {
			if min > abs(v) {
				min = abs(v)
			}
			ans += abs(v)
		}
		ans -= 2 * min
	}
	fmt.Println(ans)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

Measured memory_bytes: 5504
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    string a, b, c;
    cin >> a >> b >> c;

    if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]){
        p("YES");
    }else{
        p("NO");
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N, P;
  cin >> N >> P;
  unordered_map<long, long> foo;
  long i = 2;
  while (true) {
    if (P == 1) break;
    if (i * i > P) {
      foo[P]++;
      P = 1;
      break;
    }
    if (P % i) i++;
    else {
      foo[i]++;
      P /= i;
    }
  }
  long ans = 1;
  for (auto it: foo) rep (j, it.second / N) ans *= it.first;
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int a,b;

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

	cin>>a>>b;
	
	if (1ll*a*b<=0) return cout<<"Zero",0;
	
	int c=0;
	if (a<0) c-=a+1;
	if (b<0) c-=b;
	if (c%2==0) cout<<"Positive";
	else cout<<"Negative";
	
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

ll const MAX_V = 500005;

struct edge {
    ll to, cost;
};
vector<edge> G[MAX_V];
vector<vector<ll>> ids(1005, vector<ll>(1005, 0));

vector<ll> seen;
vector<ll> d;
bool flg;

ll dfs(int v, int p) {
    if (seen[v] == 2) return d[v];
    seen[v] = 1;

    for (auto nv : G[v]) {
        if (nv.to == p) continue;
        // cout << v << "->" << nv.to << ": " << seen[nv.to] << endl;

        if (seen[nv.to] == 1) {
            cout << -1 << endl;
            exit(0);
        }
        chmax(d[v], dfs(nv.to, v) + 1);
    }

    seen[v] = 2;

    return d[v];
}

int main() {
    INIT;

    ll N;
    cin >> N;

    ll v = 1;
    rep(i, N) {
        reps(j, i + 1, N) {
            ids[i][j] = v;
            ids[j][i] = v;
            v++;
        }
    }

    rep(i, N) {
        ll now = 0;

        rep(j, N - 1) {
            ll s;
            cin >> s;
            s--;

            ll next = ids[i][s];
            edge et = {next, 1};

            G[now].push_back(et);
            now = next;
        }
    }

    seen.assign(N * (N - 1) / 2 + 5, 0);
    d.assign(N * (N - 1) / 2 + 5, 0);

    // rep(i, N * (N - 1) / 2) {
    //     cout << i << ": ";
    //     for (auto nv : G[i]) {
    //         cout << nv.to << " ";
    //     }
    //     cout << endl;
    // }

    cout << dfs(0, -1) << endl;

    return 0;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    ll n; cin >> n;

    int ans = INF;

    for (ll i = 1; i <= sqrt(n); ++i) {
        if (n % i != 0) {
            continue;
        }

        int f = max(to_string(i).length(), to_string(n / i).length());

        ans = min(ans, f);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

type point struct {
	x, y float64
}

var radian = math.Pi * 60 / 180

// コッホ曲線
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	p1 := point{x: 0, y: 0}
	p2 := point{x: 100, y: 0}
	print(p1)
	koch(n, p1, p2)
	print(p2)
}

func koch(n int, a, b point) {
	if n == 0 {
		return
	}

	s := point{x: (2*a.x + b.x) / 3, y: (2*a.y + b.y) / 3}
	t := point{x: (a.x + 2*b.x) / 3, y: (a.y + 2*b.y) / 3}
	u := point{
		x: (t.x-s.x)*math.Cos(radian) - (t.y-s.y)*math.Sin(radian) + s.x,
		y: (t.x-s.x)*math.Sin(radian) + (t.y-s.y)*math.Cos(radian) + s.y,
	}

	koch(n-1, a, s)
	print(s)
	koch(n-1, s, u)
	print(u)
	koch(n-1, u, t)
	print(t)
	koch(n-1, t, b)
}

func print(p point) {
	fmt.Printf("%f %f\n", p.x, p.y)
}



Measured memory_bytes: 1152
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
import Debug.Trace

solve :: Int -> [Int] -> Int
solve n as = answer
  where
  posLst :: [Int]
  posLst = trace ("posLst " ++ show posLst0) posLst0
  posLst0 = costLst as
  negLst :: [Int]
  negLst = trace ("negLst " ++ show negLst0) negLst0
  negLst0 = reverse $ costLst $ reverse as
  answer = minimum $ zipWith3 f posLst negLst [0,1..]
    where f p n w = 2 * (p + n) + w

costLst :: [Int] -> [Int]
costLst xs = scanr (+) 0 $ snd $ mapAccumR f initAcc $
                zip xs (tail xs ++ [big])
  where
    initAcc :: [(Int, Int)]
    initAcc = [(0, big)]
    f :: [(Int,Int)] -> (Int,Int) -> ([(Int,Int)], Int)
    f steps@((len, gap):rem) (x, xNext)
      | 4 * x <= xNext = ((1, costF xNext x):steps, 0)
      | x <= xNext = ((len+1, gap):rem, 0)
      | otherwise = g (costC x xNext) 0 1 steps
      where
        g :: Int -> Int -> Int -> [(Int,Int)] -> ([(Int,Int)], Int)
        g !h !cost !len ((tLen,gap):rem)
          | h <= gap = ((newLen, gap-h):rem, newCost)
          | otherwise = g (h-gap) newCost newLen rem
          where newCost = cost + h*tLen
                newLen = len + tLen

big = 10 ^ 10

epsilon = 2 ** (-64)

log4 :: Int -> Double
log4 x = logBase 4 (fromIntegral x)

costC x y = ceiling (log4 x - log4 y - epsilon)
costF x y = floor (log4 x - log4 y + epsilon)

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n]:remLines1 = remLines0
      n = readBInt bs_n
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve n as

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 202108
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	vector<string> t = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	string s;
	cin >> s;
	REP(i, t.size()) {
		if (t[i] == s) {
			put(7 - i);
			break;
		}
	}
	return 0;
}


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

using namespace std;

map< unsigned long long int, unsigned long long int > prime_factor(unsigned long long int n)
{
	map< unsigned long long int, unsigned long long int > ret;
	for (unsigned long long int i = 2; i * i <= n; i++)
	{
		while (n % i == 0)
		{
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1)
		ret[n] = 1;
	return ret;
}


bool is_prime(unsigned long long int x)
{
	for (unsigned long long int i = 2; i * i <= x; i++)
	{
		if (x % i == 0) return false;
	}
	return true;
}

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

	unsigned long long int x[2], r;
	vector<unsigned long long int>v;
	unsigned long long int i;


	int cnt = 0;
	cin >> x[0] >> x[1];

	for (auto p : prime_factor(x[0]))
	{
		v.push_back (p.first);
	}
	for (auto p : prime_factor(x[1]))
	{
		v.push_back (p.first);
	}
	v.push_back(1);
	v.push_back(1);
	sort(v.begin(), v.end());
	//sort(unique(v.begin(), v.end()), v.end());

	unsigned long long int v_ = v[0];
	for (i = 1; i < v.size(); i++)
	{
		if (v[i-1] == v[i])
		{
			cnt++;
		}
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    int cnt = 0;
    while(n){
        n /= 2;
        cnt++;
    }
    cnt -= 1;
    int ans = 1;
    rep(i,cnt) ans *= 2;
    cout << ans << endl;
}

Measured memory_bytes: 3596
s = input()
a = int(s[0:2])
b = int(s[2:4])

if (1 <= a and a <= 12):
    if (1 <= b and b <= 12):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if (1 <= b and b <= 12):
        print('YYMM')
    else:
        print('NA')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
struct ll{
	int t,w;
	bool operator <(const ll a)const{
		return w<a.w;
	}
}A[200002];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&A[i].t,&A[i].w);
	sort(A+1,A+n+1);
	int now=0;
	for(int i=1;i<=n;i++){
		if(now+A[i].t>A[i].w){
			puts("No");
			return 0;
		}
		now=now+A[i].t;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int u[1100000];
vector<int> y;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e=0,f=0,g=0;
  cin >>a>>b>>c>>d;
  d=min(a,b)+min(c,d);
  cout <<d<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1ll<<(x))
#define inf 1000000000
#define MOD 1000000007
#define N 100005
#define M 10000001
#define LOG 16
#define KOK 650
#define EPS 0.00001
using namespace std;

int q,a1,a2,b1,b2,n,m;
int p1A[N],p2A[N];
char a[N],b[N];

int main() {

	//freopen("input.txt","r",stdin);

	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	cin>>(a+1)>>(b+1);

	n=strlen(a+1);
	m=strlen(b+1);

	cin>>q;

	for(int i=1;i<=n;i++) p1A[i]=p1A[i-1]+(a[i]=='A');
	for(int i=1;i<=m;i++) p2A[i]=p2A[i-1]+(b[i]=='A');

	while(q--) {

		cin>>a1>>b1>>a2>>b2;

		int c1A=p1A[b1]-p1A[a1-1];
		int c1B=(b1-a1+1)-c1A;
		int c2A=p2A[b2]-p2A[a2-1];	
		int c2B=(b2-a2+1)-c2A;

		c1A+=c1B*2;

		if(c1A<c2A+c2B) {

			int add=(c2A+c2B-c1A+2)/3;

			c1A+=add*3;

		}

		c1A-=c2A;
		c1A+=c2B;

		if(c1A%3) cout<<"NO\n";
		else cout<<"YES\n";

	}

}



Measured memory_bytes: 1536
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int a;cin>>a;cout<<48-a<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>


using namespace std;
typedef long long ll;

int main(){

    ll N, K;
    cin >> N >> K;
    vector<ll > h;
    
    ll t = 0;

    for(ll i = 0; i < N ; i++){
        cin >> t;
        h.push_back(t);
    }
    sort(h.begin(),h.end());
    ll mn = h[K-1] - h[0];
    for(ll i = K - 1; i < N ; i++){
        //cout << h[i] << ":" << h[i-K+1] << endl;
        if(mn > h[i] - h[i-K+1]) mn = h[i] - h[i-K+1];
    }

    cout << mn << endl;


}

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

int main()
{
  int n,l;
  cin>>n>>l;
  int before = (n*(n-1))/2 + (n)*l;
  int ans;
  /*if(before >= 0)
  	ans = ((n-1)*(n+2*l))/2;
  else
    ans = ((n-1)*(n-2))/2 + n*l;
  cout<<ans;*/
  int a = (n*(n-1))/2 + (n-1)*l;
  int b = ((n-1)*(n-2))/2 + (n-1)*l;
  ans = min(abs(before - a),abs(before-b));
  int t = 1-l;
  if((t>=1)&&(t<=n))
  {
    cout<<before;
    return 0;
  }
  int finalans;
  if(before>0)
  	finalans = before - ans;
  else if(before<0)
    finalans = before + ans;
   else
     finalans = before;
  cout<<finalans;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bitset>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
int n,a,sum;
bitset<4000001> S;
int main()
{
	scanf("%d",&n);S[0]=true;
	for(int i=1,a;i<=n;++i)
	{
		scanf("%d",&a);
		sum+=a;
		S|=S<<a;
	}
	for(int i=(sum+1)>>1;;++i)if(S[i])return printf("%d",i),0;
	return 0;
}

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

using namespace std;

int main(void) {
  /* y = (A-B)*x 
   * y = (A-B)*x + b */

  int N; cin >> N;
  long long s[N];
  for (int i = 0; i < N; i++) cin >> s[i];

  long long ans = 0;
  for (int i = 1; i < N-1; i++) {
    long long f = 0;

    for (int j = i, k = N-1-i; k > i; j += i, k -= i) {
      if ((N-1) % i == 0 && j >= k) break;

      f += s[j] + s[k];
      ans = max(ans, f);
    }
  }

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

Measured memory_bytes: 4364
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] arr = String.valueOf(n).toCharArray();
		n= arr[0]=='9'? n-800 : n+800;
		n= arr[1]=='9'? n-80 : n+80;
		n= arr[2]=='9'? n-8 : n+8;
		System.out.println(n);		
	}
}

Measured memory_bytes: 22612
a,b=input().split()
test = lambda x:int(x)
a=test(a)
b=test(b)

w=[int(input()) for i in range(a)]
w.sort()
sum=0
num=len(w)
for i in w:
    sum=sum+i
while b-sum>=w[0]:
    sum=sum+w[0]
    num=num+1
    
print(num)

Measured memory_bytes: 3064
def solve():
    N = int(input())
    copy_N = N
    sum_N = 0
    while copy_N > 0:
        sum_N += copy_N % 10
        copy_N = copy_N // 10
    if N % sum_N == 0:
        print("Yes")
    else:
        print("No")
    
solve()

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    for (int i = 1; i <= n; i++)
    {
        ans = (ans * i) % 1000000007;
    }
    cout << ans << endl;
    return 0;
}


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

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

    string s;
    cin >> s;

    int n = s.size();
    vector<int> ans(n+1, 0);

    rep(i, n){
        if(s[i] == '<') ans[i+1] = max(ans[i]+1, ans[i+1]);
    }

    for(int i = n-1; i >= 0; --i){
        if(s[i] == '>') ans[i] = max(ans[i+1]+1, ans[i]);
    }

    ll res = 0;
    rep(i, n+1) res += ans[i];

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2844
#include<stdio.h>
#define INF 1000000
void warshall_floyd(void);
int min(int,int);
int graph[101][101],n,c,d;

int main(void){
  int k,i,j,x,e,a,b;

  while(scanf("%d %d",&n,&k),n,k){

    for(i=0;i<=n;i++)
      for(j=0;j<=n;j++)
	graph[i][j]=(i==j?0:INF);

    for(i=0;i<k;i++){

      if(scanf("%d",&x),x){
	scanf("%d %d %d",&c,&d,&e);

	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }else{
	scanf("%d %d",&a,&b);
	if(graph[a][b]<INF)printf("%d\n",graph[a][b]);
	else printf("-1\n");
      }
    }
  }
  return 0;
}

void warshall_floyd(void){
  int i,j;
  for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
      graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
}

int min(int x,int y){
  return (x<y)?x:y;
}

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

int main(){
    int k; string s;
    cin >> k >> s;
    if(s.size() <= k) cout << s << endl;
    else cout << s.substr(0,k) + "..." << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

ll N,P;
ll A[100];
ll B[100];
ll dp[100][2];


int main(){
	cin>>N>>P;
	rep(i,N) cin>>A[i];
	rep(i,N) B[i]=A[i]%2;
	dp[0][0]=1;
	dp[0][1]=0;
	Rep(i,N){
		if(B[i+1]){
			dp[i+1][0]=dp[i][0]+dp[i][1];
			dp[i+1][1]=dp[i][0]+dp[i][1];
		}
		else{
			dp[i+1][0]=2*dp[i][0];
			dp[i+1][1]=2*dp[i][1];
		}
	}
	cout<<dp[N][P]<<endl;
	
	
	
	  return 0;
  }


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

class Info {
  public:
    int n;
    bool is_end;
    int children[26];
    Info(int n = 0) {
      this->n = n;
      is_end = false;
      for (int i = 0; i < 26; ++i) {
        children[i] = -1;
      }
    }
};

int main() {
  int n, q, k;
  std::vector<std::vector<std::vector<int>>> nums;
  int nums2[100000] = {};
  std::string s[100000];
  std::string p;
  std::vector<Info> trie;
  trie.push_back(Info());
  std::cin >> n;
  nums.resize(n, std::vector<std::vector<int>>(26, std::vector<int>(26, 0)));
  for (int ni = 0; ni < n; ++ni) {
    int ptr = 0;
    std::cin >> s[ni];
    for (char c : s[ni]) {
      if (trie[ptr].children[c - 'a'] < 0) {
        trie[ptr].children[c - 'a'] = trie.size();
        trie.push_back(Info());
      }
      ++trie[ptr].n;
      ptr = trie[ptr].children[c - 'a'];
    }
    ++trie[ptr].n;
    trie[ptr].is_end = true;
  }
  for (int ni = 0; ni < n; ++ni) {
    int ptr = 0;
    for (auto c : s[ni]) {
      for (int a = 0; a < 26; ++a) {
        int x = trie[ptr].children[a];
        if (x >= 0 and 'a' + a != c) {
          nums[ni][a][c - 'a'] += trie[x].n;
        }
      }
      if (trie[ptr].is_end) {
        ++nums2[ni];
      }
      ptr = trie[ptr].children[c - 'a'];
    }
  }
  std::cin >> q;
  for (int qi = 0; qi < q; ++qi) {
    int ans = 1;
    std::cin >> k >> p;
    for (int a = 0; a < 26; ++a) {
      for (int b = a + 1; b < 26; ++b) {
        ans += nums[k - 1][p[a] - 'a'][p[b] - 'a'];
      }
    }
    ans += nums2[k - 1];
    std::printf("%d\n", ans);
  }
  return 0;
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const int MAX_N = 205;

int N, M, R;
ll d[MAX_N][MAX_N];
int RR[10];
const ll INF = 1000000000000;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> N >> M >> R;
    REP(i, R) cin >> RR[i];
    REP(i, N + 2) REP(j, N + 2) {
        if (i == j) d[i][j] = 0;
        else d[i][j] = INF;
    }
    int x, y, w;
    REP(i, M) {
        cin >> x >> y >> w;
        d[x][y] = w;
        d[y][x] = w;
    }
    for (int k = 1; k < N + 1; k++) {
        for (int i = 1; i < N + 1; i++) {
            for (int j = 1; j < N + 1; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    sort(RR, RR + R);
    ll ans = LLONG_MAX;
    do {
        ll dist = 0;
        FOR(i, 1, R - 1) {
            dist += d[RR[i - 1]][RR[i]];
        }
        ans = min(ans, dist);
    } while(next_permutation(RR, RR + R));
    cout << ans << endl;

}

Measured memory_bytes: 640
/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
const ll mod = 998244353;
const ll nmax=1000003;
#define int ll
int n, a[100010], m, k, mn, ans, viz[100010];
multiset<int> s;
vi g[100010];

void dfs(int nod){
	viz[nod]=1;
	mn=min(mn, a[nod]);
	for(int i: g[nod]) if(viz[i]==0) dfs(i);
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n>>m;
    if(n<2*(n-m-1)) return cout<<"Impossible", 0;
    if(m==n-1) return cout<<0, 0;
    for(int i=1; i<=n; i++) cin>>a[i], s.insert(a[i]);
    for(int i=1, x, y; i<=m; i++){
		cin>>x>>y;
		x++, y++;
		g[x].pb(y);
		g[y].pb(x);
	}
	for(int i=1; i<=n; i++){
		if(viz[i]==0){
			k++;
			mn=1e18;
			dfs(i);
			ans+=mn;
			s.erase(s.find(mn));
		}
	}
	for(auto it=s.begin(); k<2*(n-m-1); k++, it++) ans+=*it;
	cout<<ans;
}


Measured memory_bytes: 12544
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
  cin >> n;
  vl t(n), a(n);
  rep(i,n) cin >> t[i];
  rep(i,n) cin >> a[i];
  vl h(n);

  h[0] = 1;
  for(int i=1;i < n;i++){
    if(t[i] > t[i-1]){
      h[i] = 1; 
    }else if(h[i] > t[i] || h[i] == 0){
      h[i] = t[i];
    }
  }

  h[n-1] = 1;
  for(int i=1;i < n;i++){
    if(h[n-i-1] == 1
       && a[n-i-1] < t[n-i-1]
       && n-i-1 != 0){
      cout << 0 << endl;
      return 0;
    }
    if(a[n-i-1] > a[n-i]){
      h[n-i-1] = 1; 
    }else if(h[n-i-1] > a[n-i-1] || h[n-i-1] == 0){
      h[n-i-1] = a[n-i-1];
    }
  }
  ll ans = 1;
  rep(i,n){
    // cout << h[i] << endl;
    ans = (ans*h[i])%1000000007;
  }
  if(t[n-1] == a[0])
    cout << ans << endl;
  else
    cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 2560
n,m=map(int,input().split());a,ans=[[],[]],0
for i in range(m):aa,bb=map(int,input().split());a[0].append(aa);a[1].append(bb)
flag=True
while flag:
  flag=False
  for i in range(1,n+1):
    c=0
    p=[]
    for j in range(len(a[0])):
      if a[0][j]==i:c+=1;p.append(j)
      if a[1][j]==i:c+=1;p.append(j)
      if c>1:break
    if c==1:
      ans+=1
      del a[0][p[0]],a[1][p[0]]
      flag=True
      break
print(ans)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	x := r.nextInt()
	w := x
	w = w / 500
	ans := w * 1000
	w = x - w*500
	ans += w / 5 * 5
	fmt.Fprintln(stdout, ans)
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N, 0), B(N - 1, 0);
  for (int i = 0; i < N - 1; i++) cin >> B[i];
  A[0] = B[0];
  for (int i = 1; i < N - 1; i++) {
    A[i] = min(B[i - 1], B[i]);
  }
  A[N - 1] = B[N - 2];
  int total = accumulate(A.begin(), A.end(), 0);
  cout << total << endl;
  return 0;
}


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

int main(){
int64_t N,A,B;
  cin >> N >> A >> B;
  
  if(A==0 && B==0){
    cout << 0 << endl;
  }
  
  else{
  int64_t P,Q;
  
  P = N / (A+B);
    Q = N % (A+B);
  
   if(Q < A){
      cout << A*P + Q << endl;
    }
  
  else{
    cout << A*(P+1) <<endl;
  }
  }
  
}


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

#define mp(x, y) make_pair((x), (y))

typedef long long ll;

ll a, b, c;
set<pair<pair<ll,ll>, ll> > s;
int ans;

int main()
{
	scanf("%lld%lld%lld", &a, &b, &c);
	s.insert(mp(mp(a, b), c));
	while(a%2==0 && b%2==0 && c%2==0) {
		ll na, nb, nc;
		na=(b+c)/2;
		nb=(a+c)/2;
		nc=(a+b)/2;
		a=na;
		b=nb;
		c=nc;
		if(s.find(mp(mp(a, b), c))==s.end()) {
			s.insert(mp(mp(a, b), c));
		} else {
			printf("-1\n");
			return 0;
		}
		ans++;
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include "math.h"
#include "stdio.h"
#include <algorithm>
#include <string>
#include <iostream>

using namespace std;

/** Problem0058 : Orthogonal **/
int main()
{
	double xA, yA, xB, yB, xC, yC, xD, yD, EPS=1e-12;
	
	while (cin >> xA >> yA >>xB >> yB >> xC >> yC >> xD >> yD) {
		if (fabs((xB-xA)*(xD-xC)+(yB-yA)*(yD-yC))<EPS)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#ifndef INT_MAX
#  define INT_MAX std::numeric_limits<int>().max()
#endif
#ifndef INT_MIN
#  define INT_MIN std::numeric_limits<int>().min()
#endif
#define LL_MAX std::numeric_limits<ll>().max()
#define LL_MIN std::numeric_limits<ll>().min()
#define INF 100000000

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

#define MAX_V 1000

// 辺を表す構造体(行先、容量、G[i]における逆辺のインデックス)
struct edge {int to, cap, rev; };

int H, W;
vector<edge> G[MAX_V];  // グラフの隣接リスト表現 (index: ノード番号)
bool used[MAX_V];       // DFS で既に調べたかのグラフ

// from から to へ向かう容量 cap の辺をグラフに追加する
void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, static_cast<int>(G[to].size())});
    G[to].push_back((edge){from, 0, static_cast<int>(G[from].size() - 1)});
}

// 増加パスを DFS で探す
int dfs(int v, int t, int f) {
    if (v == t) { return f; }
    used[v] = true;
    for(int i = 0; i < G[v].size(); ++i) {
        edge &e = G[v][i];  // v から延びるエッジ i
        if(!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// s から t への最大流を求める
int max_flow(int s, int t) {
    int flow = 0;
    for(;;) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) { return flow; }
        flow += f;
    }
}

// マス S が (ys, xs) のとき、始点 s から ys と xs へそれぞれ容量 INF の有効辺を張る
// マス T が (yt, xt) のとき、yt と xt から終点 t へそれぞれ容量 INF の有効辺を張る
// それぞれの蓮の葉 (y, s) について y と x の間に容量 1 の無向辺を張る
//
int main()
{
    const int s_num = 700;  // 始点 s のノード番号
    const int t_num = 800;  // 終点 t のノード番号
    const int h_prefix = 0; // 行を表すノードに付与する数
    const int w_prefix = 200;   // 列を表すノードに付与する数
    pair<int, int> s_pos, t_pos;
    cin >> H >> W;
    REP(i, H) {
        REP(j, W) {
            char c;
            cin >> c;
            int node_i = i + h_prefix;
            int node_j = j + w_prefix;
            if(c == 'S') {
                add_edge(s_num, node_i, INF);
                add_edge(s_num, node_j , INF);
                s_pos.first = i;
                s_pos.second = j;
            }
            else if(c == 'T') {
                add_edge(node_i, t_num, INF);
                add_edge(node_j, t_num, INF);
                t_pos.first = i;
                t_pos.second = j;
            }
            else if(c == 'o') {
                add_edge(node_i, node_j, 1);
                add_edge(node_j, node_i, 1);
            }
        }
    }

    if(s_pos.first == t_pos.first || s_pos.second == t_pos.second) {
        printf("-1\n");
        return 0;
    }

    printf("%d\n", max_flow(s_num, t_num));
    return 0;
}


Measured memory_bytes: 896
import java.util.*;

class Main{
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String a = sc.next(); 
  int ans = 0;
	int q = 0;
   for(int i = 0; i < 3; i++){
    System.out.print(10 - Character.getNumericValue(a.charAt(i)));
   }
  }
}


Measured memory_bytes: 21844
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7

s = [str(i) for i in input().split()]

ans = ""
for i in range(3):
    ans += s[i][0]

print(ans.upper())


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


int a[100000],b[100000];
int main(){
	int n;
	while(	cin >> n){
		


	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	bool f = true;
//	for(int i = 0; i < n - 1; i++){
//		for(int j = i; j < n - 1; j++){
//			if(a[j+1] > a[j]) {
//				if(a[j+1] - a[j] > 1)
//					f = false;
//					break;
//			}
//		
//		}
//		if(!f) break;
//	}	
		if(a[0] >= a[1])a[0]--;
		for(int j = 0; j < n - 1; j++){
			if(a[j+1] > a[j]) {
				a[j+1]--;
				
			}
		}	
		for(int j = 0; j < n - 1; j++){
			if(a[j] > a[j+1]) {
				f = false;
				break;
			}
		}

	if(!f) cout << "No" << endl;
	else cout << "Yes" << endl;	
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S, T;
  cin >> S >> T;
  int s=S.size()-1, t=T.size()-1, num=-1;
  bool finish=false;
  
  for(int i=t; i>=0; i--){
    num++;
    for(int j=s-num; j>=i; j--){
      if(S[j]==T[i] || S[j]=='?'){
        int temp=0;
        for(int k=j-i; k<j-i+t+1; k++){    
          if(S[k]!=T[temp] && S[k]!='?') break;
          temp++;
          if(k==j-i+t){
            finish=true;
            temp=0;
            for(int k=j-i; k<j-i+t+1; k++){
              S[k]=T[temp];
              temp++;
            }            
          }
        }
      }
      if(finish) break;
    }
    if(finish) break;
    if(i==0){
      S="UNRESTORABLE";
      s=S.size()-1;
    }
  }
  for(int i=0; i<=s; i++){
    if(S[i]=='?'){
      S[i]='a';
    }
    cout << S[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005;
int a[N],b[N],num[N];
int x[100][100];
ll n,m,k;
int main()
{
    scanf("%lld%lld",&n,&m);
 
    if(n%2019==0||m%2019==0) 
	{
		cout<<0<<endl;
		return 0;
	}
	int x1=n/2019;
    int y1=m/2019; 
    
    if(y1>x1)
	{
		cout<<0<<endl;
		return 0;
	}

	ll ans=2020;
	for(ll i=n;i<=m;i++)
	{
		for(ll j=i+1;j<=m;j++)
			ans=min((i%2019*j%2019)%2019,ans);
	}
	
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;


int main(){
  cin >> N;
  for(int i = 0;i < N;i++){
    int k,p;
    cin >> k >> p;
    if(k % p == 0){
      cout << p << endl;
    }
    else{
      cout << k % p << endl;
    }
  }
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        int c[3];
         c[0]=a+b;
         c[1]=a-b;
         c[2]=a*b;
        sort(c,c+3);
        cout<<c[2]<<endl;

    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
// #define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

using Int = __int128_t;
using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}


signed main() {

    int n, x, t;

    cin >> n >> x >> t;

    cout << (n + x - 1) / x * t << endl;

    return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var _ = LnInts();
        var N = _[0]; var W = _[1];
        var Vs = new long[N][];
        for (var i = 0; i < N; i++)
        {
            Vs[i] = LnLngs();
        }
        var dp = new long[N + 1][];
        for (int i = 0; i < dp.Length; i++)
        {
            dp[i] = new long[W + 1];
        }
        dp[0][1] = 0;
        for (int i = 0; i < N; i++)
        {
           
            for (int w = 0; w <= W; w++)
            {
                if (w >= Vs[i][0])
                {
                    dp[i + 1][w] = Max(dp[i][w], dp[i][w - Vs[i][0]] + Vs[i][1]);
                }
                dp[i + 1][w] = Max(dp[i + 1][w], dp[i][w]);
            }
        }
        Console.WriteLine(dp[N][W]);
    }

    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}

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

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();
            HashSet<Character> set = new HashSet<>();
            for (int i = 0; i < s.length(); i++) {
                if (set.contains(s.charAt(i))) {
                    out.println("no");
                    return;
                }
                set.add(s.charAt(i));
            }

            out.println("yes");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21460
import fractions

A, B, C, D = map(int, input().split())

ac_div, ac_mod = divmod(A-1, C)
ad_div, ad_mod = divmod(A-1, D)
ae_div, ae_mod = divmod(A-1, int(C*D / fractions.gcd(C, D)))
bc_div, bc_mod = divmod(B, C)
bd_div, bd_mod = divmod(B, D)
be_div, be_mod = divmod(B, int(C*D / fractions.gcd(C, D)))

ret = B - A + 1 - (bc_div - ac_div) - (bd_div - ad_div) + (be_div - ae_div)

print(ret)


Measured memory_bytes: 5716