akhauriyash/Code-Regression huggingface dataset:
#include <functional>
#include <list>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <deque>
#include <stack>
#include <cassert>
using namespace std;
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define ALL(x) (x).begin(),(x).end()
#define CASET2 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d:\n", case_n++) : 0), ___T-- > 0)
#define CASET1 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d: ", case_n++) : 0), ___T-- > 0)
#define CASET int ___T; scanf("%d ", &___T); while (___T-- > 0)
#define SZ(X) ((int)(X).size())
#define LEN(X) strlen(X)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=(b);i--)
#define REPL(i,x) for(int i=0;x[i];i++)
#define PER(i,n) for(int i=(n)-1;i>=0;i--)
#define RI1(x) scanf("%d",&x)
#define RI2(x,y) RI1(x), RI1(y)
#define RI3(x,y...) RI1(x), RI2(y)
#define RI4(x,y...) RI1(x), RI3(y)
#define RI5(x,y...) RI1(x), RI4(y)
#define RI6(x,y...) RI1(x), RI5(y)
#define GET_MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define RI(argv...) GET_MACRO(argv, RI6, RI5, RI4, RI3, RI2, RI1)(argv)
#define DRI(argv...) int argv;RI(argv)
#define WRI(argv...) while (RI(argv) != EOF)
#define DWRI(x...) int x; WRI(x)
#define RS(x) scanf("%s",x)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define X first
#define Y second
#define V(x) vector<x >

typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int INF = 1000000000;

void print(int i) { printf("%d", i); }
void print(LL i);
template<class T> void PI(T i) { print(i); puts(""); }
template<class T> void PIS(T i) { print(i); printf(" "); }

template<class T>
void PV(T const &v, int N) {
    REP(i, N) {
        print(v[i]);
        printf("%c", i == N-1 ? '\n' : ' ');
    }
}

template<class T> void PV(T const &v) { PV(v, SZ(v)); }

template<class T, class S> bool has_bit(T mask, S i) { return (mask >> i) & 1; }
long long shift(int i) { return 1ll << i; }

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
int popcount(int x) { return __builtin_popcount(x); } 
int popcount(long long x) { return __builtin_popcountll(x); } 

#include <unordered_set>
#include <unordered_map>
#define EB emplace_back
#define RL(x) scanf("%lld", &(x))
#define PL(x) printf("%lld\n", x)
#define DRL(x) LL x; RL(x)

int main() {
    DRI(N);
    VI a(N+1);
    int ans = 0;
    REP(i, N) {
        DRI(p);
        a[p] = a[p-1] + 1;
        ans = max(ans, a[p]);
    }
    PI(N-ans);
    return 0;
}


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

int main()
{
  int a, b, n=0; cin >> a >> b;
  for(int i=1; i<=b-a; ++i) {
    n += i;
  }
  cout << n-b << endl;
}


Measured memory_bytes: 256
/**
 * Created by hiramekun at 20:58 on 2020-04-19.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll r;
    cin >> r;
    cout << fixed << setprecision(10) << r * 2 * acos(-1) << endl;
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

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

  double v = pow(l,3)/27;

  printf("%.16f", v);
  cout << endl;
} 

Measured memory_bytes: 384
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {
	vector<string> s(3);
	int n = 3;
	rep(i, n)cin >> s[i];
	rep(i, n)cout << s[i][i];


	return 0;
}





Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut graph = vec![vec![]; n];
    for _ in 1..n {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push(b);
        graph[b].push(a);
    }

    let mut c: Vec<u64> = sc.vec(n);
    let sum = c.iter().sum::<u64>();
    c.sort();
    let mut ans = vec![0; n];
    ans[0] = c.pop().unwrap();
    dfs(0, 0, &mut c, &mut ans, &graph);
    println!("{}", sum - ans[0]);
    for (i, ans) in ans.into_iter().enumerate() {
        if i > 0 {
            print!(" ");
        }
        print!("{}", ans);
    }
    println!();
}

fn dfs(v: usize, p: usize, c: &mut Vec<u64>, ans: &mut Vec<u64>, graph: &Vec<Vec<usize>>) {
    for &next in graph[v].iter() {
        if next == p {
            continue;
        }
        let x = c.pop().unwrap();
        ans[next] = x;
        dfs(next, v, c, ans, graph);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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


int main() {
	char c[4];
	cin>>c;
	if(c[0]==c[1]&&c[2]==c[3]&&c[0]!=c[2]){
		cout <<"Yes";
	}
	else if(c[0]==c[2]&&c[1]==c[3]&&c[2]!=c[1]){
		cout<<"Yes";
	}
	else if(c[0]==c[3]&&c[1]==c[2]&&c[3]!=c[1]){
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
}

Measured memory_bytes: 256
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let n: usize = get_input().parse().unwrap();

    let mut v:Vec<i64> = Vec::new();
    let vline = get_input();
    for l in vline.split_whitespace() {
        v.push(l.parse().unwrap());
    }

    let mut c:Vec<i64> = Vec::new();
    let cline = get_input();
    for l in cline.split_whitespace() {
        c.push(l.parse().unwrap());
    }

    let pow:Vec<i64> = (0..(1 << n))
        .map(|i| (0..n)
             .filter(|j| i & (1 << j) > 0)
             .filter(|&i| v[i] > c[i])
             .map(|i| v[i] - c[i])
             .sum())
        .collect();
    let ans = pow.iter().max().unwrap();
    println!("{}", ans);
}

Measured memory_bytes: 12540
#include <bits/stdc++.h>
 
using namespace std;
 
#define EPS 1e-10
#define equals(a, b) (fabs(a - b) < EPS)
 
struct Point {
    double x, y;
 
    Point(){}
    Point(double x, double y) : x(x), y(y) {}
  
    Point operator - (const Point &p) const {  return Point(x - p.x, y - p.y); }
};

typedef Point Vector;

double dot(const Point &a, const Point &b)
{
    return a.x * b.x + a.y * b.y;
}
 
struct Line {
    Point s, t;
    Line(){}
    Line(Point s, Point t) : s(s), t(t) {}
}; 

bool isOrthogonalSS(const Line &s1, const Line &s2)
{
    Vector a = s1.t - s1.s;
    Vector b = s2.t - s2.s;
    return equals(dot(a, b), 0);
}

istream &operator >> (istream &is, Point &p)
{
    return is >> p.x >> p.y;
}
 
int main()
{
    Line l[2];
    while (cin >> l[0].s >> l[0].t) {
        cin >> l[1].s >> l[1].t;
        cout << (isOrthogonalSS(l[0], l[1]) ? "YES" : "NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 3184
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int menseki = 0;
        int length = 0;
        menseki = a * b;
        length = 2 * a + 2 * b;
        System.out.println(menseki + " " +length);

    }
}


Measured memory_bytes: 26032
function main(input) {
  
  var input = input.split(/\n/);
  var def = input[0] * 1;
  var t = input[1].split(' ').map(x => x * 1);
  var count = 0;
  var sw = true;
  
  while(sw) {
  	
    for (var i = 0; i < def; i++){
      
      if (t[i] % 2 === 0) {
        t[i] = t[i] / 2;
      } else {
        sw = false;
      }
    }
    
    if (sw) count ++;
    
  }
  
  
  console.log(count);
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22204
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
signed main(){
  string s;cin>>s;
  int res=0;
  int n=(int)s.length();
  int par=0;int gu=0;
  rep(i,n){
    if(i<=(n+1)/2-1){
      if(s[i]=='p')res--;
    }
    else{
      if(s[i]=='g')res++;
    }
  }
  cout<<res<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long long unsigned int llui;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef set<int> si;
typedef map<string, int> msi;

#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-9
#define DEBUG(x) cout<< '>' << #x << ':' << x << "\n";
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define sz(a) int((a).size())
#define clr(a) memset(a,0,sizeof(a))
#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;

inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

#define LSOne(S) (S&(-S))

const double pi = acos(-1);
const int oo = 0x3f3f3f3f;

template<class T> inline T gcd(T a,T b) //NOTE:__gcd(0,0) gives exception
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}

int cmp(double x, double y = 0, double tol = EPS) {
    return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

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

/*bool sortby(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
    return (a.second < b.second);
}*/

const int MAX_N = 123456;

//int arr[MAX_N];

int main(){
    int n;
    scanf("%d",&n);
    string s,t;
    set<string> S;
    cin>>t;
    S.insert(t);
    bool flag=1;
    for(int i=0;i<n-1;i++){
        cin>>s;
        if(s[0]!=t[t.length()-1] || S.find(s)!=S.end())
            flag=0;
        t=s;
        S.insert(s);
    }
    if(flag)
    printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {  
    int n;
    cin >> n;
    unordered_map<int, int> um;
    for (int i = 2; i <= n; i++) {
        int num = i;
        for (int j = 2; j * j <= num; j++) {
            while (num % j == 0) {
                num /= j;
                um[j]++;
            }
        }
        if (num > 1) {
            um[num]++;
        }
    }
    long long int res = 1;
    const int mod = 1e9 + 7;
    for (auto p : um) {
        res = res * (p.second + 1) % mod;
    }
    cout << res << endl;
}




Measured memory_bytes: 3604
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();

        boolean ok = false;
        String str = "";
        for(int i = s.length()-t.length();i >= 0;i--){
            boolean can = true;
            for(int j = 0;j < t.length();j++){
                if(s.charAt(i+j) != '?' && s.charAt(i+j) != t.charAt(j)){
                    can = false;
                }
            }
            if(can){
                str = s.substring(0,i) + t + s.substring(i + t.length());
                //System.out.println(s.substring(i,i+t.length()));
                //str = s.replaceFirst("\\" + s.substring(i,i+t.length()),t);
                ok = true;
                break;
            }
        }
        str = str.replaceAll("\\?","a");
        if(ok){
            System.out.println(str);
        }
        else{
            System.out.println("UNRESTORABLE");
        }
    }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define N 105
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
const double EPS = 1e-8;

double dot(P a, P b){ return real(conj(a)*b); }

double cross(P a, P b){ return imag(conj(a)*b); }

int ccw(P a, P b, P c){
  b -= a; c -= a;
  if(cross(b,c) > EPS) return 1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

P crossPoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}

vector<P> convex_cut(vector<P> G, L l){
  vector<P> ans;
  for(int i=0;i<G.size();i++){
    P A = G[i];
    P B = G[(i+1)%G.size()];
    if(ccw(l.first, l.second, A) != -1) ans.push_back(A);
    if(ccw(l.first, l.second, A) * ccw(l.first, l.second, B) < 0)
      ans.push_back(crossPoint(L(A,B), l));
  }
  return ans;
}

int n,x,y;
P p[N];

L line(P a,P b,double d){
  b-=a;
  P B=P(abs(b),d);
  B=B*b/abs(b)+a;
  b+=a;
  P A=P(B.real()-(b.real()-a.real()),B.imag()-(b.imag()-a.imag()));
  return L(A,B);
}

bool check(double d){
  vector<P> land;
  for(int i=0;i<n;i++)
    land.push_back(p[i]);
  for(int i=0;i<n;i++)
    land=convex_cut(land,line(p[i],p[(i+1)%n],d));
  if(!land.size())return false;
  return true;
}

double bynary_search(){
  double L=0,R=10005;
  while(L+EPS<R){
    double M=(L+R)/2.0;
    if(check(M))L=M;
    else R=M;
  }
  return L;
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin>>x>>y;
      p[i]=P(x,y);
    }
    printf("%.6f\n",bynary_search());
  }
  return 0;
}

Measured memory_bytes: 3188
import sys
input = sys.stdin.readline

N=int(input().rstrip('\n'))
if N<3:
  print(0)
else:
  ls = [int(x) for x in input().rstrip('\n').split()]
  ls = sorted(ls,reverse = True)
  res = 0
  for x in range(N-2):
    X=ls[x]
    for y in range(x+1,N-1):
      Y=ls[y]
      if X>Y:
        a = X-Y
        for z in range(y+1,N):
          Z=ls[z]
          if Y>Z and Z>a:
            res += 1
          elif Z<=a:
            break
  print(res)    

Measured memory_bytes: 9212
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>


using namespace std;


int main() {
	int n, q;
	string s;
	cin >> n >> s >> q;
	vector<set<int>>charactor(26);
	for (int i = 0; i < n; i++) {
		int x = s[i] - 'a';
		charactor[x].insert(i);
	}
	vector<int>ans;
	for (int i = 0; i < q; i++) {
		int q1;
		cin >> q1;
		if (q1 == 1) {
			int x;
			char c;
			cin >> x >> c;
			for (int j = 0; j < 26; j++) {
				charactor[j].erase(x - 1);
			}
			charactor[c - 'a'].insert(x - 1);
		}
		else {
			int x, y;
			cin >> x >> y;
			int tmp = 0;
			for (int j = 0; j < 26; j++) {
				auto itr = charactor[j].lower_bound(x - 1);
				if (itr != charactor[j].end()) {
					if (*itr <= y - 1)tmp++;
				}
			}
			ans.push_back(tmp);
		}
	}
	for (auto it = ans.begin(); it != ans.end(); it++) {
		cout << *it << endl;
	}
	return 0;
}

Measured memory_bytes: 26244
/*input
7
1 1 1 1 2 3 4
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
//------------------------------------------------------------
#define int long long
#define MAX 200900
#define INF 0x3f3f3f3f

int n , x[MAX];

int32_t main(){
	IOS;
	cin >> n;
	REP(i , 1 , n + 1) cin >> x[i] , x[i] -= i;
	sort(x + 1 , x + 1 + n);
	int mid = x[(1 + n) / 2] , sum = 0;
	REP(i , 1 , n + 1) sum += abs(mid - x[i]);
	cout << sum << endl;
    return 0;
}

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

int X;
int Y;
int Z;
int iMin;

int main()
{
int i;
int N;
int A;
int B;
int P;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> A;
	cin >> B;

	for( i = 0; i < N; i++ )
	{
		cin >> P;

		if( P <= A )
			X++;
		else if( P <= B )
			Y++;
		else
			Z++;

	}

	iMin = min( X, Y );
	iMin = min( iMin, Z );

	cout << iMin << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[3030][3030];
int main(){
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int m=t.size();
    //int dp[n][m];
    memset(dp,0,sizeof(dp));
    //if(s[0]==t[0])
    //dp[0][0]=1;
    for(int i=1;i<n+1;i++){
        for(int j=1;j<m+1;j++){
            if(s[i-1]==t[j-1])
            dp[i][j]=1+dp[i-1][j-1];
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    //cout<<dp[n][m]<<endl;
    string ans;
    int i=n,j=m;
    while(i>0&&j>0){
        if(s[i-1]==t[j-1]){
        ans.push_back(s[i-1]);
        i--;
        j--;
        }
        else if(dp[i-1][j]==dp[i][j])
        i--;
        else j--;
    }
    //cout<<ans;
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}

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

using namespace std;

int main(void)
{
   // freopen("C:\\Users\\Administrator\\Desktop\\debug.in", "r", stdin);
                                                                                                                                                                               
    double cc, dd;

    cin >> cc >> dd;

    int d = (int)cc / (int)dd;

    int r = (int)cc - (int)dd*d;

    double t = cc / dd;
  
   printf("%d %d %.5f", d, r, t);

   return 0;
}



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

int main() {
	// your code goes here
	int n,d;
	cin >> n >> d;
	int point[n][d];
	for(int i = 0 ; i < n ; i++)
	{
		for(int j = 0 ; j < d ; j++)
		{
			cin >> point[i][j];
		}
	}int ans = 0;
	for(int i = 0 ; i < n ; i++)
	{
		for(int j = i+1 ; j < n ; j++)
		{
			int tot = 0,chk,p = 0;
			while(p < d)
			{
				tot += (point[i][p]-point[j][p])*(point[i][p]-point[j][p]);
				p++;
			}
			chk = sqrt(tot);
			if(chk*chk == tot)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    string s;
    cin >> n >> s;
    map<char, ll> cnt;
    rep(i, n) cnt[s[i]]++;
    ll ans = 1;
    for(auto&& p : cnt) (ans *= (p.se+1)) %= MOD;
    cout << (ans-1+MOD)%MOD << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    int N;
    cin >> N;
    int M = 1e6;
    vector<int> isPrime(M, true);
    isPrime[0] = false;
    isPrime[1] = false;
    isPrime[2] = true;
    for (int k = 2; k < M; k++) {
        if (!isPrime[k])
            continue;

        for (int l = 2; k * l < M; l++) {
            isPrime[k * l] = false;
        }
    }

    vector<int> ans;
    for (int i = 0; i < M; i++) {
        if (isPrime[i] && i % 5 == 1) {
            ans.push_back(i);
        }
    }

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


Measured memory_bytes: 4352
#include <iostream>


using namespace std;


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

  int odds = 0;
  for (int i=0; i<n; ++i) {
    int m;
    cin >> m;

    if (m % 2 == 1)
      ++odds;
  }

  if (odds % 2 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
  
template<class T>
using Graph = std::vector<std::vector<T>>;
  
bool dfs(Graph<int> &G, int step, int u, int v,
         std::vector<bool> &visited)
{
    int n = G.size();
    int x = (step < n / 2 ? u : v);
    if (step == n - 1) {
        return true;
    }
      
    bool ret = false;
    for (int next : G[x]) {
        if (!visited[next]) {
            visited[next] = true;
  
            if (step < n / 2) {
                ret |= dfs(G, step + 1, next, v, visited);
            } else {
                ret |= dfs(G, step + 1, u, next, visited);
            }           
        }        
    }
  
    return ret;
}
  
bool solve(Graph<int> &G, int u, int v)
{
    int n = G.size();
    if (n & 1) {
        return false;
    }
  
    std::vector<bool> visited(n, false);
    visited[u] = visited[v] = true;
    return dfs(G, 1, u, v, visited);
}
  
int main()
{
    int n, u, v;
    scanf("%d %d %d", &n, &u, &v);
    u--; v--;
      
    Graph<int> G(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
  
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
  
    printf("%s\n", (solve(G, u, v) ? "Yes" : "No"));
      
    return 0;
}

Measured memory_bytes: 17584
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int a,b,n;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n; a=n;
    while(n){
        b+=n%10;
        n/=10;
    }
    if(a%b) cout << "No";
    else cout << "Yes";
}


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

int main(){
	int ans=0,N,M; cin>>N>>M;
	rep(i, M){
		int a; cin>>a;
		ans += a;
	}
	ans = N - ans;
	cout<< (ans<0?-1:ans) <<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

// 0以上n以下の数字でxで割ることのできる数
ll f(ll n, ll x)
{
    if (n <= -1l)
    {
        return 0;
    }
    else
    {
        // 0が含まれる
        return n / x + 1;
    }
}

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

    cout << f(b, x) - f(a - 1, x) << endl;
}

Measured memory_bytes: 256
while True :
    a = input()
    if a == "END OF INPUT" :
        break
    
    b = list(a)
    count = 0
    for i in range(len(b)) :
        if b[i] != ' ' :
            count += 1
        else :
            print(count, end="")
            count = 0
    print(count)


Measured memory_bytes: 5552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,x;
	cin>>n;
	while(n--)
	{
		cin>>x;
		if(x%2!=0)	
		{
			puts("first");
			return 0;
		}
	}
	puts("second");
}

Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))
s = sum(w)
t = 0
for i in range(n):
    t += w[i]
    if t * 2 >= s:
        a_1 = t - w[i]
        a_2 = t
        break
    
if (s - a_1 * 2) ** 2 <= (s - a_2 * 2) ** 2:
    print(int(((s - a_1 * 2) ** 2) ** 0.5 ))
else:
    print(int(((s - a_2 * 2) ** 2) ** 0.5 ))

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args) {
		
		//入力値の受け取り
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		sc.close();
		
		char A[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
		
		int len = S.length();
		StringBuilder sb =new StringBuilder();
		
		for(int i=0;i<len;i++) {
			char t = S.charAt(i);
			for(int j=0;j<27;j++) {
				if(t==A[j]) {
					sb.append(A[j+N]);
					break;
				}
			}
		}
		System.out.println(sb.toString());
	}
}

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

int main()
{
	string s;
	string p;
	cin >> s >>p;
	s = s + s;
	if (s.find(p, 0) >= 0 && s.find(p,0)<s.size()) cout << "Yes" << endl;
	else  cout << "No" << endl;
}


Measured memory_bytes: 3204
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <map>


using namespace std;


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

  vector < pair<long, long>> ew(n, make_pair(0, 0));//左と右のEの数

  for (int i = 1; i < n; i++) {//左側のEの数
    if (s[i-1]=='E'){
      ew[i].first += ew[i-1].first + 1;
    }else{
      ew[i].first += ew[i-1].first;
    }
  }

  for (int i = n-2; i >=0; i--) {//右側のEの数
    if (s[i+1]=='E'){
      ew[i].second += ew[i+1].second + 1;
    }else{
      ew[i].second += ew[i+1].second;
    }
  }

  // for(int i=0;i<n;i++){
  //   cout << "l:r"<< ew[i].first <<  ","<< ew[i].second << endl;
  // }


  long count=n;
  for(int i=0;i<n;i++){
    long tmp = 0;
    tmp = (i - ew[i].first) + (ew[i].second);
    if (tmp<count)count=tmp;
  }



  cout << count << endl;

  return 0;
}

Measured memory_bytes: 5380
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>
using namespace std;
using ll = long long;
string move(pair<int, int> c, pair<int, int> c_);

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	pair<int, int> c,c_;
	c = make_pair(sx, sy);
	string S;

	for (int i = sx; i < tx; i++) {
		c_ = c;
		c.first += 1;
		S += move(c, c_);
	}

	for (int i = sy; i < ty; i++) {
		c_ = c;
		c.second += 1;
		S += move(c, c_);
	}

	for (int i = tx; i > sx; i--) {
		c_ = c;
		c.first -= 1;
		S += move(c, c_);
	}

	for (int i = ty; i > sy; i--) {
		c_ = c;
		c.second -= 1;
		S += move(c, c_);
	}

	c_ = c;
	c.second -= 1;
	S += move(c, c_);

	for (int i = sx; i < tx + 1; i++) {
		c_ = c;
		c.first += 1;
		S += move(c, c_);
	}

	for (int i = sy - 1; i < ty; i++) {
		c_ = c;
		c.second += 1;
		S += move(c, c_);
	}

	c_ = c;
	c.first -= 1;
	S += move(c, c_);

	c_ = c;
	c.second += 1;
	S += move(c, c_);

	for (int i = tx; i > sx - 1; i--) {
		c_ = c;
		c.first -= 1;
		S += move(c, c_);
	}

	for (int i = ty + 1; i > sy; i--) {
		c_ = c;
		c.second -= 1;
		S += move(c, c_);
	}

	c_ = c;
	c.first += 1;
	S += move(c, c_);
	
	cout << S << endl;
	return 0;
}

string move(pair<int, int> c, pair<int, int> c_) {
	pair<int, int> dc = make_pair(c.first - c_.first, c.second - c_.second);
	string S;
	if (dc == make_pair(1, 0)) S.push_back('R');
	if (dc == make_pair(0, 1)) S.push_back('U');
	if (dc == make_pair(-1, 0)) S.push_back('L');
	if (dc == make_pair(0, -1)) S.push_back('D');
	return S;
}

Measured memory_bytes: 256
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
A.sort()
me=1
usr=N-2
lenme=A[0]
lenusr=A[N-1]
ans=A[N-1]-A[0]

for i in range(N-2):
    if max([abs(A[me]-lenme),abs(A[me]-lenusr)])>=max([abs(A[usr]-lenme),abs(A[usr]-lenusr)]):
        if abs(A[me]-lenme)>=abs(A[me]-lenusr):
            ans+=abs(A[me]-lenme)
            lenme=A[me]
        else:
            ans+=abs(A[me]-lenusr)
            lenusr=A[me]
        me+=1
    else:
        if abs(A[usr]-lenme)>=abs(A[usr]-lenusr):
            ans+=abs(A[usr]-lenme)
            lenme=A[usr]
        else:
            ans+=abs(A[usr]-lenusr)
            lenusr=A[usr]
        usr-=1
print(ans)

Measured memory_bytes: 7512
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define next nex
using namespace std;
const int MAXN = 524290;
const int MOD = 924844033;
int a[MAXN], b[MAXN];
int n, m, i, j, k, x, y;
int size[MAXN];
int first[MAXN], next[MAXN], go[MAXN], t, pre[MAXN];
int bit[MAXN], f[MAXN];
inline int get()
{
	char c;
	while ((c = getchar()) < 48 || c > 57);
	int res = c - 48;
	while ((c = getchar()) >= 48 && c <= 57)
		res = res * 10 + c - 48;
	return res;
}
inline void add(int x, int y)
{
	next[++t] = first[x]; first[x] = t; go[t] = y;
}
inline void dfs(int now, int las)
{
	size[now] = 1;
	for(int i = first[now]; i; i = next[i])
		if (go[i] != las) dfs(go[i], now), size[now] += size[go[i]];
	a[n - size[now]] --;
	a[n] ++;
	for(int i = first[now]; i; i = next[i])
		if (go[i] != las) a[size[go[i]]] --;
}
inline int ksm(int x, int y, int z)
{
	int b = 1;
	while (y)
	{
		if (y & 1) b = 1ll * b * x % z;
		x = 1ll * x * x % z;
		y >>= 1;
	}
	return b;
}
inline int ntt_init(int m)
{
	int n = 1, nn = 0;
	while (n <= m) n <<= 1, nn ++;
	int g = ksm(5, (MOD - 1) / n, MOD);
	f[0] = 1;
	for(int i = 1; i < n; i ++)
		f[i] = 1ll * f[i - 1] * g % MOD, bit[i] = (bit[i >> 1] >> 1) | ((i & 1) << nn - 1);
	return nn;
}
inline void ntt(int *a, int nn, int ty)
{
	int n = 1 << nn;
	for(int i = 0; i < n; i ++)
		if (i < bit[i]) swap(a[i], a[bit[i]]);
	for(int k = 1; k <= nn; k ++)
	{
		int len = 1 << k, wn = (ty == 1) ? f[n / len] : f[n - n / len];
		for(int j = 0; j < n; j += len)
		{
			int m = len >> 1, w = 1;
			for(int i = j; i < j + m; i ++)
			{
				int l = a[i], t = 1ll * a[i + m] * w % MOD;
				a[i] = (l + t) % MOD;
				a[i + m] = (l - t + MOD) % MOD;
				w = 1ll * w * wn % MOD;
			}
		}
	}
}
int main()
{
	cin >> n;
	for(i = 1; i < n; i ++)
	{
		x = get(); y = get();
		add(x, y);
		add(y, x);
	}
	int nn = ntt_init(n << 1), N = 1 << nn;
	dfs(1, 0);
	for(i = 1; i <= n; i ++)
		if (a[i] < 0) a[i] += MOD;
	pre[0] = 1;
	for(i = 1; i < N; i ++)
		pre[i] = 1ll * pre[i - 1] * i % MOD, a[i] = 1ll * a[i] * pre[i] % MOD;
	for(i = 0; i <= n; i ++)
		b[i] = ksm(pre[n - i], MOD - 2, MOD);
	ntt(a, nn, 1);
	ntt(b, nn, 1);
	for(i = 0; i < N; i ++)
		a[i] = 1ll * a[i] * b[i] % MOD;
	ntt(a, nn, -1);
	int po = ksm(N, MOD - 2, MOD);
	for(i = 0; i < N; i ++)
		a[i] = 1ll * a[i] * po % MOD;
	for(i = n + 1; i <= n + n; i ++)
		printf("%d\n", 1ll * a[i] * ksm(pre[i - n], MOD - 2, MOD) % MOD);
}

Measured memory_bytes: 24704
//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//
 
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <utility>
#define pb push_back
#define mk make_pair
#define endl "\n"
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long double ld;
priority_queue <lli, vector<lli>, greater<lli> > ti;
vector <lli> p[300005],a(300005),b(300005,0),f(500005,0);
lli vis[200005];
map <pair<lli,lli>,lli> mp;
set<pair<lli, lli> > s;
set<lli> st;
map<lli,lli> np,v;
queue<lli> qy;
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
lli bpow(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}
void fact(lli i)
{
    f[0]=1;
    for(lli k=1;k<=i;k++)
    {
        f[k]=(f[k-1]*k)%mod;
    }
}
lli isprime(lli n)
{
    if(n==1)
        return 0;
    for(lli i=2;i<=sqrt(n);i++)
        if(n%i==0)
            return 0;
    return 1;
}
bool cmp(lli i,lli j)
{
    return p[i].size()<p[j].size();
}
lli comb(lli n,lli i)
{
    lli g=f[n]*(bpow(f[i],mod-2))*bpow(f[n-i],mod-2);
    return g%mod;
}
lli permute(lli n, lli i)
{
    lli h=f[n-i];
    lli g=f[n]*(bpow(h,mod-2));
    return g%mod;
}
/*void sieve()
{
    for(lli i=2;i<=5000000;i++)
    {
        if(b[i]==0)
        {
        for(lli j=2;i*j<=5000000;j++)
        {
            b[i*j]=1;
        }
        }
    }
}*/
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    lli n;cin>>n;
    vector <lli> a(n);
    lli sum=0,ans=0;
    for(lli i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    for(lli i=0;i<n;i++)
    {
        sum=(sum-a[i]+mod)%mod;
        ans+=((sum)*a[i])%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 20368
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

int main(){
    int H, W;
    while(cin >> H >> W && H > 0){
        const int INF = 100000000;

        string grid[55];
        REP(y, H) cin >> grid[y];

        map< int, vector<pair<int, int>> > jewels;
        REP(y, H) REP(x, W) if(isupper(grid[y][x])) {
            jewels[ grid[y][x] ].push_back(make_pair(x, y));
        }

        static int dp[55][55][55][55] = {};
        memset(dp, -1, sizeof(dp));

        function<int(int, int, int, int)> dfs = [&](int sx, int sy, int gx, int gy){

            auto valid = [](int x, int l) { return 0 <= x && x < l; };
            if(!valid(sx, W) || !valid(sy, H)) return -INF;
            if(sx > gx || sy > gy) return -INF; // ???
            if(grid[sy][sx] == '#') return -INF;

            if(sx == gx && sy == gy) return 0;

            int& res = dp[sx][sy][gx][gy];
            if(res != -1) {
                return res;
            }

            res = -INF;
            auto update = [&](int val) { if(res < val) res = val; };

            update(dfs(sx + 1, sy, gx, gy));
            update(dfs(sx, sy + 1, gx, gy));

            if(islower(grid[sy][sx])){
                char c = grid[sy][sx] - 'a' + 'A';
                for(auto p : jewels[c]){
                    int ngx = p.first;
                    int ngy = p.second;
                    if((sx == ngx && sy + 1 == ngy) || (sy == ngy && sx + 1 == ngx)){
                        update(1 + dfs(ngx, ngy, gx, gy));
                    }else if(sx <= ngx && sy <= ngy && ngx <= gx && ngy <= gy){
                        update(1 + dfs(sx + 1, sy, ngx - 1, ngy) + dfs(ngx, ngy, gx, gy));
                        update(1 + dfs(sx + 1, sy, ngx, ngy - 1) + dfs(ngx, ngy, gx, gy));
                        update(1 + dfs(sx, sy + 1, ngx - 1, ngy) + dfs(ngx, ngy, gx, gy));
                        update(1 + dfs(sx, sy + 1, ngx, ngy - 1) + dfs(ngx, ngy, gx, gy));
                    }
                }
            }
            return res;
        };

        int res = dfs(0, 0, W - 1, H - 1);
        if(res < 0) res = -1;
        cout << res << endl;
    }
    return 0;
}

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

int main(){
  long n,ans=0;
  vector<vector<long>> a(10, vector<long>(10, 0));
  cin >>n;
  for(int i=1;i<=n;i++)a[to_string(i)[0]-'0'][i%10]++;
  rep(i,10) rep(j,10) ans+=a[i][j]*a[j][i];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 N;
    cin>>N;
    vector<int64> x(N);
    vector<int64> y(N);
    vector<int64> p(N*N);
    vector<int64> q(N*N);

    for (int64 i=0;i<N;i++){
        cin>>x[i]>>y[i];
    }
    
    int64 count=0;

    for (int64 i=0;i<N;i++){
        for(int64 j=i+1;j<N;j++){
            p[count]=x[i]-x[j];
            q[count]=y[i]-y[j];
            count++;
        }
    }

    int64 pq=0,costcut=0;

    // for(int64 i=0;i<count;i++){
    //     cout<<p[i]<<" "<<q[i]<<endl;
    // }
    
    for(int64 i=0;i<count;i++){
        pq=0;
        for(int64 j=0;j<count;j++){
            if((p[i]==p[j]&&q[i]==q[j])||(p[i]==(-1)*p[j]&&q[i]==(-1)*q[j])){
                pq++;

            }
        }
        // cout<<pq<<endl;
        costcut=max(costcut,pq);
    }

    cout<<N-costcut<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String input = in.readLine();
		String[] consonant = { "w", "", "k", "s", "t", "n", "h", "m", "y", "r"};
		for (int i = 0; i < input.length(); i++) {
			char value = input.charAt(i);
			switch (value) {
			case 'T':
				System.out.print("a");
				break;
			case 'L':
				System.out.print("i");
				break;
			case 'U':
				System.out.print("u");
				break;
			case 'R':
				System.out.print("e");
				break;
			case 'D':
				System.out.print("o");
				break;
			default:
				if (value == '0' && input.charAt(i + 1) == 'U') {
					System.out.print("nn");
					i++;
					break;
				}
				System.out.print(consonant[Integer.parseInt(value+"")]);
			}
		}
		System.out.println("");
	}
}

Measured memory_bytes: 17168
N = int(input())
A = list(map(int, input().split()))
 
def gcd(a,b):
  if b==0:
    return a
  else:
  	return gcd(b, a%b)

#L=[]
#R=[]
#L.append(0)
#R.append(0)
L=[0]*(N+1)
R=[0]*(N+1)
L[0]=0
R[0]=0

for i in range(N):
  #L.append(gcd(L[i],A[i]))
  #R.append(gcd(R[i],A[N-i-1]))
  L[i+1]=gcd(L[i],A[i])
  R[i+1]=gcd(R[i],A[N-i-1])

R.reverse()

#Res=[0]*N
res=0
for i in range(N):
  #Res.append(gcd(L[i],R[i+1]))
  res=max(res,gcd(L[i],R[i+1]))
  #Res[i]=gcd(L[i],R[i+1])
#print(max(Res))
print(res)

Measured memory_bytes: 14428
#include<stdio.h>
int getArea(int,int);
int getPerimeter(int,int);
int main(void)
{
  int a,b;
  scanf("%d%d",&a,&b);
  printf("%d %d\n",getArea(a,b),getPerimeter(a,b));
  return 0;
}
int getArea(int x,int y)
{
  return x*y;
}
int getPerimeter(int x,int y)
{
  return 2*(x+y);
}



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

int main(void){
  string s;
  cin >> s;
  string ans = "";
  int N = s.size();
  for(int i=0; i<N; i++){
    if(s[i] == '1'){
      ans += "1";
    }else if(s[i] == '0'){
      ans += '0';
    }else{
      int tmp = ans.size() -1 ;
      if(tmp < 0) continue;
      ans.erase(tmp, 1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 100000000000
long long int dp[3][100005],arr[3][100005],n;
long long int solve(long long int ch,long long int idx)
{
	if(dp[ch][idx]!=-1)
		return dp[ch][idx];
	if(idx==n)
	{
		dp[ch][idx]=arr[ch][idx];
		return dp[ch][idx];
	}
	long long int i,j,k,ans;
	if(ch==2)
	{
		i=solve(0,idx+1);
	    j=solve(1,idx+1);
	    dp[ch][idx]=arr[ch][idx]+max(i,j);
	}
	else if(ch==1)
	{
		i=solve(0,idx+1);
	    j=solve(2,idx+1);
	    dp[ch][idx]=arr[ch][idx]+max(i,j);
	} 
	else if(ch==0)
	{
		i=solve(2,idx+1);
	    j=solve(1,idx+1);
	    dp[ch][idx]=arr[ch][idx]+max(i,j);
	}
    return dp[ch][idx]; 
}
int main()
{
   long long int i,j,k,ans=0;
   scanf("%lld",&n);
   for(i=1;i<=n;i++)
   	dp[0][i]=dp[1][i]=dp[2][i]=-1;
   for(i=1;i<=n;i++)
   	scanf("%lld%lld%lld",&arr[0][i],&arr[1][i],&arr[2][i]);
   ans=max(solve(0,1),max(solve(1,1),solve(2,1)));
   /*for(i=1;i<=n;i++)
   	printf("%lld ",dp[i]);
   printf("\n");*/
   printf("%lld\n",ans);
}

Measured memory_bytes: 8064
/*
       ()       ()()()()     ()        ()       ()        ()        ()
      ()()      ()     ()    ()()      ()      ()()       ()()      ()
     ()  ()     ()      ()   ()  ()    ()     ()  ()      ()  ()    ()
    ()()()()    ()      ()   ()    ()  ()    ()()()()     ()    ()  ()
   ()      ()   ()     ()    ()      ()()   ()      ()    ()      ()()
  ()        ()  ()()()()     ()        ()  ()        ()   ()        ()

*/
#include <bits/stdc++.h>
#define MOD 1e9+7
#define SIZE (int)1e5+5
#define all(x) x.begin(),x.end()

#define si(i)  scanf("%d",&i)
#define sf(f)  scanf("%f",&f)
#define pi(i)  printf("%d",i)
#define pd(d)  printf("%lf",d)
#define deb(x) cout<<#x<<" is "<<x<<"\n";
#define lb     lower_bound
#define ub     upper_bound
#define pb     push_back

#define IOfast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int64_t exponentiation(int64_t base,int exp)
{
    if (exp == 0)
        return 1;

    if (exp == 1)
        return base;

    int64_t t = exponentiation(base, exp / 2);

    t = (t * t);

    if (exp % 2 == 0)
        return t;
    else
        return base * t;
}

vector<int> graph[SIZE];
int dp[SIZE];

int dfs(int node)
{
  if(graph[node].size() == 0)
    return 0;
  if(dp[node]!=-1)
    return dp[node];

  for(int i=0;i<graph[node].size();i++)
  {
    dp[node] = max( 1 + dfs(graph[node][i]) , dp[node]); 
  }  
  
  return dp[node];
}

int main()
{
  IOfast;
  

  int q=1;
  //cin>>q;
  memset(dp,-1,sizeof(dp));
  while(q--)
  {
    int n,m,u,v;
    cin>>n>>m;
    while(m--)
    {
      cin>>u>>v;
      graph[u].push_back(v);
    }
    
    int ans=0; 
    
    for(int i=1;i<=n;i++)
       ans = max(dfs(i),ans);
    
    cout<<ans;
  }
  
  return 0;
}


Measured memory_bytes: 8192
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

fn main() {
    input!(n: usize, ws: [i64; n]);

    let mut ans = 1 << 20;
    for i in 1..n {
        let mut left = 0;
        let mut right = 0;
        for j in 0..n {
            if j <= i {
                left += ws[j];
            } else {
                right += ws[j];
            }
        }
        ans = min(ans, (left - right).abs());
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
N = int(input())
A = list(map(int,input().split()))

cnt = [0 for i in range(N+1)]
for i in range(N):
    cnt[A[i]-1] += 1

ans = 0
ans_li = [0 for i in range(N+1)]
for i in range(N):
    ans += max(0,(cnt[i]*(cnt[i]-1))//2)
    ans_li[i] = max(0,(cnt[i]*(cnt[i]-1))//2)


for i in range(N):
    mm = cnt[A[i]-1]-1
    mm2 = ans-ans_li[A[i]-1]
    mm3 = max(0,mm*(mm-1)//2)
    # print(mm,mm2,mm3,mm2+mm3)
    print(mm2+mm3)


# print(cnt)






Measured memory_bytes: 26140