akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll D, T, S;
  cin >> D >> T >> S;
  if (T * S >= D)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3632
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    int s, w;
    cin >> s >> w;
    print((w>=s) ? "unsafe" : "safe");
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N, M;
    static Dictionary<int, List<int>> G = new Dictionary<int, List<int>>();
    static int[] A, B;
    static bool[] isVisited;
    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        M = cin.nextInt();
        A = new int[M];
        B = new int[M];
        for(int i = 0; i < M; i++)
        {
            int a = cin.nextInt() - 1;
            int b = cin.nextInt() - 1;
            A[i] = a;
            B[i] = b;
            if (!G.ContainsKey(a))
                G.Add(a, new List<int>());

            G[a].Add(b);

            if (!G.ContainsKey(b))
                G.Add(b, new List<int>());

            G[b].Add(a);
        }
        isVisited = new bool[N];
    }
    static void solve()
    {
        input();
        int ans = 0;
        for(int i = 0; i < M; i++)
        {
            isVisited = new bool[N];
            DFS(0, i);
            if (isVisited.Contains(false))
                ans++;
        }
        WriteLine(ans);
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
    static void DFS(int v, int disUseEdge)
    {
        isVisited[v] = true;
        foreach(var u in G[v])
        {
            if (!isVisited[u] && ((u != A[disUseEdge] || v != B[disUseEdge]) && (v != A[disUseEdge] || u != B[disUseEdge]) ))
                DFS(u, disUseEdge);
        }
    }
}

Measured memory_bytes: 13280
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;


int main(){
    int N, K;
    cin >> N >> K;
    ull sum = K;
    for(int i = 0; i < N - 1; i++) sum *= (K - 1);
    cout << sum << endl;
}

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

using namespace std;
typedef long long int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)

lld arr[1000000];
lld cnt;
bool visited[1000000];
vector<int> nei[1000000];
lld answer[1000000];
void DFS(int node){
  visited[node]=true;
  cnt+=arr[node];
  answer[node]=cnt;
  trav(a,nei[node]){
    if(!visited[a])DFS(a);
  }
  cnt-=arr[node];
}
int main(){
  int n,q;
  scanf("%d %d",&n,&q);
  rep(i,0,n)arr[i]=0;
  rep(i,0,n-1){
    int x,y;
    scanf("%d %d",&x,&y);
    x--;y--;
    nei[x].push_back(y);
    nei[y].push_back(x);
  }
  while(q--){
    int p;
    lld x;
    scanf("%d %lld",&p,&x);
    p--;
    arr[p]+=x;
  }
  rep(i,0,n)visited[i]=false;
  cnt=0;
  DFS(0);
  rep(i,0,n)printf("%lld\n",answer[i]);
  return 0;
  
}

Measured memory_bytes: 45184
# 1行目の入力を数値として扱う
n = int(input())
# 2行目の入力を数値のリストとして扱う
a = list(map(int, input().split()))

# 文字列の長さ分の配列を用意
ans = [0] * n

# 配列の添え字と中身を逆転させる
for i in range(1, n + 1):
    n = a[i - 1]
    ans[n - 1] = str(i)

# 答えの出力(リストの括弧を出力しない工夫)
print(' '.join(ans))

Measured memory_bytes: 15588
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 

const long long mod=1e9+7;

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

    cout<<n*n*n<<endl;

    return 0;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

const double PI = 3.14159265359;
const int INF = (int)1e9;
const ll LINF = 1e18;
const int IMOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

int main(void)
{
    int n;
    cin >> n;
    
    v_int a(n);
    ll suma = 0, sumb = 0, diff = 0;
    irep(i, n) { cin >> a[i]; suma += a[i]; }

    priority_queue<int> q;
    int ans = 0;

    irep(i, n) { 
        int b; cin >> b;
        sumb += b;
        if(b > a[i]) {
            diff += b-a[i];            
            ans++;
        } else {
            if(b != a[i]) {
                q.push(a[i]-b);
            }
        }
    }
    
    if(suma < sumb) { 
        cout << -1 << endl;
        return 0;
    }

    while(diff > 0) {
        int d = q.top(); q.pop();    
        if(diff <= d) {
            ans++;
            break;
        } else {
            diff -= d;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}
/** atcoder **/



Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(n: i32, a: i32, b: i32);
    puts!("{}\n", min(a * n, b));
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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


#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    rep(i,n){
        cout << s[i];
        cout << t[i];
    }
    cout << endl;

    return 0;
}

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

int main() {
  long int a,b,k;
  cin >> a >> b >> k;
  if(a+b<=k){
    cout << "0 0" << endl;
  }else if(a<k){
    cout << 0 << " " << a+b-k << endl;
  }else if(a>=k){
    cout << a-k << " " << b << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int X, Y, Z;
    cin >> X >> Y >> Z;

    printf("%d %d %d\n" , Z, X, Y);
    
    return 0;
}

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

int main(){
  string a,b;
  int res=1000, sum=0;
  cin>>a>>b;
  for(int i=0;i<=a.size()-b.size();i++){
    sum=0;
    for(int j=0;j<b.size();j++){
      if(a[i+j] != b[j]) sum++;
    }
    res=min(res,sum);
  }
  cout<<res<<endl;
}

Measured memory_bytes: 3532
n = int(input())
s = [input() for _ in range(n)]

import collections
a = []
for i in range(n):
    xx = list(s[i])
    xx.sort()

    a.append(''.join(xx))

c = collections.Counter(a)

ans = 0
for k in c.keys():
    v = c[k]
    ans += v * (v - 1) // 2

print(ans)


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

using namespace std;

#define ll long long
#define INF 1e15

ll dp[3005][3005];


ll ans(int l, int r, vector<ll> &vec);

int
main(void){
	int n; cin >> n;
	vector<ll> vec(n);
	
	for(int i = 0; i < n; i++) cin >> vec[i];
	
	for(int i = 0; i < n + 5; i++){
		for(int j = 0; j < n + 5; j++){
			dp[i][j] = INF;
		}
	}
	
	cout << ans(0, n - 1, vec);
	
}

ll ans(int l, int r, vector<ll> &vec){
	if(l == r) return dp[l][r] = vec[l];
	if(dp[l][r] != INF) return dp[l][r];
	
	dp[l][r] = max(vec[l] - ans(l + 1, r, vec), vec[r] - ans(l, r - 1, vec));
	return dp[l][r];
	
}

Measured memory_bytes: 71040
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll a,b,k;cin>>a>>b>>k;
    if(a>=k){
        cout<<a-k<<' '<<b<<endl;
    }else{
        if(a+b<=k){
            cout<<0<<' '<<0<<endl;
        }else{
            cout<<0<<' '<<b-(k-a)<<endl;
        }
    }
}

Measured memory_bytes: 256
def cut(d, w, s):
    s %= d + w
    if 0 < s < w:
        p1, p2 = (d, s), (d, w - s)
    elif w < s < w + d:
        s -= w
        p1, p2 = (s, w), (d - s, w)
    else:
        assert(False)
    if p1[0] * p1[1] > p2[0] * p2[1]:
        p1, p2 = p2, p1
    return [p1, p2]


while True:
    N, W, D = map(int, input().split())
    if not (N | W | D):
        break
    square = [(D, W)]
    for _ in range(N):
        p, s = map(int, input().split())
        d, w = square.pop(p - 1)
        square.extend(cut(d, w, s))
    print(*sorted(d * w for d, w in square))

Measured memory_bytes: 7600
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
    char str[50];
    scanf("%s",str);
    if(strcmp(str,"Sunny")==0)
    {
        printf("Cloudy\n");
    }
    if(strcmp(str,"Cloudy")==0)
    {
        printf("Rainy\n");
    }
    if(strcmp(str,"Rainy")==0)
    {
        printf("\Sunny");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long n,m,i,j,cnt[1005],np[1005],ans=1,mod=1e9+7;
vector<long long> pri;
void calc(int x)
{
	int i;
	for (i=0;i<pri.size()&&pri[i]*pri[i]<=x;i++)
	{
		while (x%pri[i]==0)
		{
			x/=pri[i];
			cnt[pri[i]]++;
		}
	}
	if (x>1) cnt[x]++;
}
int main()
{
	cin>>n;
	np[1]=1;
	for (i=2;i<=n;i++)
	{
		if (np[i]) continue;
		pri.push_back(i);
		for (j=2;i*j<=n;j++) np[i*j]=1;
	}
	for (i=2;i<=n;i++) calc(i);
	for (i=0;i<pri.size();i++)
	{
		ans=ans*(cnt[pri[i]]+1)%mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


string S;


int solve(){
	int ans = 0;
	rep(i, 0, SIZE(S)-1){
		if(S[i] == 'W' && S[i+1] == 'B') ans++;
		if(S[i] == 'B' && S[i+1] == 'W') ans++;
	}
	return ans;
}


signed main(){
	cin >> S;

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 512
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

// max_flow
const int MAX_V = 250;
class FordFulkerson {
public:
    struct edge {
        int to;
        int cap;
        int rev;
        edge() {}
        edge(int t, int c, int r) : to(t), cap(c), rev(r) {}
    };
    vector<edge> G[MAX_V];
    void add_edge(int from, int to, int cap) {
        G[from].push_back(edge(to, cap, G[to].size()));
        G[to].push_back(edge(from, 0, G[from].size() - 1));
    }
    int max_flow(int s, int t) {
        int flow = 0;
        while (1) {
            for (int i = 0; i < MAX_V; i++) used[i] = false;
            int f = dfs(s, t, INF);
            if (f == 0) return flow;
            flow += f;
        }
    }
private:
    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];
            if (!used[e.to] && e.cap > 0) {
                int d = dfs(e.to, t, min(e.cap, f));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    bool used[MAX_V];
};

double x[110], y[110], v[110];
double bx[110], by[110];
int n, m;

double square(double x) {return x*x;}

double dist2(double x1, double y1, double x2, double y2) {
    return square(x2-x1) + square(y2-y1);
}

int match(double dist) {
    FordFulkerson ff;
    int s = n+m, t = s+1;
    for (int i = 0; i < n; i++) {
        ff.add_edge(s, i, 1);
    }
    for (int i = 0; i < m; i++) {
        ff.add_edge(n+i, t, 1);
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (dist2(x[i], y[i], bx[j], by[j]) / square(v[i]) < dist * dist) {
                ff.add_edge(i, j+n, 1);
            }
        }
    }
    return ff.max_flow(s, t);
}

int main(void) {
    while (cin >> n >> m) {
        if (n == 0 && m == 0) break;
        double low = 0, high = 20000;
        for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> v[i];
        for (int i = 0; i < m; i++) cin >> bx[i] >> by[i];
        for (int i = 0; i < 50; i++) {
            double mid = (high + low) / 2;
            if (match(mid) >= m) {
                high = mid;
            } else {
                low = mid;
            }
        }
        printf("%.10lf\n", low);
    }
    return 0;
}

Measured memory_bytes: 1568
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n, k;
    cin >> n >> k;
    cout << min(n % k, (k - n % k)) << endl;
    return 0;
}




Measured memory_bytes: 256
import copy
N = 10**100
S = input()
n = len(S)

check = []
rc = 0
lc = 0
for i in range(n-1):
    if S[i] == "R":
        if S[i+1] == "L":
            rc += 1
            check.append(rc)
            rc = 0
        else:
            check.append(0)
            rc += 1
    else:
        check.append(0)
check.append(0)

for j in range(n-1):
    if S[-j-1] == "L":
        if S[-j-2] == "R":
            lc += 1
            check[-j-1] = lc
            lc = 0
        else:
            lc += 1
#print(check)

ans = [0 for _ in range(n)]

for k in range(n):
    if check[k] > 0 and S[k] == "R":
        if (check[k] + check[k+1]) % 2 == 0:
            #print(1)
            h = int((check[k] + check[k+1]) / 2)
            ans[k] = h
            ans[k+1] = h

        else:
            l = check[k] // 2
            r = check[k+1] // 2
            if check[k] % 2 == 1:
                r += (check[k] // 2) + 1
            else:
                r += check[k] // 2 

            if check[k+1] % 2 == 1:
                l += (check[k+1] // 2) + 1
            else:
                l += check[k+1] // 2
            
            ans[k] = r
            ans[k+1] = l
            
for q in range(n):
    print(ans[q], end=' ')

Measured memory_bytes: 6016
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n, w;
	cin >> n >> w;
	vector<vector<int > > items(n, vector<int>(2)); // 0 = weight 1 = value
	for(int i = 0; i < n; i++){
		cin >> items[i][0];
		cin >> items[i][1];
	}
	vector<vector<long long int > > dp(n, vector<long long int>(100005, 99999999999));
	dp[0][items[0][1]] = items[0][0];
	dp[0][0] = 0;
	for(int i = 1; i < n; i++){
		for(int j = 0; j < 100005; j++){
			if((j-items[i][1]) >= 0){
				dp[i][j] = min(dp[i-1][j], dp[i-1][j-items[i][1]] + items[i][0]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < 100005; i++){
		if(dp[n-1][i] <= w){
			ans = max(ans, i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 82024
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

S = input().rstrip()
T = input().rstrip()

Ns = len(S)
Nt = len(T)

dp = [[0]*(Nt+1) for _ in range(Ns+1)]
path = [[None for _ in range(Nt+1)] for _ in range(Ns+1)]

for i in range(Ns):
    for j in range(Nt):
        if S[i]==T[j]:
            if dp[i+1][j+1] < dp[i][j]+1:
                dp[i+1][j+1] = dp[i][j]+1
                path[i+1][j+1] = (i,j)
        else:
            if dp[i][j+1] < dp[i+1][j]:
                dp[i+1][j+1] = dp[i+1][j]
                path[i+1][j+1] = (i+1,j)
            else:
                dp[i+1][j+1] = dp[i][j+1]
                path[i+1][j+1] = (i,j+1)


ans = []
cur = [Ns, Nt]
while cur[0] != 0 and cur[1] != 0:
    nxt = path[cur[0]][cur[1]]
    if cur[0]-1 == nxt[0] and cur[1]-1==nxt[1]:
        ans.append(S[cur[0]-1])
    cur[0] = nxt[0]
    cur[1] = nxt[1]
answer = ''.join(reversed(ans))
print(answer)



Measured memory_bytes: 385928
#include <bits/stdc++.h>
#define ll long long

using namespace std;

typedef struct{
    int x,y,w;
}Grana;

int l;
int n,m;
vector<int> bin;
vector<Grana> graf;

void plus1()
{
    m++;
    graf.push_back({1,n,l});
    l++;
}

void dupliraj()
{
    n++;
    m+=2;
    graf.push_back({n-1,n,0});
    graf.push_back({n-1,n,l});
    l*=2;
}

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

	cin>>l;

	while(l!=0)
        bin.push_back(l%2), l/=2;

    n=2;
    m=1;
    l=1;
    int cnt=0;
    graf.push_back({1,2,0});
    for(int i=bin.size()-2;i>=0;i--)
    {
        cnt++;
        if(l==1)plus1();
        else dupliraj();
        if(bin[i]==1)
            plus1();
    }
    //cout<<"*"<<cnt<<endl;
    cout<<n<<" "<<m<<endl;
    for(int i=0;i<m;i++)
        cout<<graf[i].x<<" "<<graf[i].y<<" "<<graf[i].w<<endl;
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> length(N);
    rep(i,N){
        cin >> length[i];
    }
    sort(all(length));
    int ans = 0;
    rep(i,N - 2){
        for(int j = i + 1; j < N - 1; j++){
            int limit = length[i] + length[j] - 1;
            int left = j + 1;
            int right = N - 1;
            if (length[left] > limit){
                ans += 0;
            }
            else if (length[right] <= limit){
                ans += N - j - 1;
            }
            else{
                while(true){
                    if (right - left == 1){
                        ans += left - j;
                        break;
                    }
                    else if (length[(left + right) / 2] > limit){
                        right = (left + right) / 2;
                    }
                    else if (length[(left + right) / 2] <= limit){
                        left = (left + right) / 2;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}



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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

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


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n, m;
    cin >> n >> m;

    vector<P> v(n), w(m);
    rep(i, n){
        cin >> v[i].first >> v[i].second;
    }

    rep(i, m){
        cin >> w[i].first >> w[i].second;
    }

    vector<int> ans(n);
    rep(i, n){
        ll x = INF;
        int tmp = i;
        rep(j, m){
            ll y = abs(v[i].first - w[j].first ) + abs(v[i].second - w[j].second);
            if(x > y){
                x = y;
                tmp = j+1;
            }
        }
        ans[i] = tmp;
    }

    rep(i, n){
        cout << ans[i] << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  map<ll,ll> m;
  rep(i,n) {
    int x;
    R x;
    m[x]++;
  }
  priority_queue<ll> que;
  tr(it,m) {
    while(it->S>=2) {
      que.push(it->F);
      it->S-=2;
    }
  }
  ll ans=1;
  rep(i,2) {
    if(que.size()) {
      ans*=que.top();que.pop();
    } else ans=0;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {

    static class P{
        String name;
        int time;
    }

    static int len = 100001;
    static P[] Q = new P[len];

    static int head = 0;
    static int tail = 0;

    static boolean isEmpty(){
        return head == tail;
    }

    static boolean isFull(){
        return head == (tail + 1) % len;
    }

    static void enqueue(P p){
        if(isFull()){
            throw new IndexOutOfBoundsException();
        }
        Q[tail] = p;

        tail = (tail + 1) % len;
    }

    static P dequeue(){
        if(isEmpty()){
            throw new IndexOutOfBoundsException();
        }
        P temp = Q[head];

        head = (head + 1) % len;
        return temp;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        P p = null;
        int n = 0;
        int q = 0;
        int index = 0;
        String[] temp = null;
        while (sc.hasNextLine()){
            if(n == 0){
                temp = sc.nextLine().split(" ");
                n = Integer.valueOf(temp[0]);
                q = Integer.valueOf(temp[1]);
            }else{
                temp = sc.nextLine().split(" ");
                p = new P();
                p.name = temp[0];
                p.time = Integer.valueOf(temp[1]);
                enqueue(p);
                index ++;
                if(index == n){
                    break;
                }
            }
        }

        int sumTime = 0;//当前总运行时间

        P curr = null;
        while (head != tail){
            curr = dequeue();
            int c = min(q,curr.time);
            curr.time -= c;
            sumTime += c;
            if(curr.time > 0){
                //如果当前任务有剩余时间 则加入队列
                enqueue(curr);
            }else{
                System.out.println(curr.name + " " + sumTime);
            }
        }
    }


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



Measured memory_bytes: 105956
/*  ***  In The Name of God ... ***  */
                                      /* Yani mishe mnm shakh sham ? ...  */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define bug() cout << "BUG" << endl ;
#define X first
#define Y second
#define sz(x) (int)x.size()
#define per(how) cout << fixed << setprecision(how)
#define bit(a , b) (a >> b) & 1
#define all(v) v.begin() , v.end()
#define LB(x) (x & -x)
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 , MOD = 1e9 + 7 , SQRT = 350 ;
inline void smin(ll &x , ll y) { x = min(x , y) ; }
inline void smax(ll &x , ll y) { x = max(x , y) ; }

const ll MAXN = 1e5 + 100 ; 
ll n , a[MAXN] , cnt[MAXN] , f[MAXN] ; 

ll pw(ll a , ll b)
{
	if(b == 0)		return 1 ; 
	if(b == 1)		return a ; 
	ll x = (pw(a , b / 2)) % MOD ; 
	x = ((x % MOD)*(x % MOD))% MOD ; 
	if(b & 1)
	{
		x = ((x % MOD) * (a % MOD)) % MOD ;
		x %= MOD ; 
	}
	return x ;
}

ll inv(ll x)
{
	return pw(x , MOD - 2) % MOD ; 
}

ll c(ll s , ll x)
{
	if(x < 0)	return 0 ; 
	if(x > s)	return 0 ; 
	ll sina = f[s] % MOD ; 
	ll sina1 = inv(f[s - x]) % MOD ; 
	ll sina2 = inv(f[x])%MOD ; 
	ll sina3 = sina * sina1 ; 
	sina3 %= MOD ; 
	return (sina3 * sina2) % MOD ; 
} 

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	f[0] = 1 ; 
	for(ll i = 1 ; i < MAXN ; i++)
	{
		f[i] = f[i - 1] % MOD ; 
		f[i] = (f[i] % MOD) * i ;
		f[i] %= MOD ; 
	}
	cin >> n ; 
	ll nima = -1 ; 
	for(ll i = 1 ; i <= n + 1 ; i++)
	{
		cin >> a[i] ; 
		cnt[a[i]]++ ; 
		if(cnt[a[i]] == 2)		nima = a[i] ;
	}
	ll x , y ; 
	ll cnt = 0 ; 
	for(ll i = 1 ; i <= n + 1 ; i++)
	{
		if(a[i] == nima)
		{
			x = cnt ; 
			cnt = 0 ; 
			break ; 
		}
		cnt++ ; 
	}
	for(ll i = n + 1 ; i >= 1 ; i--)
	{
		if(a[i] == nima)
		{
			y = cnt ; 
			cnt = 0 ; 
			break ; 
		}
		cnt++ ; 
	}
	ll t = n - (x + y + 2) + 1 ; 
	for(ll i = 1 ; i <= n + 1 ; i++)
	{
		ll k = i ; 
		ll sina = c(n - 1 , k) ; 
		ll sina2 = c(n - 1 , k - 2) ; 
		ll sina3 = c(n - 1 , k - 1) ; 
		ll nima1 = c(t + y + x  , k - 1) ;
		ll nima2 = c(x + y , k - 1) ;
		nima2 *= -1 ; 
		while(nima2 < MOD)	nima2+=MOD; 
		nima2 %= MOD ; 
		cout << ((sina % MOD + sina2 % MOD ) % MOD + ((sina3 % MOD + nima1 % MOD) % MOD + nima2) % MOD) % MOD  << endl ; 
	}
	cout << endl ; 
	return 0; 
}




Measured memory_bytes: 3584
A,B,K=map(int,input().split())

ans=[]

if A<=K:
    ans.append(0)
    if B<=(K-A):
        ans.append(0)
    else:
        ans.append(B-K+A)
        
else:
    ans.append(A-K)
    ans.append(B)
    
print(str(ans[0])+' '+str(ans[1]))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) {
 if (a < b) { a = b; return true; } return false; 
 }
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll h,w;
  cin>>h>>w;
  if(h==1||w==1){
    COUT(1);
  }
  else{
    COUT((h*w+1)/2);
  }
}

Measured memory_bytes: 256
ori_month, ori_day = map(int, input().split())

def p_day_check(month, day):
    d1 = day % 10
    d10 = day // 10
    if d1 >= 2 and d10 >= 2 and d1 * d10 == month:
        return True
    else:
        return False

product_day = 0

for month in range(1, ori_month+1):
    for day in range(1, ori_day+1):
        if p_day_check(month, day):
            product_day += 1

print(product_day)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<class Z> Z rng(Z a, Z b) {
  static mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
  return uniform_int_distribution<Z>(a, b - 1)(mt);
}

lint powll(lint a, int n) {
  assert(n >= 0);
  lint res = 1;
  for (; n > 0; a *= a, n >>= 1) if (n & 1) res *= a;
  return res;
}

lint digits(auto& i) {
  lint res = 0;
  while (isdigit(*i)) res = 10 * res + *i++ - '0';
  return res;
}
lint expr(auto& i);
lint num(auto& i) {
  switch (*i) {
    case '(': {
      lint res = expr(++i);
      return ++i, res;
    }
    default: return digits(i);
  }
}
lint pw(auto& i) {
  lint res = num(i);
  if (*i == '^') return ++i, powll(res, num(i));
  return res;
}
lint term(auto& i) {
  lint res = pw(i);
  while (true) switch (*i) {
    case '*': res *= pw(++i); break;
    default: return res;
  }
}
lint expr(auto& i) {
  lint res = term(i);
  while (true) switch (*i) {
    case '+': res += term(++i); break;
    case '-': res -= term(++i); break;
    default: return res;
  }
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  auto pre = [&](string s) -> string {
    while (true) {
      bool b = false;
      for (int i = 0; i < (int)s.size(); ++i) if (s.substr(i, 2) == "  ") {
        s.erase(begin(s) + i);
        b = true;
        break;
      }
      if (!b) break;
    }
    string res;
    for (int i = 0; i < (int)s.size(); ++i) {
      if (s[i] == ' ') {
        if (isdigit(s[i - 1]) and isdigit(s[i + 1])) {
          res += '*';
        }
      } else res += s[i];
      if (isdigit(res.back()) and isdigit(s[i + 1])) continue;
      bool b0 = res.back() == ')' or isdigit(res.back()) or islower(res.back());
      bool b1 = s[i + 1] == '(' or isdigit(s[i + 1]) or islower(s[i + 1]);
      if (b0 and b1) res += '*';
    }
    return res;
  };
  auto eval = [&](string s, const V<>& a) -> lint {
    for (int i = 0; i < (int)s.size(); ++i) if (islower(s[i])) {
      s.replace(i, 1, to_string(a[s[i] - 'a']));
    }
    auto i = begin(s);
    lint res = expr(i);
    // cerr << s << ' ' << res << '\n';
    return res;
  };
  auto comp = [&](string s, string t) -> bool {
    s = pre(s);
    t = pre(t);
    bool ok = true;
    for (int _ = 0; _ < 100; ++_) {
      V<> a(26);
      for (auto&& e : a) e = rng(0, 100);
      if (eval(s, a) != eval(t, a)) {
        ok = false;
        break;
      }
    }
    return ok;
  };
  while (true) {
    string s; getline(cin, s);
    if (s == ".") break;
    while (true) {
      string t; getline(cin, t);
      if (t == ".") {
        cout << ".\n";
        break;
      }
      cout << (comp(s, t) ? "yes\n" : "no\n");
    }
  }
}


Measured memory_bytes: 3292
while s=gets do
    i=s.to_i
    x=0
    0.upto(9) do |a|
        0.upto(9) do |b|
            0.upto(9) do |c|
                0.upto(9) do |d|
                    x+=1 if [a,b,c,d].inject(:+)==i
                end
            end
        end
    end
    p x
end

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n; scan(n);
      LI xs(n); for(long &x : xs) scan(x);
      long total = 0;
      for(long x : xs) total += x;
      long a = 0, b = total;
      long res = (1LL << 53);
      for(long i = 0; i < n - 1; ++i) {
         a += xs[i];
         b -= xs[i];
         res = std::min(res, std::abs(a-b));
      }
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    int a[n+1];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int now = 1;
    int ans = -1;
    for(int i = 1; i <= n; i++){
        now = a[now];
        if(now == 2){
           ans = i;
           break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int S;
 
	cin >> S;
	int h = S / 3600;
	int m = (S % 3600) / 60;
	int s = (S % 3600) % 60;
	if((S >= 0) && (S < 86400)) {
		cout << h << ":" << m << ":" << s << endl;
	}
}

Measured memory_bytes: 3112
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 200010
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int f[N][2]; char ch[N];
int main()
{
	scanf("%s",ch+1); int n=strlen(ch+1);
	for(int i=1;i<=n;i++)
	{
		if(ch[i]!='D')	f[i][0]=max(f[i-1][1],f[i-1][0]);
		if(ch[i]!='P')	f[i][1]=max(f[i-1][1]+1,f[i-1][0]+2);
	}
	int s=f[n][0]>=f[n][1]?0:1; ch[n]=s?'D':'P';
	for(int i=n-1;i;i--)
	{
		if(ch[i]!='?')	s=ch[i]=='D';
		else
		{
			if(s)
			{
				if(f[i][1]+1>f[i][0]+2)	s=1; else	s=0; 
			}
			else
			{
				if(f[i][1]>f[i][0])	s=1; else	s=0;
			}
		}
		ch[i]=s?'D':'P';
	}
	printf("%s\n",ch+1);
	return 0;
}


Measured memory_bytes: 4916
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      	final int NUM;
      	final int DURATION;
      	final int TIMELIMIT;
      	String str = br.readLine();
      	DURATION = Integer.parseInt(str.split(" ")[0]);
      	NUM = Integer.parseInt(str.split(" ")[1]);
      	TIMELIMIT = Integer.parseInt(str.split(" ")[2]);
      	
      	int total = 0;
      	int nextCount = 1;
      	for (int i = 1; i <= TIMELIMIT; i++) {
      		if (i == nextCount * DURATION) {
      			total += NUM;
      			nextCount++;
      		}
      	}
      	System.out.println(total);
    }	
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
string t;
cin>>s;
cin>>t;
long long ans=0;
for(long long i=0;i<s.size();i++){
  if(s[i]!=t[i]){
    ans++;
  }
}
cout<<ans<<endl;
return 0;

}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int M = 1000000007;
#define pb push_back
#define fs first
#define sc second
#define forn(i,k,n) for(int i = k; i < n; ++i)
#define nfor(i,n,k) for(int i = n; i >= k; --i)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define vvpii vector<vector<pait<int,int>>>
#define all(arr) arr.begin(), arr.end()
#define endl '\n'
#define dbgarr(V,n) forn(i,0,n) cout << V[i] << " "; cout << endl;
#define dbgarrrev(V,n) nfor(i,n,0) cout << V[i] << " "; cout << endl;
#define dbgmaze(V) for(auto x: V) {for(auto y : x) cout << y <<  " ";cout << endl;}
#define dbg2d(V,n,m) forn(i,0,n) {forn(j,0,m) cout << V[i][j] <<  " ";cout << endl;}
#define N 100000
#define inf 1100000001
int dp[101][N] = {};
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, c; cin >> n >> c;
	int W[n + 1] , V[n + 1];
	forn(i,1,n + 1) cin >> W[i] >> V[i];
	int sum = 0; forn(i,1,n + 1) sum += V[i];
	forn(i,0,n + 1) forn(j,0,sum + 1) dp[i][j] = inf;
	forn(i,0,n + 1) dp[i][0] = 0;
  	forn(i,1,n + 1){
        forn(j,1,sum + 1){
        	if(j >= V[i])
        		dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - V[i]] + W[i]);
        	else dp[i][j] = dp[i - 1][j];
        }
    }
    int ans;
    forn(i,0,sum + 1){
        if(dp[n][i] <= c) ans = i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 43008
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    ll n, m; cin >> n >> m;
    ll ans = 0;
    if (m >= 2 * n) {
        ans += n;
        m -= n*2;
        ans += m/4;
    } else {
        ans += m/2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636