akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <utility>

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

#define pow CHANGETHENAMESTUPID

using namespace std;

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

const int N = 1e5 + 100;
const ll inf = 2e18;

int n, m;
int l[N], r[N], c[N];

ll tree[2 * N];

void update(int p, ll value)
{
	p += n;
	if (value > tree[p]) return;
	tree[p] = value;
    for (; p > 1; p >>= 1)
        tree[p >> 1] = min(tree[p], tree[p ^ 1]);
}

ll query(int l, int r)
{
    ll res = inf;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
        if (l & 1)
            res = min(res, tree[l++]);
        if (r & 1)
            res = min(res, tree[--r]);
    }
    return res;
}

void load()
{
	scanf("%d%d", &n, &m);
	FOR(i, m) {
		scanf("%d%d%d", l + i, r + i, c + i);
		l[i]--; r[i]--;
	}
}

void solve()
{
	FOR(i, (2*N)) tree[i] = inf;
	update(0, 0);
	int qs[m]; FOR(i, m) qs[i] = i;
	sort(qs, qs + m, [&](int x, int y) {
			if (r[x] == r[y] && l[x] == l[y]) return x < y;
			if (r[x] == r[y]) return l[x] < l[y];
			return r[x] < r[y];
			});
	FOR(j, m) {
		int i = qs[j];
		update(r[i], query(l[i], r[i] + 1) + c[i]);
	}
	ll sol = query(n-1, n);
	if (sol < inf) printf("%lld\n", sol);
	else printf("-1\n");
}

int main()
{
    load();
    solve();
    return 0;
}


Measured memory_bytes: 3328
import math

params = input()
# print(params)
array = params.split(' ')
# print(array)
a = int(array[0])
b = int(array[1])
h = int(array[2])
m = int(array[3])

pi = math.pi
c = 0

totalMin = h * 60 + m
harg = 360 * totalMin / (12 * 60)
marg = 360 * m / 60
# print(math.degrees(harg))
# print(math.degrees(marg))
harg %= 360
marg %= 360
arg = abs(harg - marg)
# print(arg)
arg = math.radians(arg)

c2 = a * a + b * b - 2 * a * b * math.cos(arg)
c = math.sqrt(c2)
print(c)


Measured memory_bytes: 9480
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			String str;
			String text = scan.next();
			int counter = 0;
			while(!(str = scan.next()).equals("END_OF_TEXT")){
				if(text.equals(str.toLowerCase()))counter++;
			}
			System.out.println(counter);
		}finally{
			if(scan!=null)scan.close();
		}
	}
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;
    
    ll a, b;
    ll a_max = 0, b_min;
    rep(i, N) {
        cin >> a >> b;
        if (chmax(a_max, a))
            b_min = b;
    }
    cout << a_max + b_min << endl;
}


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

using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < n; ++i)
int main() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	REP(i, n) {
		int a;
		cin >> a;
		if (a >= k) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(c-b<2) cout<<a+1<<endl;
	else{
		a-=b-1;
		cout<<(c-b)*(a/2)+a%2+b<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < 3; i++) {
            set.add(sc.nextInt());
        }
        if(set.size() == 2){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn bis<P>(ok: i64, ng: i64, p: P) -> i64
    where P: Fn(i64) -> bool {
    let mid = (ok + ng) / 2;
    if (ok - ng).abs() == 1 {
        ok
    } else if p(mid) {
        bis(mid, ng, p)
    } else {
        bis(ok, mid, p)
    }
}

fn main() {
    let Q: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (A, B): (Vec<i64>, Vec<i64>) = {
        let (mut A, mut B) = (vec![], vec![]);
        for _ in 0..Q {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            A.push(iter.next().unwrap().parse().unwrap());
            B.push(iter.next().unwrap().parse().unwrap());
        }
        (A, B)
    };

    // 高橋君よりスコアの小さい参加者は、どちらかのコンテストでsqrt(ab)より小さい
    // 順位をとっていることを利用して数え上げる
    let ans = (0..Q).map(
        |i|
        {
            let a = std::cmp::min(A[i], B[i]);
            let b = std::cmp::max(A[i], B[i]);
            let s = bis(0, b + 1, |k| k * k < a * b);
            let res = if a == b {
                2 * (a - 1)
            } else if s * (s + 1) >= a * b {
                2 * (s - 1)
            } else {
                2 * (s - 1) + 1
            };
            res.to_string()
        }
    )
    .collect::<Vec<_>>()
    .join("\n");

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


Measured memory_bytes: 4352
// author: pankaj_m05

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	ll ans = a[0];
	int j = 1;
	for(int i = n - 2; i > 0; i -= 2, ++j) 
        ans += (a[j] * 2);
    if(n & 1) 
    	ans -= a[j - 1];
	cout << ans;
    return 0;
}

Measured memory_bytes: 4424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int goal = sc.nextInt();
		sc.close();
	
		int time=0;
		int x=0;
		while(true){
			x += time;
			if(x >= goal)
				break;
			time++;
		}
		System.out.println(time);

	}

}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
  ll r = a % b;
  return r ? gcd(b, r) : b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

int main() {
  int n; cin >> n;
  ll t[n]; for (int i = 0; i < n; i++) cin >> t[i];

  ll ans = t[0];
  for (int i = 1; i < n; i++) ans = lcm(ans, t[i]);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
int main(void) {
  int n, m;
  cin >> n >> m;
  cout << n*(n-1)/2 + m*(m-1)/2 << endl;
}


Measured memory_bytes: 3192
/*
By Snickeen
*/
#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef int LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VL vector<LL>
#define VII vector<PII >
#define VLL vector<PLL >
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define FF first
#define SS second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}
 
const LL MAXN=1e5+10;
LL t,n,m,ans;
LL MOD=1e9+7,inf=0x1f1f1f1f;
db eps=1e-5;

LL qp(LL x,LL y){
	LL res=1;
	while(y){
		if(y&1)res*=x;
		x*=x;
		y>>=1;
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0;
	cin>>n>>k;
	ans=k*qp(k-1,n-1);
	cout<<ans<<endl; 
	return 0;
}

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

vector<long long>weight;
vector<long long>value;

long long dp[109] [100009];

long long knapsack(long long n, long long w)
{
    if(n==0 || w==0) return 0;

    else if(dp[n][w]>0) return dp[n][w];

    else {

       if(weight[n-1]>w) dp[n][w] = knapsack(n-1,w);

       else dp[n][w] = max(value[n-1]+knapsack(n-1,w-weight[n-1]), knapsack(n-1,w));
    }

    return dp[n][w];
}


int main()
{
    long long n,x,y,atmost;
    cin>>n>>atmost;

    while(n--) cin>>x>>y,weight.push_back(x),value.push_back(y);
    n=weight.size();

    cout<<knapsack(n,atmost);

}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a,b;
cin>>a>>b;
if(a+b>=10)cout<<"error"<<endl;
else cout<<a+b<<endl;
//system("pause");
return 0;
}

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

int main(){
  long long n,A,B;
  cin>>n;
  vector<long long> a(n+1);
  vector<long long> b(n);
  for(int i=0;i<n+1;i++){
    cin>>A;
    a[i] = A;
  }
  for(int i=0;i<n;i++){
    cin>>B;
    b[i] = B;
  }
  long long ans = 0;
  long long rest = 0;
  for(int i=0;i<n;i++){
    if (b[i]>a[i]-rest){
      ans += a[i]-rest;
      rest = min(b[i]-(a[i]-rest),a[i+1]);
    }else{
      ans += b[i];
      rest = 0;
    }
    ans += rest;
  }
  cout<<ans<<endl;

}

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

using namespace std;

int N,Y;

void solve(){
    int price = 0;
    int num = 0;

    for(int i=0; i<=N; i++){
        for(int j=0; j<=N; j++){
            num = N-i-j;
            price = Y- 10000*i - 5000*j;

            if (price == 1000*num && num >= 0 && price>=0){
                printf("%d %d %d\n",i,j,num);
                return;
            }
        }
    }
    printf("-1 -1 -1\n");
    return;
}



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

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  ll a, b;
  scanf("%d%lld%lld", &n, &a, &b);
  vector<ll> f(n + 1, 1ll << 55);
  f[0] = 0;
  for (int _ = 1; _ <= n; _++) {
    int x;
    scanf("%d", &x);
    vector<ll> g(n + 1, 1ll << 55);
    for (int i = 0; i <= n; i++) if (f[i] != 1ll << 55) {
      if (x > i) {
        g[x] = min(g[x], f[i]);
        g[i] = min(g[i], f[i] + a);
      } else {
        g[i] = min(g[i], f[i] + b);
      }
    }
    f = g;
  }
  ll ans = f[0];
  for (int i = 1; i <= n; i++) {
    ans = min(ans, f[i]);
  }
  printf("%lld\n", ans);
}



Measured memory_bytes: 384
function main()
	H,W=map(x->parse(Int,x),split(readline()))
	cnt=zeros(Int,26)
	for _=1:H
		for c=chomp(readline())
			cnt[Int(c)-96]+=1
		end
	end
	c4=c2=c1=0
	if H%2==1&&W%2==1
		c1=1
		c2=div(H-1,2)+div(W-1,2)
	elseif H%2==1&&W%2==0
		c2=div(W,2)
	elseif H%2==0&&W%2==1
		c2=div(H,2)
	end
	c4=div(H*W-c1-2c2,4)
	for i=1:26
		t=min(c4,div(cnt[i],4))
		c4-=t
		cnt[i]-=4t
	end
	for i=1:26
		t=min(c2,div(cnt[i],2))
		c2-=t
		cnt[i]-=2t
	end
	println(c4==c2==0&&sum(cnt)==c1 ? "Yes" : "No")
end
main()

Measured memory_bytes: 172980
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n), pos(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
        pos[a[i]] = i;
    }

    set<int> st;
    st.insert(-1);
    st.insert(n);
    
    ll ans = 0;
    rep(i, n) {
        st.insert(pos[i]);
        auto it = st.find(pos[i]);
        int l = *prev(it);
        int r = *next(it);
        ans += 1LL * (pos[i] - l) * (r - pos[i]) * (i+1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 14220
//if acyclic graph try toposort
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
template <typename T>void umax(T &a, T b){
    a = max(a, b);
}
template <typename T>void umin(T &a, T b){
    a = min(a, b);
}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}

ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const ll N = 1e5 + 5;
vll g[N];
ll in[N];
void solve(){
    ll n, m;
    cin >> n >> m;
    for(ll i = 0, x, y; i < m; i++){
        cin >> x >> y;
        g[x].pb(y);
        in[y]++;
    }
    vll dp(n + 1);
    queue<ll> q;
    for(ll i = 1;i <= n; i++){
        if(in[i] == 0){
            q.push(i);
            dp[i] = 0;
        }
    }
    while(!q.empty()){
        ll curr = q.front();
        q.pop();
        for(ll x : g[curr]){
            in[x]--;
            if(in[x] == 0){
                dp[x] = 1 + dp[curr];
                q.push(x);
            }

        }
    }
    ll ans = 0;
    foa(i, 1, n + 1){
        umax(ans, dp[i]);
    }
    ANS;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    while(TC--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 10296
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int64_t n, a, b;
  cin >> n >> a >> b;

  int64_t diff = b - a;
  if(diff % 2 == 0) cout << diff / 2 << endl;
  if(diff % 2 == 1) cout << min(n-b, a-1) + diff/2 + 1 << endl;
  return 0;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  vector<vector<ll>> dp(n + 1, vector<ll>(13, 0));

  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      if (s[i] != '?' && s[i] - '0' != j) {
        // iの位で、jを使えない
        continue;
      }
      for (int k = 0; k < 13; k++) {
        dp[i + 1][(10 * k + j) % 13] += dp[i][k];
      }
    }
    for (int j = 0; j < 13; j++) {
      dp[i + 1][j] %= MOD;
    }
  }
  cout << dp[n][5] << endl;
}


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

#define MAX 1002

int n;
int t;

long double d;

int main(){
    cin>>n>>t;
    for(int i=0;i<n;i++){
        int x,h;
        scanf("%d%d",&x,&h);
        d=max(d,(long double)(h)/(long double)(x));
    }
    long double ans=t;
    ans*=d;
    printf("%.16f\n",(double)ans);
    return 0;
}


Measured memory_bytes: 3228
#include <stdio.h>

int main(void) {
	int N, X;
	int m[128];
	int i;
	int saitei = 0;
	int nokori;
	int saisyou = 99999999;
	if (scanf("%d%d", &N, &X) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &m[i]) != 1) return 1;
		saitei += m[i];
		if (m[i] < saisyou) saisyou = m[i];
	}
	nokori = X - saitei;
	printf("%d\n", N + nokori / saisyou);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <utility>
#include <string>
#define rep(i,n) for(int i=0; i<(n); i++)
#define dm(x) cerr << #x << " = " << x << endl;
using namespace std;

char map[20][21];
int H,W,N;

struct po{
  int x;
  int y;
  po operator+(po &p){
    po t={x+p.x, y+p.y};
    return t;
  }
  char &l(){return map[x][y];}
  bool v(){return 0<=x && x<H && 0<=y && y<W;}
  void d(){dm(x);dm(y);}
};

po mp(int x,int y){
  po t={x, y};
  return t;
}

int main()
{
  int T;
  scanf("%d", &T);
  rep(datasetindex, T){
    po p={0,0},d={0,0};
    char c[101];
    scanf("%d %d", &H, &W);
    rep(i,H) scanf("%s", map[i]);
    scanf("%d", &N);
    scanf("%s", c);
    //dm(H);dm(W);
    rep(j,W) rep(i,H){
      switch(map[i][j]){
      case '^':p=mp(i,j);d=mp(-1,0);break;
      case '>':p=mp(i,j);d=mp(0,1);break;
      case 'v':p=mp(i,j);d=mp(1,0);break;
      case '<':p=mp(i,j);d=mp(0,-1);break;
      }
    }
    //rep(i,H) printf("%d : %s\n", i, map[i]);
    //p.d();d.d();
    rep(i,N){
      switch(c[i]){
      case 'S':{
        po s=p;
        do{s=s+d;}while(s.v() && s.l()!='*' && s.l()!='#');
        if(s.v() && s.l()=='*')
          s.l()='.';
        break;
      }
      case 'U':
        p.l()='.';
        d=mp(-1,0);
        if((p+d).v() && (p+d).l()=='.')
          p=p+d;
        p.l()='^';
        break;
      case 'R':
        p.l()='.';
        d=mp(0,1);
        if((p+d).v() && (p+d).l()=='.')
          p=p+d;
        p.l()='>';
        break;
      case 'D':
        p.l()='.';
        d=mp(1,0);
        if((p+d).v() && (p+d).l()=='.')
          p=p+d;
        p.l()='v';
        break;
      case 'L':
        p.l()='.';
        d=mp(0,-1);
        if((p+d).v() && (p+d).l()=='.')
          p=p+d;
        p.l()='<';
        break;
      }
      //rep(i,H) printf("%d : %s\n", i, map[i]);
    }
    rep(i,H) printf("%s\n",map[i]);
    if(datasetindex<T-1)
      printf("\n");
  }
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;




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

	int n;cin>>n;

	vector<int> d(n);

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

	for(int i=0; i<n-1; i++){
		if(d[i] <=d[i+1]){
			if(d[i+1]-d[i] >=1)--d[i+1];
		}else {
			writeln("No");
			return 0;
		}
/*		for(auto e:d){
			cout<<e<<" ";
		}
		cout<<endl;*/
	}

	writeln("Yes");



}




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

using namespace std;

int i,j,n;
char s[105],s1[105];

int main(){
	scanf("%d", &n);
	scanf("%s%s", s, s1);
	for(i = 0; i < n; i++){
		bool flag = 0;
		for(j = i; j < n; j++){
			if(s[j] != s1[j - i])
			flag = 1;
		}
		if(flag == 0)
		return 0 * printf("%d\n", n + i);
	}
	printf("%d\n", 2 * n);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int k, s; cin >> k >> s;
	int ans = 0;
	rep(x, 0, k)rep(y, 0, k)
	{
		if (0 <= s - x - y && s - x - y <= k)++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  long long n , d;
  scanf("%lld %lld",&n ,&d);

  long long x[n] , y[n];
  for(int i = 0;i < n;i ++){
    scanf("%lld %lld",&x[i] , &y[i]);
  }
  
  int count = 0;
  for(int i = 0;i < n;i ++){
    if(d*d >= x[i]*x[i] + y[i]*y[i]){
      count ++;
    }
  }

printf("%d",count);

return 0;
}

Measured memory_bytes: 4856
N = int(input())
T = list(map(int, input().split()))
M = int(input())
ans = []

for i in range(M):
  p,x = map(int, input().split())
  tmp = list(T)
  tmp[p-1] = x
  ans.append(sum(tmp))

for i in range(len(ans)):
  print(ans[i])
  

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    char[] b = a.toCharArray();
    int start = 0;
    int end  = a.length() - 1;
    int ans = 0;
    while(start < end){
      if(b[start] != b[end]){
        ans++;
      }
      start++;
      end--;   
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)

ll solve(int N){
	vl L(N+1);
	L[0] = 2;
	L[1] = 1;
	rp(i,2,N+1){
		L[i] = L[i-1] + L[i-2];
	}
	return L[N];
}

int main(){
	int N; cin>>N;
	ote(solve(N));
}


Measured memory_bytes: 256
#include <stdio.h>
#define BUFMAX 20

int main(){
    char buf[BUFMAX];
    int m, f, b, c;

    fgets(buf,BUFMAX,stdin);
    buf[BUFMAX-1] = '\0';
    sscanf(buf,"%d %d %d", &m, &f, &b);
    c = b - m;
    if(c < 0){
      c = 0;
    }
    if((f - c) < 0){
      printf("NA\n");
    }
    else {
      printf("%d\n",c);
    }

    return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> eg;
typedef vector<eg> el;
typedef vector<ii> vii;
typedef vector<vii> al;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
vvi g;
int cs[512][512][4];
const int MN = 17;
const int SH = 8;
int am[MN][MN];
int n;
const int MSK = 1<<15;
const int HL = (1<<SH)-1;
void pre() {
	memset(cs,0,sizeof(cs));
	for(int fm=0;fm<=HL;fm++) {
		for(int sm=0;sm<=HL;sm++) {
			for(int id=0;id<4;id++) {
				ll a = fm,b = sm;
				if(id&2) {
					a <<= SH;
				}
				if(id&1) {
					b <<= SH;
				}
				for(int i=0;i<n;i++) {
					if(!((1<<i)&a)) continue;
					for(int j=0;j<n;j++) {
						if(!((1<<j)&b)) continue;
						cs[fm][sm][id] += am[i][j];
					}
				}
			}
		}
	}
}
ll calc(int a, int b) {
	ll res = 0;
	for(int i=0;i<4;i++) {
		int fm=a,sm = b;
		if(i&2) {
			fm >>= SH;
		} else {fm &= HL;}
		if(i&1) {
			sm >>= SH;
		} else {sm &= HL;}
		res += cs[fm][sm][i];
	}
	return res;
}
ll dp[1<<MN][MN];
int main() {
	int m;
	scanf("%d %d",&n,&m);
	memset(am,0,sizeof(am));
	for(int i=0;i<1<<MN;i++) {
		for(int j=0;j<MN;j++) {
			dp[i][j] = 1e12;
		}
	}
	g.assign(n,vi());
	for(int i=0;i<m;i++) {
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		a--;b--;
		am[a][b] = am[b][a] = c;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	pre();
	dp[1][0] = 0;
	for(int i=0;i<(1<<n);i++) {
		for(int j=0;j<n;j++) {
			for(int k=0;k<g[j].size();k++) {
				int u = g[j][k];
				dp[i|(1<<u)][u] = min(dp[i|(1<<u)][u],dp[i][j]+calc(i&(~(1<<j)),1<<u));
			}
			int mm = 1<<n;
			int msk = ((1<<n)-1)&(~i);
			while(1) {
				mm--;
				mm &= msk;
				if(mm <= 0) break;
				dp[mm|i][j] = min(dp[mm|i][j],dp[i][j]+calc(i&(~(1<<j)),mm));
			}
		}
	}
	printf("%lld\n",dp[(1<<n)-1][n-1]);
}

Measured memory_bytes: 21760
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        long a = scan.nextLong();
        String bs = scan.next();
        int b = Integer.parseInt(Character.toString((bs.charAt(0)))) * 100
                + Integer.parseInt(Character.toString((bs.charAt(2)))) * 10
                + Integer.parseInt(Character.toString((bs.charAt(3))));
        System.out.println((long)a * b / 100);
        scan.close();
    }
}

Measured memory_bytes: 26928
import sys
# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

while 1:
    m, f, r = map(int, readline().split())
    if m == -1 and f == -1 and r == -1:
        break
    s = m + f
    if m == -1 or f == -1:
        print('F')
    elif s >= 80:
        print('A')
    elif s >= 65:
        print('B')
    elif s >= 50:
        print('C')
    elif s >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')



Measured memory_bytes: 5584
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}

mt19937 rng(20010709);
const int mod = 1000000007;
const int INF = 1000000001;

int n, k, h[100005], dp[100005];

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

    cin >> n >> k;

    for (int i = 1; i <= n; i++)
        cin >> h[i];

    for (int i = 2; i <= n; i++) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);

        for (int j = max(1, i - k); j < i; j++)
            umin(dp[i], dp[j] + abs(h[j] - h[i]));
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

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;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(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 DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)


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

	ll sum = 0;
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		int buf; cin >> buf;

		if (buf != 0) {
			sum += buf;
		}
		else {
			ans += sum / 2;
			sum = 0;
		}
	}

	ans += sum / 2;

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	char S[3];
	int rep;
	
	S[0] = '0';
	S[1] = '0';
	S[2] = '0';
	
	scanf("%s", S);
	
	if (S[2] == 0)
	{
		printf("%c%c", S[0],S[1]);
	}
	
	else
	{
		printf ("%c%c%c", S[2], S[1], S[0]);
	}
	
	return 0;
}


Measured memory_bytes: 128
from math import sin, cos, pi, sqrt
a, b, h, m = (int(i) for i in input().split())
alpha, beta = 2*pi/12*h + 2*pi/12/60*m, 2*pi/60*m
ax, ay = a*sin(alpha), a*cos(alpha)
bx, by = b*sin(beta), b*cos(beta)
print(sqrt((ax - bx)**2 + (ay - by)**2))

Measured memory_bytes: 9452
#include "bits/stdc++.h"

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

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

    if(k%2 == 1){
    int cnt = 0;
    for(int i = 1;i <= n; i++){
        if((2*i)%k == 0) cnt++;
    }
    cout << cnt + cnt*(cnt-1)*3 + cnt*(cnt-1)*(cnt-2);
    }else{
        int cnt1 = 0;
        int cnt2 = 0;
        for(int i = 1;i <= n; i++){
            if((2*i)%k == 0) cnt1++;
            if(i%k == 0){
                cnt1--;
                cnt2++;
            }
        }
        int ans = cnt1 + cnt1*(cnt1-1)*3 + cnt1*(cnt1-1)*(cnt1-2)
                + cnt2 + cnt2*(cnt2-1)*3 + cnt2*(cnt2-1)*(cnt2-2);
        cout << ans;
    }
    
    return 0;
}
//g++ -std=c++14 code1.cpp


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int A,B,M;
  cin>>A>>B>>M;
  int a[A],b[B],x[M],y[M],c[M];
  int mina=1000000;
  int minb=1000000;
  int min=1000000;
  for(int i=0;i<A;i++){
    cin>>a[i];
    if(mina>a[i]){
      mina=a[i];
    }
  }
  for(int i=0;i<B;i++){
    cin>>b[i];
    if(minb>b[i]){
      minb=b[i];
    }
  }
  for(int i=0;i<M;i++){
    cin>>x[i]>>y[i]>>c[i];
    if(min>a[x[i]-1]+b[y[i]-1]-c[i]){
      min=a[x[i]-1]+b[y[i]-1]-c[i];
    }
  }
  if(min>mina+minb){
    min=mina+minb;
  }
  cout<<min;
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);ios::sync_with_stdio(false);
	int A = 0, B = 0;
	for (int i = 0; i < 4;i++) {
		int s; cin >> s;
		A += s;
	}
	for (int i = 0; i < 4;i++) {
		int s; cin >> s;
		B += s;
	}
	cout << max(A, B) << endl;
}

Measured memory_bytes: 3208
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_FLOWER_MAX	100										// 最大花数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Now[D_FLOWER_MAX];								// 現在高さ
static int si1Goal[D_FLOWER_MAX];								// 目標高さ
static int siFCnt;												// 花数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// データ - 初期化
	memset(si1Now, 0, sizeof(si1Now));							// 現在高さ

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 花数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siFCnt);

	// 配列 - 取得
	for (i = 0; i < siFCnt; i++) {
		fscanf(szpFpI, "%d", &si1Goal[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 回数 - 取得
	int liCnt = 0;
	int liSNo = 0;
	while (liSNo < siFCnt) {

		// 目標高さ
		if (si1Now[liSNo] >= si1Goal[liSNo]) {
			liSNo++;								// 次へ
			continue;
		}

		// 範囲 - 取得
		int liENo = liSNo;
		for (i = liENo + 1; i < siFCnt; i++) {
			if (si1Now[i] < si1Goal[i]) {
				liENo = i;
			}
			else {
				break;
			}
		}

		// 水やり
		liCnt++;
		for (i = liSNo; i <= liENo; i++) {
			si1Now[i]++;
		}
	}

	// 結果 - セット
	sprintf(lc1Out, "%d\n", liCnt);

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main()
{
  int l, m, n, ans, t;
  while(1)
  {
    t = 0;
    ans = -1;
    cin >> l;
    if(l == 0)
      break;
    for(int i = 0; i < 12; i++)
    {
      cin >> m >> n;
      t += m - n;
      if(t >= l && ans == -1)
        ans = i + 1;
      
    }
    if(ans == -1)
      cout << "NA\n";
    else
      cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fr first
#define sc second
#define pb push_back
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
const int INF = 1e9+7;
const int MAXN = 3e5 + 200;
const  long double eps = 1e-16;
const long double pi = acos(-1.0);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int n;
int k;
long long a[MAXN];
void solve(){
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a + 1, a + n + 1);
    if (k >= n){
        cout << 0 << endl;
        return;
    }
    long long ans = 0;
    for (int i = 1; i <= n - k; i++){
        ans += a[i];
    }
    cout << ans << endl;
}



int main() {
ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
cout.setf(ios::fixed), cout.precision(7);
 //freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
 int step;
 step = 1;
  for (int i = 1; i <= step; i++){
         solve();
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E17
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	ll n, m, in, inn, innn;
	vl a, b, c;
	cin >> n >> m;
	rep(i, m) {
		cin >> in >> inn >> innn;
		a.push_back(in - 1);
		b.push_back(inn - 1);
		c.push_back(-innn);
	}
	vl dist(n,LINF);
	dist[0] = 0;
	rep(i,n-1){
		rep(j, m) {
			dist[b[j]] = min(dist[b[j]], dist[a[j]] + c[j]);
		}
	}
	vb veb(n,false);
	rep(i, n - 1) {
		rep(j, m) {
			if (dist[b[j]] > dist[a[j]] + c[j]) {
				dist[b[j]] = dist[a[j]] + c[j];
				veb[b[j]] = true;
			}
		}
	}
	if(veb.back())cout << "inf";
	else cout << -dist.back();
	cout << endl;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ++mp[s];
  }
  long long ans = 0;
  for (auto x : mp) {
    ans += 1ll * x.second * (x.second - 1);
  }
  cout << ans / 2ll << '\n';
  return 0;
}


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

int dp[100001] = {0};

int main(){
	int n,m,tmp;
	cin >> n >> m;
	for(int i=0;i<m;++i){
		cin >> tmp;
		dp[tmp] = -1;
	}
	dp[0] = 1;
	for(int i=0;i<n;++i){
		for(int j=1;j<=2;++j){
			int next = i+j;
			if(next > n || dp[next] == -1 || dp[i] == -1) continue;
			dp[next] = (dp[next] +dp[i])%1000000007;
		}
	}

	cout << dp[n] <<endl;
	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m;
    cin >> n >> m;
    vector<ll> a (n);
    vector<pair<ll, ll>> b;
    F0R(i, n) cin >> a[i];
    F0R(i, m) 
    {
        ll x, y;
        cin >> x >> y;
        b.pb({y, x});
    }
    sort(b.begin(), b.end(), greater<pair<ll, ll>>());
    sort(a.begin(), a.end());
    ll pos = 0;
    F0R(i, b.sz())
    {
        F0R(j, b[i].s)
        {
            if(a[pos] < b[i].f)
            {
                a[pos] = b[i].f;
                pos++;
            }
            if(pos >= a.sz()) break;
        }
        if(pos >= a.sz() || a[pos] > b[i].f) break;
    }
    ll res = 0;
    F0R(i, a.sz()) res += a[i];
    cout << res;
    return 0;
}

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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;


/*
두 그거에 대해서.
0<=t<=N에 대해서.
D[i]: t시간이ㅔ i에 있으면 타카하시가 이기는지.
t를 거꾸로 보면서. 만약 A가 내리는 거면 
*/

int h, w, sr, sc, n;
char S[200010], T[200010];

pii solve(char u, char d, int s, int e){
	pii st = {s,e};

	for(int i=n; i>=1; i--){
		if(T[i]==u) st.second = min(st.second+1, e);
		if(T[i]==d) st.first  = max(st.first-1,  s);

		if(S[i]==u) st.first  = st.first+1;
		if(S[i]==d) st.second = st.second-1;

		// cout<<st.first<<' '<<st.second<<'\n';
		if(st.first+1>=st.second) return st;
	}

	return st;
}


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

	cin>>h>>w>>n>>sr>>sc;
	cin>>(S+1)>>(T+1);

	pii row = solve('U', 'D', 0, h+1);
	pii col = solve('L', 'R', 0, w+1);

	// cout<<row.first<<' '<<row.second<<'\n';
	// cout<<col.first<<' '<<col.second<<'\n';

	bool aowin = (row.first<sr && sr<row.second && col.first<sc && sc<col.second);

	cout<<(aowin ? "YES" : "NO")<<'\n';

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c,t;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<' '<<b<<' '<<c<<'\n';
    return 0;
}

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


int main(){
	int n;
	while(cin>>n&&n){
		int c=0;
		while(n-1){
			c++;
			if(n&1)n=3*n+1;
			else n>>=1;
		}
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

// return primes between [2, sqrt(N)]
void SOE(ll N, vi & p) {
    int m = int(floor(sqrt(N))) + 1;
    int s[m];
    REP(i ,m) s[i] = i;

    FOR (i, 2, m) {
        if (s[i] != i) continue;

        p.pb(i);

        for (int j = i+i; j <= m; j += i) {
            s[j] = i;
        }
    }
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll a, b;
    cin >> a >> b;

    ll l = gcd(a, b);

    vi prime;
    SOE(l, prime);

    map<int, int> m;
    for(auto e: prime) {
        while(l % e == 0) {
            l /= e;
            m[e]++;
        }
    }

    if (l > 1) m[l]++;

    print(m.size() + 1);
    
}


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

int main()
{
    std::vector<int> v;
    v.clear();
    
    int a, n;
    std::cin >> n;
    for(int i=0; i<n; i++)
    {
        std::cin >> a;
        v.push_back(a);
    }
    
    sort(v.begin(), v.end());
    
    int s=0;
    for(int i=1; i<=n; i++)
    {
        s += i%2 == 0 ?  -v[n-i] : v[n-i];
    }
    
    std::cout << s << std::endl;
    
    return 0;
}


Measured memory_bytes: 888
#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 exist = false;
  for (int i = 0; i <= 100000; ++i) {
    int y = x - 100 * i;
    if (y >= 0 && y <= 5 * i) exist = true;
  }
  if (exist) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<int, pair<int, int>> piii;
//loop
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//STL
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

const int INF = 1e9;

void Main()
{
    int n;
    cin >> n;
    vector<int> R(n);
    REP(i, n)
    cin >> R.at(i);

    int minv = R.at(0);
    int maxv = -1000000001;
    FOR(i, 1, n - 1)
    {
        if (R.at(i) - minv > maxv)
        {
            maxv = R.at(i) - minv;
        }
        if (R.at(i) < minv)
        {
            minv = R.at(i);
        }
    }
    cout << maxv << endl;
}

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



Measured memory_bytes: 3560
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);

	        int N = sc.nextInt();
	        int[] a = new int[N];
	        for(int i=0;i<N;i++) {
	        	a[i] = sc.nextInt();
	        }
	        long ans=0;
	        for(int i=0;i<N;i++) {
	        	ans=ans+a[i]/2;
	        	if(i!=N-1&&a[i]%2==1&&a[i+1]!=0) {
	        		ans++;
	        		a[i+1]--;
	        	}
	        }
	        
	        System.out.println(ans);
	       
	    }

	}

Measured memory_bytes: 52200
// tested by Hightail: https://github.com/dj3500/hightail
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <stack>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define INF 1001001001
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define mp make_pair
#define pii pair<int,int>
#define ll long long
#define vi vector<int>
#define SZ(x) ((int)((x).size()))
#define fi first
#define se second
#define wez(n) int (n); scanf("%d",&(n));
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
inline void pisz(int n) { printf("%d\n",n); }
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){FOR(i,SZ(t))s<<t[i]<<" ";return s; }
#define DBG(vari) cout<<"["<<__LINE__<<"] "<<#vari<<" = "<<(vari)<<endl;
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (__typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define TESTS wez(testow)while(testow--)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define IOS ios_base::sync_with_stdio(0);

const int N = 200200;
int a[N];

int main () {
   wez2(n,x)
   FORI(i,n) scanf("%d", a+i);
   ll res = 0;
   REP(i,1,n) {
      if (a[i-1] + a[i] > x) {
         int d = a[i-1] + a[i] - x;
         res += d;
         a[i] -= d;
      }
   }
   cout << res;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int N;
    cin>>N;
    if(N%10==9)
        cout<<"Yes"<<endl;
    else if(N>=90 && N<=99)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3540