akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    // Your code here!
    char s1[300001];
    char s2[300001];
    int q;
    int t,f;
    char c;
    
    int flag=0;
    int s1len=0, s2len=0;
    
    scanf("%s", s1);
    s1len=strlen(s1);
    scanf("%d", &q);
    
    for(int i = 0; i < q; i++){
        scanf("%d", &t);
        if(t==1){
            flag = 1-flag;
        }else{
            scanf("%d %c", &f, &c);
            if(f-flag==1){
                s2[s2len]=c;
                s2[s2len+1]='\0';
                s2len++;
            }else{
                s1[s1len]=c;
                s1[s1len+1]='\0';
                s1len++;
            }
        }
    }
    
    if(flag == 0){
        for(int i=s2len-1; i>=0; i--){
            printf("%c",s2[i]);
        }
        for(int i=0; i<s1len; i++){
            printf("%c",s1[i]);
        }
    }else{
        for(int i=s1len-1; i>=0; i--){
            printf("%c",s1[i]);
        }
        for(int i=0; i<s2len; i++){
            printf("%c",s2[i]);
        }
    }
}


Measured memory_bytes: 768
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{
    static int N;
    static int[] T, A;
    static void Main()
    {
        N = int.Parse(Console.ReadLine());
        T = new int[N];
        A = new int[N];
        for(int i = 0; i < N; i++)
        {
            string[] s = Console.ReadLine().Split(' ');
            T[i] = int.Parse(s[0]);
            A[i] = int.Parse(s[1]);
        }
        long taka, ao;
        taka = T[0];
        ao = A[0];
        for(int i = 1; i < N; i++)
        {
            long ta;
            if (taka % T[i] == 0)
            {
                ta = taka;
            }
            else
            {
                long a = taka % T[i];
                ta = taka - a + T[i];
            }
            long aa = ta / T[i] * A[i];
            long ab;
            if (ao % A[i] == 0)
            {
                ab = ao;
            }
            else
            {
                long a = ao % A[i];
                ab = ao - a + A[i];
            }
            long tb = ab / A[i] * T[i];
            if (aa >= ao && tb >= taka)
            {
                if (aa + ta < ab + tb)
                {
                    taka = ta;
                    ao = aa;
                }
                else
                {
                    taka = tb;
                    ao = ab;
                }
            }
            else if (aa < ao)
            {
                taka = tb;
                ao = ab;
            }
            else if(tb<taka)
            {
                taka = ta;
                ao = aa;
            }
        }
        Console.WriteLine(taka + ao);
    }
   
}




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

int main(){
  int n,r=0; 
  int a[30]={};
  cin >> n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }  

  for(int i=1;i+1<n;i++){
    if((a[i-1]<a[i]&&a[i]<a[i+1])
       ||(a[i-1]>a[i]&&a[i]>a[i+1]))r++;
  }
  cout<<r<<endl;
}

Measured memory_bytes: 256
// =====================================================================
// macros
// =====================================================================

/// stdin macro from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537
macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

/// input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

/// test macro from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn answer_test() {
            $(
                assert_eq!(answer($input), $output);
            )*
        }
    };
}
// =====================================================================
// test cases
// =====================================================================

test!{
    /// write inputs for test cases here.
    /// e.g.) 
    /// ```
    /// "1 2 3"=>"4",
    /// r"4 5 6
    ///   7 8 9"=>"10",
    /// ```
    r"
    abcdabc
    "=>"2",
}

// =====================================================================
// functions
// =====================================================================

/// answer fn for the problem
fn answer(input: &str)->String{
    input!{
        source = input,
        s: chars,
    }
    let mut result = 0;
    let halfsize:usize = s.len() / 2;
    let startpoint = if s.len() % 2 == 0{halfsize}else{halfsize+1};
    for i in startpoint..s.len(){
        if s[i] != s[s.len() - (i+1)]{
            result = result +1;
        }
    }
    return result.to_string();
}

/// the entry point
fn main() {
    println!("{}",answer(&stdin!()));
}


Measured memory_bytes: 4352
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb emplace_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<int, pii>
#define puu pair<ULL, ULL>
#define pdd pair<long double, long double>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e5 + 5;
vector<int> g[N];
int d[N][3];
int n, m, u, v, s, t;
queue<pii> q;
int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; ++i) {
        scanf("%d %d", &u, &v);
        g[u].pb(v);
    }
    scanf("%d %d", &s, &t);
    for (int i = 1; i <= n; ++i) d[i][0] = d[i][1] = d[i][2] = -1;
    d[s][0] = 0;
    q.push({s, 0});
    while(!q.empty()) {
        pii p = q.front();
        q.pop();
        int u = p.fi;
        int dd = p.se;
        for (int v : g[u]) {
            int nx = (dd+1)%3;
            if(~d[v][nx]) continue;
            d[v][nx] = dd+1;
            q.push({v, dd+1});
        }
    }
    if(~d[t][0])printf("%d\n", d[t][0]/3);
    else printf("-1\n");
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>

const long long MOD = 1000000007;

int n,m;
map<int,int> v;
map<int,int> w;
vector<vector<bool>> ck(100,vector<bool>(10001,false));
vector<vector<long long>> dp(100,vector<long long>(10001,0));

int nap(int i,int u){
  if(i==n) return 0;
  
  if(ck.at(i).at(u)) return(dp.at(i).at(u));
  else{
    ck.at(i).at(u)=true;
    
    if(w.at(i)>u) dp.at(i).at(u)=nap(i+1,u);
  	else dp.at(i).at(u) = max(nap(i+1,u), nap(i+1,u-w.at(i))+v.at(i));
    
    return dp.at(i).at(u);
  }
}
  

int main(){
  cin >> n >> m;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    v[i]=a;
    w[i]=b;
  }
  int ans = nap(0,m); 
  cout << ans << endl;
}


Measured memory_bytes: 10656
#include<iostream>
#include<stdio.h>
#include<ios>
#include<cstdio>
#include<cmath>
#include<string>
#include<string.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<assert.h>
#include<bitset>
#include<tuple>
#include<climits>
#include<deque>
#include<utility>
#include<unordered_map>
#include<unordered_set>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<ext/pb_ds/assoc_container.hpp>
#include<chrono>
using namespace __gnu_pbds;
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    int a,b,c,k;cin>>a>>b>>c>>k;
    if(k<=a) cout<<k;
    else if(k<=a+b) cout<<a;
    else if(k>a+b) cout<<a-(k-a-b);
    return 0;
}


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

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
           
    int n;
    cin>>n;
    cout<<(1-n)<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int h,w;

char M[101][101];

pair<int,int> f(int y,int x){
  pair<int,int> p;
  if(M[y][x]=='.'){
    p=mp(y,x);
    return p;
  }
  if(M[y][x]=='#'){
    p=mp(-1,-1);
    return p;
  }
  if(M[y][x]=='>'){
    M[y][x]='#';
    f(y,x+1);
  }else if(M[y][x]=='^'){
    M[y][x]='#';
    f(y-1,x);
  }else if(M[y][x]=='<'){
    M[y][x]='#';
    f(y,x-1);
  }else if(M[y][x]=='v'){
    M[y][x]='#';
    f(y+1,x);
  }
}

signed main(){
  while(cin>>h>>w,h){
    rep(i,h)rep(j,w)cin>>M[i][j];
    pair<int,int> P=f(0,0);
    if(P.fir==-1&&P.sec==-1){
      cout<<"LOOP"<<endl;
    }else{
      cout<<P.sec<<' '<<P.fir<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3108
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder2020Ned
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int EnemyHP = int.Parse(input[0]);
            int DeathblowType = int.Parse(input[1]);

            var input2 = Console.ReadLine().Split(' ');
            
            var AttackList = new List<int>();
            for(int i = 0; i < input2.Length; i++)
            {
                AttackList.Add(int.Parse(input2[i]));
            }

            int Attack = AttackList.Sum();
            if (EnemyHP<=Attack)
            {
                Console.Write("Yes");
            }
            else
            {
                Console.Write("No");
            }
            Console.Read();
        }        
    }
}


Measured memory_bytes: 19168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int h = fr.nextInt();
		int w = fr.nextInt();
		String[] str = new String[h];
		for (int i=0; i<h; i++) {
			str[i] = fr.nextLine();
		}
		boolean res = true;
		for (int i=0; i<h && res; i++) {
			for (int j=0; j<w && res; j++) {
				if (str[i].charAt(j) == '#') {
					res &= ((i>0 && str[i-1].charAt(j) == '#') 
							|| (j > 0 && str[i].charAt(j-1) == '#') 
							|| (i < h-1 && str[i+1].charAt(j) == '#')
							|| (j <w-1 && str[i].charAt(j+1) == '#'));
				}
			}
		}
		System.out.println(res ? "Yes" : "No");
	}
	
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


Measured memory_bytes: 25280
inputs = [input() for i in range(2)]

n = int(inputs[0])

def parse(str,num):
    s1 = str[0:num]
    s2 = str[num+1:2*num+1]
    return [s1,s2]

words = parse(inputs[1],n)

output = ''

for i in range(n+1):
    for j in words:
        output = output + j[i-1:i]

print(output)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned int uint;
// vector<pair<uint, uint>> d;
uint d[100000];
bool gint(uint& l, uint& r) { return l > r; }
 
int main(int, char**)
{
	unsigned int n;
	ll t = 0;
	cin >> n;
 
	for (unsigned int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		d[i] = a + b;
		t -= b;
	}
 
	sort(d, d+n, gint);
 
	for (unsigned int i = 0; i < n; i+=2) {
        t += (ll)(d[i]);
	}
 
    cout << t << endl;
	return 0;
}

Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

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

    static class ACirclePond {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int r = in.nextInt();
            out.println(2 * r * Math.PI);
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.buflen = 0;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        private byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public int nextInt() {
            if (!hasNext()) throw new NoSuchElementException();
            int n = 0;
            boolean minus = false;
            byte b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 25664
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

//////
const int N = 1e6; 
ll fact[N+1];

void set_fact() {
    fact[0] = 1;
    rep(i,N) fact[i+1] = ((((ll)i+1) % mod) * fact[i]) % mod;
}

ll mod_inv(ll a, ll m) {
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

// n! mod p 
ll mod_fact(ll n, ll p, ll &e) {
    e = 0;
    if (!n) return 1;
    ll res = mod_fact(n/p, p, e);
    e += n/p;

    if ((n/p)%2) 
        return res * (p - fact[n%p]) %p;
    else
        return res * fact[n%p] % p;
}

// nCk mod p ; O(log_p n)
ll mod_comb(ll n, ll k, ll p) {
    if (n<0 || k<0 || n<k) return 0;
    ll e1, e2, e3;
    ll a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n-k, p, e3);
    if (e1 > e2+e3) return 0;
    return a1 * mod_inv(a2*a3%p, p) % p;
}

// nHk mod p ;
ll mod_h_comb(ll n, ll k, ll p) {
    return mod_comb(n+k-1, k, p);
}
///////////////////////

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

    set_fact();
    int x, y; cin >> x >> y;
    int cnt1 = 0, cnt2 = 0;

    while(x != 0 or y != 0){
        if(x < 0 or y < 0){
            cout << 0 << endl;
            return 0;
        }
        if(x >= y){
            x -= 2, y -= 1;
            cnt1++;
        }
        else {
            x -= 1, y -= 2;
            cnt2++;
        }
    }

    ll res = DIV(fact[cnt1 + cnt2], MUL(fact[cnt1], fact[cnt2], mod), mod);
    cout << res << endl;


    return 0;
}


Measured memory_bytes: 8064
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    ll ans = lcm(A, B);
    cout << ans << endl;
}


Measured memory_bytes: 256
import itertools
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    else:
        y=[]
        l=list(range(1,n+1))
        for t in itertools.combinations(l,3):
            s=sum(t)
            y.append(s)
        print(y.count(x))


Measured memory_bytes: 7020
#include<bits/stdc++.h>
using namespace std;
int n,b[200001];
string s[200001];
struct node
{
	string s;
	int x;
}a[200001];
bool cmp(string s,string x)
{
	return s<x;
}
bool cmp1(node x,node y)
{
	if(x.x!=y.x)
	return x.x>y.x;
	return x.s<y.s;
}
signed main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	cin>>s[i];
	sort(s+1,s+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		if(s[i]==s[i-1])
		b[i]=b[i-1];
		else
		b[i]=i;
	}
	for(int i=1;i<=n;i++)
	{
		a[b[i]].x++;
		if(b[i]==i)
		a[b[i]].s+=s[i];
	}
	sort(a+1,a+n+1,cmp1);
	cout<<a[1].s<<endl;
	for(int i=2;a[i].x==a[i-1].x&&i<=n;i++)
	cout<<a[i].s<<endl;
	return 0;
}

Measured memory_bytes: 27520
w = input()

abc = "abcdefghijklmnopqrstuvwxyz"

abc_count = []
abc_index = 0
isBeautiful = True
for ch in abc:
    abc_count.append(w.count(ch))
    if abc_count[abc_index] % 2 == 1:
        isBeautiful = False
        break
    abc_index += 1

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


Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}
template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}
void solve(){
    int n;
    read(n);
    vi a(n);
    REP(i,n) cin >> a[i];
    ll ans = 0;
    REP(i,n) ans += a[i] - 1;
    write(ans);
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
int a,b,c; cin >> a >> b >> c;
string ans = "No";
if(a==b && b == c)ans = "Yes";
cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
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; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

// https://atcoder.jp/contests/abc162/submissions/11879810
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  vector<map<int, ll> > dp(n + 2);
  dp[0][0] = 0;
  rep(i, n) {
    // [0, i - 1] の個数, max sums
    for (const auto &[c, val] : dp[i]) {
      // ないと tle
      if (c < i / 2 - 1 || c > (i + 1) / 2) continue;
      // 0 との max をとらないよう
      if (!dp[i + 1].count(c)) dp[i + 1][c] = -INF;
      chmax(dp[i + 1][c], dp[i][c]);

      if (!dp[i + 2].count(c + 1)) dp[i + 2][c + 1] = -INF;
      chmax(dp[i + 2][c + 1], dp[i][c] + a[i]);
    }
  }
  ll ans = -INF;
  rep(i, n + 2) if (dp[i].count(n / 2)) chmax(ans, dp[i][n / 2]);
  cout << ans << endl;
}


Measured memory_bytes: 44652
#include<iostream>
using namespace std;
int L[250002],R[250002],cnt;
void merge(int A[],int n,int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	L[n1]=R[n2]=2000000000;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		cnt++;
		if(L[i]<=R[j]){
			A[k]=L[i++];
		}else{
			A[k]=R[j++];
		}
	} 
}
int ms(int A[],int n,int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
		ms(A,n,left,mid);
		ms(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}
int main(){
	int A[500000],n;
	cnt = 0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	ms(A,n,0,n);
	for(int i=0;i<n;i++){
		if(i){
			cout<<" ";
		}
		cout<<A[i];
	}
	cout<<endl;
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 6984
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
int a[n-1];
for(int i = 0; i < n - 1; ++i){
	cin >> a[i];
}
int sum = 0, i;
for(int i = 0; i < n - 2; ++i){
	sum += min(a[i],a[i+1]);
}
cout<<sum+a[n-2]+a[0];
return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    k = int(input())
    x = [int(x) for x in input().split()]
    x.sort()
    answer = 0
    for i in range(n):
        answer += min(2 * x[i], 2 * abs(x[i] - k))
    print(answer)


if __name__ == '__main__':
    main()



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

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; }

const long long INF = 1LL << 60;

int main(){
  int a, b;
  cin >> a >> b;

  rep(i, 10100){
    if(i*8/100==a && i*10/100==b){
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}


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

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

Measured memory_bytes: 3632
//Rextester.Program.Main is the entry point for your code. Don't change it.
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //Your code goes 
             var input = Console.ReadLine();

            var array = input.Split(' ');
            var a = array[0];
            var b = array[1];
           

                                
              if(a == "H") {
                Console.WriteLine(b);
            
            } else if ((a == "D") && (b == "H")) {
                  Console.WriteLine('D');

            } else {
                Console.WriteLine('H');
            }
                                
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll A[MAX_N], B[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	priority_queue<pl> que;
	rep(i, 0, N) {
		cin >> B[i];
		if(A[i] < B[i]) que.push(pl(B[i], i));
	}
	ll cnt = 0;
	while(!que.empty()) {
		pl p = que.top(); que.pop();
		int at = p.sec;
		// debug(vl(B, B + N), p, cnt);
		ll r = B[(N + at - 1) % N] + B[(at + 1) % N];
		if(B[at] <= r) {
			cout << -1 << "\n";
			return;
		}
		if(B[at] % r > A[at]) {
			cnt += B[at] / r;
			B[at] %= r;
			que.push(pl(B[at], at));
		}
		else {
			if((B[at] - A[at]) % r) {
				cout << "-1\n"; 
				return;
			}
			else {
				cnt += (B[at] - A[at]) / r;
				B[at] = A[at];
			}
		}
	}
	cout << cnt << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 11504
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

int main(void) {
    int N,T;
    vector<int> cost(N), time(N);
    cin >> N >> T;

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

    int min_cost = INT32_MAX;
    for(int i = 0; i < N; ++i) {
        if(time[i] <= T) {
            if (min_cost > cost[i]) {
                min_cost = cost[i];
            }
        }
    }

    cout << ((min_cost != INT32_MAX) ? to_string(min_cost) : "TLE") << endl;

    return 0;
}

Measured memory_bytes: 33024
#include<iostream>
#include<vector>
int main() {
	int n, m;
	std::vector<int> a;
	std::cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int x;
		std::cin >> x;
		a.push_back(x);
	}
	for (int i = 1; i <= m; i++) {
		for (int j = 0; j < n-1; j++) {
			if (a[j] % i > a[j + 1] %i) {
				int x;
				x = a[j];
				a[j] = a[j + 1];
				a[j + 1] = x;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		std::cout << a[i] << std::endl;
	}
}


Measured memory_bytes: 3172
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var h=new int[10];
		var g=new int[10];
		var d=new Tuple<int,int>[10][];
		for(int i = 0;i<10;i++) {
			int p=i,j=1,k=0;
			d[i]=new Tuple<int,int>[20];
			do{
				d[i][j]=Tuple.Create(k,p);
				if(p>9){
					p=(p.ToString()[0]-'0')+(p.ToString()[1]-'0');
				}
				else{
					p+=i;
					j++;
				}
				k++;
			}
			while(p!=i);
			h[i]=j-1;
			g[i]=k;
		}
		int m=sc.I;
		long ans=0;
		var a=new int[m];
		for(int i = 0;i<m;i++) {
			var e=sc.La;
			ans+=((e[1]-1)/h[e[0]])*g[e[0]]+d[e[0]][((e[1]-1)%h[e[0]])+1].Item1;
			a[i]=d[e[0]][((e[1]-1)%h[e[0]])+1].Item2;
			if(i!=0){
				a[i]+=a[i-1];
				ans++;
				if(a[i]>9){
					a[i]=(a[i].ToString()[0]-'0')+(a[i].ToString()[1]-'0');
					ans++;
				}
			}
		}
		Console.WriteLine(ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll M, D; cin >> M >> D;
    ll ans = 0;
    rep2(m, 1, M + 1){
        rep2(d, 1, D + 1){
            if (d / 10 >= 2 && d % 10 >= 2 && ((d % 10) * (d / 10) == m)){ans++;}
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3640
#include "iostream"
#include "algorithm"
using namespace std;

int mmfunc(int a, int b, int h, int w)
{
  return max({a*w, (h - a) * b, (h - a) * (w - b)}) - min({a*w, (h - a) * b, (h - a) * (w - b)});
}

int main()
{
  int h, w;
  cin >> h >> w;
  if (h % 3 == 0 || w % 3 == 0)
  {
    cout << 0 << "\n";
  }
  else
  {
    cout << min({h, w, mmfunc(h / 3, w / 2, h, w), mmfunc(h / 3 + 1, w / 2, h, w), mmfunc(w / 3, h / 2, w, h), mmfunc(w / 3 + 1, h / 2, w, h)}) << "\n";
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
int X[10],Y[10],M;
bool check()
{
	int m,x[10],y[10];
	cin>>m;
	for(int i=0;i<m;i++)cin>>x[i]>>y[i];
	if(m!=M)return 0;
	bool f=1;
	for(int i=1;i<m;i++)
	{
		f&=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
			==abs(X[i]-X[i-1])+abs(Y[i]-Y[i-1]);
	}
	for(int i=1;i<m-1;i++)
	{
		f&=((x[i-1]-x[i])*(y[i+1]-y[i])-(y[i-1]-y[i])*(x[i+1]-x[i])>0)
			==((X[i-1]-X[i])*(Y[i+1]-Y[i])-(Y[i-1]-Y[i])*(X[i+1]-X[i])>0);
	}
	if(f)return 1;
	f=1;
	for(int i=1;i<m;i++)
	{
		f&=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
			==abs(X[m-i-1]-X[m-i])+abs(Y[m-i-1]-Y[m-i]);
	}
	for(int i=1;i<m-1;i++)
	{
		f&=((x[i-1]-x[i])*(y[i+1]-y[i])-(y[i-1]-y[i])*(x[i+1]-x[i])>0)
			==((X[m-i]-X[m-i-1])*(Y[m-i-2]-Y[m-i-1])-(Y[m-i]-Y[m-i-1])*(X[m-i-2]-X[m-i-1])>0);
	}
	return f;
}
main()
{
	while(cin>>n,n)
	{
		cin>>M;
		for(int i=0;i<M;i++)cin>>X[i]>>Y[i];
		for(int i=0;i<n;i++)if(check())cout<<i+1<<endl;
		cout<<"+++++"<<endl;
	}
}



Measured memory_bytes: 3084
while True:
    n, m  = map(int, raw_input().split())
    if n==0 and m==0: break
    c = {i:0 for i in range(m)}
    for i in range(n):
        a = map(int, raw_input().split())
        for j in range(m):
            c[j] += a[j]
    ans=[k[0]+1 for k in sorted(c.items(),key=lambda x:x[1],reverse=True)]
    print " ".join(map(str,ans))

Measured memory_bytes: 6296
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






void stoogesort(vector<int> &a, int l, int r){
    if(a[l] > a[r]){
        swap(a[l], a[r]);
    }
    if(r - l + 1 >= 3){
        int t = (r - l + 1) / 3;
        stoogesort(a, l, r - t);
        stoogesort(a, l + t, r);
        stoogesort(a, l, r - t);
    }
}


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n){
        cin >> a[i];
    }
    REP(i, 100){
        stoogesort(a, 0, n - 1);
        cerr << i << endl;
    }
    cout << a[n - 1] - a[0] << endl;
}

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


int main() {
    ll n; cin >> n;
    ll sum = 0;
    vector<ll> a(n),b(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
        a[i]--;
        b[a[i]]++;
    }
    for(ll i=0;i<n;i++){
        sum += b[i] * (b[i]-1)/2;
    }
    for(ll i=0;i<n;i++){
        cout << sum - b[a[i]] +1 << endl;
    }
}

Measured memory_bytes: 5760
// CodeForces - 1A
#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    
    if((a % 2 == 0) || (b % 2 == 0))    cout << "Even";
    else    cout << "Odd";
    
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



string s;
void solve(){
	cin >> s;
	int n = s.size();
	
	bool ok = 1;
	for(int i = 0; i < n/2; i++){
		if(s[i] != s[n-i-1]){
			ok = 0;
		}
	}
	for(int i = 0; i < n/4; i++){
		if(s[i] != s[n/2-i-1]){
			ok = 0;
		}
	}
	for(int i = (n+3)/2-1; i < n; i++){
		int I = (n+3)/2 + n-i-2;
		if(s[i] != s[I]){
			ok = 0;
		}
	}
	cout << (ok ? "Yes" : "No") << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 int n, h;
	 cin>>n>>h;
	 int arr[n];
	 int i, count=0;
	 for(i=0; i<n ;i++)
	 {
	 	cin>>arr[i];
	 	if(arr[i]>=h)
	 	count++;
	 }
	 cout<<count;
	}

Measured memory_bytes: 640
#include <cstdio>

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

int main()
{
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  printf("%d\n", max(0, c - (a - b)));
  return 0;
}

Measured memory_bytes: 128
n,l = map(int,input().split())
azi = list()
for i in range(n):
    azi.append(l+i)
kei = sum(azi)
s = list()
for i in range(n):
    s.append(kei-azi[i])

tmp = float('inf')
ans = 0
for i in range(n):
    if tmp >= abs(kei-s[i]):
        ans = s[i]
        tmp = abs(kei-s[i])
print(ans)

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	string n;
	
	cin>>n;
	
	cout<<(n.size() - 1) * 9 + n.front() - '0' - (n.find_first_not_of('9', 1) != string::npos)<<'\n';
}


Measured memory_bytes: 256
def main():
    N = int(input())
    P = list(map(int, input().split()))

    ans = 1
    m = P[0]
    for i in range(1, N):
        if P[i] > m:
            continue
        m = min(m, P[i])
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 24744
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c;
  	cin >> a >> b >>c;
  if(a == b && a != c){
    cout << "Yes";
  } else if (a == c && a != b){
    cout << "Yes";
  } else if (b == c && b != a){
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    int n,k;
    cin>>n>>k;
    vi dp(n+2,INF);
    vi h(n+1);
    rep(i,n) cin>>h[i];
    dp[0]=0;
    rep(i,n){
        rep(j,k){
            if(i+j>n) break;
            dp[i+j+1]=min(dp[i+j+1],dp[i]+abs(h[i]-h[i+j+1]));
        }
    }
    out(dp[n-1]);
}

Measured memory_bytes: 1792
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int cnt = 0;
    REP(i, a + 1){
        REP(j, b + 1){
            REP(k, c + 1){
                int hoge = i * 500 + j * 100 + k * 50;
                if(hoge == x) cnt += 1;
            }
        }
    }
    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 256
int main(){
int a,b,c,h;
scanf("%d%d%d",&a,&b,&c);
if(a>b){
h=a;
a=b;
b=h;
}
if(b>c){
h=b;
b=c;
c=h;
}
if(a>b){
h=a;
a=b;
b=h;
}
printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int Least_Common_Multiple(int a,int b){
    int result;
    result = a;
    while(result%b != 0){
        result += a;
    }
    return result;
}

int Greatest_Common_Factor(int a, int b){
    if(a > b){
        return Greatest_Common_Factor(a-b,b);
    }
    else if(a <  b){
        return Greatest_Common_Factor(a,b-a);
    }
    else{
        return a;
    }
}

int main(void) {
	int a,b;
	while(scanf("%d %d",&a,&b) != EOF){
	    printf("%d %d\n",Greatest_Common_Factor(a,b),Least_Common_Multiple(a,b));
	}
	return 0;
}

Measured memory_bytes: 1688
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;

int main() {
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    cout << double(w)*double(h)/2 << " ";
    if(w == 2*x && h == 2*y) {
        cout << 1;
    }else {
        cout << 0;
    }
    return 0;
}

Measured memory_bytes: 256
#500
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

N = int(input())
A = list(map(int,input().split()))
LCM = 0
S = 0

for i in range(N):
    if i == 0:
        LCM = A[0]
    else:
        LCM = lcm(LCM,A[i])

for j in range(N):
    S = S + (LCM // A[j])

S = S % (10**9 + 7)
print(S)

Measured memory_bytes: 6112
import java.util.Scanner;

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

        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (b - a <= 0)
            System.out.println("delicious");
        else if (b - a <= x)
            System.out.println("safe");
        else
            System.out.println("dangerous");
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int a,b,c;
	string s="Impossible";
	cin >> a; cin >> b;// cin >> c;
	//a[0]==a[2]?cout << "Yes"<< endl: cout << "No" << endl;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)s = "Possible";
	cout << s << endl;
	
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    int i=0,x=0,y,ans;
    cin>>s;
    int ls=s.length();
    while(i<ls)
    {
        if(s[i]=='p') x++;
        i++; 
    }
    y=i/2;
    ans=y-x;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 512