akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<map>
#include<queue>
#include<iterator>
#include<iomanip>
#include <string>
#include <algorithm>
#include <set>
#include <iomanip>
using namespace std;

map<int,int>mp1,mp2;
int main()
{
    int n;
    cin>>n;
    int arr[n+2],odd1=0,odd2=0,even1=0,even2=0,valo=0,vale=0;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        if(i&1)
        {
            mp1[arr[i]]++;
            if(mp1[arr[i]] >= odd1)
            {
                if(valo != arr[i])
                    odd2 = odd1;
                odd1 = mp1[arr[i]];
                valo = arr[i];
            }
            else if(mp1[arr[i]] > odd2 and valo != arr[i])
            {
                odd2 = mp1[arr[i]];
            }
        }
        else
        {
            mp2[arr[i]]++;
            if(mp2[arr[i]] >= even1 )
            {
                if(vale != arr[i])
                    even2 = even1;
                even1 = mp2[arr[i]];
                vale = arr[i];
            }
            else if(mp2[arr[i]] > even2 and vale != arr[i])
            {
                even2 = mp2[arr[i]];
            }
        }
    }

    if(valo != vale)
    {
        cout<<(n/2 - odd1) + (n/2 - even1)<<endl;
    }
    else
    {
        if(even2 == 0 and odd2 > 0)
            cout<<min((n/2-odd1) + n/2,(n/2-odd2) + (n/2 - even1));
        else if(even2 > 0 and odd2 == 0)
            cout<<min((n/2-even1) + n/2, (n/2-even2) + (n/2 - odd1));
        else if(even2 == 0 and odd2 == 0)
            cout<<min((n/2-even1)+n/2,(n/2-odd1) + n/2);
        else
            cout<<min((n/2-even1) + (n/2 - odd2), (n/2-even2) + (n/2 - odd1));
    }

    return 0;

}


Measured memory_bytes: 5376
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m, x = na()
ca = nan(n)

ans = inf
for i in range(2 ** n):
    und = [0] * m
    money = 0
    for j in range(n):
        if (i >> j) & 1:
            c = ca[j][0]
            money += c
            for k in range(m):
                und[k] += ca[j][k + 1]
    flag = True
    for j in range(m):
        if und[j] < x:
            flag = False
    if flag:
        ans = min(ans, money)

if ans == inf:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 74056
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int dx[] = {1, -1, 0, 0};
int dy[] = {0 ,0, 1, -1};

int main(){
    int a, b;
    cin >> a >> b;
    if(a > b){
        cout << a - 1 << endl;
    }
    else cout << a << endl;
}

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

int main() {
  int N; cin >> N;
  vector<int> a(N + 1); for (int i = 1; i <= N; i++) cin >> a[i];
  int ans = 0;
  for (int i = N; i >= 0; i--) {
    if (a[i] == 0) continue;
    if (a[a[i]] == i) {
      ans++;
      a[a[i]] = 0, a[i] = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		long total = 0;
		int count = 0;
		for (int i = 0; i < n; i++) {
			long a = arr[i];
			if (a > 2 * total) {
				count = 1;
			} else {
				count++;
			}
			total += a;
		}
		System.out.println(count);
	}
}


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

using namespace std;

typedef long long LL;
typedef pair<LL,LL> pii;
#define N 300000
#define P(x,y) make_pair(x,y)

LL n,m,x,y,now,f[N],g[N],ans;
bool vis[N];
vector<LL> a[N];
priority_queue<LL> pq1;
priority_queue<pii> pq2,pq3;
priority_queue<LL,vector<LL>,greater<LL> > fin1,fin2;

int main(){
	scanf("%lld%lld",&n,&m);
	for (LL i=1;i<=n;++i){
		scanf("%lld%lld",&x,&y);
		a[x].push_back(y);
	}
	for (LL i=1;i<=m;++i){
		sort(a[i].begin(),a[i].end(),greater<LL>());
		f[i]=a[i][0]+a[i][1];
		pq2.push(P(f[i],i));
		if (a[i].size()>2){
			g[i]=f[i]+a[i][2];
			pq3.push(P(g[i],i));
		}
	}
	for (LL i=1;i<=n;++i){
		LL t1=pq1.empty()?-1:pq1.top(),t2=pq2.empty()?-1:pq2.top().second;
		if (t1==-1&&t2==-1){puts("-1"); continue;}
		if (t2==-1||t1*2>f[t2]){
			++now; pq1.pop();
			fin1.push(t1);
			printf("%lld\n",ans+=t1);
		}
		else{
			if (now+1==i){
				LL tmp=0;
				if (t1>=0) tmp=ans+t1;
				if (!fin1.empty()) tmp=max(tmp,ans+f[t2]-fin1.top());
				if (!fin2.empty()&&!pq3.empty()) tmp=max(tmp,ans+pq3.top().first-fin2.top());
				if (!tmp) puts("-1");
				else printf("%lld\n",tmp);
			}
			else{
				now+=2; pq2.pop(); vis[t2]=1;
				for (;!pq3.empty()&&vis[pq3.top().second];pq3.pop());
				for (LL i=2;i<(LL)a[t2].size();++i) pq1.push(a[t2][i]);
				fin2.push(f[t2]);
				printf("%lld\n",ans+=f[t2]);
			}
		}
	}
	
	return 0;
}
			

Measured memory_bytes: 21224
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

int calcmin(vector<int> v[5])  {
  int min = v[0].size();
  for (int i = 1; i < 5; i++) {
    if (min > v[i].size()) min = v[i].size();
  }
  return min;
}

int main() {
  int h, tmp, score;
  bool flag;
  while (cin >> h, h) {
    vector<int> column[5];
    int memo[h][5];
    flag = true;
    score = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < 5; j++) {
        cin >> tmp;
        memo[i][j] = tmp;
      }
    }
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < 5; j++) {
        column[j].pb(memo[h-i-1][j]);
      }
    }
    while (flag) {
      flag = false;
      vector<int> del_col, del_row;
      for (int i = 0; i < calcmin(column); i++) {
        if (column[0][i] == column[1][i] && column[1][i] == column[2][i] && column[2][i] == column[3][i] && column[3][i] == column[4][i]) {
          score += 5*column[2][i], flag = true;
          del_row.pb(i), del_row.pb(i), del_row.pb(i), del_row.pb(i), del_row.pb(i);
          del_col.pb(0), del_col.pb(1), del_col.pb(2), del_col.pb(3), del_col.pb(4);
        } else if (column[0][i] == column[1][i] && column[1][i] == column[2][i] && column[2][i] == column[3][i]) {
          score += 4*column[2][i], flag = true;
          del_row.pb(i), del_row.pb(i), del_row.pb(i), del_row.pb(i);
          del_col.pb(0), del_col.pb(1), del_col.pb(2), del_col.pb(3);
        } else if (column[1][i] == column[2][i] && column[2][i] == column[3][i] && column[3][i] == column[4][i]) {
          score += 4*column[2][i], flag = true;
          del_row.pb(i), del_row.pb(i), del_row.pb(i), del_row.pb(i);
          del_col.pb(1), del_col.pb(2), del_col.pb(3), del_col.pb(4);
        } else if (column[0][i] == column[1][i] && column[1][i] == column[2][i]) {
          score += 3*column[2][i], flag = true;
          del_row.pb(i), del_row.pb(i), del_row.pb(i);
          del_col.pb(0), del_col.pb(1), del_col.pb(2);
        } else if (column[1][i] == column[2][i] && column[2][i] == column[3][i]) {
          score += 3*column[2][i], flag = true;
          del_row.pb(i), del_row.pb(i), del_row.pb(i);
          del_col.pb(1), del_col.pb(2), del_col.pb(3);
        } else if (column[2][i] == column[3][i] && column[3][i] == column[4][i]) {
          score += 3*column[2][i], flag = true;
          del_row.pb(i), del_row.pb(i), del_row.pb(i);
          del_col.pb(2), del_col.pb(3), del_col.pb(4);
        }
      }
      for (int i = del_col.size()-1; i >= 0; i--) {
        column[del_col[i]].erase(column[del_col[i]].begin()+del_row[i]);
      }
    }
    cout << score << el;
  }
}

Measured memory_bytes: 1220
s=list(input())
#print(s)
count=0
for i in range(len(s)//2):
    if s[i]!=s[-(i+1)]:
        #print(s[i],s[-(i+1)])
        s[-(i+1)]=s[i]
        count+=1
#print("".join(s))
print(count)

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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b) cout << "YES" << endl;
    else cout << "NO" << endl;

  }


  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main()
{
  int i,j,n,alt,cnt=0,mini;

  scanf("%d",&n);

  int a[n];

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

  for( i = 0 ; i < n ; i++)
    {
      mini = i;
      
      for(j = i ; j < n ; j++)
	{
	  if(a[j] < a[mini])
	    {
	      mini = j;
	    }
	}
      if(i != mini)
	{
      alt = a[i];
      a[i] = a[mini];
      a[mini] = alt;
      cnt +=1;
	}
    }
 for(i = 0 ; i < n ; i++)
    {
      printf("%d",a[i]);
      if(i != n-1) printf(" ");
      else printf("\n");
    }
  printf("%d\n",cnt);
  
  return 0;

}



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

int main()
{
  double v;

  while (~scanf("%lf", &v)){
    int i = 1;
    while (1){
      if ((v / 9.8) * (v / 9.8) * 4.9 <= 5 * i - 5){
        printf("%d\n", i);
        break;
      }
      i++;
    }
  }

  return (0);
}

Measured memory_bytes: 1212
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B_GraphPartition solver = new B_GraphPartition();
        solver.solve(1, in, out);
        out.close();
    }

    static class B_GraphPartition {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            boolean[][] g = new boolean[n][n];
            for (int i = 0; i < n; i++) {
                char[] s = in.next().toCharArray();
                for (int j = 0; j < n; j++) {
                    g[i][j] = s[j] == '1';
                }
            }

            int ans = -1;
            for (int s = 0; s < n; s++) {
                int[] q = new int[n];
                int qt = 0;
                int qh = 1;
                q[0] = s;
                int[] d = new int[n];
                Arrays.fill(d, n);
                d[s] = 0;
                boolean ok = true;
                while (qt < qh) {
                    int i = q[qt++];
                    for (int j = 0; j < n; j++) {
                        if (!g[i][j]) {
                            continue;
                        }
                        if (d[j] > 1 + d[i]) {
                            d[j] = 1 + d[i];
                            q[qh++] = j;
                        }
                        if (d[j] == d[i]) {
                            ok = false;
                        }
                    }
                }
                if (ok) {
                    ans = Math.max(ans, 1 + d[q[qh - 1]]);
                }
            }

            out.println(ans);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 24592
let input = require('fs').readFileSync( '/dev/stdin', 'utf8' );
let arr = input.split('\n');
for (let i = 0; i < arr.length; i ++) {
    let Arr = arr[i].split(' ').map(Number);
    let H = Arr[0];
    let W = Arr[1];
    if (H === 0 && W === 0) break;
    let str = '';
    for (let k = 0; k < H; k ++) {
        for (let j = 0; j < W; j ++) {
            if ( k % 2 === 0) {
                if (j % 2 === 0) str += '#';
                else str += '.';
            } else {
                if (j % 2 === 0) str += '.';
                else str += '#';
            }
        }
        str += '\n';
    }
    console.log(str);
}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int L = a + b;
    int R = c + d;
    if(L > R){
        cout << "Left" << endl;
    }else if(L < R){
        cout << "Right" << endl;
    }else {
        cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 256
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a, b, c, d = map(int, input().split())

num = b - a + 1
divc_b = b // c
divd_b = b // d
divcd_b = b // (lcm(c, d))
divc_a = (a-1) // c
divd_a = (a-1) // d
divcd_a = (a-1) // (lcm(c, d))

print(num - (divc_b + divd_b - divcd_b) + (divc_a + divd_a - divcd_a))

Measured memory_bytes: 5076
k,n=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*(n-1)
b= [x - y for (x, y) in zip(a[1:],a[:-1])]
c=0
c=k+a[0]-a[n-1]
m=max(b)
M=max(m,c)
print(k-M)

Measured memory_bytes: 25840
#include <stdio.h>

int gcd(int p, int q){
  if ((p % q) == 0)
    return q;
  return gcd(q, p%q);
}

int main(void){
  int ans = 0;
  int k;
  int a, b, c;
  scanf("%d", &k);
  for(a = 1; a <= k; a++){
    for(b = 1; b <= k; b++){
      for(c = 1; c <= k; c++){
        ans += gcd(gcd(a, b), c);
      }
    }
  }
  printf("%d\n", ans);
}

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

using ll=long long;
int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vector<ll> v(50);
    for(int i=0;i<50;i++){
        ll zero=0;
        for(int j=0;j<n;j++){
            zero+=(a[j]>>i)&1;
        }
        v[i]=zero;
    }
    function<ll(ll)> dfs=[&](ll i){
        if(i==0){
            if(k&1){
                return max(v[i],n-v[i]);
            }
            else{
                return v[i];
            }
        }
        else{
            if((k>>i)&1){
                ll sum=0;
                for(int j=i-1;j>=0;j--){
                    sum+=(max(v[j],n-v[j])<<j);
                }
                return max(dfs(i-1)+((n-v[i])<<i),sum+(v[i]<<i));
            }
            else{
                return dfs(i-1)+(v[i]<<i);
            }
        }
    };
    cout<<dfs(49)<<endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace AtcoderExpress
{


    class Program2
    {

        static void Main(string[] args)
        {
            var NZW = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = NZW[0];
            var Z = NZW[1];
            var W = NZW[2];

            var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();


            if(N == 1)
            {
                Console.WriteLine(Abs(W-A[0]));
            }
            else
            {
                var Max1 = Abs(W - A[N - 1]);
                var Max2 = Abs(A[N - 2] - A[N - 1]);
                var Max = Math.Max(Max1, Max2);
                Console.WriteLine(Max);
            }
            
        }


    }
}


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

int main(){
  vector<int> v,u;
  int N,i,absm=0,p=0,flag=0,count=0,M=2e-6,m=2e6;
  int Mp,mp;
  cin >> N;
  int a[N];
  for(i=0;i<N;i++){
    cin >> a[i];
    if(a[i]>M){
      M=a[i];
      Mp=i;
    }
    if(a[i]<m){
      m=a[i];
      mp=i;
    }
  }
  if(m<0 && M>=0){
    if(abs(M)-abs(m)>=0){
      absm = M;
      p = Mp;
      flag = 1;
    }
    else{
      absm = m;
      p = mp;
      flag = 0;
    }
    for(i=0;i<N;i++){
      if(a[i]==absm)continue;
      else {
        a[i]+=absm;
        v.push_back(p+1);
        u.push_back(i+1);
        count++;
      }
    }
  }
  if(m>=0 || flag==1){
    for(i=0;i<N-1;i++){
      if(a[i]<=a[i+1])continue;
      else{
          a[i+1]+=a[i];
          v.push_back(i+1);
          u.push_back(i+2);
          count++;
      }
    }
  }else if(M<0 || flag == 0){
    for(i=N-1;i>0;i--){
      if(a[i]<a[i-1]){
        a[i-1]+=a[i];
        v.push_back(i+1);
        u.push_back(i);
        count++;
      }
    }
  }
  cout << count << endl;
  if(!(v.empty())){
    for(i=0;i<v.size();i++){
      cout << v[i] << " " << u[i] << endl;
    }
  }
  //for(i=0;i<N;i++)cout << a[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

ll n,m,b[200020],S[200020],C[200020];

void solve(){
    cin >> n >> m;
    rep(i,n){
        int a;
        cin >> a;
        b[a]++;
    }
    rep(i,200011){
        S[i+1]+=S[i]+b[i+1];
        C[i+1]+=C[i]+ll(i+1)*b[i+1];
    }
    int ng=0,ok=200010;
    while(ok-ng>1){
        int mid=(ng+ok)/2;ll res=0;
        rep(i,200001){
            res+=b[i]*(S[200010]-S[max(0,mid-i-1)]);
        }
        if (res<=m) ok=mid;
        else ng=mid;
    }
    //cout << ok << endl;
    ll T=0;
    rep(i,200001){
        T+=b[i]*(S[200010]-S[max(0,ok-i-1)]);
    }
    //cout << T << endl;
    ll ans=0;
    ans+=(ok-1)*(m-T);
    rep(i,200001){
        ans+=(ll)i*b[i]*(S[200010]-S[max(0,ok-i-1)]);
        ans+=b[i]*(C[200010]-C[max(0,ok-i-1)]);
    }

    cout << ans << endl;
}

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

Measured memory_bytes: 4352
#include <stdio.h>

char ch[30];

int main(void)
{
    int i;
    char tmp[105];

    scanf("%s", tmp);
    for (i = 0; tmp[i]; i++)
    {
        ch[tmp[i]-'a']++;
    }

    for (i = 0; i < 26; i++)
    {
        if (ch[i] & 0x1) break;
    }

    if (i < 26) printf("No\n");
    else printf("Yes\n");
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin>>n;
  vector<pair<long long,long long>> prime;
  for(long long i=2;i*i<=n;i++){
    long long x=0;
    while(n%i==0){
      n/=i;
      x++;
    }
    auto a=make_pair(i,x);
    prime.push_back(a);
  }
  auto a=make_pair(n,1);
  if(n!=1)prime.push_back(a);
  int ans=0;
  for(auto p:prime){
    int x=p.second;
    int y=1;
    while(y<=x){
      x-=y;
      y++;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n, q);
  in(string, s);
  vector<int> cum(n);
  for (int i = 1; i < s.size(); ++i) {
    cum[i] = cum[i - 1];
    if (s[i - 1] == 'A' && s[i] == 'C') ++cum[i];
  }
  while (q--) {
    in(int, l, r);
    out(cum[r - 1] - cum[l - 1]);
  }
}


Measured memory_bytes: 3816
from sys import stdin
def input():
    return stdin.readline().strip()

n = int(input())

def adjust(x, y):
    if x % y == 0:
        return x // y
    else:
        return x//y + 1

ta, ao = 1, 1
for _ in range(n):
    t, a = map(int, input().split())
    mul = max([adjust(ta, t), adjust(ao, a)])
    ta = mul * t
    ao = mul * a

print(ta + ao)

Measured memory_bytes: 66156
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  for(int i=0; i<n; i++){
    cin>>s.at(i);
  }
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  cout<<s.size()<<endl;
  return 0;
}

Measured memory_bytes: 9524
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  string s;cin >> s;
  int n = s.size();
  string t = s.substr(0,( n - 1 ) / 2 );
  string u = s.substr(( n + 1 ) / 2 , ( n - 1 ) / 2 );

  string sr = s, tr = t, ur = u;
  reverse(sr.begin(), sr.end());
  reverse(tr.begin(), tr.end());
  reverse(ur.begin(), ur.end());  

  if(s == sr && t == tr && u == ur) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 256
a, b, x = map(int, input().split())
v = a**2 * b
import math
if x >= v/2:
    ans = math.degrees(math.atan(2 * (v - x) / a**3))
else:
    ans = math.degrees(math.atan(a * b**2 / (2 * x)))
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <set>
using namespace std;

int main(void)
{
    int N,x;
    scanf("%d",&N);
    set<int> s;
    while(N--)
    {
        scanf("%d",&x);
        if(s.count(x)==0)
            s.insert(x);
        else
            s.erase(x);
    }
    printf("%d\n",s.size());
    return 0;
}


Measured memory_bytes: 4864
package main

import (
	"fmt"
)

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	var k int
	fmt.Scan(&k)
	ans := 0
	for a := 1; a <= k; a++ {
		for b := 1; b <= k; b++ {
			for c := 1; c <= k; c++ {
				ans += gcd(gcd(a, b), c)
			}
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(3 * n);
    rep(i, 0, 3 * n){
        cin >> a[i];
    }
    priority_queue<int, vector<int>, greater<int> > q;
    int sum = 0;
    rep(i, 0, n){
        q.push(a[i]);
        sum += a[i];
    }
    vector<int> as(3 * n);
    as[n - 1] = sum;
    rep(i, n, 2 * n){
        q.push(a[i]);
        sum += a[i];
        int tmp = q.top(); q.pop();
        sum -= tmp;
        as[i] = max(as[i - 1], sum);
    }
    priority_queue<int> qq;
    sum = 0;
    rep(i, 2 * n, 3 * n){
        qq.push(a[i]);
        sum += a[i];
    }
    vector<int> bs(3 * n);
    bs[2 * n] = sum;
    repb(i, 2 * n - 1, n){
        qq.push(a[i]);
        sum += a[i];
        int tmp = qq.top(); qq.pop();
        sum -= tmp;
        bs[i] = min(bs[i + 1], sum);
    }
    int ans = -1e18;
    rep(i, n - 1, 2 * n){
        chmax(ans, as[i] - bs[i + 1]);
    }
    cout << ans << endl;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

vector<i64> dp;
vector<vector<i64>> g;

i64 dfs(i64 i) {
    if (dp[i] != -1) return dp[i];

    i64 res = 0;
    for (auto& e : g[i]) res = max(res, dfs(e) + 1);
    return dp[i] = res;
}

void solve() {
    i64 n, m;
    cin >> n >> m;

    g.resize(n);
    for (i64 i = 0; i < m; i++) {
        i64 x, y;
        cin >> x >> y, x--, y--;
        g[x].emplace_back(y);
    }

    dp.resize(n, -1);
    i64 ans = 0;
    for (i64 i = 0; i < n; i++) ans = max(ans, dfs(i));
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

typedef long long ll;
typedef unsigned int uint;

template <class T> inline T max(const T& a, const T& b) { return a > b ? a : b; }
template <class T> inline T min(const T& a, const T& b) { return a < b ? a : b; }
template <class T> inline void cmax(T& a, const T& b) { if (b > a) a = b; }
template <class T> inline void cmin(T& a, const T& b) { if (b < a) a = b; }

namespace io {
const int maxBuff = 1 << 15;
char b[maxBuff], *S = b, *T = b;
#define gc (S == T && (T = (S = b) + fread(b, 1, maxBuff, stdin), S == T) ? 0 : *S++)

inline int in() {
    int ans = 0, neg = 0; char ch = gc;
    while (ch < '0' || ch > '9') { if (ch == '-') neg = 1; ch = gc; }
    do { ans = ans * 10 + ch - '0'; ch = gc; } while (ch >= '0' && ch <= '9');
    return neg ? -ans : ans;
}
} // namespace io

const int N = 1e5 + 5;
const ll inf = 1e16;

struct node { int l, r, c; } a[N];
int n, m;
ll T[N * 4], lazy[N * 4];

inline bool cmp(const node& a, const node& b) {
    if (a.l != b.l) 
        return a.l < b.l; 
    if (a.r != b.r) 
        return a.r < b.r;
    return a.c < b.c;
}

void build(int k, int l, int r) {
    T[k] = lazy[k] = inf;
    if (l == r)
        return;
    int mid = (l + r) / 2;
    build(k * 2, l, mid);
    build(k * 2 + 1, mid + 1, r);
}

inline void pushdown(int k) {
    cmin(T[k * 2], lazy[k]), cmin(lazy[k * 2], lazy[k]);
    cmin(T[k * 2 + 1], lazy[k]), cmin(lazy[k * 2 + 1], lazy[k]);
    lazy[k] = inf;
}

void modify(int k, int l, int r, int x, int y, ll v) {
    if (x <= l && r <= y) {
        cmin(T[k], v), cmin(lazy[k], v);
        return;
    }
    pushdown(k);
    int mid = (l + r) / 2;
    if (x <= mid)
        modify(k * 2, l, mid, x, y, v);
    if (y > mid)
        modify(k * 2 + 1, mid + 1, r, x, y, v);
    T[k] = min(T[k * 2], T[k * 2 + 1]);
}

ll query(int k, int l, int r, int x, int y) {
    if (x <= l && r <= y)
        return T[k];
    pushdown(k);
    int mid = (l + r) / 2;
    ll ans = inf;
    if (x <= mid)
        cmin(ans, query(k * 2, l, mid, x, y));
    if (y > mid)
        cmin(ans, query(k * 2 + 1, mid + 1, r, x, y));
    return ans;
}

void debug(int x) {
    printf("%lld", query(1, 1, n, x, x));
}

int main() {
    using io ::in;
    n = in(), m = in();
    for (int i = 1; i <= m; ++i)
        a[i].l = in(), a[i].r = in(), a[i].c = in();
    std ::sort(a + 1, a + 1 + m, cmp);
    build(1, 1, n);
    //for (int i = 1; i <= n; ++i)
    //    printf("%lld ", T[i]); puts("");
    modify(1, 1, n, 1, 1, 0);
    //for (int i = 1; i <= n; ++i)
    //    debug(i), printf(" "); puts("");
    for (int i = 1; i <= m; ++i) {
        ll cur = query(1, 1, n, a[i].l, a[i].r) + a[i].c;
        //printf("%d %d %lld\n", a[i].l, a[i].r, cur);
        modify(1, 1, n, a[i].l, a[i].r, cur);
    }
    //for (int i = 1; i <= n; ++i)
    //    debug(i), printf(" "); puts("");
    ll ans = query(1, 1, n, n, n);
    if (ans >= inf) 
        puts("-1");
    else
        printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 7552
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf 1000000000000000000

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n){
        cin>>a[i];
    }
    int s=0;
    int ans=0;
    rep(i,n){
        if(a[i]==0){
            ans+=s/2;
            s=0;
        }
        else{
            s+=a[i];
        }
    }
    ans+=s/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(){
  int n;
  cin >> n;
  if(n<1200){
    cout << "ABC" << endl;
  }else if(n<2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
}
  

Measured memory_bytes: 3604
#include<stdio.h>
#define MAX 100
#define INFTY 200000
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
int n,T[MAX][MAX];
 
void dijkstra(){
  int minv,i,v,u;
  int d[MAX],color[MAX];
 
  for(i=0;i<n;i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }
 
  d[0] = 0;
  color[0] = GRAY;
  
  while(1){
    minv = INFTY;
    u = -1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    
    if(u == -1)break;
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && T[u][v] != INFTY){
	if(d[v]>d[u]+T[u][v]){
	  d[v] = d[u] + T[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  
  for(i=0;i<n;i++){
    printf("%d",i);
    printf(" ");
    d[i]= (d[i] == INFTY) ? -1 : d[i];
    printf("%d\n",d[i]);
  }
}
 
int main(){
  int i,j,k,c,u,v;
 
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      T[i][j] = INFTY;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      T[u][v] = c;
    }
  }
  
  dijkstra();
 
  return 0;
}

Measured memory_bytes: 636
#include <stdio.h>

int main ()
{
	int i, x, y;
	
	while(1) {
		scanf ("%d %d", &x, &y);
		if( x == 0 && y == 0 ) break;
		else if ( x < y ) {
			printf ( "%d %d\n", x, y );
		}else {
			printf ( "%d %d\n", y, x );
		}
	}
	
	return 0;
}


Measured memory_bytes: 1916
def main():
    n = int(input())
    dic = {}
    for i in range(10):
        for j in range(10):
            dic[(i, j)] = 0
    for num in range(1, n+1):
        str_num = str(num)
        i = int(str_num[0])
        j = int(str_num[-1])
        dic[(i, j)] += 1

    total = 0
    for i in range(10):
        for j in range(10):
            total += dic[(i, j)] * dic[(j, i)]
    print(total)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=25;
const int mod=1e9+7;
int n,m;
int f[Maxn][Maxn];
int pw2[Maxn*Maxn];
int dp[Maxn][65536];
bool bad[65536];
void Add(int &x,int y){
	x+=y;
	if (x>=mod) x-=mod;
}
int main(){
	pw2[0]=1;
	for (int i=1;i<Maxn*Maxn;i++){
		pw2[i]=2*pw2[i-1]%mod;
	}
	scanf("%d %d",&n,&m);
	for (int i=0;i<m;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		u--;v--;f[u][v]=1;
	}
	for (int i=0;i<(1<<n);i++){
		if ((i&1) && !(i&2)) bad[i]=1;
		if ((i&2) && !(i&1)) bad[i]=1;
		if (!bad[i]){
			int cnt=0;
			for (int j=0;j<n;j++){
				if (i>>j&1){
					for (int k=0;k<n;k++){
						if (!(i>>k&1)){
							if (f[j][k])cnt++;
						}
					}
				}
			}
			cnt=pw2[cnt];
			for (int j=0;j<n;j++){
				if (!(i>>j&1)){
					int t=0;
					for (int k=0;k<n;k++){
						if ((i>>k&1)){
							if (f[j][k])t++;
						}
					}
					t=pw2[t]-1;
					cnt=1ll*cnt*t%mod;
				}
			}
			dp[0][i]=cnt;
		//	cout<<i<<' '<<cnt<<endl;
		}
	}
	int Al=(1<<n)-1;
	for (int i=0;i<n;i++){
		for (int t=0;t<(1<<n);t++){
			if (dp[i][t]){
				int rem=Al^t;
				int tmp=rem;
				while (tmp){
					if (!bad[tmp]){
						int R=rem^tmp;
						int cnt=1;
						for (int j=0;j<n;j++){
							if (tmp>>j&1){
								for (int k=0;k<n;k++){
									if(R>>k&1){
										if (f[j][k]) cnt=cnt*2%mod;
									}
								}
							}
						}
						for (int j=0;j<n;j++){
							if (R>>j&1){
								int cc=0;
								for (int k=0;k<n;k++){
									if(tmp>>k&1){
										if (f[j][k]) cc++;
									}
								}
								cc=pw2[cc]-1;
								cnt=1ll*cnt*cc%mod;
							}
						}
						Add(dp[i+1][t^tmp],1ll*dp[i][t]*cnt%mod);
					}
					tmp=(tmp-1)&rem;
				}
			}
		}
	}
	int res=0;
	for (int i=0;i<=n;i++){
		Add(res,dp[i][Al]);
	}
	int vv=pw2[m];
	res=vv-res+mod;res%=mod;
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 2688
N = int(input())
S = input()
S_ = []

for i in range(len(S)-1):
    if i == len(S)-2 and S[i] != S[i+1]:
        S_.append(S[i])
        S_.append(S[i+1])
    elif i == len(S)-2 and S[i] == S[i+1]:
        S_.append(S[i])
    elif S[i] != S[i+1]:
        S_.append(S[i])
if len(S_) == 0:
    print('1')
else:
    print(len(S_))
    


Measured memory_bytes: 3956
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String s = sc.next();
			System.out.println((s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  int a;
  cin >> a >> s;
  bool ans = false;
  if(a % 2 == 0){
  		if(s.substr(0,a/2) == s.substr(a/2,a/2))ans  = true;
  }
  if(ans)cout << "Yes" <<endl;
  else cout << "No" <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100
#define INF 100000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];
//M：隣接行列

int prim(){
  int u, min, sum = 0;
  int d[MAX], p[MAX], color[MAX];
  //d：重みが最小の変の記録, p：MSTにおける最小の親の記録
  //color：訪問状態の記録
  int i, j;

  //初期化
  for(i = 0; i < n; i++){
    d[i] = INF;
    p[i] =  -1;
    color[i] = WHITE;
  }
  d[0] = 0;

  while(1){
    min = INF;
    u = -1;

    //最小経路の保存
    for(i = 0; i < n; i++){
      if(min > d[i] && color[i] != BLACK){
        u = i;
        min = d[i];
      }
    }

    if(u == -1) break;
    color[u] = BLACK;

    for(j = 0; j < n; j++){
      if(color[j] != BLACK && M[u][j] != INF){
        if(d[j] > M[u][j]){
          d[j] = M[u][j];
          p[j] = u;
          color[j] = GRAY;
        }
      }
    }
  }
  for(i = 0; i < n; i++){
    if(p[i] != -1){
      sum += M[i][p[i]];
    }
  }

  return sum;
}

int main(){
  int i, j, ans;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d",&M[i][j]);
      if(M[i][j] == -1) M[i][j] = INF;
    }
  }

  ans = prim();
  printf("%d\n",ans);

  return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<long> a(N, 0);
    long in[N];
    for (int i = 0; i < N; i++)
    {
        int b;
        cin >> b;
        b--;
        in[i] = b;
        a[b]++;
    }

    long total = 0;
    for (int i = 0; i < N; i++)
    {
        if(a[i] >= 2) total += a[i] * (a[i] - 1) / 2;
    }

    vector<long> ans(N, 0);
    for (int i = 0; i < N; i++)
    {
        ans[i] = total - a[in[i]] + 1;
    }

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


}

Measured memory_bytes: 7296
n = int(input())
A = list(map(int, input().split()))
ans = 1
max = 10**18
if 0 in A:
    print(0)
    exit(0)
for i in range(n):
    ans *= A[i]
    if (ans > max):
        print(-1)
        exit(0)
print(ans)

Measured memory_bytes: 21572
#coding: utf-8

N, M = map(int, input().split())
H = list(map(int, input().split()))
nodes = [set() for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    nodes[a-1].add(b-1)
    nodes[b-1].add(a-1)

count = 0
for i in range(N):
    height = H[i]
    if all(map(lambda x: H[x] < height, nodes[i])):
        count += 1
print(count)
    

Measured memory_bytes: 45168
#include <stdio.h>

int main()
{
	char str[100001];
	scanf("%s", str);
	int i = 0;
	int count = 0;
	while (str[i])
	{
		if (str[i] == str[i + 1])
		{
			if(str[i] == '0')
			{
				count++;
				str[i + 1]++;
			}
			else if (str[i] == '1')
			{
				count++;
				str[i + 1]--;
			}
		}
		i++;
	}
	printf("%d\n", count);
	return (0);
}


Measured memory_bytes: 256
def Call(n):
    s = ''
    for x in range(1,n+1):
        i = int(x)
        if i%3 == 0:
            temp = ' ' + str(x)
            s += temp
        elif i%10 == 3:
            temp = ' ' + str(x)
            s += temp
        else:
            i = int(i/10)
            while i:
                if i%10 == 3:
                    temp = ' ' + str(x)
                    s += temp
                    break
                i = int(i/10)
    return s


def main():
    n = int(input())
    print(Call(n))

if __name__ == "__main__":
    main()


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

const int mo=998244353;
ll modpow(ll a, ll n = mo-2) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}


template<class T> vector<T> fft(vector<T> v, bool rev=false) {
	int n=v.size(),i,j,m;
	
	for(i=0,j=1;j<n-1;j++) {
		for(int k=n>>1;k>(i^=k);k>>=1);
		if(i>j) swap(v[i],v[j]);
	}
	for(int m=2; m<=n; m*=2) {
		T wn=modpow(5,(mo-1)/m);
		if(rev) wn=modpow(wn);
		for(i=0;i<n;i+=m) {
			T w=1;
			for(int j1=i,j2=i+m/2;j2<i+m;j1++,j2++) {
				T t1=v[j1],t2=(ll)w*v[j2]%mo;
				v[j1]=t1+t2;
				v[j2]=t1+mo-t2;
				while(v[j1]>=mo) v[j1]-=mo;
				while(v[j2]>=mo) v[j2]-=mo;
				w=(ll)w*wn%mo;
			}
		}
	}
	if(rev) {
		ll rv = modpow(n);
		FOR(i,n) v[i]=(ll)v[i]*rv%mo;
	}
	return v;
}

template<class T> vector<T> MultPoly(vector<T> P,vector<T> Q,bool resize=false) {
	if(resize) {
		int maxind=0,pi=0,qi=0,i;
		int s=2;
		FOR(i,P.size()) if(norm(P[i])) pi=i;
		FOR(i,Q.size()) if(norm(Q[i])) qi=i;
		maxind=pi+qi+1;
		while(s*2<maxind) s*=2;
		P.resize(s*2);Q.resize(s*2);
	}
	P=fft(P), Q=fft(Q);
	for(int i=0;i<P.size();i++) P[i]=(ll)P[i]*Q[i]%mo;
	return fft(P,true);
}

int N,M;
vector<ll> A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N) cin>>x, A.push_back(x);
	FOR(i,M) cin>>y, B.push_back(y);
	A.resize(1<<20);
	B.resize(1<<20);
	auto C=MultPoly(A,B);
	FOR(i,N+M-1) cout<<C[i]<<" ";
	cout<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 44388
# -*- coding: utf-8 -*-
"""
Created on Sat Sep  8 11:35:12 2018

@author: maezawa
"""

n, m = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))

ax = 0
for i in range(1,n):
    ax += (n-i)*i*(x[i]-x[i-1])%(10**9+7)

ay = 0
for j in range(1,m):
    ay += (m-j)*j*(y[j]-y[j-1])%(10**9+7)
    
print(ax*ay%(10**9+7))

Measured memory_bytes: 18556
#include <iostream>

using namespace std;

int dat[401];

bool isACGT(char c) {
	return c == 'A' || c == 'G' || c == 'C' || c == 'T';
}

int main() {
	string s;
	cin >> s;
	int l = s.length();
	int maxlen = 0;
	for (int i = 0; i < l; i++){
		int len = 0;
		while (isACGT(s[i])) {
			i++;
			len++;
			if (i >= l)break;
		}
		if (len > maxlen)maxlen = len;
	}
	cout << maxlen << endl;
}

Measured memory_bytes: 3656
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int NM_MAX = 802;

int n, m, k;

bool ma[NM_MAX][NM_MAX];

struct Cell
{
    int a, b;
};

Cell S;

int dl[] = {-1, 0, 1, 0}, dc[] = {0, 1, 0, -1};

bool inside (int a, int b)
{
    return (1 <= a && a <= n && 1 <= b && b <= m);
}

queue <Cell> q;

int dist[NM_MAX][NM_MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++)
    {
        string s;
        cin >> s;
        for(int j = 1; j <= m; j++)
        {
            ma[i][j] = (s[j - 1] == '#');
            if(s[j - 1] == 'S')
                S = Cell{i, j};
        }
    }
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            dist[i][j] = -1;
    q.push(S);
    dist[S.a][S.b] = 0;
    while(!q.empty())
    {
        Cell u = q.front();
        q.pop();
        for(int d = 0; d < 4; d++)
        {
            Cell v = Cell{u.a + dl[d], u.b + dc[d]};
            if(!inside(v.a, v.b) || ma[v.a][v.b] == true || dist[v.a][v.b] != -1)
                continue;
            q.push(v);
            dist[v.a][v.b] = dist[u.a][u.b] + 1;
        }
    }
    int ans = INT_MAX;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            if(dist[i][j] != -1 && dist[i][j] <= k)
                ans = min(ans, (min({i - 1, n - i, j - 1, m - j}) + k - 1) / k + 1);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6828
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, y int
	fmt.Scan(&n, &y)

	var res = abc085c(n, y)
	fmt.Println(res)
}

func abc085c(n, y int) string {
	var res = ""

	for tenThous := 0; tenThous <= n; tenThous++ {
		for fiveThous := 0; fiveThous <= n; fiveThous++ {
			if tenThous+fiveThous > n {
				break
			}
			var thous = n - (tenThous + fiveThous)
			if tenThous+fiveThous+thous == n && tenThous*10000+fiveThous*5000+thous*1000 == y {
				res = strconv.Itoa(tenThous) + " " + strconv.Itoa(fiveThous) + " " + strconv.Itoa(thous)
				return res

			}
		}
	}
	return "-1 -1 -1"

}


Measured memory_bytes: 512
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
N = ri()
print(N * (N - 1) // 2)

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


using namespace std;
//using namespace boost::multiprecision; 

#define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define TC int t; cin >> t; while(t--)
#define li long int
#define ll long long
#define ull unsigned long long 
#define Vec(x) vector <x>
#define Pai(x,y) pair <x,y>
#define Map(x,y) map <x,y>
#define UMap(x,y) unordered_map <x,y>
#define Set(x) set <x>
#define Sta(x) stack <x>
#define Qu(x) queue <x>
#define DQ(x) deque(x)
#define PriorQ(x)	priority_queue <x>
#define bg begin()
#define ed end()
#define sz size()
#define ct(x) count(x)
#define len length()
#define F first
#define S second
#define Makep make_pair
#define ins(x) insert(x)
#define ers(x) erase(x)
#define endl "\n";
#define MOD 1000000007
#define PI 2*acos(0.0)
#define clr() clear()
#define fori0(n) for(int i=0;i<n;i++)
#define foriab(a,b) for(int i=a;i<b;i++)
#define mem0(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,1,sizeof(x))
#define autoit(x) for(auto it=x.beg;it!=x.ed;it++)
#define count0(x) __builtin_popcount(x)
#define ret return 
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

const ll Inf=1e9+5;



namespace funset{
bool checkvow(char x){
	return ((0x208222)>>(x&(0x1f)))&1;
	}
ll highpow2(ll x){
	return (x&~(x-1));
	}
bool chk2(ll x){
		return (x&(x-1));
	}
ll powMOD(ll a, ll b){
    ll res=1;
    a%=MOD;
    while(b){
        if(b&1){
            res=res*a%MOD;
        }
        a=a*a%MOD;
        b>>=1;
     }
    return res;
    }
ll powwMOD(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1){
            res=res*a;
         }
            a=a*a;
            b>>=1;
        }
    return res;
    }     	
}

vector <ll> vis(27,0);

using namespace funset;

string s;

ll fact(ll n){
    if(n<=1)
        return 1;
    return n*fact(n-1);
}

bool compare( pair <string,ll> &a, pair <string,ll> &b){
	return (a.S>b.S)||(a.S==b.S && a.F < b.F);	 
}
void solve(){
	ll n;
	cin >> n;
	ll a[n];
	for(ll &x:a)
		cin >> x;
	sort(a,a+n);
	ll ans=0;
	for(ll i=0;i<n;i++)
		for(ll j=i;j<n;j++)
			for(ll k=j;k<n;k++){
				if(a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k]  && (a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[k]+a[j]>a[i]))
					ans++;
			}
	cout << ans << endl;		
}
int main(){
    //TC
	solve();
	ret 0;
}

Measured memory_bytes: 3636