akhauriyash/Code-Regression huggingface dataset:
/*
 *Author - Abhas Jain
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
typedef long long ll;
typedef long double ld;
 
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 998244353;
 
void solve() 
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<string, int> mp; 
    int zer = n;
    ll pr = 1;
    for (int i = 0; i < s.length(); ++i) {
    	if (s[i] == 'R') {
    		if (mp["GB"] + mp["BG"] != 0) {
    			pr *= mp["GB"] + mp["BG"];
    			pr %= mod;
    			if (mp["GB"]) mp["GB"]--;
    			else mp["BG"]--;
    		} else if (mp["G"] + mp["B"] != 0) {
    			pr *= mp["G"] + mp["B"];
    			pr %= mod;
    			if (mp["G"]) {
    				mp["G"]--;
    				mp["GR"]++;
    			}
    			else {
    				mp["B"]--;
    				mp["BR"]++;
    			}
    		} else {
    			pr *= zer;
    			pr %= mod;
    			zer--;
    			mp["R"]++;
    		}
    	} else if (s[i] == 'G') {
    		if (mp["RB"] + mp["BR"] != 0) {
    			pr *= mp["RB"] + mp["BR"];
    			pr %= mod;
    			if (mp["RB"]) mp["RB"]--;
    			else mp["BR"]--;
    		} else if (mp["R"] + mp["B"] != 0) {
    			pr *= mp["R"] + mp["B"];
    			//cout << mp["R"] << "lil" << endl;
    			pr %= mod;
    			if (mp["R"]) {
    				mp["R"]--;
    				mp["RG"]++;
    			}
    			else {
    				mp["B"]--;
    				mp["BG"]++;
    			}
    		} else {
    			pr *= zer;
    			pr %= mod;
    			zer--;
    			mp["G"]++;
    		}    		
    	} else {
    		if (mp["RG"] + mp["GR"] != 0) {
    			pr *= mp["RG"] + mp["GR"];
    			pr %= mod;
    			if (mp["RG"]) mp["RG"]--;
    			else mp["GR"]--;
    		} else if (mp["R"] + mp["G"] != 0) {
    			pr *= mp["R"] + mp["G"];
    			pr %= mod;
    			if (mp["R"]) {
    				mp["R"]--;
    				mp["RB"]++;
    			}
    			else {
    				mp["G"]--;
    				mp["GB"]++;
    			}
    		} else {
    			pr *= zer;
    			pr %= mod;
    			zer--;
    			mp["B"]++;
    		}
    	}
    	//cout << pr << endl;
    }
    cout << pr << endl;
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

Measured memory_bytes: 720
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int c = saori.saori_hayami();
		int d = saori.saori_hayami();
		int ans = 0;
		if(a > b){
			ans += b;
		} else {
			ans += a;
		}
		if(c > d){
			ans += d;
		} else {
			ans += c;
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
#include<stdio.h>
#include<string.h>
int main()
{
	char S[4];
	scanf("%s",S);
	if(S[0]==S[1] || S[2]==S[3] || S[1]==S[2])
	{
		printf("Bad\n");
	}
	else
		printf("Good\n");
	return 0;
}


Measured memory_bytes: 128
/*

by.YXH_XianYu
   2018.6.15
 */
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define MXN 10000

int n,ch;
long long ans,tmp;

int main(){
	//freopen("mothergoose.in","r",stdin);
	//freopen("mothergoose.out","w",stdout);

	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&ch);
		for(int i=(1<<30),j=30;i>=2;i/=2,j--)
			if(ch%i==0)
				ch/=i,ans+=j;
	}
	printf("%lld\n",ans);

	return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a*b%2 == 1) cout << "Odd" << endl;
  else cout << "Even" << endl;
}

Measured memory_bytes: 256
#
# File    : C.rb
# Author  : Kazune Takahashi
# Created : 2018-12-2 21:03:42
# Powered by Visual Studio Code
#

n = gets.to_i

ary = Array.new(11){[]}
ary[0] = ['7', '5', '3']

10.times{|t|
  ary[t].each{|x|
    ary[t+1] << x + '7'
    ary[t+1] << x + '5'
    ary[t+1] << x + '3'
  }
}

ans = []
11.times{|t|
  ans.concat(ary[t])
}

res = 0

ans.each{|str|
  if !(str.include?('3') && str.include?('5') && str.include?('7'))
    next
  end
  if str.to_i <= n
    res += 1
  end
}

puts res

Measured memory_bytes: 28412
#include<iostream>
using namespace std;
int a,b,c,x,n,m,p;
int main (void) {
    cin >> n >> m;
    p = 1;
    for (int i = 1; i <= m; i ++) {
        p*=2;
    }
    cout <<(n-m)*p*100 + m*p*1900;
    return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int a, b;

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

    if (a <= 0 && b >= 0) {
	puts("Zero");
    } else if (a > 0) {
	puts("Positive");
    } else {
	int neg = b - a + 1;
	if (neg & 1) {
	    puts("Negative");
	} else puts("Positive");
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  bool flag[10001] = {0};
  for(int i = 2;i < 10001;i++){
    if(flag[i])continue;
    for(int j = i + i;j < 10001;j += i)flag[j] = true;
  }
  int n;
  int d;
  int sum = 0;
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> d;
    int j,flug = 0;
    for(j = 2;j < 10001 && j < d;j++){
      if(flag[j])continue;
      if(d % j == 0){flug = 1;break;}
    }
    if(!flug)sum++;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   string s;
   cin >> s;

   int cnt = 0;
   rep(i,s.size()/2){
      if(s[i] != s[s.size()-1-i]){
         cnt++;
      } 
   }

   cout << cnt << endl;



   return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [0 for _ in range(n+1)]
for i in range(1,n+1):
  if i*i>n:
    break
  for j in range(1,n+1):
    if i*i + j*j +i*j > n:
      break
    for k in range(1,n+1):
      tmp = i*i + j*j + k*k + i*j + j*k + k*i
      if tmp<=n:
        a[tmp]+=1
      else:
        break
for i in range(1,n+1):
  print(a[i])


Measured memory_bytes: 9084
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();

		for(int k=0;k<K;k++){
			if(A+k<=B)
			System.out.println(A+k);
		}
		int max = A+K;
		for(int k=K-1;k>=0;k--){
			if(max>B-k) continue;
			System.out.println(B-k);
		}
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define inf 10e+8
int n;
int f[100][10];
int p[100][11];
int t[10]={};
int cnt(int n){
  int c=0;
  for(int i=0;i<10;i++){
    if(f[n][i]&&t[i]) c++;
  }
  return c;
}

void next(){
  t[0]+=1;
  for(int i=0;i<9;i++){
    t[i+1]+=t[i]/2;
    t[i]=t[i]%2;
  }
}

int main(){
  int max=-inf;
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<10;j++)
      cin>>f[i][j];
  for(int i=0;i<n;i++)
    for(int j=0;j<11;j++)
      cin>>p[i][j];
  t[0]=1;
  while(t[9]!=2){
    int tmp=0;
    for(int i=0;i<n;i++){
      tmp+=p[i][cnt(i)];
    }
    if(max<tmp)max=tmp;
    next();
  }
  cout<<max<<endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    ll n;
    cin >> n;
    vector<ll>b(n-1);
    for (ll i = 0; i < n - 1; i++) {
        cin >> b[i];
    }

    vector<ll>a(n);
    a[0] = b[0];

    for (ll i = 1; i < n - 1; i++) {
        a[i] = min(b[i], b[i-1]);
    }

    a[n - 1] = b[n - 2];

    ll s = 0;

    for (ll i = 0; i < n ; i++) {
        s += a[i];
    }

    cout << s << endl;
    return 0;

}



Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long A, B, C;
  cin >> A >> B >> C;
  if (C == 0) {
    cout << "YES" << endl;
    return;
  }
  for (long i = A; i % B > 0; i += A) {
    if (i % B == C) {
      cout << "YES" << endl;
      return;
    }
  }
  cout << "NO" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
ll dp[110][100010] = {};

int main(){
	ll N,W;
	cin >> N >> W;
	ll w[110], v[110];
	rep(i,0,N){
		cin >> w[i] >> v[i];
	}
	rep(i,0,N+1){
		rep(j,0,1000*N+1){
			dp[i][j] = 2e9;
		}
	}
	dp[0][0] = 0;

	rep(i,0,N){
		rep(j,0,1000 * N + 1){
			if(j - v[i] >= 0){
				dp[i+1][j] = min(dp[i+1][j], dp[i][j - v[i]] + w[i]);
			}
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);

		}
	}
	ll ans = 0;
	rep(i,0,1000*N+1){
		if(dp[N][i] <= W){
			ans = max(ans, i);
		}
	}
	cout << ans << endl;


}

Measured memory_bytes: 80128
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main() {


    zoom;
    long double N, K;
    cin>>N>>K;
    ll mV = (ll)ceil(N / 2.0);
    if(K <= mV)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
    std.range, std.container, std.bigint, std.ascii, std.typecons;

// }}}
// nep.scanner {{{
class Scanner
{
    import std.stdio : File, stdin;
    import std.conv : to;
    import std.array : split;
    import std.string : chomp;

    private File file;
    private char[][] str;
    private size_t idx;

    this(File file = stdin)
    {
        this.file = file;
        this.idx = 0;
    }

    private char[] next()
    {
        if (idx < str.length)
        {
            return str[idx++];
        }

        char[] s;
        while (s.length == 0)
        {
            s = file.readln.chomp.to!(char[]);
        }

        str = s.split;
        idx = 0;

        return str[idx++];
    }

    T next(T)()
    {
        return next.to!(T);
    }

    T[] nextArray(T)(size_t len)
    {
        T[] ret = new T[len];

        foreach (ref c; ret)
        {
            c = next!(T);
        }

        return ret;
    }

    void scan()()
    {
    }

    void scan(T, S...)(ref T x, ref S args)
    {
        x = next!(T);
        scan(args);
    }
}
// }}}

void main()
{
    auto cin = new Scanner;
    string s;
    cin.scan(s);
    writeln(s[0] ~ (s.length - 2).to!string ~ s[$ - 1]);
}


Measured memory_bytes: 256
s = input().strip()
i=0
p=-1
while True:
  if i+2 == len(s):
    if s[i]==s[i+1]:
      p=1
      break
  elif i+1 == len(s):
    break
  else:
    if s[i] == s[i+1]:
      p=1
      break
    elif s[i] == s[i+2]:
      p=2
      break
  i+=1

if p==1:
  print(i+1, i+2)
elif p==2:
  print(i+1, i+3)
else:
  print(-1, -1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/rope>

using namespace __gnu_pbds; 
using namespace __gnu_cxx;
using namespace std;

typedef long long ll;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
template<typename T> using oset = 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> >;
template<typename T> void done(T ans) {cout << ans << "\n"; exit(0);}

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);

clock_t time_p=clock();
void printTime(){
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}


ll mod=1e9+7;
const int N = 1e5 + 5;
bool collinear(int x1, int y1, int x2, int y2, int x3, int y3) {
  return (y1 - y2) * (x1 - x3) == (y1 - y3) * (x1 - x2);
}

int32_t main(){
    io();
    cout << fixed << setprecision(100);
    ll a, b, c;
    cin >> a >> b >> c;
    a = a + b + 2*sqrtl((long double)a)*sqrtl((long double)b);
    if(a < c - 0.0000000001) {
        cout << "Yes";
    }
    else    cout << "No";


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x,k,d;
	cin>>x>>k>>d;
	x=(x>0?x:-x);
	if(x/d>=k)
	{
		cout<<x-k*d;
		return 0;
	}
	k-=x/d;
	if(k%2==0)
	{
		cout<<x%d;
		return 0;
	}
	cout<<-(x%d-d);
	return 0;
}

Measured memory_bytes: 3636
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    var str = StdIn.readLine()
    val q =  StdIn.readInt()

    for(_ <- 1 to q){

      val line = StdIn.readLine().split(" ")
      val a = line(1).toInt
      val b = line(2).toInt

      line(0) match {
        case "replace" => {
          str = str.take(a) + line(3) + str.takeRight(str.length - b - 1)
        }
        case "reverse" => {
          str = str.take(a) + str.slice(a,b + 1).reverse + str.takeRight(str.length - b - 1)
        }
        case "print"   => println(str.slice(a,b + 1))
      }
    }
  }
}

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

int main(){
  int N; cin >> N;
  int ans = 1e9;
  for(int i = 0; i <= N; i++){
    int c6 = 0, c9 = 0;
    int t = i;
    while(t > 0){
      c6 += t%6;
      t /= 6;
    }
    t = N - i;
    while(t > 0){
      c9 += t%9;
      t /= 9;
    }
    ans = min(ans, c6 + c9);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
 
int main()
{
    int a[5], k;
    rep(i, 5)cin >> a[i];
    cin >> k;
    if(a[4]-a[0] <= k){
        cout << "Yay!" << endl;
    }
    else cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int occ_a = -1, occ_z = -1;

int main()
{
    char ch;
    for (int i = 0; (ch = getchar()) >= 'A' && ch <= 'Z'; ++i) {
        if (ch == 'A' && occ_a == -1) occ_a = i;
        else if (ch == 'Z') occ_z = i;
    }
    printf("%d\n", occ_z - occ_a + 1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

const int maxv = 100005;




int main(){
    string s, t;
    map<char, vector<int>> counter;
    cin >> s >> t;

    rep(i,s.size()){
        int index = i+1;
        // 各文字毎の出現位置を格納
        counter[s[i]].push_back(index);
    }

    ll ans = 0;
    int prev_index;
    // tの文字数分繰り返す
    rep(i, t.size()){
        char ch = t[i];
        // Sに登場しなかった場合は終了
        if (counter[ch].empty()){
            cout << -1 << endl;
            return 0;
        }
        if (i == 0) {
            prev_index = counter[ch][0];
            ans = prev_index;
            continue;
        }
        else{
            int size = counter[ch].size();
            vector<int> c = counter[ch];
            int next_index;
            if (prev_index >= c[size-1]){
                next_index = c[0];
            }
            else{
                //int c_index = upper_bound(c.begin(), c.end(), prev_index) - c.begin();
                
                ll ng = -1;
                ll ok = c.size();
                
                while(abs(ok-ng)>1){
                    ll mid = (ok+ng) / 2;
                
                    if(c[mid] > prev_index) ok = mid;
                    else ng = mid;
                }

                next_index = c[ok];
            }

           if (prev_index < next_index){
                ans += next_index - prev_index;
            }else{
                ans += next_index + (s.size() - prev_index);
            }
            prev_index = next_index;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4420
import java.util.*
 
fun main(args : Array<String>) {
    val scanner = Scanner(System.`in`)
    val N = scanner.nextLine().toInt()
    var temp = scanner.nextLine().split(" ")
    val arr = IntArray(temp.size) { temp[it].toInt() } 
    var count = 0
    for(i in 0 until arr.size - 2) {
      for(j in i + 1 until arr.size - 1) {
        for(k in j + 1 until arr.size) {
           if(arr[i] != arr[j] && arr[j] != arr[k] && arr[k] != arr[i]) {
              val temp = intArrayOf(arr[i], arr[j], arr[k])
              val max = temp.max()!!
              if(temp.sum() - max > max) count++ 
           }
        }
      }
    }
    
    // 4 4 5 7 9
    println(count)
}

Measured memory_bytes: 49144
n,a,b=map(int,input().split())
s=list(input())
ac=0
bc=0
for i in range(n):
    if s[i]=='a':
        if ac+bc<a+b:
            print('Yes')
            ac+=1
        else:
            print('No')
    elif s[i]=='b':
        if ac+bc<a+b and bc<b:
            print('Yes')
            bc+=1
        else:
            print('No')
    else:
        print('No')
          

Measured memory_bytes: 4708
#include<stdio.h>
int main(void){
	int a;
	int b;
	scanf("%d %d\n",&a,&b);
	if(a<b){
	printf("a < b\n",a,b);
	}else if(a==b){
	printf("a == b\n",a,b);
	}else{
	printf("a > b\n",a,b);
	}
	
	return 0;
}


Measured memory_bytes: 2084
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a,b,c,d;

int gcd(int a,int b)
{
	if(b == 0) return a;
	return gcd(b,a%b);
}
int main(void)
{
 	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
 	ll t1 = b/c-(a-1)/c;
 	ll t2 = b/d-(a-1)/d;
// 	ll g = c*d/__gcd(c,d);
	ll g = c*d/gcd(c,d);
 	ll t3 = b/g-(a-1)/g;
 	printf("%lld",(b-a+1)-t1-t2+t3);
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.buffer.readline

N = int(input())
adj = [[] for _ in range(N+1)]
edge = {}
for i in range(N-1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)
    edge[(a, b)] = i
    edge[(b, a)] = i

que = deque()
que.append(1)
seen = [-1] * (N+1)
seen[1] = 0
ans = [0] * (N-1)
while que:
    v = que.pop()
    j = 1
    for u in adj[v]:
        if seen[u] < 0:
            if j == seen[v]:
                j += 1
            seen[u] = j
            ans[edge[(u, v)]] = j
            que.appendleft(u)
            j += 1

print(max(ans))
for a in ans:
    print(a)


Measured memory_bytes: 93796
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, dp[108][4][4][4];
ll MOD = 1e9+7;
//acgt
string dec(int i, int j, int k){
	string c[4] = {"a", "c", "g", "t"};
	string r = c[i]+c[j]+c[k];
	return r;
}

int main(){
	cin >> n;
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 4; j++){
			for(int k = 0; k < 4; k++){
				string d = dec(i, j, k);
				if(d == "acg" || d == "agc" || d == "gac"){dp[0][i][j][k] = 0;}
				else{dp[0][i][j][k] = 1;}
			}		
		}	
	}
	
	for(int step = 1; step <= n-3; step++){
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				for(int k = 0; k < 4; k++){
					string d = dec(i, j, k);
					if(d == "acg" || d == "agc" || d == "gac"){dp[step][i][j][k] = 0;}
					else{
						if(d == "tgc" || d == "ggc" || d == "cgc" || d == "gcc" || d == "gtc" ){
							dp[step][i][j][k] += dp[step-1][1][i][j];
							dp[step][i][j][k] += dp[step-1][2][i][j];
							dp[step][i][j][k] += dp[step-1][3][i][j];
							dp[step][i][j][k] %= MOD;
						}
						else{
							dp[step][i][j][k] += dp[step-1][0][i][j];
							dp[step][i][j][k] += dp[step-1][1][i][j];
							dp[step][i][j][k] += dp[step-1][2][i][j];
							dp[step][i][j][k] += dp[step-1][3][i][j];
							dp[step][i][j][k] %= MOD;
						}
					}
				}		
			}	
		}
	}
	
	ll ans = 0;
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 4; j++){
			for(int k = 0; k < 4; k++){
				ans += dp[n-3][i][j][k];
				ans %= MOD;
			}		
		}	
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
signed main(){
    int n,p;
    cin>>n>>p;
    int a=0,b=0;
    REP(i,n){
        int t;
        cin>>t;
        if(t%2){
            a++;
        }else{
            b++;
        }
    }
    if(p&&!a){
        cout<<0<<endl;
        return 0;
    }
    if(!p&&!a){
        cout<<(int)pow(2,n)<<endl;
        return 0;
    }
    cout<<(int)pow(2,n-1)<<endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    set<string> st;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
}


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

using ll = long long;
const int AMAX = 1e5;
ll cnt[AMAX+1];

int main(){
  int n;
  ll k;
  cin>>n >>k;
  
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a >>b;
    cnt[a]+=b;
  }
  
  for(int i=1;i<=AMAX;i++){
    if(k<=cnt[i]){
      cout<<i<<endl;
      return 0;
    }
    k-=cnt[i];
  }
}

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


using namespace std;

#define ll long long

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
        cin >> b[i];
    vector<int> c(n);
    ll s = 0;
    bool eq = true;
    for (int i = 0; i < n; i++) {
        c[i] = a[i] - b[i];
        if (c[i] != 0) {
            eq = false;
        }
        s += c[i];
    }
    if (eq) {
        cout << "Yes\n";
        return 0;
    }
    if (s >= 0) {
        cout << "No\n";
        return 0;
    }
    ll neg = 0;
    ll pos = 0;
    for (int i = 0; i < n; i++) {
        if (c[i] < 0) {
            neg += (-1 * c[i]) / 2;
        } else {
            pos += c[i];
        }
    }
    if (neg < pos) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }
    return 0;
}












Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  long X;cin>>X;
  for(long a=-1000;a<=1000;a++)for(long b=-1000;b<=1000;b++){
    long y=a*a*a*a*a-b*b*b*b*b;
    if(X==y){cout<<a<<" "<<b;return 0;}
  }
}

Measured memory_bytes: 3644
n = input()
l = len(n)
k = int(input())
dp = [[[0]*(k+1) for _ in range(2)] for _ in range(l+1)]
dp[0][0][0] = 1
for i in range(l):
    nd = int(n[i])
    if nd == 0:
        for j in range(k+1):
            dp[i+1][0][j] += dp[i][0][j]
    else:
        for j in range(k+1):
            dp[i+1][1][j] += dp[i][0][j]
        for j in range(k):
            dp[i+1][0][j+1] += dp[i][0][j]
            dp[i+1][1][j+1] += dp[i][0][j]*(nd-1)
    for j in range(k):
        dp[i+1][1][j+1] += dp[i][1][j]*9
    for j in range(k+1):
        dp[i+1][1][j] += dp[i][1][j]
# for i in range(l+1): print(dp[i])
print(dp[l][0][k]+dp[l][1][k])

Measured memory_bytes: 9220
while (m,f,r = gets.chomp.split.map(&:to_i)) != [-1, -1, -1]
  if m == -1 || f == -1
    puts "F"
  else
    case m + f
    when 80..100
      puts "A"
    when 65..80
      puts "B"
    when 50..65
      puts "C"
    when 30..50
      puts r >= 50 ? "C" : "D"
    else
      puts "F"
    end
  end
end

Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, a[205];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	FOR(i, 2*n) cin >> a[i];
	sort(a, a+2*n);
	int ret = 0;
	FOR(i, n) {
		ret += min(a[2*i], a[2*i+1]);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
while tmp = gets
  tmp = tmp.chomp.to_f
  if tmp <= 48
    puts "light fly"
  elsif tmp <= 51
    puts "fly"
  elsif tmp <= 54
    puts "bantam"
  elsif tmp <= 57
    puts "feather"
  elsif tmp <= 60
    puts "light"
  elsif tmp <= 64
    puts "light welter"
  elsif tmp <= 69
    puts "welter"
  elsif tmp <= 75
    puts "light middle"
  elsif tmp <= 81
    puts "middle"
  elsif tmp <= 91
    puts "light heavy"
  elsif 91 < tmp
    puts "heavy"
  end

end


Measured memory_bytes: 6848
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int K  = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
      
     if(B/K*K>=A){
     System.out.println("OK");
     }else{ 
    System.out.println("NG");
    }
}
}

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

ll gcd (ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

ll fraction (ll n) {
    ll res = 1;
    for (ll i = n; i >= 1; i--) {
        res *= i;
    }
    return res;
}

const int MOD = 1000000007;

int main() {
    ll n, k; cin >> n >> k;
    ll ans = k;
    rep (i, n-1) {
        ans *= k-1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#define MIN -1000000
#define MAX 1000000
using namespace std;

int main() {
    int K, X; cin >> K >> X;
    int s, g;

    s = max(X - K + 1, MIN);
    g = min(X + K - 1, MAX);
    for (int i = s; i <= g; i++) cout << i << ' ';
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

a, b, ab, x, y = map(int, input().split())

sum_cost = 0

# 両方必要な部分の計算
if x <= y:
    ryoho = x
else:
    ryoho = y
if (a + b)/ 2 <= ab:
    sum_cost += (a * ryoho)
    sum_cost += (b * ryoho)
else:
    sum_cost += (ab * ryoho * 2)

# 片方が多く必要な部分の計算
kataho = abs(x - y)
if x >= y:
    if a <= ab * 2:
        sum_cost += (a * kataho)
    else:
        sum_cost += (ab * kataho * 2)
else:
    if b <= ab * 2:
        sum_cost += (b * kataho)
    else:
        sum_cost += (ab * kataho * 2)

print(sum_cost)

Measured memory_bytes: 3064
a,b = map(int,list(input().split(" ")))
n = int(input())
c = [0 for i in range(1002)]
ans = 0
c[a]+=1
c[b]-=1
for i in range(n):
      s,f = map(int,list(input().split(" ")))
      c[s]+=1
      c[f]-=1
for i in range(1001):
      c[i+1] += c[i]
      if(c[i]>1):
            ans = 1
print(ans)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K,length=0;
    cin >> N >> K;
    vector<int>l(N);
    for(int i=0;i<N;i++){
        cin >> l.at(i);
    }
    sort(l.begin(),l.end(),greater<int>());
    for(int i=0;i<K;i++){
        length+=l.at(i);
    }
    cout << length;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define MAXN 100010

using namespace std;

int main()
{
    int N, i = 0, num = 0;
    long long a[MAXN] = {0};
    scanf("%d", &N);
    while(i < N)
    {
        scanf("%lld", &a[i]);
        i++;
    }
    sort(a, a+N);
    i = 0;
    while(i < N - 1)
    {
        if(a[i] != a[i + 1])
        {
            num++;
            i++;
        }
        else
        {
            i++;
            i++;
        }
    }
    if(i == N-1)
        printf("%d\n", num + 1);
    else
        printf("%d\n", num);
}


Measured memory_bytes: 1024
def sol():
    n,m=map(int,input().split())
    t,w={},{}
    p,q=set(),set()
    for i in range(m):
        l,r,d=[int(i) for i in input().split()]
        if l in w: w[l].add((r,d))
        else: w[l]={(r,d)}
        p.add(l)
        q.add(r)
    s=p-q
    chk=set()
    if len(s)==0:
        print(["No","Yes"][m==0])
        exit()
    for i in s:
        chk.add((i,0))
        while len(chk):
            x=chk.pop()
            if x[0] in w:
                for j in w[x[0]]:
                    if (i,j[0]) in t and t[(i,j[0])]!=t[(i,x[0])]+j[1]:
                        print("No")
                        exit()
                    elif (i,j[0]) not in t:
                        #t[(i,j[0])]=t[(i,x[0])]+j[1]
                        t[(i,j[0])]=x[1]+j[1]
                        chk.add((j[0],x[1]+j[1]))
    print("Yes")

if __name__=="__main__":
    sol()


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

namespace ABC106B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int ans = 0;
            for (int i = 1; i <= N; i++)
            {
                int count = 0;
                if (i % 2 == 0) continue;
                for (int j = 1; j <= i; j++)
                {   
                    if (i % j == 0) count++;
                }
                if (count == 8) ans++;
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 13140
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanRunes()
	t := scanRunes()

	ss := map[rune][]int{}
	for i, e := range s {
		ss[e] = append(ss[e], i)
	}

	f := map[rune]bool{}
	for _, e := range ss {
		for i := 0; i < len(e)-1; i++ {
			if t[e[i]] != t[e[i+1]] {
				fmt.Fprintln(wr, "No")
				return
			}
		}
		if f[t[e[0]]] {
			fmt.Fprintln(wr, "No")
			return
		}
		f[t[e[0]]] = true
	}
	debug(ss, f)
	fmt.Fprintln(wr, "Yes")

}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll T,N;
#define p(i,n,vect) for(ll i=0;i<(ll)n;++i) {cout<<vect[i]<<" ";} cout<<"\n";
void solve()
{
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   ll p=a*c;
   ll q=a*d;
   ll r=b*c;
   ll s=b*d;
   cout<<max(p,max(q,max(r,s)))<<"\n";
}
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
   
  
    solve();
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
const int N=20005;
const int MOD=1e9+7;
 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
 int a[N],b[N],c[N];
 
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/




int x,y;
cin>>x>>y;
if(y%2)
{
	cout<<"No";
	return 0;
}
int a=2*x;
int b=4*x;
if(y>=a && y<=b)
{
	cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;
}



Measured memory_bytes: 3652
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

X = input()

n = 0
for x in X:
  if x == "S":
    n += 1
  else:
    if n > 0:
      n -= 1

print(2*n)


Measured memory_bytes: 4380
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
typedef long long ll;
typedef vector<pair<int, char> > P;

int main() {
    ll n;
    cin >> n;
    P part(3*n);
    for(ll i=0;i<n;i++){
        cin >> part[i].first;
        part[i].second = 'c';
    }
    for(ll i=0;i<n;i++){
        cin >> part[n+i].first;
        part[n+i].second = 'b';
    }
    for(ll i=0;i<n;i++){
        cin >> part[2*n+i].first;
        part[2*n+i].second = 'a';
    }
    
    sort(part.begin(),part.end());
   ll st1=1,st2=0,st3=0,st4=0;
    for(ll i=0;i<3*n;i++){
        switch(part[i].second){
            case 'c':
            st2 += st1;
            break;
            case 'b':
            st3 += st2;
            break;
            case 'a':
            st4 += st3;
            break;
        }
    }
    cout << st4 << endl;
}

Measured memory_bytes: 2560
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var check = 0;
  var isOK = false;
  while(check <= N){
    if((check * (check + 1)) / 2 == N){
      isOK = true;
      break;
    }
    check++;
  }
  if(!isOK){
    myout("No");
    return;
  }
  myout("Yes");
  var list = new Array(check + 1);
  for(var i = 0; i < check + 1; i++){
    list[i] = new Array(check);
  }
  var count = 1;
  for(var i = 0; i < check; i++){
    for(var j = i; j < check; j++){
      list[i][j] = count;
      list[j + 1][i] = count;
      count++;
    }
  }
  myerr(list);
  myout(list.length);
  var output = new Array(list.length);
  for(var i = 0; i < list.length; i++){
    list[i].unshift(check);
    output[i] = list[i].join(" ");
  }
  myout(myconv(output, 9));
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b) cout << c << endl;
    if(a==c) cout << b << endl;
    if(b==c) cout << a << endl;
    return 0;
}

Measured memory_bytes: 3608
n,*a=map(int,open(0).read().split())
sa = sum(a)
ha = sa/2
x = 0
for i in range(n):
  x+=a[i]
  if x>=ha:
    break
y = sa-x
print(min(abs(x-y),abs((x-a[i])-(y+a[i]))))

Measured memory_bytes: 25124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

struct P { int x, y, h; };

int main() {
    int N; cin >> N;
    vector<P> v;
    P p0{-1,-1,-1};
    for (int i = 0; i < N; ++i) {
        P p; cin >> p.x >> p.y >> p.h;
        if (p0.h < 0 && p.h > 0) p0 = p;
        v.emplace_back(p);
    }
    for (int cx = 0; cx <= 100; ++cx) {
        for (int cy = 0; cy <= 100; ++cy) {
            bool ok = true;
            int h = p0.h + abs(p0.x - cx) + abs(p0.y - cy);
            for (const auto &p: v) {
                int h_now = max(h - abs(p.x - cx) - abs(p.y - cy), 0);
                if (p.h != h_now) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                cout << cx << " " << cy << " " << h << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3576
#include <cstdio>
#include <cstring>
#include <algorithm>

using std::sort;

const int MAXN=200005;
int n;
int a[MAXN],b[MAXN];

inline void merge(int a[],int mid){ //归并a: 1~mid和mid+1~n
	static int tmp[MAXN];
	tmp[0]=0;
	int lp=1,rp=mid+1;
	while(lp<=mid && rp<=n){
		if(a[lp]<=a[rp])
			tmp[++tmp[0]]=a[lp++];
		else tmp[++tmp[0]]=a[rp++];
	}
	while(lp<=mid) tmp[++tmp[0]]=a[lp++];
	while(rp<=n) tmp[++tmp[0]]=a[rp++];
	memcpy(a+1,tmp+1,n<<2);
}

inline void mod_sort(int a[],int mod){
	int cur=n+1;
	//solve是从高到低依次mod 2^k，
	//所以每次取模时只有两段：a<mod,mod<=a<2*mod
	//而a之前都有序，
	//所以按这个分成1~cur-1，cur~n，
	//这两段也是分别有序的，归并一下就好了
	//这样每次排序是O(n)的
	for(int i=n;i;--i){
		if(a[i]>=mod) cur=i;
		a[i]&=mod-1;
	}
	merge(a,cur-1);
}

inline long long cal(int lim){
	//计算a_i+b_j>=lim的个数
	//用cur卡着走，a_i+b_{cur}恰好<lim
	long long ret=0;
	for(int i=1,cur=n;i<=n;++i){
		while(cur>=1 && a[i]+b[cur]>=lim)
			--cur;
		ret+=n-cur;
	}
	return ret;
}

inline int solve(){
	int ret=0;
	long long tmp=0;
	//虽然都小于2^28，但加起来可以到2^29-2，所以要考虑第28位
	for(int i=28;i>=0;--i){
		//这里要消除高位的影响，所以mod 2^{i+1}，
		//所以a_i+b_j<4*2^i，因为当a_i+b_j<2^i不会对第i位产生贡献，
		//这里考虑的a_i+b_j>=2^i
		mod_sort(a,1<<i+1),mod_sort(b,1<<i+1);
		//考虑第i位，如果a_i+b_j在[2^i,2*2^i)和[3*2^i,4*2^i)，
		//那么第i位为1，因为在[2*2^i,3*2^i)只能是第i+1位为1，
		//所以计算a_i+b_j在[2^i,2*2^i)和[3*2^i,4*2^i)的个数
		//由于模了2^{i+1}，
		//所以就cnt=cnt(>=2^i)-cnt(>=2*2^i)+cnt(>=3*2^i)
		tmp=cal(1<<i)-cal(2<<i)+cal(3<<i);
		ret|=(tmp&1)<<i;
	}
	return ret;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)
		scanf("%d",&b[i]);
	sort(a+1,a+n+1),sort(b+1,b+n+1);
	printf("%d",solve());
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#define For(i,a,b) for(int i=(a);i<(b);i++)
#define Rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15) cout << "+" << endl;
	else if (a*b == 15) cout << "*" << endl;
	else cout << "x" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <math.h>

#include <cmath>
#include <iostream>
using namespace std;
int main() {
    long long n,t=0;
    cin >> n;
    for (long long i = 0; i < n;i++){if(((i+1)%3)!=0&&((i+1)%5)!=0){
            t = t + i+1;
    }
    }
    cout << t << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  double p;
  if (n%2==0) p = 0.5;
  if (n%2==1) p = (n+1.0)/ (n*2.0);
  
  cout << fixed << setprecision(6);
  cout << p << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;

bool flag;

int main()
{
	int n;
	cin>>n;
	int a[15];
	while(n--)
	{
		for(int i=0;i<10;i++)
			cin>>a[i];
		flag=0;
		int l=-1,r=-1;
		for(int i=0;i<10;i++)
		{
			if(a[i]>l) l=a[i];
			else if(a[i]>r) r=a[i];
			else flag=1;
		 } 
		 
		if(!flag)
		 	cout<<"YES"<<endl;
		else
		 	cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 3040
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define read(x) scanf("%d",&x)
int n;
unsigned long long M=1;
inline int deg(unsigned long long x){
	int ret=0;
	while(x) x>>=1,++ret;
	return ret;
}
bool flag=0;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	REP(i,n){
		unsigned long long x;cin>>x;
		if (x==0){
			cout<<0<<endl;return 0;
		}
		int dx=deg(x);
		int dm=deg(M);
		if (dx+dm>62) flag=1;
		M=M*x;
		if (M>(unsigned long long)1e18) flag=1;
	}
	if (flag) cout<<-1<<endl;
	else cout<<M<<endl;
	return 0; 
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int a = 0;
		for(int i=0; i<S.length(); i++) {
			if(S.charAt(i) == T.charAt(i)) {
				continue;
			}
			a++;
		}
		sc.close();
		System.out.println(a);
	}

}

Measured memory_bytes: 41052
#include <bits/stdc++.h>
using namespace std;
#define INF 100005
#define MOD 1000000007

int main()
{
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    string a;
    cin >> a;
    string b;
    for(int i=0;i<a.size();i++)
    {
    	if(a[i]=='0' || a[i]=='1')
    	{
    		b.push_back(a[i]);
    	}else
    	{
    		if(b.size()>0)
    		{
    			b.pop_back();
    		}
    	}
    }
    cout << b << endl;
}


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

#define MAX_N 100000

int N;
pair<int, int> a[MAX_N];

void solve(){
  sort(a, a + N);
  long long ans = 0;
  for(int i = 0; i < N; i++){
    // 偶数なら+0奇数なら+1することで、奇数と偶数が入れ替わった箇所を見つける
    // 奇数から偶数でも、偶数から奇数でもどちらも区別せず、カウントしている
    ans += abs(i - a[i].second) % 2;
  }
  cout << ans / 2 << endl;
  return ;
}

int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a[i].first;
    a[i].second = i;
  }
  solve();
  return 0;
}


Measured memory_bytes: 1024
A,B,C,X,Y = map(int,input().split())
ans = 0
if 2*C <= A+B:
    Z = min(X,Y)
    ans = 2*C*Z
    X -= Z
    Y -= Z
ans += min(2*C*X,A*X)
ans += min(2*C*Y,B*Y)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 
#define F first 
#define S second 
#define ll long long 
#define mp make_pair 
#define pb push_back 

using namespace std;

void test(){
	int n,m;
	cin>>n>>m;
	int a[n];
	f(i,n)cin>>a[i];
	ll tot = 0;
	f(i,n)tot = tot + a[i];
	ll lim = tot/(4*m);
	if(tot%(4*m)!=0)lim++;
	int count = 0;
	f(i,n)if(a[i]>=lim)count++;
	if(count>=m)cout<<"Yes\n";
	else cout<<"No\n";
}

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

Measured memory_bytes: 256
//
// Created by kuroneko on 2019-07-06.
//

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>

typedef long long ll;
using namespace std;

int main() {
    char b; cin >> b;
    if (b == 'A') cout << "T" << endl;
    else if (b == 'T') cout << "A" << endl;
    else if (b == 'G') cout << "C" << endl;
    else cout << "G" << endl;
    return 0;
}


Measured memory_bytes: 256