akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include<map>

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

using namespace std;


int inputValue() {
  int a;
  cin >> a;
  return a;
};
void inputVector(vector<int>* v) {
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int a;
  while (cin >> a) {
    if (a == -1)break;
    v->push_back(a);
  }
};

void inputVector(vector<int> * p, int a) {
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

void inputVector2(vector<vector<int>>& v, int r, int c) {
  int temp;
  for (size_t i = 0; i < r; i++)
  {
    for (size_t j = 0; j < c; j++)
    {
      scanf("%d", &temp);
      v[i][j] = temp;
    }
  }
}
void inputVector3(vector<int>* v0, vector<int>* v1) {
  int a;
  unsigned short count = 0b0;
  while (cin >> a) {
    if (a == -1)break;
    if (count)v0->push_back(a); else v1->push_back(a);
    count = count ^ 1;
  }
};

template <typename T>
void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  }
  else {
    cout << a << "\n";
  }
}



int main(int argc, const char * argv[]) {
  int hidari = 0;
  int ue = 0;
  int ima;
  int h;
  int w;
  int count = 0;
  string temp;
  vector<string> kotae;
  scanf("%d", &h);
  scanf("%d", &w);
  for (size_t i = 0; i < h; i++)
  {
    for (size_t j = 0; j < w-1; j++)
    {
      scanf("%d", &ima);
      ima = ima + hidari;
      hidari = 0;
      if (ima % 2 == 1) {
        count++;
        hidari = 1;
        temp = to_string(i+1);
        temp += " ";
        temp += to_string(j+1);
        temp += " ";
        temp += to_string(i+1);
        temp += " ";
        temp += to_string(j+2);
        kotae.push_back(temp);
      }
    }
    if (i != h - 1) {
      scanf("%d", &ima);
      ima = ima + hidari + ue;
      hidari = 0;
      ue = 0;
      if (ima % 2 == 1) {
        count++;
        ue = 1;
        temp = to_string(i+1);
        temp += " ";
        temp += to_string(w);
        temp += " ";
        temp += to_string(i+2);
        temp += " ";
        temp += to_string(w);
        kotae.push_back(temp);
      }
    }
  }
  cout << count << endl;
  for (auto& k : kotae) {
    cout << k << endl;
  }
  return 0;
}

Measured memory_bytes: 10868
#include <iostream>
#include <vector>
#include <utility>
#include <limits>
#include <functional>
#include <queue>
#include <cmath>
#include <cassert>
#include <cstdint>

using namespace std;

string solve(const string& s, int k) {
    constexpr auto kNumAlpha = 'z' - 'a' + 1;

    string ss = s;
    int r = k;
    for (auto&& c : ss) {
        if (c == 'a') {
            continue;
        }

        int l = 'z' - c + 1;
        if (r >= l) {
            c = 'a';
            r -= l;
        }
    }

    r -= (r / kNumAlpha) * kNumAlpha;
    ss.back() += r;

    return ss;
}


int main() {
    string s;
    cin >> s;

    int k;
    cin >> k;

    cout << solve(s, k) << endl;

    return 0;
}

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

using namespace std;

int n, T, c, t;
int ans=0x3f3f3f3f;

int main() {
	cin>>n>>T;
	for(int i=1; i<=n; i++) {
		cin>>c>>t;
		if (t<=T) ans=min(ans, c);
	}
	if (ans==0x3f3f3f3f) cout<<"TLE"<<endl;
	else cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int A[4];
	for (string s; cin >> s&&s != "0000";) {
		int cnt = 0;
		if (s[0] == s[1] && s[1] == s[2] && s[2] == s[3]) {
			cout << "NA" << endl;
			continue;
		}
		while (s != "6174") {
			cnt++;
			rep(i, 0, 4) {
				A[i] = s[i] - '0';
			}
			sort(A, A + 4);
			int L = 0, S = 0;
			rep(i, 0, 4) {
				L *= 10;
				S *= 10;
				L += A[3 - i];
				S += A[i];
				//dump(L); dump(S);
			}
			stringstream ss;
			ss << setfill('0') << setw(4) << L - S;
			s = ss.str();
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3176
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll a[100010];
    rep(i,0,N) cin >> a[i];
    ll cnt2 = 0, cnt4 = 0;
    rep(i,0,N){
        if(a[i] % 4 == 0) cnt4++;
        else if(a[i] % 2 == 0) cnt2++;
    }
    if(cnt4 >= N/2){
        print("Yes");
    }else{
        ll n2 = N - cnt4 * 2;
        if(cnt2 >= n2){
            print("Yes");
        }else{
            print("No");
        }
    }
    

}

Measured memory_bytes: 1024
#include <cstdio>

using namespace std;

const int N = 100'009;

bool ok[N];
int bad[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    ok[i] = false;
    bad[i] = 0;
  }
  for (int i = 0; i < m; ++i) {
    int x;
    char s[9];
    scanf("%d%s", &x, s);
    --x;
    if (ok[x]) {
      continue;
    }
    if (s[0] == 'A') {
      ok[x] = true;
    } else {
      ++bad[x];
    }
  }
  int a = 0, b = 0;
  for (int i = 0; i < n; ++i) {
    if (ok[i]) {
      ++a;
      b += bad[i];
    }
  }
  printf("%d %d\n", a, b);
}


Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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 ]) => {
        (1..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

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

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

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

fn main() {
    input!(
    n: usize,
    y: usize,
    );
    for i in 0..n + 1 {
        let si = 1000 * i;
        if si > y {
            break;
        }
        for j in 0..(n - i + 1) {
            let sj = si + 5000 * j;
            if sj > y {
                break;
            }
            let sk = sj + 10000 * (n - i - j);
            if sk == y {
                println!("{} {} {}", n - i - j, j, i);
                return;
            }
        }
    }
    println!("-1 -1 -1");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,M=2005;
int C[M][M];
int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=0; i<=n; i++){
		C[i][0]=1;
		for(int j=1; j<=i; j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for(int i=1; i<=k; i++){
		if(i>n-k+1) {
			puts("0"); continue;
		}
		long long w=1;
		w=(w*C[n-k+1][i])%mod;
		w=(w*C[k-1][i-1])%mod;
		printf("%lld\n",w);
	}
	return 0;
}

Measured memory_bytes: 15104
# ABC058c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
dicts = []
for _ in range(n):
    s = input()[:-1]
    d = dict()
    for i in s:
        if (d.get(i) != None):
            d[i] += 1
            continue
        d[i] = 1
    dicts.append(d)
# print(dicts)

ans = set(dicts[0])
for i in range(1, n):
    ans.intersection_update(dicts[i])
# print(ans)

ans2 = dict()
for i in dicts:
    for j in ans:
        if (ans2.get(j) != None):
            ans2[j] = min(i[j], ans2[j])
            continue
        ans2[j] = i[j]
# print(ans2)

st = []

for i in ans2.keys():
    for j in range(ans2[i]):
        st.append(i)
# print(st)

st.sort()
print(*st, sep='')

Measured memory_bytes: 39536
#include<stdio.h>
int main(){
  int h,w,i,j,k,l;
  while(scanf("%d %d",&h,&w)){
    if(h==0 && w==0)break;
    for(i=1;i<h-1;i++){
      if(i==1){
        for(k=0;k<w-1;k++)printf("#");
        printf("#\n");
      }
      for(j=1;j<w-1;j++){
        if(j==1)printf("#");
        printf(".");
        if(j==w-2)printf("#\n");
      }
    }
     for(l=0;l<w-1;l++)printf("#");
     printf("#\n");
     printf("\n");
  }
  return 0;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> v(n,0);
    rep(i,n) cin >> v.at(i);
    sort(v.rbegin(),v.rend());
    v.at(0) /= 2;
    int ans = accumulate(v.begin(),v.end(),0);
    cout << ans << endl;   
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int; // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n){ int ret = 1; for(int i = 1; i < n + 1; ++i) { ret = ret * i; } return ret; }

/* 最大公約数 */
template <typename T>T gcd(T x, T y){ return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>T lcm_n(vector<T> &numbers) { T l; l = numbers[0]; for(int i = 1; i < numbers.size(); ++i) { l = lcm(l, numbers[i]); } return l; }

/*
 * DP向け
 */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/*
 * グラフ
 */
class Graph {
   public:
    vector<vector<int>> G;
    vector<int> Trans;
    vector<int> inDeg;
    int numV;
 
    Graph(int numV) {
        this->numV = numV;
        inDeg.assign(numV, 0);
        Trans.assign(numV, 0);
        G.assign(numV, vector<int>());
    }
 
    int topologicalSort(int v, vector<int> &dp) {
        if (dp[v] != -1) {
            return dp[v];
        }
 
        int res = 0;
 
        for (auto to : G[v]) {
            chmax(res, topologicalSort(to, dp) + 1);
        }
 
        return dp[v] = res;
    }
};


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

  vector<bool> have(n, false);

  for(int i = 0; i < k; ++i){
    int d;
    cin >> d;

    for(int j = 0; j < d; ++j){
      int tmp;
      cin >> tmp;
      if(!have[tmp-1]) have[tmp-1] = true;
    }
  }

  int ans = 0;

  for(auto v : have){
    if(!v) ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	llint Ta,Tb,A,B,x;cin>>Ta>>Tb;
	cin>>A>>B;
	cin>>x;A-=x;
	cin>>x;B-=x;
	if(A<0){A*=-1;B*=-1;}
	B*=-1;A*=Ta;B*=Tb;
	if(B<A){cout<<0<<endl;return 0;}
	if(B==A){cout<<"infinity"<<endl;return 0;}
	cout<<B/(B-A)+(A-1)/(B-A)<<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) {
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") {
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

struct root {
	int i;
	int value;
};

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

Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
	int a,b,c,d,n,k;
	while(scanf("%d",&n) != EOF)
	{
		k = 0;
	for(a = 0;a <10;a++)
	{
		for(b = 0;b < 10;b++)
		{
			for(c = 0;c < 10;c++)
			{
				for(d = 0;d < 10;d++)
				{
					if(a+b+c+d == n)
					{
						k++;
					}
				}
			}
		}
	}
	
	printf("%d\n",k);
	}
	return 0;
	
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    // 初手で全部偶数にできれば先手が勝てる
    ll cnt = 0;
    rep(i, n) if(a[i]%2 == 1) cnt++;
    cout << (cnt >= 1 ? "first" : "second") << endl;
}

Measured memory_bytes: 4000
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N; std::cin >> N;

  ll ans = 1e13;
  for(ll i=1; i<=std::sqrt(N); i++) {
    if ( N % i == 0 ) {
      ans = std::min(ans, (i-1+N/i-1));
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main() {
  long long A,B,C;
  cin >> A >> B >> C;
  if(A%2==0 || B%2==0 || C%2==0){ cout << '0' << endl; return 0;}
  cout << min({A*B,B*C,C*A}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}


//#########################################



int main() {
 int n=D();
 int a[n];
 set<int>st;
 for(int i=0;i<n;i++){
     scanf("%d",&a[i]);
     st.insert(a[i]);
 }
cout<<st.size();

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n,m;cin>>n>>m;
  int res=n*(n-1)/2+m*(m-1)/2;
  cout<<res<<endl;
  return 0;
}


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

int main()
{
    string s;
    while(cin>>s)
    {
        if(s=="0")break;
        int sum=0;
        REP(i,s.size()) 
        {

            sum+=s[i]-'0'; 
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 3152
import sys
import operator

n, m = map(int, input().split())

a = [int(x) for x in sys.stdin.readline().rstrip().split()]
a.sort()

cards = [[int(x) for x in sys.stdin.readline().rstrip().split()] for _ in range(m)]
cards.sort(key=operator.itemgetter(1), reverse=True)

a_idx = 0
a_len = len(a)

for i in range(len(cards)):
    for j in range(cards[i][0]):
        if a_idx == a_len or a[a_idx] >= cards[i][1]:
            break
        else:
            a[a_idx] = cards[i][1]
            a_idx += 1

print(sum(a))

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

#define int long long
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define sq(x) (x)*(x)
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define t4i tuple<int,int,int,int>
#define mii map<int,int>

const int INF = 1LL<<60;
const int MOD = 998244353;

template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
string to_string(string s) {return 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, typename B, typename C>
string to_string(tuple<A, B, C> t) {return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) { return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";}
template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}
string bin_string(int x) {
    const int d = 32;
    string result(d, ' ');
    REP(i, 0, d) result[d-1-i] = '0'+(x>>i & 1LL);
    return result;
}

int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int a,b;
  	cin >> a >> b;
  	if (a+b&1) cout << "IMPOSSIBLE";
  	else cout << (a+b>>1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <typename T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const vector<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
void ce(void){cerr << '\n';}
template <typename T>
void ce(const T n){cerr << n << '\n';}
template <typename T>
void cesp(const T n){cerr << n << ' ';}
template <typename T>
void ce(initializer_list<T> v){for(T i : v) cesp(i); ce();}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	ll ans = 0;
	rep(i, n) {
		REP(j, i + 1, n) {
			REP(k, j + 1, n) {
				Vec b = {a[i], a[j], a[k]};
				sort(all(b));
				if (b[0] != b[1] && b[1] != b[2] && b[0] + b[1] > b[2]) ans++;
			}
		}
	}
	co(ans);

	return 0;
}


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

using namespace std;

int main(){
  int N,M,K; cin >> N >> M >> K;
  bool flag = false;
  for(int k = 0; k <= N; k++){
    for(int l = 0; l <= M; l++){
      if( (k* M + l* N - 2*k * l) == K){ flag = true; break;}
    }}
  
  if(flag){ cout << "Yes" << endl;}
  else{ cout << "No" << endl;} return 0;}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define SZ(x) ((int)((x).size()))

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

template<class TH>
void _dbg(const char* name, TH val){
    clog << name << ": " << val << endl;
}
template<class TH, class... TA>
void _dbg(const char* names, TH curr_val, TA... vals) {
    while(*names != ',') clog << *names++;
    clog << ": " << curr_val << ", ";
    _dbg(names+1, vals...);
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
    #define dbg_arr(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg(...)
    #define dbg_arr(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    int N;
    cin >> N;
    multiset<int> S;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        S.insert(x);
    }
    int res = 0;
    while (!S.empty()) {
        int x = *S.rbegin();
        S.erase(prev(S.end()));
        int pot = 1;
        while (pot <= x) pot *= 2;
        dbg(x, pot);
        int y = pot-x;
        if (S.count(y) == 0) continue;
        res++;
        S.erase(S.lower_bound(y));
    }
    cout << res << "\n";
}


Measured memory_bytes: 9600
//*********Abhay is awesome *************\

#include<bits/stdc++.h>


#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define piii pair<int,pii>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repc(i,a,n) for(int i=a;i<n;++i)
#define  repd(i,a,n) for(int i=a;i>n;--i)

using namespace std;
using ll = long long;
const ll N = 3*1e5 +5 ;
const ll mod = 1e9+7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;

typedef vector<ll> vi;


void solve(){
	ll n,k;
	cin>>k>>n;
	vi v(n);
	cin>>v[0];
	ll max=0 ;
	repc(i,1,n){
		cin>>v[i];
		max=(max>(v[i]-v[i-1]))?max:(v[i]-v[i-1]);
	}
	max=(max>(v[0]+k-v[n-1]))?max:(v[0]+k-v[n-1]);
	cout<<k-max;

}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output1.txt", "w", stdout);
	//#endif
	solve(); 
	return  0;
}



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

// Hello, this is a snippet.

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


int main (){

    int N;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }

    sort(a,a+N);
    cout << a[N-1] - a[0] << endl;
    
    return 0;
}


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

typedef unsigned long ul;
typedef pair<ul, ul> P;

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

    int n, h, w;
    cin >> n >> h >> w;
    cout << (n-h+1) * (n-w+1) << '\n';
}


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

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

    int strSize = S.size();
    int count = 0;
    for(int i = 0;i < strSize;i++){
        if(S[i] != T[i]){
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3916
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,X,T; cin >> N >> X >> T;
    int ans = 0;
    int cnt = 0;
    while (cnt < N) {
        cnt += X;
        ans += T;
    }

    cout << ans << ln;
}

Measured memory_bytes: 3652
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;
import java.util.Map.Entry;

public class Main{
	
	public static void main(String[] args) throws IOException{
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		Scanner in = new Scanner(System.in);
		
		boolean ans = true;
		int[][] c = new int[3][3];
		
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				c[i][j] = in.nextInt();
			}
		}
		
		if(!(c[0][0] - c[0][1] == c[1][0] - c[1][1] && c[2][0] - c[2][1] == c[1][0] - c[1][1])) ans = false;
		if(!(c[0][2] - c[0][1] == c[1][2] - c[1][1] && c[2][2] - c[2][1] == c[1][2] - c[1][1])) ans = false;
		
		if(!(c[0][0] - c[1][0] == c[0][1] - c[1][1] && c[0][2] - c[1][2] == c[0][1] - c[1][1])) ans = false;
		if(!(c[2][0] - c[1][0] == c[2][1] - c[1][1] && c[2][2] - c[1][2] == c[2][1] - c[1][1])) ans = false;
		
		System.out.println(ans ? "Yes" : "No");
	}
}


Measured memory_bytes: 21716
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int max(const vector<int>& v){
    int ret = v[0];
    for(uint i=1; i<v.size(); ++i){
        if(v[i] > ret){ ret = v[i]; }
    }
    return ret;
}
int64 div_ceil(int64 lhs, int64 rhs){ return (lhs-1)/rhs + 1; }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, H; cin >> N >> H;
    vector<int> vA(N), vB(N); for(int i=0; i<N; ++i){ cin >> vA[i] >> vB[i]; }
    
    int vA_max = max(vA);
    
    vector<int> vB_g; // greater than vA_max.
    for(uint i=0; i<vB.size(); ++i){ if(vB[i]>vA_max){ vB_g.push_back(vB[i]); } }
    sort(vB_g.begin(), vB_g.end(), greater<int>());
    
    int cnt=0;
    for(uint i=0; i<vB_g.size(); ++i){
        H -= vB_g[i]; ++cnt;
        if(H<=0){ cout << cnt << endl; return 0; }
    }
    
    cout << cnt + div_ceil(H, vA_max) << endl;
    
    return 0;
}

Measured memory_bytes: 1660
using System;

public class my
{
	public static void Main()
	{
		Console.ReadLine();
		my.SelectionSort(my.GetIntArray());
	}
	
	public static void SelectionSort(int[] A)
	{
		int cnt = 0;
		
		for(int i = 0; i < A.Length; i++ ) {
			int minj = i;
			
			for(int j = i; j < A.Length; j++) {
				if( A[j] < A[minj])	minj = j;
			}
			
			if(minj != i) {
				cnt++;
				my.Swap(ref A[i], ref A[minj]);
			}
		}
		
		my.WriteArray(A);
		Console.WriteLine(cnt);
	}
	
	private static void Swap(ref int a, ref int b) 
	{
		int tmp = a;
		a = b;
		b = tmp;
	}
	
	private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}
	
	private static void WriteArray(int[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static long GetLong()
	{
		return long.Parse(Console.ReadLine());
	}
}

Measured memory_bytes: 9248
//author rhythmicankur
                                                                 //god_is_almighty
#include<bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define ld long double
#define pb push_back
#define mk make_pair
#define fori(a,b,c) for(int i=a;i<b;i+=c)
#define ford(a,b,c) for(int i=a;i>=b;i-=c)
#define PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 998244353
#define M2 1000000007
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
#define test4(x,y,z,a) cout<<"x is "<<x<<"        y is "<<y<<"        z is "<<z<<"        a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"        y is "<<y<<"        z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"        y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl
ll power(ll a,ll b,ll m){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;

int main()
{
	int n,m;
	cin>>n>>m;
	string p[n];
	for(int i=0;i<n;i++)
	cin>>p[i];
	
	long dp[n][m];
	//memset(dp,0,sizeof(dp));
	
	for(int i=0;i<n;i++)
	for(int j=0;j<m;j++)
	dp[i][j]=0;
	
	for(int i=0;i<m;i++)
	{
		if(p[0][i]=='#')
		break;
		
		dp[0][i]=1;
	}
	for(int i=1;i<n;i++)
	for(int j=0;j<m;j++)
	{
		if(j==0)
		{
			if(p[i-1][j]!='#'&&p[i][j]!='#')
			dp[i][j]=dp[i-1][j];
		}
		else 
		{	if(p[i][j]!='#')
			dp[i][j]=dp[i-1][j]+dp[i][j-1];
			dp[i][j]%=M2;
		}
	}
	/*for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		cout<<dp[i][j]<<" ";
		
		cout<<endl;
	}*/
	cout<<dp[n-1][m-1];
	
}

Measured memory_bytes: 9088
#include <iostream>
using namespace std ;
int main (){
int x,c,z;
cin >> x>>c>>z ;


if (x*c<=z){
    cout << x*c;

}

else if (x*c==z){
    cout << x*c;
}
else if (x*c>z){
    cout << z;
}
return 0;
}


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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#define showvv(v)
#endif

using namespace std;

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define MAX 100000
#define int ll

struct node {
  int v, d;
  node(int v, int d):v(v),d(d){}
  bool operator<(const node &n) const { return d > n.d; }
};
struct edge {
  int to, d;
  edge(int to, int d):to(to),d(d){}
};
ll V;
vector<edge> G[MAX];
ll dist[MAX]; // shortest distance

void dijkstra(int s) {
  memset(dist, -1, sizeof(dist));
  priority_queue<node> que;
  que.push(node(s, 0));
  while(!que.empty()){
    int v = que.top().v, d = que.top().d;
    que.pop();
    if(dist[v] >= 0 and dist[v] <= d) continue;
    dist[v] = d;
    for(int i = 0; i < G[v].size(); i++)
      que.push(node(G[v][i].to, d+G[v][i].d));
  }
}

main(){
  int n; cin >> n;
  ll a,b,c;
  rep(i,n-1){
    cin >> a >> b >> c;
    a--; b--;
    G[a].pb(edge(b,c));
    G[b].pb(edge(a,c));
  }

  int q,k; cin >> q >> k; k--;

  dijkstra(k);

  int x,y;
  rep(i,q){
    cin >> x >> y; x--; y--;
    cout << dist[x] + dist[y] << endl;;
  }
  //rep(i,n) cout << dist[i] << endl;
}

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

int main()
{
  int X;
  cin >> X;
  bool break_flg = false;
  for (int i = -120; i<= 120; i++) {
    for (int j = -120; j <= 120; j++) {
      if(pow(i, 5) - pow(j, 5) == X) {
        cout << i << ' ' << j << endl;
        break_flg = true;
        break;
      }
    }
    if (break_flg) {
      break;
    }
  }
}

Measured memory_bytes: 4024
#include <stdio.h>
#include <algorithm>
#include <iostream>

#define max(a,b) ((a>b)?a:b)

using namespace std;

int main(void){
    int n,i,s=0,e,m,flag;
    long long int* pos;
    long long int a[200001],sum,mid,lim,ans=-1,tmp,x,y,p,q,v,w;
    scanf("%d",&n);
    a[0] = 0LL;
    for(i=1; i<=n; i++){
        scanf("%lld",&a[i]);
        a[i] += a[i-1];
    }
    sum = a[n];
    for(i=1; i<=n; i++){
        a[n+i] = sum + a[i];
    }
    lim = (sum+3)/3;
    e=0;
    while(s<=n){
        tmp = a[e] - a[s];
        if(tmp>lim){
            s++;
        }else if(s==e){
            e++;
        }else{
            flag = 0;
            mid = ((sum-tmp)/2)+a[e];
            pos=lower_bound(a,a+2*n+1,mid);
            m=(int)(pos-a);
            x = a[m]-a[e];
            y = sum-tmp-x;
            m--;
            p = a[m]-a[e];
            q = sum-tmp-p;
            if(x>=tmp && y>=tmp){
                ans = max(ans,tmp);
                flag = 1;
            }else if(p>=tmp && q>=tmp){
                ans = max(ans,tmp);
                flag = 1;
            }
            if(flag==1){
                e++;
            }else{
                s++;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2752
if __name__ == "__main__":
    S = input()
    T = input()
    ans = len(T)
    for i in range(len(S)-len(T)+1):
        cnt = 0
        for j in range(len(T)):
            if T[j] != S[i+j]:
                cnt += 1
        ans = min(ans, cnt)
    print(ans)


Measured memory_bytes: 9072
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



s = input()
t = input()

def sub(s,t):
    """共通部分文字列長
    """
    ls = len(s)
    lt = len(t)
    dp = [[0]*(lt+1) for _ in range(ls+1)]
    ###
    prev = [[None]*(lt+1) for _ in range(ls+1)]
    ###
    for i in range(1,ls+1):
        for j in range(1,lt+1):
            vals = [dp[i][j-1], dp[i-1][j]]
            if s[i-1]==t[j-1]:
                vals.append(dp[i-1][j-1] + 1)
            m = max(vals)
            dp[i][j] = m
            ###
            ind = vals.index(m)
            if ind==0:
                prev[i][j] = (i,j-1)
            elif ind==1:
                prev[i][j] = (i-1,j)
            else:
                prev[i][j] = (i-1,j-1)
            ###
    return dp, prev

dp, prev = sub(s,t)
ans = []
i,j = len(s), len(t)
while prev[i][j] is not None:
    if prev[i][j]==(i-1, j-1):
        ans.append(s[i-1])
    i,j = prev[i][j]
print("".join(ans[::-1]))

Measured memory_bytes: 428636
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#define forn(a, n) for(int a = 0; a<(int) (n); ++a)
#define rforn(a, n) for(int a = (n)-1; a>=0; --a)
using namespace std;
const int N = 6e5+20;

int main()
{
    int n;
    cin>>n;
    int par = n/2;
    int im = n - par;
    cout<<par*im<<endl;

}

Measured memory_bytes: 3592
import Text.Printf

main :: IO ()
main = do
    str <- getContents
    let inputs = [read word :: Integer | word <- words str]
    let a = head inputs
    let b = head $ tail inputs

    putStrLn $ show (a `div` b) ++ " " ++ show (a `mod` b) ++ " "
      ++ printf "%.10f" ((realToFrac a / realToFrac b) :: Double)

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned ui;
typedef unsigned long long ul;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<int> vi;
#define pb push_back
#define fi first
#define se second
#define do(i, j, k) for(int i = j; i <= (k); i ++)
#define open(i, j, k) for(int i = j; i < (k); i ++)
#define dec(i, j, k) for(int i = j; i >= (k); i --)
#define mfil(x, k) memset(x, k, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
#define fio(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout)
template <class T> bool chkmin(T &x, T y)
{ return y < x ? (x = y, true) : false; }
template <class T> bool chkmax(T &x, T y)
{ return y > x ? (x = y, true) : false; }
struct __init { __init()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cout.precision(16); cout << fixed;
    srand(time(0) ^ ul(new char));
} } static __init__;
/* default code ends here */

const int maxn = 55;
int n;
pii p[maxn];
set<pii> st;
pii operator + (pii x, pii y)
{
    return pii(x.fi + y.fi, x.se + y.se);
}
pii operator - (pii x, pii y)
{
    return pii(x.fi - y.fi, x.se - y.se);
}

int main()
{
    cin >> n;
    do(i, 1, n)
        cin >> p[i].fi >> p[i].se;
    do(i, 1, n)
        st.insert(p[i]);
    int ans = n;
    do(i, 1, n)
        do(j, i + 1, n)
        {
            pii d = p[j] - p[i];
            int tot = 0;
            do(k, 1, n)
                tot += !st.count(p[k] + d);
            chkmin(ans, tot);
        }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

int main() {
    int n;
    long long temp, total=0;
    cin >> n;

    map<string,int> words;
    for(int i=0; i<n; i++){
        string str;
        cin >> str;
        sort(str.begin(), str.end());
        words[str]++;
    }

    for(auto word : words){
        temp = word.second;
        total += temp*(temp-1)/2;
    }

    cout << total;

    return 0;
}

Measured memory_bytes: 11136
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 10000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

struct Dinic{
  
  struct edge {
    int to, cap, rev;
    edge(int a, int b, int c):to(a),cap(b),rev(c){}
  };
  
  vector<vector<edge> > G;
  vector<int> level, iter;
  int MAX_V;
  int last_solve;
  
  Dinic(int max_v):G(max_v,vector<edge>()),MAX_V(max_v),last_solve(0){}
  
  int add_edge(int from,int to,int cap){
    int id = G[from].size();
    
    G[from].push_back(edge(to,cap,G[to].size()));
    G[to].push_back(edge(from,0,G[from].size() - 1));
    
    return id;
  }
  
  void bfs(int s){
    level.assign(MAX_V,-1);
    queue<int> q;
    level[s] = 0;
    q.push(s);
    while(q.size()){
      int v = q.front(); q.pop();
      for(int i=0;i<G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap > 0 && level[e.to] < 0){
          level[e.to] = level[v] + 1;
          q.push(e.to);
        }
      }
    }
  }
  
  int dfs(int v, int t, int f){
    if(v == t) return f;
    for(int &i = iter[v];i < G[v].size(); i++){
      edge &e = G[v][i];
      if(e.cap > 0 && level[v] < level[e.to]){
        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;
  }
  
  int solve(int s, int t){
    int flow = 0;
    while(1){
      bfs(s);
      if(level[t] < 0){
        last_solve += flow;
        return last_solve;
      }
      iter.assign(MAX_V,0);
      int f;
      while((f = dfs(s, t, INF)) > 0) flow += f;
    }
  }
  
};

int k,n,m;
int a[SIZE],b[SIZE],c[SIZE];

Dinic calc_first(queue<pair<int,pair<int,int> > > &q){
  Dinic dinic(102);
  vector<pair<int,pair<int,int> > > vec;
  
  for(int i=0;i<m;i++){
    int id = dinic.add_edge(a[i],b[i],c[i]);
    int id2 = dinic.add_edge(b[i],a[i],c[i]);
    vec.push_back({i,{id,id2}});
  }

  for(int i=2;i<=k+1;i++){
    dinic.add_edge(0, i, INF);
  }

  dinic.solve(0,1);

  for(int i=0;i<vec.size();i++){
    if(dinic.G[a[vec[i].first]][vec[i].second.first].cap == 0 ||
       dinic.G[b[vec[i].first]][vec[i].second.second].cap == 0){
      q.push(vec[i]);
    }
  }
  
  return dinic;
}

int main(){

  scanf("%d%d%d",&k,&n,&m);
  
  for(int i=0;i<m;i++){
    scanf("%d%d%d",a+i,b+i,c+i);
    a[i]++;
    b[i]++;
  }

  int ans = 0;
  queue<pair<int,pair<int,int> > > q;
  
  Dinic dinic = calc_first(q);
  
  while(q.size()){
    Dinic dinic2 = dinic;
    pair<int,pair<int,int> > t = q.front(); q.pop();
    
    dinic2.G[a[t.first]][t.second.first].cap += INF;
    dinic2.G[b[t.first]][t.second.second].cap += INF;
    ans = max(ans,dinic2.solve(0,1));
  }

  if(ans >= INF){
    puts("overfuro");
  }else{
    printf("%d\n",ans);
  }
  
  return 0;
}

Measured memory_bytes: 3636