akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 99999999
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

Weight chinesePostman(const Graph &g) {
  Weight total = 0;
  vector<int> odds;
  REP(u, g.size()) {
    FOR(e, g[u]) total += e->weight;
    if (g[u].size() % 2) odds.push_back(u);
  }
  total /= 2;
  int n = odds.size(), N = 1 << n;
  Weight w[n][n]; // make odd vertices graph
  REP(u,n) {
    int s = odds[u]; // dijkstra's shortest path
    vector<Weight> dist(g.size(), INF); dist[s] = 0;
    vector<int>    prev(g.size(), -2);
    priority_queue<Edge> Q;
    Q.push( Edge(-1, s, 0) );
    while (!Q.empty()) {
      Edge e = Q.top(); Q.pop();
      if (prev[e.dst] != -2) continue;
      prev[e.dst] = e.src;
      FOR(f,g[e.dst]) {
        if (dist[f->dst] > e.weight+f->weight) {
          dist[f->dst] = e.weight+f->weight;
          Q.push(Edge(f->src, f->dst, e.weight+f->weight));
        }
      }
    }
    REP(v,n) w[u][v] = dist[odds[v]];
  }
  Weight best[N]; // DP for general matching
  REP(S,N) best[S] = INF;
  best[0] = 0;

  for (int S = 0; S < N; ++S)
    for (int i = 0; i < n; ++i) if (!(S&(1<<i)))
      for (int j = i+1; j < n; ++j) if (!(S&(1<<j)))
        best[S|(1<<i)|(1<<j)] = min(best[S|(1<<i)|(1<<j)], best[S]+w[i][j]);
  return total + best[N-1];
}

int main(){
	int i,V,E,s,t,e;
	//for(scanf("%d",&T);T;putchar(--T?' ':'\n')){
		scanf("%d%d",&V,&E);
		Graph g(V);
		for(;E--;)scanf("%d%d%d",&s,&t,&e),g[s].push_back(Edge(s,t,e)),g[t].push_back(Edge(t,s,e));
		printf("%d\n",chinesePostman(g));
	//}
}

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

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

int main()
{
    int n;
    cin >> n;
    int g[15][15];
    rep(i, n)rep(j, n) g[i][j] = -1;
    rep(i, n) {
        int m;
        cin >> m;
        rep(j, m) {
            int a, x;
            cin >> a >> x;
            --a;
            g[i][a] = x;
        }
    }

    int ans = 0;
    rep(i, 1 << n) {
        vector<int> d(n);
        rep(j, n) if (i >>j&1) {
            d[j] = 1;
        }
        bool ok = true;
        rep(j, n) {
            if (d[j]) {
                rep(k, n) {
                    if (g[j][k] == -1) continue;
                    if(g[j][k] != d[k]) ok =false;
                }
            }
        }
        if (ok) ans = max(ans, __builtin_popcount(i));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s;
		int n = 0;
		
		s = sc.next();
		for (int i = 0; i < 4; i++)
			if (s.charAt(i) == '+')
				n++;
			else
				n--;
		
		System.out.println(n);
	}
}

Measured memory_bytes: 21716
#include <stdio.h>

int main(void){
    int A,B,Amin,Bmin,Ahigh;
    scanf("%d %d",&A,&B);
    if(A%2==1){
        Amin=(25*A)/2+1;
        Ahigh=(25*A+25)/2;
    }
    else{
        Amin=12*A+A/2;
        Ahigh=(25*A+25)/2+1;
    }
    Bmin=10*B;
    if(Amin>=Bmin){
        if(Amin<Bmin+10){
            printf("%d",Amin);
        }
        else{
            printf("%d",-1);
        }
    }
    else{
        if(Bmin<Ahigh){
            printf("%d",Bmin);
        }
        else{
            printf("%d",-1);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;
int main(){
   string s;
   cin>>s;
   if(s.length()==2) cout<<s;
   if(s.length()==3){
   	for(int i = 2;i >=0 ;i--){
	   	cout<<s[i];
	   }
   }
}

Measured memory_bytes: 256
import numpy as np
#from numba import njit

#(N, K) = map(int, input().split())
#A = np.array(list(map(int, input().split())))
N = int(input())
A = np.array(list(map(int, input().split())))
Q = int(input())
BC = []
for _ in range(0,Q):
    BC += [list(map(int, input().split())),]

M = {}
for n in A:
    M[n] = M.get(n, 0) + 1


#@njit
def solve(N,A,Q,BC,M):
    S = 0
    for (k,v) in M.items():
        S += k*v
    for (b,c) in BC:
        t = M.pop(b,0)
        M[c] = M.get(c,0) + t
        S += (c-b)*t
        print(S)
    return S
        
S = solve(N,A,Q,BC,M)


Measured memory_bytes: 56412
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()	
	{
		char[] s = Console.ReadLine().ToCharArray();
		char[] t = Console.ReadLine().ToCharArray();
		Array.Sort(s);
		Array.Sort(t);
		Array.Reverse(t);

		Console.WriteLine((new string(s)).CompareTo(new string(t)) < 0 ? "Yes" : "No");
	}
}





Measured memory_bytes: 13408
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

int H, W;

bool judge(int x, int y)
{
    return 0 <= x && x < H && 0 <= y && y < W;
}

int main()
{
    const char dot = '.';
    const char shp = '#';

    const int move = 8;

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

    if (scanf("%d%d", &H, &W) < 2) return 0;

    vector<string> vs(H);

    for (int i = 0; i < H; i++)
    {
        char tmp[50];
        if (scanf("%s", tmp) < 1) return 0;
        vs[i] = tmp;
    }

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (vs[i][j] == shp)
            {
                printf("%c", shp);
                continue;
            }

            int count = 0;
            for (int k = 0; k < move; k++)
            {
                if (judge(i + dy[k], j + dx[k]))
                {
                    if (vs[i + dy[k]][j + dx[k]] == shp) count++;
                }
            }
            printf("%d", count);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#define llint long long
#define inf 1000000000000000000

using namespace std;

llint mod;

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

struct UnionFind{
	int size;
	vector<int> parent;
	vector<llint> dif;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		dif.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i, dif[i] = 1;
	}
	int root(int i){
		if(parent[i] == i) return i;
		int res = root(parent[i]);
		dif[i] *= dif[parent[i]], dif[i] %= mod;
		return parent[i] = res;
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	bool unite(int i, int j, llint d){
		int root_i = root(i), root_j = root(j);
		
		llint dif_i = dif[i], dif_j = dif[j];
		if(root_i == root_j){
			if(dif_i * d % mod != dif_j) return false;
			return true;
		}
		
		parent[root_i] = root_j;
		dif[root_i] = dif_j * modpow(dif_i * d % mod, mod-2) % mod;
		return true;
	}
};

struct edge{
	int to, cost;
	edge(int a, int b){
		to = a, cost = b;
	}
};

llint n, m;
llint u[100005], v[100005], w[100005];
UnionFind uf(100005);

int main(void)
{
	cin >> n >> m;
	for(int i = 1; i <= m; i++) cin >> u[i] >> v[i] >> w[i];
	
	mod = 1000000021;
	uf.init();
	for(int i = 1; i <= m; i++){
		if(!uf.unite(u[i], v[i], w[i])){
			cout << "No" << endl;
			return 0;
		}
	}
	
	mod = 1000000033;
	uf.init();
	for(int i = 1; i <= m; i++){
		if(!uf.unite(u[i], v[i], w[i])){
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	
	return 0;
}


Measured memory_bytes: 6260
A, B, K = (int(i) for i in input().split())

ans_list=[]

maximum=max(A,B)

for num in range(1, maximum+1, 1):
    if((A%num == 0)and (B%num == 0)):
        ans_list.append(num)

print(ans_list[::-1][K-1])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t

int main(){
    int N, A, B;
    string S;
    cin >> N >> A >> B >> S;

    
    int pass = 0;
    int abr = 0;
    rep (i, N){
        string ans = "No";
        if (S.at(i) == 'a'){
            if (pass < A + B) {
                ans = "Yes";
                pass++;
            }
        }
        if (S.at(i) == 'b'){
            if (pass < A + B && abr < B){
                ans = "Yes";
                pass++;
                abr++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
    return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    int n;cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int mx = 0;
    rep(i,n) mx = max(mx,a[i]);
    vector<int> num(1000005,0),cnt(1000005,0);
    rep(i,n){
        if(a[i]>0) {
            num[i] = cnt[a[i]-1] - cnt[a[i]];
            cnt[a[i]]++;
        }else {
            num[i] = 3 - cnt[0];
            cnt[0]++;
        }
    }
    //rep(i,10) cout << num[i] << endl;
    int i = 0;
    mint ans = 1;
    rep(i,n){
        //cout << num[i] <<" " ;
        ans *= num[i];

    }
    cout << ans <<" "<< endl;
}

Measured memory_bytes: 11360
#include <iostream>
using namespace std;
int n,r;
int card[50];

void shuffle(int p,int c) {
  int temp[50];
  for(int i=0;i<n;i++) {
    temp[i] = card[i];
  }
  for(int i=0;i<c;i++) {
    card[i] = temp[p-1+i];
  }
  for(int i=c;i<c+p-1;i++) {
    card[i] = temp[i-c];
  }
}

int main() {
  int p,c;
  while(cin >> n >> r) {
    if(n==0&&r==0)break;
    for(int i=0;i<n;i++) {
      card[i] = n-i;
    }
    for(int i=0;i<r;i++) {
      cin >> p >> c;
      shuffle(p,c);
    }
    cout << card[0] << endl;
  }
}

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

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int sum=0;
    for(int i=0;i<n;i++)sum+=a[i];
    int cnt=0;
    for(int i=0;i<n;i++){
        if((double)a[i]>=(double)sum/(4*m))cnt++;
    }
    if(cnt>=m){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[200000];
int main(){
  int i;
  long long res = 0;
  map<int,int> mp;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=(0);i<(N);i++){
    res += mp[i-A[i]];
    mp[i+A[i]]++;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200419-1

// --- original code ---
// int N, A[2d5];
// {
//   ll res = 0;
//   map<int,int> mp;
//   rd(N,A(N));
//   rep(i,N){
//     res += mp[i-A[i]];
//     mp[i+A[i]]++;
//   }
//   wt(res);
// }


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

int main(){
  string s; cin >> s;
  string t; cin >> t;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (s[(i+j)%n] != t[j]) break;
      if (j == n-1) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
S = list(S)
S_no_x = []
def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True
inds = []
for i,c in enumerate(S):
    if c != "x":
        S_no_x.append(c)
        inds.append(i)
if not is_kaibun(S_no_x):
    print(-1)
else:
    l = len(S_no_x)

    if l == 0:
        print(0)
    else:
        mae = ""
        usiro = ""
        if l % 2 == 0:
            mae_ind = inds[l // 2 - 1]
            usiro_ind = inds[l // 2]
            mae = S[:mae_ind +1]
            usiro = S[usiro_ind :]
        else:
            center = inds[l // 2]
            mae = S[:center]
            usiro = S[center +1:]

        usiro.reverse()
        usiro_x = []
        mae_x = []
        cot = 0
        usiro.append("@")
        for c in usiro:
            if c == "x":
                cot += 1
            else:
                usiro_x.append(cot)
                cot = 0
        cot = 0
        mae.append("@")
        for c in mae:
            if c == "x":
                cot += 1
            else:
                mae_x.append(cot)
                cot = 0
        ans = 0
        for a,b in zip(mae_x,usiro_x):
            ans += abs(a-b)
        print(ans)





Measured memory_bytes: 10224
package main

import (
	"fmt"
	"sort"
)

func main() {
	var (
		a, b, c, ans int
		dic          [][]int
		flg          bool
	)
	fmt.Scan(&a, &b, &c)

	for {
		abc := []int{a, b, c}
		sort.Ints(abc)
		if contains(dic, abc) {
			ans = -1
		}
		for _, v := range abc {
			if v%2 != 0 {
				flg = true
			}
		}
		if flg || ans < 0 {
			break
		}
		ans++
		dic = append(dic, abc)
		var (
			x = b/2 + c/2
			y = c/2 + a/2
			z = a/2 + b/2
		)
		a = x
		b = y
		c = z
	}
	fmt.Println(ans)
}

func contains(dic [][]int, abc []int) bool {
	for i := range dic {
		flg := false
		for j := range dic[i] {
			if dic[i][j] != abc[j] {
				flg = true
			}
		}
		if !flg {
			return true
		}
	}
	return false
}


Measured memory_bytes: 512
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void test_case();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	int a, b, q;
	cin >> a >> b >> q;
	vector < ll > s(a);
	for (auto &el: s) {
		cin >> el;
	}
	vector < ll > t(b);
	for (auto &el: t) {
		cin >> el;
	}
	while (q--) {
		ll pos;
		cin >> pos;
		ll ind_s = lower_bound(all(s), pos) - s.begin();
		ll ind_t = lower_bound(all(t), pos) - t.begin();
		ll ans = LINF;
		for (int sh = ind_s - 1; sh <= ind_s + 1; ++sh) {
			for (int te = ind_t - 1; te <= ind_t + 1; ++te) {
				if (sh >= 0 && sh < a && te >= 0 && te < b) {
					ll dis_s = s[sh] - pos;
					ll dis_t = t[te] - pos;
					if (dis_s > 0 && dis_t > 0) {
						ans = min(ans, max(dis_s, dis_t));
					} else if (dis_s < 0 && dis_t < 0) {
						ans = min(ans, abs(min(dis_s, dis_t)));
					} else {
						ans = min(ans, min(2 * abs(dis_s) + abs(dis_t), 2 * abs(dis_t) + abs(dis_s)));
					}
				}
			}
		}
		cout << ans << "\n";
	}
}

Measured memory_bytes: 2944
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   	//freopen("input.txt","r",stdin);
//   	freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int b[n],c[n];
	long long int ans = -1;
	if(n%2!=0)
	{
		b[0] = 1;
		b[n-1] = 1;
		bool mins = true;
		for(int i=1;i<n-1;i++)
		{
			b[i] = 2;
			if(mins)
			{
				b[i]*=-1;
			}
			mins = !mins;
		}
		for(int i=0;i<n;i++)
		{
			c[i] = -1*b[i];
		}
		sort(b,b+n);
		sort(c,c+n);
		long long int temp=0,temper =0;
		for(int i=0;i<n;i++)
		{
			temp+= (a[i]*b[i]);
			temper+=(a[i]*c[i]);
		}
		ans = max(temp,temper);
	}
	else
	{

		b[0] = 1;
		b[n-1] = -1;
		bool mins = true;
		for(int i=1;i<n-1;i++)
		{
			b[i] = 2;
			if(mins)
			{
				b[i]*=-1;
			}
			mins = !mins;
		}
		for(int i=0;i<n;i++)
		{
			c[i] = -1*b[i];
		}
		sort(b,b+n);
		sort(c,c+n);
		long long int temp=0,temper =0;
		for(int i=0;i<n;i++)
		{
			temp+= a[i]*b[i];
			temper+=a[i]*c[i];
		}
		ans = max(temp,temper);
	}
	cout<<ans;

	return 0 ;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N, M, Q;
  cin >> N >> M >> Q;
  ll sum[N][N] = {}, trains[N][N] = {}, ans[N][N] = {};
  rep(_, M){
    ll L, R;
    cin >> L >> R;
    sum[L-1][R-1]++;
    trains[L-1][R-1]++;
  }
  rep(r, N) rep(l, N-1) sum[l+1][r] += sum[l][r];

  rep(l, N) repi(r, l, N){
    if(l == r) ans[l][r] = trains[l][r];
    else if(l == 0) ans[l][r] = ans[l][r-1] + sum[r][r];
    else ans[l][r] = ans[l][r-1] + sum[r][r] - sum[l-1][r];
  }
  // rep(i, N){
  //   debug(trains[i]);
  //   debug(sum[i]);
  //   debug(ans[i]);
  // }
  rep(_, Q){
    ll p, q;
    cin >> p >> q;
    cout << ans[p-1][q-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007, MAX = 100001;

int n;
int ans[MAX];
vector<vpi> edge(MAX);

void dfs(int v, int parent, int color) 
{
  ans[v] = color;

  for (auto next : edge[v]) {
    int to = next.fi, weight = next.se;

    if (to == parent) continue;
    if (weight % 2) dfs(to, v, color ^ 1);
    else dfs(to, v, color);
  }
}

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

  cin >> n;
  rep(i, n-1) {
    int u, v, w; cin >> u >> v >> w;
    edge[u-1].eb(v-1, w);
    edge[v-1].eb(u-1, w);
  }

  dfs(0, -1, 0);
  rep(i, n) cout << ans[i] << endl;

  return (0);
}


Measured memory_bytes: 11780
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<bool> arr;
	for(int i=0;i<n;i++)
	{
		vector<int> cnt;
		int a,b,c;
		cin>>a>>b>>c;
		cnt.push_back(a);
		cnt.push_back(b);
		cnt.push_back(c);
		sort(cnt.begin(),cnt.end());
		if(sqrt(cnt[0]*cnt[0] + cnt[1]*cnt[1]) == cnt[2])
			arr.push_back(true);
		else
			arr.push_back(false);
	}
	for(int i=0;i<arr.size();i++)
	{
		if(arr[i] == true)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;

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

    string s;
    cin >> s;
    int a = -1, b;
    rep(i, s.size())
    {
        if (s[i] == 'A' && a == -1)
            a = i;
        if (s[i] == 'Z')
            b = i;
    }
    cout << b - a + 1 << endl;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define ll long long
#define rg register
#define inf 0x7f7f7f7f7f7f7f
#define maxn 521255
#define int ll
#define mod 998244353
#define pi 3.14159265358979323846264
#define x1 asdsa
#define x2 eajifedf
#define x3 jifefi
#define x4 asdij
#define x5 dskfj
#define y1 sid
#define y2 asdas
#define y3 asdoj
#define y4 xzy
#define y5 nb
#define IT set<node>::iterator
#pragma GCC optimize(3)
#pragma -fcrossjumping
#pragma -fdefer-pop
#pragma -fmerge-constans
#pragma -fthread-jumps
#pragma -floop-optimize
#pragma -fif-conversion
#pragma -fif-conversion2
#pragma -fdelayed-branch
#pragma -fguess-branch-probability
#pragma -fcprop-registers
#pragma -fforce-mem
#pragma -foptimize-sibling-calls
#pragma -fstrength-reduce
#pragma -fgcse
#pragma -fcse-follow-jumps
#pragma -frerun-cse-after-loop
#pragma -fdelete-null-pointer-checks
#pragma -fextensive-optimizations
#pragma -fregmove
#pragma -fschedule-insns
#pragma -fsched-interblock
#pragma -fcaller-saves
#pragma -fpeephole2
#pragma -freorder-blocks
#pragma -fstrict-aliasing
#pragma -funit-at-a-time
#pragma -falign-functions
#pragma -fcrossjumping
#pragma -finline-functions
#pragma -fweb
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
inline void print(ll x)
{
	if(x>=10)
	{
		print(x/10);
	}
	putchar(x%10+'0');
}
inline ll max(ll a,ll b)
{
	if(a>b) return a;
	return b;
}
inline ll min(ll a,ll b)
{
	if(a>b) return b;
	return a;
}
int jc[maxn];
int n,k,a,b,ans;
inline int ksm(int a,int b)
{
	int ans=1;
	a%=mod;
	while(b)
	{
		if(b&1) ans=(ans*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return ans%mod;
}
inline void pre_work()
{
	int sum=1;
	jc[0]=1;
	for(rg int i=1;i<=n+10;++i)
	{
		sum*=i;
		sum%=mod;
		jc[i]=sum;
	}
}
inline int C(int n,int m)
{
	if(m>n) swap(n,m);
	int ny=ksm((jc[m]*jc[n-m])%mod,mod-2);
	return jc[n]%mod*ny%mod;
}
signed main()
{
	n=read(),a=read(),b=read(),k=read();
	pre_work();
	for(rg int i=0;i<=n;++i)
	{
		if(a*i>k) break;
		int res=k-a*i;
		if(res%b!=0) continue;
		else
		{
			int numb=res/b;//b的数量 
			if(numb>n) continue;
			ans+=(C(n,i)*C(n,numb)%mod);
			ans%=mod;
		}
	}
	cout<<ans%mod;
} 

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

int main() {
  string s;
  cin >> s;
  vector<int> arr(2019);
  int res = 0;
  for (char c : s) {
    vector<int> new_arr(2019);
    int x = c - 48;
    for (int i = 0; i < 2019; ++i) {
      int y = (i * 10 + x) % 2019;
      new_arr[y] += arr[i];
    }
    new_arr[x]++;
    res += new_arr[0];
    arr = new_arr;
  }
  cout << res << endl;
}


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

int main(void){
    
    int N,A;
    cin >> N;
    
    for(int i=0;i<N;i++){
        cin >> A;
        if(A % 2 == 0){
            if(A % 3 != 0 &&  A % 5 != 0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;

int s[3];
int l[9];
int N;
vector<int> v;
int dfs(int k,vector<vector<int>> a){
    int ret=INF;
    if(k==N){
        sort(ALL(v));
        for (int i = 0; i < 3; i++) {
            if(!a[i].size()) return ret;
        }
        do{
            int tmp=0;
            for (int i = 0; i < 3; i++) {
                tmp+=abs(s[v[i]]-accumulate(ALL(a[i]),0))+(a[i].size()-1)*10;
            }
            ret=min(ret,tmp);
        }while(next_permutation(ALL(v)));
        return ret;
    }
    ret=min(ret,dfs(k+1,a));
    for (int i = 0; i < 3; i++) {
        a[i].pb(l[k]);
        ret=min(ret,dfs(k+1,a));
        a[i].pop_back();
    }
    return ret;
}

int main(){
    cin >> N;
    for (int i = 0; i < 3; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }
    v.pb(0);
    v.pb(1);
    v.pb(2);
    cout << dfs(0,vector<vector<int>>(3)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

/** Application main entry point. */
int main (
  int argc,
  char *argv[ ]
  )
{
  int res = 100000;
  int n;
  
  scanf ( "%d", &n );

  while ( n-- )
  {
    res += res / 20;
    if ( res % 1000 )
    {
      res = ( res / 1000 ) * 1000 + 1000;
    }
  }
  printf ( "%d\n", res );

  return ( 0 );
}

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

 
int main() {
	int k,s;
	cin >> k >> s;
	
	int ans=0;
	
	
	for(int i=0;i<k+1;i++){
		//cout << "test" << endl;
		for(int j=0;j<k+1;j++){
			int l=s-(i+j);
			if(0<=l && l<=k){
					ans++;
			}
		}
	}
			
	
	
	
	cout << ans << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int f(char x)
{
	if(x == 'R')
		return 0;
	if(x == 'G')
		return 1;
	if(x == 'B')
		return 2;
}

int main()
{
	int n;
	cin >> n;
	vector<vector<int> > rgb(3,vector<int>(n+1,0));
	string s;
	cin >> s;
	for(int i = 1; i <= n; i++){
		rgb[0][i] = (s[i-1] == 'R');
		rgb[1][i] = (s[i-1] == 'G');
		rgb[2][i] = (s[i-1] == 'B');
	}
	for(int i = 1; i <= n; i++)
	{
		rgb[0][i] += rgb[0][i-1];
		rgb[1][i] += rgb[1][i-1];
		rgb[2][i] += rgb[2][i-1];
	}

	// for(int i = 0; i <3; i++)
	// {
	// 	for(int j = 0; j <= n; j++)
	// 	{
	// 		cout << rgb[i][j] << " ";
	// 	}
	// 	cout <<endl;
	// }

	long long ans = 0;
	for(int i = 0; i < n; i++)
	{
		int idx = f(s[i]);

		int nxt1 = (idx+1)%3;
		int nxt2 = (idx+2)%3;

		ans += rgb[nxt1][i]*(rgb[nxt2][n] - rgb[nxt2][i]);
		//cout << rgb[nxt1][i]*(rgb[nxt2][n] - rgb[nxt2][i]) << endl;
		ans += rgb[nxt2][i]*(rgb[nxt1][n] - rgb[nxt1][i]);
		//cout << rgb[nxt2][i]*(rgb[nxt1][n] - rgb[nxt1][i]) << endl;
		int j = i-1;
		int k = i+1;
		while(j >= 0 and k < n)
		{
			if(s[j] != s[i] and s[j] != s[k] and s[i] != s[k])
			{
				ans -=1;
				//cout << i << " " << j << " " << k << endl;
			}
			j--;
			k++;
		}

		//cout << endl;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3636
// https://atcoder.jp/contests/abc100/tasks/abc100_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

struct Cake {
    int x, y, z;
};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<Cake> v(N);
    for (auto &t : v) {
        cin >> t.x >> t.y >> t.z;
    }
    int maxv = 0;
    // x, y, zで±を反転
    REP(i, 8) {
        sort(ALL(v), [&](Cake const &lhs, Cake const &rhs) {
            int ls = lhs.x * (i & 1 ? 1 : -1) + lhs.y * (i & 2 ? 1 : -1) +
                     lhs.z * (i & 4 ? 1 : -1);
            int rs = rhs.x * (i & 1 ? 1 : -1) + rhs.y * (i & 2 ? 1 : -1) +
                     rhs.z * (i & 4 ? 1 : -1);
            return ls > rs;
        });
        int sum = 0;
        REP(j, M) {
            sum += v[j].x * (i & 1 ? 1 : -1) + v[j].y * (i & 2 ? 1 : -1) +
                   v[j].z * (i & 4 ? 1 : -1);
        }
        maxv = max(maxv, sum);
    }
    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 256
import kotlin.system.measureTimeMillis

val dGrid = mutableListOf<List<Int>>()
var C = 0

val list0M = mutableMapOf<Int,Int>()
val list1M = mutableMapOf<Int,Int>()
val list2M = mutableMapOf<Int,Int>()
fun main(args: Array<String>) {
    val (n, c) = readLine()!!.split(" ").map(String::toInt)
    C = c
    val list0 = mutableListOf<Int>()
    val list1 = mutableListOf<Int>()
    val list2 = mutableListOf<Int>()

    for (i in 1..c) {
        dGrid.add(readLine()!!.split(' ').map(String::toInt))
    }

    for (i in 1..n) {
        val cList = readLine()!!.split(' ').map(String::toInt)
        list0.addAll(cList.filterIndexed { index, it -> (index + i + 1) % 3 == 0 })
        list1.addAll(cList.filterIndexed { index, it -> (index + i + 1) % 3 == 1 })
        list2.addAll(cList.filterIndexed { index, it -> (index + i + 1) % 3 == 2 })
    }

    for (i in 1..c) {
        list0M[i] = list0.filter { it == i }?.size?:0
        list1M[i] = list1.filter { it == i }?.size?:0
        list2M[i] = list2.filter { it == i }?.size?:0
    }
    val millis = measureTimeMillis { run() }

}

private fun run() {



    var min = Long.MAX_VALUE
    for (c1 in 1..C) {
        for (c2 in 1..C) {
            if (c1 == c2) continue
            for (c3 in 1..C) {
                if ((c1 == c2) || (c2 == c3) || (c1 == c3)) continue

                val sum = calcD(c1, list0M) + calcD(c2, list1M) + calcD(c3, list2M)
                min = Math.min(sum, min)
            }
        }
    }
    println(min)
}

fun calcD(c: Int, map: Map<Int, Int>): Long {
    var sum = 0L
    for (i in 1..C) {
        sum += dGrid[i - 1][c - 1] * map!![i]!!
    }
    return sum
}

Measured memory_bytes: 57760
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int64_t n, m;
    cin >> n >> m;
    priority_queue<int64_t> que;
    for (int i = 0; i < n; i++)
    {
        int64_t v;
        cin >> v;
        que.push(v);
    }
    for (int i = 0; i < m; i++)
    {
        auto v = que.top();
        que.pop();
        que.push(v / 2);
    }
    int64_t sum = 0;
    while (!que.empty())
    {
        sum += que.top();
        que.pop();
    }
    cout << sum << endl;
}


Measured memory_bytes: 1400
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll a, b, h, m;
  cin >> a >> b >> h >> m;

  double dl = 6.0 * m;
  double ds = 30 * (h + m / 60.0);

  double theta = abs(dl - ds);
  chmin(theta, 360.0 - theta);

  double ans = a * a + b * b - 2 * a * b * cos(theta*M_PI/180.0);
  ans = sqrt(ans);

  cout << ans << endl;

  return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int P[100000];

vector<int>G[100000];
int to[100000];

int dist[100000];

signed main(){
    scanf("%lld",&N);
    rep(i,N)scanf("%lld",&P[i]);

    memset(to,-1,sizeof(to));
    queue<pint>que;
    rep(i,N){
        if(P[i]==0)que.push(pint(i,i)),to[i]=i;
        else{
            G[i+P[i]].pb(i);
        }
    }

    while(que.size()){
        int v,a;
        tie(v,a)=que.front();
        que.pop();
        for(auto u:G[v]){
            to[u]=a;
            que.push(pint(u,a));
        }
    }

    fill_n(dist,N,1001001001);
    dist[0]=0;
    queue<int>que2;
    que2.push(0);
    while(que2.size()){
        int v=que2.front();
        que2.pop();
        for(int i=1;i<=6;i++){
            if(v+i>=N)continue;
            int u=v+i;
            if(to[u]==-1)continue;
            u=to[u];
            if(dist[u]!=1001001001)continue;
            dist[u]=dist[v]+1;
            que2.push(u);
        }
    }

    cout<<dist[N-1]<<endl;
    return 0;
}

Measured memory_bytes: 10744
#include <stdio.h>
#include <string.h>
int main(void){
	char b[101],c[101];
	int a,i,tcnt=0,hcnt=0;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%s %s",&b,&c);		
		if(strcmp(b,c)>0)
			tcnt+=3;
		if(strcmp(b,c)==0){
			tcnt++;
			hcnt++;}
		if(strcmp(b,c)<0)
			hcnt+=3;
	}
	printf("%d %d\n",tcnt,hcnt);
	return 0;
}
	

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

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

    rep(i, K) {
        if (i%2 == 0) {
            if (A%2) A--;
            B += A/2;
            A /= 2;
        }
        else {
            if (B%2) B--;
            A += B/2;
            B /= 2;
        }
    }

    cout << A << " " << B << endl;
}


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

m = sum(A)
plc = 0
l = sum(A)
S = 0

for i in range(N):
    S += A[i]
    if abs(S-l/2) < m:
        m = abs(S-l/2)
        plc = i

print(abs(sum(A[:(plc+1)])-sum(A[(plc+1):])))

Measured memory_bytes: 26060
#include <bits/stdc++.h>
using namespace std;
#define data_type long long
#define endl "\n"
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(nullptr);
    data_type n,ans=0;
    cin>>n;
    vector<data_type>vc(n);
    for(auto &i:vc)
        cin>>i;
    for(int i=0;i<n;i++)
    {
       for(int j=i+1;j<n;j++)
       {
          for(int k=j+1;k<n;k++)
            if(vc[i]!=vc[j]&& vc[i]!=vc[k] && vc[j]!=vc[k])
             if(vc[i]+vc[j]>vc[k]&& vc[j]+vc[k]>vc[i]&& vc[i]+vc[k]>vc[j])
             ans++;
       }
    }
cout<<ans<<endl;

    return 0;
}


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

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

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int x, y;
    cin >> x >> y;

    bool ok = false;
    for (int i = 0; i <= x; ++i) {
        if(i * 2 + (x-i) * 4 == y){
            ok = true;
        }
    }

    cout << (ok ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int a=0,b=0,count=0;

void dictionary(int *p,int i,int n,int *P,int *Q){
    int j,k,t;
    if (a!=0&&b!=0) {
        return;
    }
    if (i<n) {
        for (j=i; j<=n; j++) {
            t=p[j];
            for (k=j;k>i; k--) p[k]=p[k-1];
            p[i]=t;
            dictionary(p, i+1,n,P,Q);
            for (k=i; k<j; k++) p[k]=p[k+1];
            p[j]=t;
        }
    }else{
        count++;
        for (j=1; j<=n; j++) if (P[j-1]!=p[j]) break;
        if (j==n+1) a=count;
        for (j=1; j<=n; j++) if (Q[j-1]!=p[j]) break;
        if (j==n+1) b=count;
    }
}

int main(){
    int n,i,dict[10]={};
    int p[10],q[10];
    scanf("%d",&n);
    scanf("%d",&p[0]);
    for (i=1; i<n; i++) scanf(" %d",&p[i]);
    scanf("%d",&q[0]);
    for (i=1; i<n; i++) scanf(" %d",&q[i]);
    for (i=1; i<=n; i++) dict[i]=i;
    dictionary(dict,1,n,p,q);
    if (a-b<0) {
        printf("%d",b-a);
    }else printf("%d",a-b);
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>

#define S_SIZE 100000

using namespace std;

int S[S_SIZE];

bool isContain(int left,int right,int number){
	int m = (left + right)/2;
	if(S[m] == number){
		return true;
	}else if(left == right){
		return false;
	}else if(S[m] < number){
		return isContain(m + 1,right,number);
	}else{	//S[m] > number
		if(right - left == 1){
			return isContain(left,m,number);
		}else{
			return isContain(left,m-1,number);
		}
	}
}

int main(){

	int tmp;
	int n,q,count = 0;

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

	int left,right;
	scanf("%d",&q);
	for(int i = 0; i < q; i++){
		scanf("%d",&tmp);
		left = 0;
		right = n-1;
		if(isContain(left,right,tmp))
		{
			count++;
		}
	}
	printf("%d\n",count);
}

Measured memory_bytes: 1576
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int p[105000];
vector<int> prime;
int main(){
    for(int i = 2;i * i <= 105000;i++){
	if(p[i])continue;
	for(int j = i * i;j < 105000;j += i){
	    p[j] = 1;
	}
    }
    for(int i = 2;i < 105000;i++){
	if(p[i] == 0)
	    prime.push_back(i);
    }
    int n;
    while(cin >> n){
	int up = *(upper_bound(prime.begin(), prime.end(), n));
	int less = *(lower_bound(prime.begin(), prime.end(), n) - 1);
	cout << less << " " << up << endl;
    }
    return 0;
}

Measured memory_bytes: 1728
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
string strin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin() {ll x;scanf("%lld",&x);return x;}

int main(){
    int n=in();
    vecll a(n*3),sum1(n+1),sum2(n+1);
    multiset<ll> s1;
    multiset<ll,greater<ll>> s2;
    rep(i,n*3)a[i]=lin();
    rep(i,n){
        sum1[0]+=a[i];
        s1.insert(a[i]);
        sum2[n]+=a[2*n+i];
        s2.insert(a[2*n+i]);
    }
    rep(k,n){
        s1.insert(a[n+k]);
        sum1[k+1]=sum1[k]+a[n+k]-*s1.begin();
        s1.erase(s1.begin());
        s2.insert(a[2*n-k-1]);
        sum2[n-1-k]=sum2[n-k]+a[2*n-k-1]-*s2.begin();
        s2.erase(s2.begin());
    }
    ll ans=LONG_MIN;
    rep(k,n+1)ans=max(ans,sum1[k]-sum2[k]);
    cout<<ans<<endl;
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
vector<int> arr(MAXX);
void trozen()
{
    string s;
    cin>>s;
    int ans=0;
    int count=0;
    for(auto i:s)
    {
        if(i=='R') count++;
        else count=0;
        ans=max(ans,count);
    }
    cout<<ans<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 10932
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    char c;cin>>c;
    c+='b'-'a';
    cout<<c<<endl;
}

Measured memory_bytes: 3492
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n) ans += a[i] - 1;
    cout << ans << endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int num = sc.nextInt();
			if (num == -1) {
				break;
			}
			int price = 1150;

			if(num > 10){
				for (int i = 11; i <= num; i++) {
					if(i > 30){
						price += 160;
					}else if (i > 20) {
						price += 140;
					}else if(i > 10 ){
						price += 125;
					}
				}
			}
			System.out.println(4280 - price);

		}
	}

}

Measured memory_bytes: 26276
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
 
const auto ready = []()
{
    std::cin.tie(0);
    std::cout.tie(0);
    std::ios_base::sync_with_stdio(false);
    return true;
}();
 
int main()
{
    int n, m;
    std::cin >> n >> m;
    std::vector<std::string> a(50);
    std::vector<std::string> b(50);
    for(int i = 0; i < n; ++i) std::cin >> a[i];
    for(int i = 0; i < m; ++i) std::cin >> b[i];
    int ans = 0;
    for(int i = 0; i <= n - m; ++i)
    {
        for(int j = 0; j <= n - m; ++j)
        {
            bool match = true;
            for(int row = i; row < i + m; ++row)
            {
                for(int col = j; col < j + m; ++col)
                {
                    if(a[row][col] != b[row - i][col - j]) match = false;
                }
            }
            if(match) ++ans;
        }
    }
    if(ans) std::cout << "Yes\n";
    else std::cout << "No\n";
    return 0;
}

Measured memory_bytes: 3616