akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)


int main() {
  int n;
  string s;
  cin >> n >> s;
  string a = s.substr(0, n/2);
  string b = s.substr(n/2, n);
  if (a == b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
def hantei(moji):
    l=len(moji)
    kano=True
    for i in range((l)//2):
        if(moji[i]!=moji[l-i-1]):
            kano=False
    return kano

s=input()
n=len(s)
ans=hantei(s) and hantei(s[:n//2]) and hantei(s[n//2+1:])

if(ans):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int N = sc.nextInt();
		int total = 0;
		for(int i = 0;i < N;i++) {
			int A = sc.nextInt();
			total += A;
		}
		if(total >= H) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 58520
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 xx, kk, dd;
	cin >> xx >> kk >> dd;
	if(xx < 0)
	{
		xx *= -1;
	}
	if(xx == 0)
	{
		if(kk % 2 == 0)
		{
			cout << 0 << endl;
		}
		else
		{
			cout << dd << endl;
		}
		return 0;
	}
	if(xx / dd >= kk)
	{
		cout << (xx - kk * dd) << endl;
	}
	else
	{
		kk -= xx / dd;
		xx %= dd;
		if(kk % 2 == 0)
		{
			cout << xx << endl;
		}
		else
		{
			cout << (dd - xx) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3616
#include<cstdio>

int main(){
	int a[] = {0,0,31,60,91,121,152,182,213,244,274,305,335,366};
	int m, d;
	char day[7][10] = {"Monday", "Tuesday", "Wednesday", "Thursday","Friday","Saturday","Sunday"};
	scanf("%d %d", &m, &d);
	while(m || d){
		printf("%s\n", day[(a[m] + d + 2) % 7]);
		scanf("%d %d", &m, &d);
	}
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
#define p pair<int,int>
using namespace std;

int ans[100000];
int cou[100000];
vector<int>V[100000];
p d[150000];
signed main(){
int n,m;cin>>n>>m;
for(int i=0;i<n+m-1;i++){
int a,b;cin>>a>>b;a--;b--;
d[i]={a,b};
V[a].push_back(b);
cou[b]++;
}
int S=0;
for(int i=0;i<n;i++){if(!cou[i]){S=i;break;}}
queue<int>Q;
Q.push(S);
while(Q.size()){
int t=Q.front();Q.pop();
  for(int i:V[t]){
  cou[i]--;
    if(!cou[i]){
    Q.push(i);
      ans[i]=t+1;
    }
  }
}
  for(int i=0;i<n;i++)cout<<ans[i]<<endl;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)
ll MOD = 998244353;

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  vvi DP(C + 1, vi(D + 1));
  DP[A][B] = 1;
  for (int i = A + 1; i <= C; i++) {
    DP[i][B] = (DP[i - 1][B] * B) % MOD;
  }
  for (int j = B + 1; j <= D; j++) {
    DP[A][j] = (DP[A][j - 1] * A) % MOD;
  }

  for (int i = A + 1; i <= C; i++) {
    for (int j = B + 1; j <= D; j++) {
      DP[i][j] = DP[i - 1][j] * j + DP[i][j - 1] * i + (MOD - DP[i - 1][j - 1]) * (i - 1) * (j - 1);
      DP[i][j] %= MOD;
    }
  }

  ll ans = DP[C][D];
  cout << ans << endl;
}


Measured memory_bytes: 73516
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

n, k = na()
p = na()
d = [0] * (n + 1)
for i in range(n):
    a = (p[i] * (p[i] + 1) // 2) * (1 / p[i])
    d[i + 1] = d[i] + a

ans = 0.0
for i in range(n - k + 1):
    a = d[i + k] - d[i]
    ans = max(ans, a)

print(ans)

Measured memory_bytes: 67824
S = input()
M = {'a':0,'b':0,'c':0}
for s in S:
    M[s] += 1
L = sorted(M.values(),key=lambda x: -x)
if len(L) == 1:
    if L[0] == 1:
        print('YES')
    else:
        print('NO')
elif len(L) == 2:
    print('NO')
else:
    if L[0] - L[2] > 1:
        print('NO')
    else:
        print('YES')

Measured memory_bytes: 3188
#include <stdio.h>
int main(void){
    int n, i, j, k;
    int b, f, r, v;
    int count[4][3][10] = {0};

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        count[b - 1][f - 1][r - 1] += v;
    }
    
    for(i = 0; i < 4; i++){
        for(j = 0; j < 3; j++){
            for(k = 0; k < 10; k++){
                printf(" %d", count[i][j][k]);
                if(k == 9) putchar('\n');
                if(i != 3 && j == 2 && k == 9) printf("####################\n");
            }
        }
    }
    return 0;
} 


Measured memory_bytes: 1968
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}


pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: i64 = 1_000_000_007;
const INF: i64 = std::i64::MAX/3;

fn solve() {
	let (a,b) = read!(i64,i64);
	println!("{}",a*b);
}

fn run() {
    solve();
}


Measured memory_bytes: 2268
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cassert>
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FOREACH(i,c) for(__typeof((c).begin())i = (c).begin();i!=(c).end(); ++i)

//v4
int cond = 1;
string to_string(char c){return'\''+string(1,c)+'\'';}
string to_string(const string&s){return'"'+s+'"';}
string to_string(const char*s){return to_string((string)s);}
string to_string(bool b){return(b?"true":"false");}
string to_string(std::vector<bool>::reference&r){return to_string((bool)r);}
template<typename A,typename B>string to_string(const pair<A,B>&p){return"("+to_string(p.first)+", "+to_string(p.second)+")";}
template<typename A>string to_string(A v){int f=1;string r="{";for(auto x:v){if(!f){r+=", ";}f=0;r+=to_string(x);}r+="}";return r;}
template<typename A,typename B>string to_string(map<A,B>v){int f=1;string r="{";for(auto x:v){if(!f){r+=", ";}f=0;r+=to_string(x.first)+" -> "+to_string(x.second);}r+="}";return r;}
void __db(int i,const vector<string>&s){cerr<<endl;}
template<typename T,typename... A>void __db(int i,const vector<string>&s,T t,A... a){if(i)cerr<<", ";cerr<<s[i]<<" = "<<to_string(t);__db(i+1,s,a...);}
string __cl(string s){while(!s.empty()&&s[0]==' ')s.erase(0,1);while(!s.empty()&&s.back()==' ')s.pop_back();return s;}
vector<string>__vars(string s){vector<string>r;s+=",";string n="";int d=0;for(auto x:s)if(x==','&&d==0){if(!n.empty())r.push_back(__cl(n));n="";}else{n+=x;if(x=='('||x=='[')d++;else if(x==')'||x==']')d--;}return r;}
#define DB(...){if(cond){cerr<<"Line:"<<__LINE__<<" ";__db(0,__vars(#__VA_ARGS__),__VA_ARGS__);}}


int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  map<int, int> failed;
  set<int> acc;
  int res = 0;
  REP(i, m) {
    int pr;
    char c, d;
    scanf("%d %c%c", &pr, &c, &d);

    if (c == 'A') {
      if (!acc.count(pr)) {
        res += failed[pr];
        acc.insert(pr);
      }
    } else {
      failed[pr]++;
    }
  }
  printf("%d %d\n", (int)acc.size(), res);
  return 0;
}

Measured memory_bytes: 9600
#include <algorithm>
#include <iostream>
#include <string>

#include <vector>
#include <cmath>
#include <limits>
#include <functional>
using namespace std;

int main()
{
    int N, x;
    cin >> N >> x;
    int ans = 0;

    int a[105];
    for (int i = 0; i < 105; i++)
    {
        a[i] = 1000000001;
    }

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

    sort(a, a + 105);

    for (int i = 0; i < N; i++)
    {
        x -= a[i];
        if (x < 0)
        {
            break;
        }
        else
        {
            ans++;
        }
    }

    if (x > 0)
        ans--;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int a,b;
    cin >> a >> b;
    int tap=1;
    if(b == 0){
        cout << 0 << endl;
        return 0;
    }
    int answer = 0;
    REP(i,20){
        if(tap >= b){
            break;
        }
        tap += a-1;
        answer++;
    }
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a==b) cout << c << endl;
  if(a==c) cout << b<< endl;
  if(b==c) cout << a << endl;
  
  return 0;
}

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



int main() {
    int R, G, B, N; cin >> R >> G >> B >> N;
    int ans = 0;
    rep(i, 3000) rep(j, 3000)
        if ((N - (i*R+j*G)) % B == 0 && (N - (i*R+j*G)) >= 0) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
from copy import deepcopy
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    l = [2,5,5,4,5,6,3,7,6]
    d = {}
    for i in A:
        if l[i-1] not in d:
            d[l[i-1]] = i
        else:
            if d[l[i-1]] < i:
                d[l[i-1]] = i
    d3 = {}
    for i in d:
        d3[d[i]] = i
    d2 = list(d)
    d2.sort()
    s = [[[-1] * (len(d2)) for _ in range(len(d2))] for _ in range(N+1)]
    dp = [[0] * (len(d2)) for _ in range(N+1)]
    for w in range(N+1):
        if w % d2[0] == 0:
            dp[w][0] = w // d2[0]
            s[w][0] = [0] * (len(d2))
            s[w][0][0] = w // d2[0]
    for i in range(1, len(d2)):
        for w in range(N+1):
            if w < d2[i]:
                continue
            elif max(dp[w-d2[i]]) > 0:
                x = dp[w-d2[i]].index(max(dp[w-d2[i]]))
                if dp[w][i-1] > dp[w-d2[i]][x] + 1:
                    dp[w][i] = dp[w][i-1]
                    s[w][i] = deepcopy(s[w][i-1])
                else:
                    dp[w][i] = dp[w-d2[i]][x] + 1
                    s[w][i] = deepcopy(s[w-d2[i]][x])
                    s[w][i][i] += 1
            elif w == d2[i]:
                dp[w][i] = 1
                s[w][i] = [0] * len(d2)
                s[w][i][i] = 1
            else:
                dp[w][i] = dp[w][i-1]
                s[w][i] = deepcopy(s[w][i-1])
    maxn = 0
    for i in s[-1]:
        if sum(i) <= 0:
            continue
        qq = []
        for j,v in enumerate(i):
            if v > 0:
                qq.append((d[d2[j]],v))
        qq.sort(key=lambda x:x[0], reverse=True)
        r = ''
        for k in qq:
            r += str(k[0]) * k[1]
        if int(r) > maxn:
            maxn = int(r)
    print(maxn)
main()


Measured memory_bytes: 67292
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
int main()
{
    fastio();
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    ll h,n;
    cin>>h>>n;
    std::vector<pair<ll,ll> >v ;
    for(int i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        v.pb(mp(x,y));
    }
    sort(all(v));
    ll k = h+v[n-1].ff+1;
    ll dp[k]={1000000000};
    for(int i=0;i<k;i++)
        dp[i]=10000000000;
    dp[0]=0;
    for(int i=1;i<k;i++)
    {
        for(int j=0;j<v.size();j++)
        {
            if(i-v[j].ff>=0)
            {
                dp[i]= min(dp[i],dp[i-v[j].ff]+v[j].ss);
            }
        }
    }
    ll ans = dp[h];
    for(int i=h;i<k;i++)
        ans = min(ans,dp[i]);
    cout<<ans<<endl;
    
}

Measured memory_bytes: 384
n,k = map(int,input().split())
l = [0 for i in range(n)]
for _ in range(k):
    temp = int(input())
    d = list(map(int,input().split()))
    for i in d:
        l[i-1] += 1
count = 0
for i in range(n):
    if l[i] == 0:
        count += 1
print(count)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define ll long long int
#define infpos INT_MAX/8
#define infneg INT_MIN
#define mk_p make_pair

using namespace std;
//ifstream in("C:/testes programas/t.txt");
//ofstream out("C:/testes programas/o.txt");
//ifstream file("C:/testes programas/out.txt");
bool tes(char a){
  return ((a=='A')||(a=='C')||(a=='G')||(a=='T'));
}
int main(){
  ios::sync_with_stdio(0);
  string s;
  cin>>s;
  int w = 0;
  int ant = 0;
  for(int i=0;i<s.size();i++){
    if(!tes(s[i])){
      ant = i+1;
      continue;
    }
    w = max(i-ant+1, w);
  }
  cout<<w<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000000
#define MAX 200001
#define MOD 1000000007

int main(){
    int N, T; 
    cin >> N >> T;
    vector<P> AB(N);
    for(int i = 0; i < N; i++){
        int A, B;
        cin >> A >> B;
        AB[i] = {A, B};
    }
    int ans = 0;
    sort(AB.begin(), AB.end());
    vector<vector<int>> dp(N + 5, vector<int>(T+3, 0));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < T; j++){
            if(j - AB[i].first >= 0) dp[i + 1][j] = max(dp[i][j - AB[i].first] + AB[i].second, dp[i][j]);
            else dp[i + 1][j] = dp[i][j];
            ans = max(ans, dp[i][j] + AB[i].second);
        }   
    }
    cout << ans << endl;
}

Measured memory_bytes: 38536
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<Int> B(N-1);
  cin>>B;
  Int ans = B[0];
  for(Int i=0;i<N-2;i++){
    if(B[i] <= B[i+1]) ans += B[i];
    else ans += B[i+1];
  }
  ans += B.back();
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
    double a, b, x;cin>>a>>b>>x;
    double area = x / a;

    double border = a * b / 2.0;
    if (area > border){
        double diff = (area - border);
        double diff_hight = (2.0 * area ) / a - b;

        double longest = sqrt((a * a + (b- diff_hight) * (b-diff_hight)));
        double cos_c = (((b- diff_hight) * (b- diff_hight)) - (a * a) - (longest * longest)) / (2 * a * longest);

        double result = acos (cos_c) * 180.0 / M_PI;
        cout << setprecision(10) << 180.0 - result <<endl;
    } else {
        double a_temp = (area * 2.0) / b;
        double longest = sqrt((a_temp * a_temp) + (b * b));
        double cos_c = ((b * b) - (a_temp * a_temp) - (longest * longest)) / (2 * a_temp * longest);
        cout << setprecision(10) << 180.0 - acos(cos_c) * 180.0 / M_PI<<endl;

    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

const int maxv = 100005;

vector<int> d;

bool isOK(ll mid, ll key){
    if (key > d[mid]) return true;
    else return false; 
}

ll binary_search(ll key){
    ll ng = -1;
    ll ok = d.size();

    while(abs(ok-ng)>1){
        int mid = (ok+ng) / 2;

        if(isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    rep(i,N){
        ll a = A[i];
        ll index = binary_search(a);
        if (index != d.size()){
            d[index] = a;
        }else{
            d.push_back(a);
        }
    }

    cout << d.size() << endl;
}

Measured memory_bytes: 4688
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    
    int n;
    string s;
    cin >> n >> s;
    for (ll i=0;i<s.length();i++) {
        if(s[i] + n > static_cast<int>('Z')){
            cout << static_cast<char>(s[i] + n - 26);
        }else{
            cout << static_cast<char>(s[i] + n);
        }
    }
    cout << endl;
}

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

int main(int argc, char const *argv[]) {
  //入力
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  //道筋と訪問済み
  vector<int> s;            //道筋作成
  vector<int> o(n + 1, -1); //訪問済みかどうか。最初は全て-1で初期化
  int c = 1, l = 0;         // cは周期の長さ、lは周期外の長さ

  // solver
  int v = 1;           //現在訪問しているノード
  while (o[v] == -1) { //-1以外になったら訪問済み
    o[v] = s.size();   //一度訪問したノードにsのサイズを入れる
    s.push_back(v);    //訪問順に入れていく
    v = a[v - 1];      //次訪問するノードを代入
  }
  c = s.size() - o[v]; //周期長を計算
  l = o[v];            //周期外の長さ

  //出力
  if (k < l)
    cout << s[k] << endl;
  else {
    k -= l;
    k %= c;
    cout << s[l + k] << endl;
  }
  return 0;
}


Measured memory_bytes: 5768
import java.util.Scanner;

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

        int n = Integer.parseInt(scan.nextLine());
        double Rj = 0;
        double Ri = 0;
        double newR;
        double maxProfit = -1000000000;
        double tmpProfit = -1000000000;
        double tmp = 0;

        int value;
        for (int i=0; i<n; i++){
            newR = Integer.parseInt(scan.nextLine());
            if (i == 0){
                Rj = newR;
                Ri = newR;
                continue;
            }
            if (newR < Ri){
                tmp = newR - Ri;
                if (tmp > tmpProfit)
                    tmpProfit = tmp;
                Ri = newR;
                Rj = newR;
                continue;
            }
            if (newR >= Rj){
                Rj = newR;
                tmp = Rj - Ri;
                if (tmp > maxProfit)
                    maxProfit = tmp;
                continue;
            }
        }

        if (tmpProfit > maxProfit)
            maxProfit = tmpProfit;
        else if (tmpProfit == maxProfit)
            maxProfit = 0;

        System.out.println((int)(maxProfit));
    }
}

Measured memory_bytes: 163820
//Solution for aoj 0560:Planetary Exploration
#include <iostream>
using namespace std;
int n, m, k, res[3], mid, a, b;
int planet2[1001][1001][4], ex[4];
char planet[1001][1001];
int jud(char a){
	if (a == 'J')
		return 1;
	if (a == 'O')
		return 2;
	if (a == 'I')
		return 3;
}
int main(){
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cin >> planet[i][j];
		}
	}
	planet2[1][1][jud(planet[1][1])] = 1;
	for (int i = 2; i <= n; i++){
		for (int j = 1; j<4; j++)
			planet2[i][1][j] = planet2[i - 1][1][j];
		planet2[i][1][jud(planet[i][1])]++;
	}
	for (int i = 2; i <= m; i++){
		for (int j = 1; j<4; j++)
			planet2[1][i][j] = planet2[1][i - 1][j];
		planet2[1][i][jud(planet[1][i])]++;
	}
	for (int i = 2; i <= n; i++){
		for (int j = 2; j <= m; j++){
			for (int l = 1; l<4; l++){
				planet2[i][j][l] = planet2[i - 1][j][l] + planet2[i][j - 1][l] - planet2[i - 1][j - 1][l];
			}
			planet2[i][j][jud(planet[i][j])]++;
		}
	}
	for (int i = 0; i<k; i++){
		for (int j = 0; j<4; j++){
			cin >> ex[j];
		}
		for (int j = 1; j<4; j++){
			cout << planet2[ex[2]][ex[3]][j] - planet2[ex[0] - 1][ex[3]][j] - planet2[ex[2]][ex[1] - 1][j] + planet2[ex[0] - 1][ex[1] - 1][j];
			if (j != 3)
				cout << ' ';
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 17632
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}
int dp[100100];
int dfs(whei(int)&G, int v){
	if (dp[v] != -1)return dp[v];
	int s = 0;
	for (auto x : G[v])s = max(s, dfs(G, x)+1);
	return dp[v] = s;
}

int main() {
	int n, m;
	cin >> n >> m;
	whei(int) G(n);
	rep(j, 0, m) {
		int a, b;
		cin >> a >> b;
		a--;
		--b;
		G[a].push_back(b);
	}
	rep(i, 0, n)dp[i] = -1;
	int ans = 0;
	rep(i, 0, n) {
		ans = max(ans, dfs(G, i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8192
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
vector<P>D;
int N[2],h,r,K,res,dp[205];
int main()
{
	for(;;)
	{
		res=0;
		D.clear();
		memset(dp,0,sizeof(dp));
		for(int c=0;c<2;c++)
		{
			scanf("%d",&N[c]);
			if(!c&&!N[0])return 0;
			for(int i=0;i<N[c];i++)
			{
				scanf("%d%d",&r,&h);
				D.push_back(make_pair(r,h));
			}
		}
		K=N[0]+N[1];
		sort(D.begin(),D.end());
		for(int i=0;i<K;i++)
		{
			dp[i]=max(dp[i],1);
			for(int j=0;j<i;j++)
				if(D[i].first>D[j].first&&D[i].second>D[j].second)
					dp[i]=max(dp[j]+1,dp[i]);
			res=max(dp[i],res);
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n;
char p[20];

void dfs(int a,int tot){
    if(tot == n){
        for(int i = 0; i < n; i++)printf("%c",p[i]);
        cout << endl;
        return;
    }
    for(int i = 0; i <= min(a+1,tot); i++){
        p[tot] = 'a'+i;
        dfs(max(a,i),tot+1);
    }
}

int main(){
    cin >> n;
    dfs(0,0);
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;
int main() {
    int A,B,X;
    string ans;
    cin >> A >> B >> X;
    if ( A<=X && X <= B+A) ans = "YES";
    else ans = "NO";
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
# 5 n
# 4 4 9 7 5 l

n = gets.to_i
array_l = gets.split.map(&:to_i)

array_n = (0..(n-1)).to_a
conbination = array_n.combination(3).to_a

count = 0
conbination.each do |conb|
  l_1 = array_l[conb[0]]
  l_2 = array_l[conb[1]]
  l_3 = array_l[conb[2]]

  array_tri = [l_1, l_2, l_3]
  array_tri.uniq!
  next if array_tri.length <= 2
  array_tri.sort!

  if array_tri[0] + array_tri[1] > array_tri[2]
    count += 1
  end
end

puts count


Measured memory_bytes: 27812
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define S(x) (int) x.size()
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define M 100005
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884
using namespace std;

void solve()
{
	int x, n;
	cin>>x>>n;
	int a[n], flag = 0;
	f(i, 0, n) cin>>a[i];
	sort(a, a+n);
	map <int, int> mp;
	f(i, x-2*n, x+2*n) mp[i] = 0;
	f(i, 0, n) mp[a[i]]++;
	int ans1, ans2;
	f(i, x, x+2*n)
	{
		if(mp[i] == 0)
		{
			ans1 = i;
			break;
		}
	}
	fb(i, x, x-2*n)
	{
		if(mp[i] == 0)
		{
			ans2 = i;
			break;
		}
	}
	if(abs(x-ans1) < abs(x-ans2)) cout<<ans1;
	else cout<<ans2;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3684
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    A, B, C = map(int, input().split())
    for i in range(1, 1000):
        if (i * A) % B == C:
            print(YES)
            return
    print(NO)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

const int N   = 3e5+7;
const int MOD = 1e9+7;
const int INF = (~(1<<31));

int fre(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}

inline int read(){
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||'9'<ch;ch=getchar())if(ch=='-') f=-1;
	for(;'0'<=ch&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}

#define lal puts("****");
#define pb  push_back
#define mp  make_pair
#define x   first
#define y   second

/*****************************************************************/

struct edge{
    int to,next,w;
}G[N<<1];
int head[N],tot;
void add(int u,int v,int w){
    G[tot].w=w,G[tot].to=v,G[tot].next=head[u],head[u]=tot++;
    G[tot].w=w,G[tot].to=u,G[tot].next=head[v],head[v]=tot++;
}

LL dp[N];

void dfs(int u,int f,LL w){
    dp[u]=w;
    for(int i=head[u],to;i!=-1;i=G[i].next){
        to = G[i].to;
        if(to == f) continue;
        dfs(to,u,w+G[i].w);
    }
}

int n,q,k;

int main(){
    memset(head,-1,sizeof(head));tot=0;
    scanf("%d",&n);
    for(int i=2,u,v,w;i<=n;i++){
        scanf("%d %d %d",&u,&v,&w);
        add(u,v,w);
    }

    scanf("%d%d",&q,&k);
    dfs(k,0,0);
    
    for(int x,y;q--;){
        scanf("%d%d",&x,&y);
        printf("%lld\n", dp[x]+dp[y]);
    }
    return 0;
}

Measured memory_bytes: 11392
#pragma GCC optimize("Ofast")   //Comment optimisations for an interative problem/use endl
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;  
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss;  
typedef vector<pll> vpll; 
typedef vector<ll> vll; 
typedef vector<vll> vvll; 
typedef unordered_map<ll,ll> um;

#define fastio ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define sqr(x) ((ll)(x) * (x)) 
#define reset(a, b) memset(a, b, sizeof(a)) 
#define f first 
#define s second 
#define mp make_pair 
#define pb push_back 
#define all(v) v.begin(), v.end() 
#define alla(arr, sz) arr, arr + sz 
#define showv(v) for(auto it: (v))cout<<it<<" ";newl;
#define newl cout<<"\n"

const ll MAXN=1e+2+7;
const ll MOD=1e+9+7, INF=0x7f7f7f7f7f7f7f7f;const int INFi=0x7f7f7f7f;
double EPS = 1e-9;  
double PI = acos(-1); 

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
ll t,n;
ll i,j,a[200007],min1;
 
//<<-----Implement Functions Here---->>//
 
 
//<<-----Start of Main--------------->>//

int main()
{
	cin >> n;
	for(i =0;i<n;i++)cin>>a[i];
	min1 = a[0];ll count1 = 1;

	for(i=1;i<n;i++)
	{
		if(min1>a[i]){count1++;min1 =a[i];}
	}
	cout<<count1;
	
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn =3e5+13;

int a[maxn];
int vis[maxn];
ll b[maxn];
int main()
{
	ll n;
	int x,m;
	scanf("%lld%d%d",&n,&x,&m);
	a[1]=x;
	int cnt =1;
	vis[a[1]]=1;
	int last,fir;
	while(1)
	{
		a[cnt+1]=1ll*a[cnt]*a[cnt]%m;
	    cnt++;
	    if(!vis[a[cnt]]) vis[a[cnt]]=cnt;
	    else 
		{
		last = cnt - vis[a[cnt]];
		fir = vis[a[cnt]];
		break;}
	}
	for(int i=1;i<=cnt;i++)
	{
		b[i]=b[i-1]+1ll*a[i];
	}
	
	ll ans=b[fir-1]+(b[cnt-1]-b[fir-1])*((n-fir+1)/(last))+b[(n-fir+1)%last+fir-1]-b[fir-1];
	printf("%lld",ans);
 } 

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

using namespace std;

using ll = long long;

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

    vector<ll> a(n), b(n);
    ll suma = 0, sumb = 0;

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

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

    if (suma < sumb) {
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    ll need = 0;
    vector<ll> v;
    for (int i = 0; i < n; i++) {
        if (b[i] > a[i]) {
            ans++;
            need += b[i] - a[i];
        } else if (a[i] > b[i]) {
            v.push_back(a[i] - b[i]);
        }
    }

    sort(v.rbegin(), v.rend());
    for (ll x : v) {
        if (need <= 0) break;
        need -= x;
        ans++;
    }

    if (need > 0) {
        cout << -1 << endl;
        return 0;
    }

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

Measured memory_bytes: 2428
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	reverse(all(a));
	vector<int> lis(n, inf);
	rep(i, n) {
		int idx = upper_bound(all(lis), a[i]) - lis.begin();
		lis[idx] = a[i];
	}
	int ans = 0;
	rep(i, n) if (lis[i] != inf) ans = i + 1;
	cout << ans << '\n';
}

Measured memory_bytes: 1024
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

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

    int c_count=0;

    if(S[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }
    for(int i=2; i< S.length()-1; i++){
        if(S[i]=='C') c_count++;
    }
    int small_chara=0;

    rep(i,S.length()){
        if(S[i]>='a' && S[i]<='z')small_chara++;
    }
    if((S.length()-small_chara==2)&& c_count==1 ){
        cout <<"AC" << endl;
    }else{
        cout <<"WA" << endl;
    }
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  unordered_map<string, int> count;
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    ans += count[s]++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 10660
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn = 100007;
char a[maxn];
int n;
int main()
{
    cin>>a;
    n = strlen(a);
    int ans = n;
    for(int i=1;i<n;i++)if(a[i-1]!=a[i])ans=min(ans,max(i,n-i));
    cout<<ans<<endl;
}


Measured memory_bytes: 384
function main()
    a = parse(readline())
    b = parse(readline())
    c = parse(readline())
    x = parse(readline())
    count = 0
    for i in 0:a
        for j in 0:b
            for k in 0:c
                s = 500i + 100j + 50k
                if s == x 
                    count += 1
                end
            end
        end
    end
    println("$count")
end

main()

Measured memory_bytes: 120836
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;

Vi f[100100];
int group[100100];


int dfs(int v, int g, int par=-1){
  group[v] = g;
  int ans = 1;
  for (auto i: f[v])
    if (i != par and not group[i])
      ans += dfs(i, g, v);
  
  return ans;
}


signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);
  
  int n, m, k;
  cin >> n >> m >> k;
  
  for (int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--, b--;
    f[a].pb(b);
    f[b].pb(a);
  }

  vector<Pi> bl;
  for (int i = 0; i < k; i++){
    int a, b;
    cin >> a >> b;
    a--, b--;
    bl.pb({a, b});
  }

  
  int group_name = 1;
  Vi group_size;
  for (int i = 0; i < n; i++)
    if(not group[i])
      group_size.pb(dfs(i, group_name++));


  
  int ans[n];
  for (int i = 0; i < n; i++){
    ans[i] = group_size[group[i] - 1] - f[i].size() - 1;
  }
  
  for (int i = 0; i < bl.size(); i++){
    int first = bl[i].fi;
    int second = bl[i].se;
    if (group[first] == group[second])
      ans[first]--, ans[second]--;
  }

  for (int i = 0; i < n; i++)
    cout << ans[i] << " ";
  cout << endl;
  

  
  

  
  
}


Measured memory_bytes: 10868
#pragma region 宣言部分
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;

#pragma endregion



int main(){
    ll n;
    cin >> n;
    string s = "";
    while(n > 0){
        ll x = n%26;
        char c = 'a' + (int)(x -1);
        //cout << x << endl;
        if(x == 0){
            s = s + 'z';
            n--;
        }else{
            s = s + c;
        }
        n /= 26;
    }
    for(int i = s.size()-1 ; i >= 0;i--){
        cout << s[i] ;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main(void){
    // Your code here!
 int n;
 cin >> n;
 if(n>=400 && n<=599)
 cout << '8';
 else if(n>=600 && n<=799)
 cout << '7';
 else if(n>=800 && n<=999)
 cout << '6';
 else if(n>=1000 && n<=1199)
 cout << '5';
 else if(n>=1200 && n<=1399)
 cout << '4';
 else if(n>=1400 && n<=1599)
 cout << '3';
 else if(n>=1600 && n<=1799)
 cout << '2';
 else if(n>=1800 && n<=1999)
 cout << '1';
 return 0;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int member[1000];
bool cp[1000][1000];
int main(){
  int n,q;
  while(cin>>n>>q,n){
    for(int i=0;i<1000;i++)member[i]=0;
    for(int i=0;i<1000;i++)
      for(int j=0;j<1000;j++)cp[i][j]=0;
    for(int i=0;i<n;i++){
      int num;
      cin>>num;
      int tmp;
      for(int j=0;j<num;j++){
	cin>>tmp;
	cp[i][tmp-1]=true;
      }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<1000;j++){
	if(cp[i][j]==true)member[j]++;
      }
    }
    int M=0;
    int ans;
    for(int i=999;i>=0;i--){
      M=max(member[i],M);
      if(member[i] == M){
	ans = i+1;
      }
    }

    if(M>=q){
      cout <<ans << endl;
    }else{
      cout << 0 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2140
t = 1
# t = input()
# t = int(t)
def max(a,b):
	if a > b:
		return a
	return b
while t > 0:
	t -= 1
	n = int(input())
	# n,k = map(int,input().strip().split())
	v = list(map(int,input().strip().split()))[0:n]
	# m = {}
	l = []
	for i in range(n):
		l.append(0)
	# ans = 0
	j = 1
	for i in v:
		l[i-1] = j
		j += 1
	# print(ans)
	for i in l:
		print(i,end=" ")


Measured memory_bytes: 91184
from collections import Counter

n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
set_a = set(a)

count_list = []
if len(set_a) <= k:
    print(0)
else:
    a = Counter(a)
    cost = 0
    for (v, c) in a.most_common()[k:]:
        cost += c
    print(cost)

Measured memory_bytes: 48992
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long ll;
const int N=2e5+5;
int n,a[N][3];
ll dp[N][5];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i][0]);
        a[i][1]=a[i][0]%2==0;
        a[i][2]=a[i][0]==0?2:a[i][0]%2;
    }
    for(int i=1;i<=n;i++)
    {
        ll mn=1e18;
        for(int j=0;j<5;j++)
        {
            mn=min(mn,dp[i-1][j]);
            ll s;
            if(j==0) s=a[i][0];
            else if(j==1) s=a[i][2];
            else if(j==2) s=a[i][1];
            else if(j==3) s=a[i][2];
            else s=a[i][0];
            dp[i][j]=mn+s;
        }
    }
    ll ans=1e18;
    for(int i=0;i<5;i++) ans=min(ans,dp[n][i]);
    printf("%lld\n",ans);
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define ft              first
#define sd              second
#define ll          long long
#define pb              push_back
#define mkp           make_pair
#define pll             pair<ll,ll>
#define vll             vector<int>
#define mll             map<ll,ll>
#define pqg             priority_queue<ll>
#define pqs             priority_queue<ll,vll,greater<ll>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod          1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define MAXN   10000001
void online_judge()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
}

void ISO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
int main() {

    ISO();
    online_judge();
    int t;
    t = 1;
    while (t--)
    {

        int n;
        cin >> n;
        int dp[n][3];
        int a, b, c;
        cin >> a >> b >> c;
        dp[0][0] = a;
        dp[0][1] = b;
        dp[0][2] = c;
        for (int i = 1; i < n; ++i)
        {
            cin >> a >> b >> c;
            dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a;
            dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b;
            dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + c;
        }
       

        cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<< "\n";
    }

    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    return 0;
}

Measured memory_bytes: 4728
from collections import defaultdict
n = int(input())
a = [[]]
for _ in range(n):
    tmp = [int(x) for x in input().split()]
    a.append(tmp[::-1])

p = [i for i in range(1, n+1)]
c = defaultdict(int)
done = 0
for d in range(1, n*(n-1)//2+1):
    np = []
    for pp in p:
        if len(a[pp]) == 0:
            continue
        x = a[pp].pop()
        l = min(x, pp)
        r = max(x, pp)
        c[l, r] += 1
        if c[l, r] == 2:
            np.append(l)
            np.append(r)
            done += 1
    if done == (n*(n-1)//2):
        print(d)
        exit()
    if len(np) == 0:
        print(-1)
        exit()
    p = np

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

int main()
{
	int n;
	int taro = 0;
	int hanako = 0;
	string t, h;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> t;
		cin >> h;
		if (t == h)
		{
			taro += 1;
			hanako += 1;
		}
	else
	{
		if (t > h)
		{
			taro += 3;
		}
		else
		{
			hanako += 3;
		}
	}
	}
	cout << taro << " " << hanako << endl;

	return 0;
}

Measured memory_bytes: 3200