akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        eratos(100000);
        int Q = cin.nextint;
        var A = new List<int>();
        foreach (var item in prime)
        {
            if (is_prime[item] && is_prime[(item + 1) / 2])
            {
                A.Add(item);
            }
        }
        for (int i = 0; i < Q; i++)
        {
            WriteLine(-lower_bound(A, cin.nextint) + upper_bound(A, cin.nextint));
        }
    }
    
    int lower_bound(List<int> arr, int val)
    {
        int low = 0, high = arr.Count();
        int mid;

        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid] < val) low = mid + 1;
            else high = mid;
        }
        return low;
    }
    int upper_bound(List<int> arr, int val)
    {
        int low = 0, high = arr.Count();
        int mid;

        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid] <= val) low = mid + 1;
            else high = mid;
        }
        return low;
    }
    List<int> prime;
    bool[] is_prime;
    void eratos(int n)
    {
        prime = new List<int>();
        is_prime = new bool[n + 1];
        for (int i = 0; i <= n; i++) is_prime[i] = true;
        is_prime[0] = is_prime[1] = false;
        for (int i = 0; i <= n; i++)
        {
            if (is_prime[i])
            {
                prime.Add(i);
                for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
            }
        }
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 17868
#include<iostream>
using namespace std;
int main(){
int x,y;
while(true){
cin >>x>>y;
if(x==0&&y==0){
  break;
}
if(x>y){
  cout <<y<<" "<<x<<endl;
}else if(x<y){
  cout <<x<<" "<<y<<endl;
}else{
  cout <<x<<" "<<y<<endl;
}
}
return 0;
}

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    abc148b()
}

fun abc148b() {
    val n = readLine()!!.toInt()
    val (s, t) = readLine()!!.split(' ')

    val answer = (0 until n).map { s[it].toString() + t[it].toString() }.joinToString("")

    println(answer)
}


Measured memory_bytes: 38180
n=int(input())
s=list(map(int,input().split()))


result=[]

for i in range(n):
    posi=-1
    for index,ss in enumerate(s):
        if ss==index+1:
            posi=index
    if posi==-1:
        print(-1)
        exit()
    else:
        result.append(s[posi])
        s.pop(posi)

for item in result[::-1]:
    print(item)
    



Measured memory_bytes: 38640
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double v[] = new double[N];
		for(int i = 0; i < N; i++) {
			v[i] = sc.nextDouble();
		}
		Arrays.sort(v);
		double ans = (v[0] + v[1]) / 2;
		for(int i = 2; i < N; i++) {
			ans = (ans + v[i]) / 2;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 24916
fun main(args: Array<String>) {
    val (n, k, q) = readLine()!!.split(' ').map(String::toLong)
    val aList = mutableListOf<Long>()
    val ansCount = Array(n.toInt() + 1) { 0 }
    (1..q).forEach {
        val a = readLine()!!.toLong()
        aList.add(a)
        ansCount[a.toInt()] = ansCount[a.toInt()] + 1
    }

    for (i in 1..n.toInt()) {
        val p = k - q + ansCount[i]
        if (p > 0) {
            println("Yes")
        } else {
            println("No")
        }
    }
}

Measured memory_bytes: 48100
N,M = map(int, input().split())
X = [ [int(j) for j in input().split()] for _ in range(N)]

ans = 0
for i in range(1<<3):
    p = sorted(X, reverse=True, key=lambda x:(x[0] if (i & (1<<2)) else -x[0]) + (x[1] if (i & (1<<1)) else -x[1]) + (x[2] if (i & (1<<0)) else -x[2]))

    p = [ (x[0] if (i & (1<<2)) else -x[0]) + (x[1] if (i & (1<<1)) else -x[1]) + (x[2] if (i & (1<<0)) else -x[2]) for x in p]
    ans = max(ans, sum(p[:M]))
print(ans)

Measured memory_bytes: 3336
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define double long double
const int mod = 1e9 + 7;
const int K = 26;

int32_t main()
{   
    fastio;
    
    int a, b, c, k; cin >> a >> b >> c >> k;
    int ans = 0;
    if(k > 0){
    	ans += min(k,a);
    	k -= min(k, a);
    }

    if(k > 0){
    	k -= min(k, b);
    }

    if(k > 0){
    	ans += -1*min(k,c);
    	k -= min(k, c);
    }

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



Measured memory_bytes: 3608
#include <stdio.h>

char is_sosuu[1299710];

int sosuu_list_size;
int sosuu_list[100000];

void make_sosuu_list(void) {
	int i,j;
	for(i=0;i<1299710;i++)is_sosuu[i]=1;
	is_sosuu[0]=is_sosuu[1]=0;
	for(i=2;i<1299710;i++) {
		if(is_sosuu[i]) {
			for(j=i+i;j<1299710;j+=i)is_sosuu[j]=0;
		}
	}
	sosuu_list_size=0;
	for(i=0;i<1299710;i++) {
		if(is_sosuu[i])sosuu_list[sosuu_list_size++]=i;
	}
}

int nibun_tansaku(int searchfor) {
	int left,right,mid;
	left=0;right=sosuu_list_size-1;
	while(left<=right) {
		mid=(left+right)/2;
		if(sosuu_list[mid]<=searchfor)left=mid+1;
		else right=mid-1;
	}
	return left-1;
}

int main(void) {
	int query;
	int pos;
	make_sosuu_list();
	while(1) {
		scanf("%d",&query);
		if(query==0)break;
		if(query<=1 || is_sosuu[query])puts("0");
		else {
			pos=nibun_tansaku(query);
			printf("%d\n",sosuu_list[pos+1]-sosuu_list[pos]);
		}
	}
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int count=0;
  int ans=0;
  for(int i=0; i<s.size(); i++){
    for(int j=i; j<s.size(); j++){
     for(int k=i; k<=j; k++){
      if(s[k] == 'A' || s[k] == 'T' || s[k] == 'G' || s[k] == 'C' ){
        count++;
      }
      else{
        count = 0;
      }
     }
     ans = max(ans,count);
     count = 0;
    }
    
  }
  
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

int a = 0;
int b = 0;

scanf("%d %d",&a,&b);

if(a < b) {
printf("a < b\n");
} else if (a > b) {
printf("a > b\n");
} else {
printf("a == b\n");
}

return 0;

}



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

int main() {
  int H, W;
  cin >> H >> W;
  
  string a, b;
  for (int i=0; i<H+2; i++) {
    a = "#";
    if ((i == 0 || i == H+1)) {
      for (int j=0; j<W+1; j++)
        a += '#';
      cout << a << endl;
    }
    else {
      cin >> b;
      a += b;
      a += '#';
      cout << a << endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
// #include <sstream>
#include <stdio.h>
#include <string>
// #include <cstdio>
// #include <bitset>
// #include <math.h>
//#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a; i<b; i++)

string S;

typedef long long ll;

int main() {
  cin >> S;

  //cout << S << "\n";
  
  string tmp_AB, tmp_CD;
  tmp_AB = tmp_AB +S[0];
  tmp_AB = tmp_AB +S[1];
  tmp_CD = tmp_CD +S[2];
  tmp_CD = tmp_CD +S[3];

  int num_AB = atoi(tmp_AB.c_str());
  int num_CD = atoi(tmp_CD.c_str());
  //cout << num_AB << "\n";
  //cout << num_CD << "\n";

  bool is_m_AB = false;
  bool is_m_CD = false;
  if ((1 <= num_AB) && (num_AB <= 12))
    is_m_AB = true ; 

  if ((1 <= num_CD) && (num_CD <= 12))
    is_m_CD = true ; 

  if (is_m_AB && is_m_CD) {
    printf("AMBIGUOUS\n");
  } else if ((true==is_m_AB) && (false==is_m_CD)) {
    printf("MMYY\n");
  } else if ((false==is_m_AB) && (true==is_m_CD)) {
    printf("YYMM\n");
  } else {
    printf("NA\n");
  }

  
#if 0
  istringstream ss;

    ss << tmp;
    int num;
    ss >> num;
    cout << num << "\n";
#endif
#if 0
  string U = S[0] + S[1];
  string L = S[2] + S[3];
  cout << U << "\n";
  cout << L << "\n";
#endif

  // ll a = S[0] - '0';
  // ll b = S[1] - '0';
  // ll c = S[2] - '0';
  // ll d = S[3] - '0';
  //cout << a << b << c << d << "\n";

#if 0
  int cnt = 1;
  for(auto tmp_c: S) {
    if (cnt==k) {
      printf("%c", tolower(tmp_c));
    } else {
      printf("%c", tmp_c);
    }
    cnt++;
  }
  printf("\n");
#endif

  return 0;
}

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

int main(){
    int N,d[51],ans=0;
    cin >> N;
    rep(i,N) cin >> d[i];
    rep(i,N){
        for(int j = i+1;j < N;j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//38
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<cmath>
#include<map>
 
using namespace std;

map<pair<vector<int>,int>,double> memo;

vector<int> c;

double dfs(int nr,int p){
  if(nr==0){
    return p;
  }else if(memo.count(make_pair(c,p))){
    return memo[make_pair(c,p)];
  }else{
    double md=1<<30;
    for(int i=3;i<=10;i++){
      if(c[i]){
	c[i]--;
	md=min(md,dfs(nr-1,i)+2*sqrt(i*p));
	c[i]++;
      }
    }
    memo[make_pair(c,p)]=md;
    return md;
  }
}
 
int main(){
  for(int w;cin>>w;){
    string s;
    getline(cin,s);
    stringstream ss(s);
    c=vector<int>(11);
    memo.clear();
    int nr=0;
    for(int r;ss>>r;){
      c[r]++;
      nr++;
    }
    int i;
    for(i=3;i<=10;i++){
      if(c[i]){
	c[i]--;
	if(dfs(nr-1,i)+i<=w)break;
	c[i]++;
      }
    }
    cout<<((i<=10)?"OK":"NA")<<endl;
  }
  return 0;
}

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

N, M = map(int, input().split())
A = set(map(int, input().split()))
B = set(map(int, input().split()))
mod = 10**9 + 7
row = col = 0
cnt = 0
ans = 1
for x in range(1, N*M+1)[::-1]:
    if x in A and x in B:
        row += 1
        col += 1
    elif x in A:
        row += 1
        ans = ans * col % mod
    elif x in B:
        col += 1
        ans = ans * row % mod
    else:
        if col * row - cnt > 0:
            ans = ans * (col * row - cnt) % mod
        else:
            ans = 0
            break
    cnt += 1
for i in range(1, N * M - cnt + 1):
    ans = ans * i % mod
print(ans)



Measured memory_bytes: 41196
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

// Since the answer is always 0 for multiples take sth max less then 
// multiple, so min(b-1,n)
int main(){
    ll a,b,n;
    while(cin>>a>>b>>n){
        ll x = min(n,b-1);
        ll res = (a*x)/b;
        cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


int sq(int x){
	return x*x;
}

int main(){

	int d;
	while(cin>>d){
		int sum=0;
		for(int cp = d; cp != 600; cp+=d){
			sum+=sq(cp)*d;
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

struct Edge {
	int to, weight;
	Edge(int t, int d) : to(t), weight(d) {}
};

int main() {
	int V, E, r;
	cin >> V >> E >> r;
	vector<vector<Edge>> graph(V);
	Rep(i, E) {
		int s, t, d;
		cin >> s >> t >> d;
		graph[s].push_back(Edge(t, d));
	}
	vector<int> cost(V, INFTY);
	cost[r] = 0;
	priority_queue<int, vector<int>, greater<int>> PQ;
	PQ.push(r);
	while (!PQ.empty()) {
		int v = PQ.top();
		PQ.pop();
		Rep(i, graph[v].size()) {
			if (cost[graph[v][i].to] > cost[v] + graph[v][i].weight) {
				cost[graph[v][i].to] = cost[v] + graph[v][i].weight;
				PQ.push(graph[v][i].to);
			}
		}
	}
	Rep(i, V) {
		if (cost[i] == INT_MAX) cout << "INF" << endl;
		else cout << cost[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 16060
#include <iostream>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, v, even[100008], odd[100008];

int main() {
	cin >> n;
	for(ll i = 1; i <= n; i++){
		cin >> v;
		if(i%2 == 0){even[v]++;}
		else{odd[v]++;}
	}
	
	ll emax1 = 0; ll e1 = -1;
	ll emax2 = 0; ll e2 = -1;
	ll omax1 = 0; ll o1 = -1;
	ll omax2 = 0; ll o2 = -1;
	for(ll i = 1; i <= 100000; i++){
		if(even[i] > emax1){
			emax2 = emax1;
			emax1 = even[i];
			e2 = e1;
			e1 = i;
		}
		else{
			if(even[i] > emax2){
				emax2 = even[i];
				e2 = i;
			}
		}
	}
	for(ll i = 1; i <= 100000; i++){
		if(odd[i] > omax1){
			omax2 = omax1;
			omax1 = odd[i];
			o2 = o1;
			o1 = i;
		}
		else{
			if(odd[i] > omax2){
				omax2 = odd[i];
				o2 = i;
			}
		}
	}	
	
	ll ans = n;
	if(e1 == o1){
		if(emax1 > omax1){ans -= emax1+omax2;}
		if(emax1 < omax1){ans -= emax2+omax1;}
		if(emax1 == omax1){ans -= (emax2 > omax2)? omax1+emax2 : emax1+omax2;}
	}
	else{
		ans -= emax1+omax1;
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
rest = []
for i in range(n):
    sp = list(map(str, input().split()))
    sp[1] = int(sp[1])
    sp.append(i + 1)
    rest.append(sp)
rest.sort(key=lambda x: (x[0], -x[1]))
for _ in range(n):
    print(rest[_][2])


Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long

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

    int d,g; cin >> d >> g;
    vector<int> p(d+1),c(d+1);
    for(int i = 1;i < d+1;i ++){
        cin >> p.at(i) >> c.at(i);
    }

    vector<int> ten(d+1);
    for(int i = 1;i < d+1;i ++){
        ten.at(i) = 100*i*p.at(i) + c.at(i);
    }

    vector<int> rekkyo(d+1);

    int ans = 1000000000000000;

    while(rekkyo.at(0) == 0){
        int sum = 0;
        int kazu = 0;

        for(int i = 1;i < d+1;i ++){
            if(rekkyo.at(i) == 1){
                sum += ten.at(i);
                kazu += p.at(i);
            }
        }

        if(sum < g){
            int dekai;
            for(int i = d;i > 0;i --){
                if(rekkyo.at(i) == 0){
                    dekai = i;
                    break;
                }
            }

            int count = 0;
            while(sum < g){
                sum += 100 * dekai;
                kazu ++;
                count ++;
            }

            if(count > p.at(dekai)-1){

                rekkyo.at(d) ++;
                for(int i = d;i > 0;i --){
                    if(rekkyo.at(i) == 2){
                        rekkyo.at(i) = 0;
                        rekkyo.at(i-1) ++;
                    }
                }
                continue;
            }
            
        }
        
        ans = min(ans,kazu);

        rekkyo.at(d) ++;
        for(int i = d;i > 0;i --){
            if(rekkyo.at(i) == 2){
                rekkyo.at(i) = 0;
                rekkyo.at(i-1) ++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int hikaku(const void *n1,const void *n2)
{
    return *(int*)n2-*(int*)n1;
}

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

    qsort(a,n,sizeof(int),hikaku);
    int p=2;
    int q=1;
    ans=a[0];
    int s=0;

    while(p<n)
    {
        ans=ans+a[q];
        if(s==0)
        {
            s=1;
        }
        else
        {
            s=0;
            q=q+1;
        }
        p=p+1;
    }


    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = int.Parse(Console.ReadLine());
            for (int testcase = 0; testcase < t; testcase++)
            {
                int[] nd = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int n = nd[0];
                int d = nd[1];

                int ans = 127 * (n - 1);
                if (n % 2 == 0)
                {
                    ans += 127 - d;
                    Console.WriteLine(ans);
                }
                else
                {
                    ans += d;
                    Console.WriteLine(ans);
                }
            }

        }
    }
}


Measured memory_bytes: 3288
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

# import sys, math, random
# import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
 
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    A, B, C = list(map(int,input().split()))
    o=max(A,B,C)
    print(A+B+C-o)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin >> n;
    if (n % 2 == 0)
        n /= 2;
    cout << 2 * n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,ans;
int a[600];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=2*n;++i)
		scanf("%d",&a[i]);
	sort(a+1,a+1+2*n);
	for (int i=1;i<=2*n;i+=2)
		ans+=a[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
using Int = long long;
#define REP(i, n) for (int i = 0; i < n; i++)
int main()
{
    int H, W; cin >> H >> W;
    int C[10][10]; REP(i, 10) REP(j, 10) cin >> C[i][j];
    int mincost[10]; // calc
    REP(i, 10) mincost[i] = C[i][1];
    bool flag = true;
    while (flag) {
        flag = false;
        REP(i, 10) REP(j, 10) {
            if (mincost[i] > C[i][j] + mincost[j]) {
                mincost[i] = C[i][j] + mincost[j];
                flag = true;
            }
        }
    }
    int ans = 0;
    REP(i, H) REP(j, W) {
        int t; cin >> t;
        if (t != -1) ans += mincost[t];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
d=gcd(a,b)
pf={}
for i in range(2,int(d**0.5)+1):
  while d%i==0:
    pf[i]=pf.get(i,0)+1
    d//=i
if d>1:
  pf[d]=1
P=list(pf.keys())
print(len(P)+1)

Measured memory_bytes: 3064
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(void){
  ll N;
  cin >> N;
  vector<pair<ll, ll>> xy(N);
  rep(i, N) cin >> xy[i].first >> xy[i].second;
  sort(xy.begin(), xy.end());
  reverse(xy.begin(), xy.end());
  vector<pair<ll, ll>> sa;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      ll dx = xy[i].first - xy[j].first;
      ll dy = xy[i].second - xy[j].second;
      sa.push_back({dx, dy});
    }
  }

  ll ans = N;
  rep(i, sa.size()){
    ll dx = sa[i].first;
    ll dy = sa[i].second;
    ll cost = 0;
    vector<bool> flag(N, 0);
    for(int j = 0; j < N; j++){
      if(flag[j] == 1) continue;
      cost++;
      flag[j] = 1;
      int now = j;
      bool update = 1;
      while(update){
        update = 0;
        for(int ne = 0; ne < N; ne++){
          if(ne == now) continue;
          if(xy[now].first - xy[ne].first == dx && xy[now].second - xy[ne].second == dy){
            flag[ne] = 1;
            now = ne;
            update = 1;
          }
        }
      }
    }
    ans = min(ans, cost);
  }
  cout << ans << endl;

}


Measured memory_bytes: 384
#include <stdio.h>
#include <vector>
#define MN 500000
typedef long long LL;
const int mod=1000000007;
int n,a[MN+5],b[MN+5],c[MN+5],ans=0;
std::vector<int> v[1<<20];
int qpow(LL bsc,int y){
	LL ret=1;
	while(y){
		if(y&1) ret=(ret*bsc)%mod;
		bsc=(bsc*bsc)%mod;
		y>>=1;
	}
	return ret;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i]^b[i-1];
		c[i]=c[i-1]+(b[i]==0);
		v[b[i]].push_back(i);
	}
	if(b[n]==0){
		for(int s=1;s<(1<<20);s++){
			int prev=0,pre0=1;
			for(int i=0;i<v[s].size();i++){
				prev=(prev+pre0)%mod;
				if(i+1!=v[s].size())
					pre0=(pre0+1ll*(c[v[s][i+1]]-c[v[s][i]])*prev)%mod;
			}
			ans=(ans+prev)%mod;
		}
		ans=(ans+qpow(2,c[n]-1))%mod;
		printf("%d\n",ans);
	}else{
		int s=b[n];
		int prev=0,pre0=1;
		for(int i=0;i<v[s].size();i++){
			prev=(prev+pre0)%mod;
			if(i+1!=v[s].size())
				pre0=(pre0+1ll*(c[v[s][i+1]]-c[v[s][i]])*prev)%mod;
		}
		printf("%d\n",pre0);
	}
}

Measured memory_bytes: 40308
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

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

long long sum[200001];
long long N;
long long a[200000];
const long long MOD = 1000000007;

int main() {
  cin >> N;
  rep(i, N) {
    cin >> a[i];
  }
  sum[N] = 0;
  rep(i, N) {
    sum[N-i-1] = sum[N-i] + a[N-i-1];
    sum[N-i-1] %= MOD;
  }
  long long ans = 0;
  rep(i, N) {
    ans += a[i] * sum[i+1];
    ans %= MOD;
  }
  cout << ans << endl;
  // rep(i, N) {
  //   cout << sum[i] << " ";
  // }
  // cout << endl;
  return 0;
}

Measured memory_bytes: 6712
import java.util.Scanner;

public class Main {
	
	public static int check(int a,int b,int c){
		int data;
		
		if(a>=b)data=a;
		else data=b;
		if(data>=c){}
		else data=c;
		
		return data;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int A=s.nextInt();
		int B=s.nextInt();
		int C=s.nextInt();
		int K=s.nextInt();
		int d;
		int all=0;
		
		d=Main.check(A,B,C);
		if(d==A)all=B+C;
		if(d==B)all=A+C;
		if(d==C)all=B+A;
		for(int i=0;i<K;i++){
			d*=2;
		}
		System.out.print(all+d);

	}

}


Measured memory_bytes: 23636
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/);
let num = input[1].split(' ').map(Number);
num.sort(function(a,b){ return a - b ;});
let min = num[0];
let max = num[num.length - 1];
let sum = 0;
for (let i=0; i<num.length; i++) {
        sum += num[i];
}
 console.log(min + ' ' + max + ' ' + sum)


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


int main(void){
  int a[3][3];
  rep(i,3){
    rep(j,3){
      scanf("%d",&a[i][j]);
    }
  }
  int n; scanf("%d",&n);
  int b[n];
  rep(i,n){
    scanf("%d",&b[i]);
  }
  int c[3][3];
  rep(i,3){
    rep(j,3){
      c[i][j] = 0;
    }
  }
  rep(i,n){
    rep(j,3){
      rep(k,3){
        if(b[i] == a[j][k]){
          c[j][k] = 1;
        }
      }
    }
  }
  rep(i,3){
    if(c[0][i] and c[1][i] and c[2][i]){
      printf("Yes");
      return 0;
    }
  }
  rep(i,3){
    if(c[i][0] and c[i][1] and c[i][2]){
      printf("Yes");
      return 0;
    }
  }
  if(c[0][0] and c[1][1] and c[2][2]) printf("Yes");
  else if(c[2][0] and c[1][1] and c[0][2]) printf("Yes");
  else printf("No");
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
gu, ki = [], []
for i in range(n):
	if i % 2 == 0:
		ki.append(v[i])
	else:
		gu.append(v[i])
ki_flag, gu_flag = False, False
kict = Counter(ki)
guct = Counter(gu)
kict_mc = kict.most_common()
guct_mc = guct.most_common()
if len(kict_mc) > 1:
	ki_flag = True
if len(guct_mc) > 1:
	gu_flag = True
ki_first = kict_mc[0][0]
if ki_flag:
	ki_second = kict_mc[1][0]
gu_first = guct_mc[0][0]
if gu_flag:
	gu_second = guct_mc[1][0]
if ki_flag & gu_flag:
	if ki_first == gu_first:
		print(min([n - kict_mc[0][1] - guct_mc[1][1], n - kict_mc[1][1] - guct_mc[0][1]]))
	else:
		print(n - kict_mc[0][1] - guct_mc[0][1])
elif ki_flag:
	if ki_first == gu_first:
		print(n - kict_mc[1][1] - guct_mc[0][1])
	else:
		print(n - kict_mc[0][1] - guct_mc[0][1])
elif gu_flag:
	if ki_first == gu_first:
		print(n - kict_mc[0][1] - guct_mc[1][1])
	else:
		print(n - kict_mc[0][1] - guct_mc[0][1])
else:
	if ki_first == gu_first:
		print(int(n / 2))
	else:
		print(n - kict_mc[0][1] - guct_mc[0][1])

Measured memory_bytes: 23768
#include <stdio.h>
#include <string.h>

int main(void){
    int n,a = 0,w = 0,t = 0,r = 0;
    scanf("%d",&n);

    char buffer[20];
    for (int i = 0; i < n + 1; ++i) {
        fgets(buffer,sizeof(buffer),stdin);
        switch (buffer[0]) {
            case 'A':
                a++;
                break;
            case 'W':
                w++;
                break;
            case 'T':
                t++;
                break;
            case 'R':
                r++;
                break;
        }
    }

    printf("AC x %d\n",a);
    printf("WA x %d\n",w);
    printf("TLE x %d\n",t);
    printf("RE x %d\n",r);


    return 0;
}

Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)


int main(){
 ll X,K,D;
 cin>>X>>K>>D;
 X=abs(X);

if(X/D>=K){
  cout<<X-D*K<<endl;
  return 0;
}

ll kai = X/D;


if((K-kai)%2==0){
  cout<<X-D*kai<<endl;
}
else{
  cout<<abs(X-D*kai-D)<<endl;
}




}










Measured memory_bytes: 3636
from collections import Counter 
n=int(input())
s=[Counter(list(input())) for i in range(n)]
  
INF=100
a=[INF]*26
for i in s:
  for j in range(26):
    k=j+ord('a')
    a[j]=min(a[j],i[chr(k)])
for i in range(26):
  if a[i]>50:
    a[i]=0
ans=''
for i in range(26):
  ans+=chr(i+ord('a'))*a[i]
print(ans)

Measured memory_bytes: 40432
#include<bits/stdc++.h>
        #define rep(i,n) for (int i = 0; i < (n); ++i)
        #define rep2(i, a, b) for (int i = (a); i < (b); i++)
        using namespace std;
        using ll = long long;
        using P = pair<int,int>;
        using Vi = vector<int>;
         
        int main() {
        	long long n;
        	cin >> n;
        	vector<long long> r;
        	while (n > 0) {
              	n -= 1;
        		r.push_back(n % 26);
        		n /= 26;
        	}
        	string name = "";
        	rep(i, r.size()) {
        		name = char('a' + r.at(i)) + name;
        	}
        	cout << name << endl;
        	return 0;
        }

Measured memory_bytes: 3640
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;
 

void solve()
{
    ll x;
    scanf("%lld", &x);

    ll i;
    for (i = -2000; i <= 2000; i++) {
        ll y = x + i*i*i*i*i;

        ll tmp=(ll)(pow((double)y, 0.2));
        if (tmp*tmp*tmp*tmp*tmp == y) {
             printf("%lld %lld\n", tmp, i); return;
        }
        tmp++;
        if (tmp*tmp*tmp*tmp*tmp == y) {
             printf("%lld %lld\n", tmp, i); return;
        }
        tmp -= 2;
        if (tmp*tmp*tmp*tmp*tmp == y) {
            printf("%lld %lld\n", tmp, i); return;
        }
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 2620
#include<stdio.h>

int main()


{


    int n,k,x,y;
    scanf("%d%d%d%d",&n,&k,&x,&y);
    if(n<=k)
    {
        printf("%d\n",n*x);
    }
    else
    {

        int  baki=n-k;

        int   taka1=k*x;
        int  taka2=baki*y;
        printf("%d\n",taka1+taka2);
    }
    return 0;





}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <cmath>

int main(void){
    int n,a,b;
    std::cin >> n >> a >> b;

    int ans = 0;
    for(int i = 1; i <= n; i++){
        int tmp = i;
        int sum = 0;
        while(tmp > 0){
            sum += tmp%10;
            tmp = tmp/10;
        }

        if(sum >= a && sum <= b){
            ans += i;
        }
    }

    std::cout << ans;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9+5
int main() {
	int n, k;
	cin>>n>>k;
	vector<int> v(n);
	for(int &i : v) {
		cin>>i;
	}
	
	vector<int> dp(n, INF);
	dp[0] = 0;
	dp[1] = abs(v[1] - v[0]);
	
	for(int i=2;i<n;i++) {
		for(int j=i-1;j>=0 && j>=i-k;j--)
			dp[i] = min(dp[i], abs(v[i]-v[j])+dp[j]);
	}
	
	cout<<dp[n-1];
}

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

int main()
{
    int n,count=1;
    cin>>n;
    if(n%2==0)
    {
        n=n/2;
        cout<<n;
    }
    else{
        n=n/2;
        n=n+1;
        cout<<n;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 110

typedef pair<pair<int,int> ,pair<pair<int,int>,pair<int,int> > > p6;
#define P6(a,b,c,d,e,f) make_pair(make_pair(a,b),make_pair(make_pair(c,d),make_pair(e,f)))
#define P(a,b) make_pair(a,b)

bool solve(){
  int w,h;
  char s[61][31];
  bool dp[61][31][61][31][2] = {};
  
  scanf("%d%d",&w,&h);

  if(w == 0) return false;

  priority_queue<p6> pq;

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      scanf(" %c",s[i]+j);

      if(s[i][j] == 'S'){
        pq.push(P6(0,i,j,i,j,0));
        pq.push(P6(0,i,j,i,j,1));
      }
    }
  }
  
  while(pq.size()){
    auto p = pq.top();
    pq.pop();
    
    int cost = p.first.first;
    int y1 = p.first.second;
    int x1 = p.second.first.first;
    int y2 = p.second.first.second;
    int x2 = p.second.second.first;
    int e = p.second.second.second;
    
    if(dp[y1][x1][y2][x2][e]) continue;
    dp[y1][x1][y2][x2][e] = true;

    if(s[y1][x1] == 'T' || s[y2][x2] == 'T'){
      printf("%d\n",-cost);
      return true;
    }

    for(int i=-2;i<=2;i++){
      for(int j=1;j+abs(i)<=3;j++){
        if(e == 0){
          if(s[y1+i][x1+j] != 'X' &&
             0 <= y1+i && y1+i < h &&
             0 <= x1+j && x1+j < w){
            int add_cost = (s[y1+i][x1+j]-'0')*(s[y1+i][x1+j] != 'T');
            pq.push(P6(cost-add_cost,y1,x1,y1+i,x1+j,1));
          }
        }else{
          if(s[y2+i][x2-j] != 'X' &&
             0 <= y2+i && y2+i < h &&
             0 <= x2-j && x2-j < w){
            int add_cost = (s[y2+i][x2-j]-'0')*(s[y2+i][x2-j] != 'T');
            pq.push(P6(cost-add_cost,y2+i,x2-j,y2,x2,0));
          }
        }
      }
    }
  }

  puts("-1");
  
  return true;
}

int main(){

  while(solve());
  
  return 0;
}

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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

Int n, cnt;
Int r, g, b;
std::string s;

int main(){
	cin >> n >> s;
	RC(i, n){
		if(s[i] == 'R') ++r;
		else if(s[i] == 'G') ++g;
		else if(s[i] == 'B') ++b;
	}
	RC(i, n){
		for(Int j = 1; i + j * 2 < n; ++j){
			if(
				s[i] != s[i + j]
				&& s[i] != s[i + 2 * j]
				&& s[i + j] != s[i + 2 * j]
			){
				++cnt;
			}
		}
	}
	cout << r * g * b - cnt << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
 using namespace  std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
const double pi=3.1415926535897932384626433832;
const long long mod=1e9+7;
//long long primeset[5000000]={};
typedef complex<double> cd;
typedef long long ll;
typedef double ld;
//#define For(i,0,n) for(long long i = 0 ; i<n ;i++) 
cd fast_exp(cd a, long long b)
{
	if (b == 0)
		return 1;
	
	cd res = fast_exp(a, b / 2);
		
	res = res * res;
	
	if (b % 2 == 1)
		res = res * a;
	
	return res;
}

long long fastexpon(long long a,long long b,long long mod)
{
	if(b==0)
		return 1;
	
	long long res=fastexpon(a,b/2,mod);
	
	res=(res*res)%mod;
	if(b%2==1)
		res= (res * a)%mod;

	return res;
}


//template ends here




int n;
//int girlspaired=0;
//int marriedmen=0;
int dp[2200000];
int a[22][22]={};
int way_giver(int girlspaired)
{
	if(dp[girlspaired]>=0)
		{
			//cout<<"hey";
			return dp[girlspaired];
		}
	int marriedmen=0;
	int cur=1;
	for(int i=0 ;i<n ;i++)
	{
		if((girlspaired&cur))
			marriedmen++;
		cur=cur<<1;
	}
	//cout<<"marriedmen = "<<marriedmen<<'\n';
	if(marriedmen == n)
	{
		//cout<<"hey";
		dp[girlspaired]=1;
		return dp[girlspaired];
	}

	int ways=0;
	cur=1;
	int check=0;
	for(int i=0 ;i<n ;i++)
	{	
		//cout<<"\n";
		//cout<<"marriedmen= "<<marriedmen<<'\n';
		//cout<<"cur = "<<cur<<'\n';
		//cout<<"girlspaired = "<<girlspaired<<'\n';
		//cout<<".....\n";
		if(a[marriedmen][i]==1  )
		{
			//girlspaired=girlspaired;
			
			//cout<<"and = "<<(girlspaired&cur);
			if((girlspaired&cur)==0)
			{	
				ways= (ways+way_giver((girlspaired^cur))  )%mod ;
				check=1;
			}	
			//cout<<"girlspaired  = "<<girlspaired<<'\n';
		}
		cur=cur<<1;
		//cout<<"cu===="<<cur<<'\n';
	}

	if(check==0)
		{
			//cout<<"heyeahhhhhh";
			dp[girlspaired]=0;
			return 0;
		}
	else 
		{
			dp[girlspaired]=ways;
			return ways;
		}		
}




int main()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int n;
	cin>>n;
	//int a[25][25]={};
	for(int i=0 ;i<n ;i++)
		for(int j=0 ;j<n ;j++)
			cin>>a[i][j];

	for(int i=0 ;i<2200000 ;i++)
		dp[i]=-1;

	cout<<way_giver(0)<<'\n';		

	//cout<<'\n'<<"time elapsed: "<<clock()*1000.0 / CLOCKS_PER_SEC<<" ms"<<'\n';
	return 0;
}

Measured memory_bytes: 8832
#include<stdio.h>
 
int main(){
  int n,i,j,k,m,g[100][100]={},gg[100][100]={},a,b,c,cnt=0;
  scanf("%d %d\n",&n,&m);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(i!=j)
        g[i][j]=gg[i][j]=1001;
    }
  }
  for(i=0;i<m;i++){
    scanf("%d %d %d",&a,&b,&c);
    g[a-1][b-1]=g[b-1][a-1]=gg[a-1][b-1]=gg[b-1][a-1]=c;
  }
  for(k=0;k<n;k++){
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
        if(g[i][j]>g[i][k]+g[k][j])
          g[i][j]=g[i][k]+g[k][j];
      }
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(gg[i][j]!=1001&&gg[i][j]!=g[i][j])
        cnt++;
    }
  }
  printf("%d\n",cnt/2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define Boost                       \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);
#define endl '\n'
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fo(i, x, y) for (__typeof(x) i = x; i < y; ++i)
#define fr(i, x, y) for (__typeof(x) i = x; i > y; i--)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define F first
#define S second
#define vdp(n, x) vector<vector<ll>> dp(n + 1, vector<ll>(x + 1));

const ll mod = 1000000007;
const ll AM = 2e5 + 5;

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

int main()
{
    Boost;
    ll n;
    cin>>n;
    ll ht[n];
    fo(i, 0, n) {
        cin>>ht[i];
    }
    ll dp[n];
    dp[1]=abs(ht[1]-ht[0]);
    dp[0]=0;
    fo(i, 2, n) {
        dp[i]=MIN(dp[i-1]+abs(ht[i]-ht[i-1]), dp[i-2]+abs(ht[i]-ht[i-2]));
    }
    // fo(i, 0, n) {
    //     cout<<dp[i]<<" ";
    // }
    // cout<<endl;
    cout<<dp[n-1];
}

Measured memory_bytes: 5164
#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 max=1000000000;
    int N;
    cin >> N;
    int a[N];
    rep(i,N){
        cin >> a[i];
    }
    map<int,int> l,r;
    rep(i,N){
        if(l.find(i+a[i])!=l.end()){
            l[i+a[i]]++;
        }else{
            l[i+a[i]]=1;
        }
    }
    ll count=0;
    rep(j,N){
        if(l.find(j-a[j])!=l.end()){
            count+=l[j-a[j]];
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 13756
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;  
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 

//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,n,m,k;
ll t=1;

void solve()
{ll cnt=0;
    cin>>n>>m;
    m*=m;
    while(n--)
    {
        cin>>a>>b;
        cnt+=(((a*a)+(b*b)<=m)?1:0);
    }
   cout<<cnt;
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007
 
signed main(){
 
	lli l,r;
	cin>>l>>r;
 
	/*lとrの間に2019の倍数があれば0が答え*/
	/*ない場合はl%2019 * (l+1)%2019が答え*/
 
	/*
	lli min2019 = l/2019 * 2019;
	lli max2019 = r/2019 * 2019;
	if(l <= min2019 && min2019 <= r){
		cout<<0<<endl;
		return 0;
	}
	if(l<=max2019 && max2019 <= r){
		cout<<0<<endl;
		return 0;
	}
	cout<< ((l%2019)*((l+1)%2019)) %2019 <<endl;
	*/
 
	/*100000000000通りくらいやれば答えが出るはずなのでそれで行う*/
	const lli cntMax = 100000000;
	lli cnt=0;
	lli ans=INF;
	for(lli i=l;i<=l+2030;i++){
		if(i>r-1)break;
		for(lli j=l+1;j<=l+1+2030;j++){
			if(j>r)break;
			lli tmp = (i * j) %2019;
			ans = min(ans,tmp);
			if(ans==0)break;
			cnt++;
			if(cnt>cntMax)break;
		}
		if(ans==0)break;
		if(cnt>cntMax)break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    long long k;
    cin>>k;
    int a[200000];
    for(int i(0);i<n;i++){
        cin>>a[i];
    }
    long long one_lap(-1);
    int next_des(1);
    long long time(0);
    bool passed[200000]={0};
    int pos(-1);
    for(long long i(0);i<k;i++){
        passed[next_des-1] = true;
        next_des = a[next_des-1];
        time++;
        if(passed[next_des-1]){
            pos = next_des;
            break;
        }
    }
    int tmp_des(1);
    int first_time(0);
    if(pos != 1){
        for(int i(0);i<time;i++){
            tmp_des = a[tmp_des-1];
            if(pos == tmp_des){
                first_time = ++i;
                break;
            }
        }
    }
    one_lap = time - first_time;
    long long remain = (long long)k - first_time;
    remain %= one_lap;
    for(long long i(0);i<remain;i++){
        next_des = a[next_des-1];
    }
    cout<<next_des<<endl;
    return 0;
}

Measured memory_bytes: 4168