akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
             
public static class Program
{
    public static void Main()
    {
        int[] R = GetIntArray();
        int N = R[0];
        int K = R[1];
	if (K == 1)
	{
		Console.WriteLine("YES");
		return;
        }
	Console.WriteLine(2 * K <= N + 1? "YES": "NO");
    }
    
    private static string ReadLine()
    {
    	return Console.In.ReadLine();
    }
    
    public static int[] GetIntArray()
    {
    	List<int> temp = new List<int>();
    	foreach (string c in ReadLine().Split(' '))
            temp.Add(int.Parse(c));
        return temp.ToArray();
    }
    
    public static int GetInt()
    {
    	return int.Parse(ReadLine());
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n,m;
  string s;

  cin >> n >> m >> s;
  vector<int> ans;
  
  while(n>0){
    for(int i=max(n-m,0); i<=n; i++){
      if(s[i]=='1')continue;
      if(i==n){
        puts("-1");
        return 0;
      }
      ans.pb(n-i);
      n=i; break;
    }
  }

  reverse(all(ans));
  rep(i,sz(ans)) cout << ans[i] << " ";
  cout  << endl;
  return 0;
}


Measured memory_bytes: 1144
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	String s = scan.next();
      	int acounter = 0;
      	int bcounter = 0;
      	if(s.charAt(0) == s.charAt(1)){
        	if(s.charAt(2) == s.charAt(3) && s.charAt(1) != s.charAt(2)){
            	System.out.print("Yes");
            }
          	else{
            	System.out.print("No");
            }
        }
      	else if(s.charAt(0) == s.charAt(2)){
        	if(s.charAt(1) == s.charAt(3) && s.charAt(1) != s.charAt(2)){
            	System.out.print("Yes");
            }
          	else{
            	System.out.print("No");
            }
        }
      	else if(s.charAt(0) == s.charAt(3)){
        	if(s.charAt(2) == s.charAt(1) && s.charAt(0) != s.charAt(2)){
            	System.out.print("Yes");
            }
          	else{
            	System.out.print("No");
            }
        }
      	else {
        	System.out.print("No");
        }
    }
 
}

Measured memory_bytes: 25172
"use strict"
function Main(input) {
  const array = input.split(" ")
  if(array.length == 2){
    const curtain = array[1]*2;
    console.log(array[0] > curtain ? array[0] - curtain : 0)
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    for i in range(1, n):
        a[i] += a[i - 1]
    answer = float("inf")
    for i in range(n - 1):
        answer = min(answer, abs(a[-1] - 2 * a[i]))
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    //happiness[i][0] - points of happiness for activity A
    //happiness[i][1] - points of happiness for activity B
    //happiness[i][2] - points of happiness for activity C
    int happiness[n][3];
    for (int day = 0; day < n; day++) {
        for (int act = 0; act < 3; act++) {
            cin>>happiness[day][act];
        }
    }
    int res[n][3];
    for (int act = 0; act < 3; act++) {
        res[0][act] = happiness[0][act];
    }
    for (int day = 1; day < n; day++) {
        for (int act = 0; act < 3; act++) {
            res[day][act] = happiness[day][act] + max (res[day-1][(act+1)%3], res[day-1][(act+2)%3]);
        }
    }
    cout<<max (res[n-1][0], max (res[n-1][1], res[n-1][2]))<<"\n";
    return 0;
}


Measured memory_bytes: 5936
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class CWelcomeToAtCoder {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n, m;
        in >> n >> m;
        int p[100010];
        string s[100010];
        rep(i, m){
            in >> p[i] >> s[i];
        }

        vector<int> seen(n+1, 0);
        vector<int> pena(n+1, 0);
        vector<int> ac(n+1, 0);
        int acnum=0, penanum=0;
        rep(i, m){
            if(seen[p[i]]) continue;
            if(s[i] == "AC"){
                ac[p[i]] = 1;
                seen[p[i]] = 1;
            }else if(s[i] == "WA"){
                pena[p[i]]++;
            }
        }

        reps(i, 1, n){
            if(ac[i]){
                acnum++;
                penanum += pena[i];
            }
        };

        out << acnum sp penanum << endl;
	}
};


int main() {
	CWelcomeToAtCoder solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 7296
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    long long N, M;
    cin >> N >> M;
    long long ans;
    if (M >= 2 * N)
    {
        ans = N + (M - 2 * N) / 4;
    }else if (M == 2 * N)
    {
        ans = N;
    }else if (M <= 2 * N)
    {
        ans = M / 2;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 504
import bisect
import sys

N, K = map(int, input().split())
x = list(map(int, input().split()))

zIndex = bisect.bisect_left(x, 0)

if zIndex == 0:
    print(x[K - 1])
    sys.exit()
ans = 10 ** 9
for i in range(N - K + 1):
    if zIndex > i + K - 1:
        ans = min(ans, abs(x[i]))
    else:
        tmp1 = min(abs(x[i]), x[i + K - 1])
        tmp2 = max(abs(x[i]), x[i + K - 1])
        ans = min(ans, (tmp1 * 2) + tmp2)

print(ans)

Measured memory_bytes: 14452
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>n;--i)

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,n,i,ans;
    string a;
    char ch1,ch2,ch3,ch4;
    cin >> a;
    ch1=a[0];
    ch2=a[1];
    ch3=a[2];
    ch4=a[3];
    if(ch1==ch2&&ch3==ch4&&ch1!=ch3) 
    {
        cout << "Yes" ;
    }
    else if(ch1==ch3&&ch2==ch4&&ch1!=ch2) 
    {
        cout << "Yes" ;
    }
    else if(ch1==ch4&&ch2==ch3&&ch1!=ch2) 
    {
        cout << "Yes" ;
    }
    else cout << "No" ;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
dam = sum(A)
for i in range(1,N-1,2):
    dam -= 2*A[i]
X = [dam]
for i in range(N-1):
    Xtemp = 2*A[i]-X[i]
    X.append(Xtemp)
print(" ".join(map(str,X)))

Measured memory_bytes: 19144
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=4e18;
const ll MOD=1e9+7;
const double EPS=1e-7;

ll N;
ll d[100010];

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

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ull_t = unsigned long long;

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

    unordered_set<string> S;
    for (int i = 0; i < N; ++i)
    {
        string s;
        cin >> s;
        S.insert(s);
    }

    cout << S.size() << endl;
}


Measured memory_bytes: 17592
// AOJ ALDS1_4_C Dictionary
// 2018.4.27 bal4u
 
#include <stdio.h>
 
// バッファを経ずstdinから数値を得る
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
int  tr['T'+1];
char f[33554432];
 
int main()
{
    int n, k, c;
 
    tr['A'] = 0, tr['C'] = 1, tr['G'] = 2, tr['T'] = 3;
    n = in();
    while (n--) {
        if (gc() == 'i') {
            k = 7; while (--k) gc();
            k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
            f[k] = 1;
        } else {
            k = 5; while (--k) gc();
            k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
            if (f[k]) pc('y'), pc('e'), pc('s');
            else      pc('n'), pc('o');
            pc('\n');
        }
    }
    return 0;
}


Measured memory_bytes: 2968
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

struct UnionFind {
  vector<int> par;
  vector<int> rank;
  UnionFind(int n): par(n), rank(n) {
    for(int i=0; i<n; i++) {
      par[i] = i;
      rank[i] = 0;
    }
  }
  int find(int x) {
    if(par[x] == x) {
      return x;
    }
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if(rank[x] == rank[y]) {
        rank[x]++;
      }
    }
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int l = s.size();
  VI xs(l+2);
  xs[0] = xs[l+1] = 0;
  transform(s.begin(), s.end(), xs.begin()+1, [](char c){return c-'a';});
  transform(xs.begin(), xs.end()-1, xs.begin()+1, xs.begin(), [](int x, int y){return (y+26-x)%26;});
  xs.pop_back();
  UnionFind u(l+1);
  int N;
  cin >> N;
  REP(i,0,N) {
    int l, r;
    cin >> l >> r;
    u.unite(l-1, r);
  }
  for(int i=0, j=l; i < j; i++, j--) {
    u.unite(i, j);
  }
  VI sum(l+1, 0);
  REP(i,0,l+1) {
    sum[u.find(i)] += xs[i];
    sum[u.find(i)] %= 26;
  }
  bool ans = all_of(sum.begin(), sum.end(), [](int x){return x == 0;});
  cout << (ans ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 2000
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                long[] a = new long[n];
                long[] b = new long[n];
                for(int i = 0 ; i < n ; i++){
                        a[i] = sc.nextLong();
                        b[i] = sc.nextLong();
                }
                long pct = 0;
                sc.close();
                for(int i = 0 ; i < n ; i++){
                        long yono = (b[n - i - 1] - a[n - i - 1] % b[n - i - 1]) % b[n - i - 1];
                        pct += yono;
                        for(int j = 0 ; j < n - i ; j++){
                                a[j] += yono;
                        }
                }
                System.out.println(pct);
        }
}
//give me AC!!
//＿＿＿＿＿＿＿＿＿＿pct

Measured memory_bytes: 63104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    bool zero = 0;
    ll minus = 0;
    int N = in<ll>();
    vector<ll> A(N);
    REP(i,N){
        ll catc = in<ll>();
        if(catc == 0)zero = 1;
        if(catc < 0)minus += 1;
        A[i] = (catc < 0 ? -1 * catc : catc);
    }
    sort(ALL(A));
    ll answer = 0;
    REP(i,N){
        if(i == 0){
            if(minus % 2 == 1&&zero == 0){
                answer -= A[i];
            }else{
                answer += A[i];
            }
        }else{
            answer += A[i];
        }
    }
    cout << answer << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <string.h>
#include <math.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REP(i,x,y)	for (int (i)=(x);(i)<(y);(i)++)
#define REP_(i,x,y)	for ((i)=(x);(i)<(y);(i)++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

#define P 100
#define Q (P/2)

int A,B,ans;
char s[P][P];
int main() {
	
	cin >> A >> B;
	
	cout << P << " " << P << endl;
	
	REP(i,0,Q) REP(j,0,P) s[i][j] = '#';

	REP(i,Q,P) REP(j,0,P) s[i][j] = '.';
	
	int i,j;
	while (A>1) {
		j = 0;
		while (j<P) {
			s[i][j] ='.';
			j += 2;
			A--;
			if (A<=1)break;
		}
		i += 2;
	}
	i = Q+1;
	while (B > 1) {
		j = 0;
		while (j<P) {
			s[i][j] ='#';
			j += 2;
			B--;
			if (B<=1)break;
		}
		i += 2;
	}
	
	REP(i, 0,P) {
		REP(j, 0,P)  cout << s[i][j];
		cout << endl;
	}
	
//	cout << s[0][0];

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i=0; i<N; i++){
    cin >> A[i];
  }
  
  int count=0;
  while (1){
    for (int i=0; i<N; i++){
      if (A[i]%2 == 0){
        A[i] /= 2;
      }else{
        cout << count << endl;
        return 0;
      }
    }
    count++;
  }
}

Measured memory_bytes: 3568
# include <iostream>
using namespace std;
int h,*a;
void maxHeapify(int i)
{
	int l = 2*i, r = 2*i+1,largest;
	if(l <= h && a[l] > a[i]) largest = l;
	else largest = i;
	if(r <= h && a[r] > a[largest]) largest = r;
	
	if(largest != i)
	{
		swap(a[i],a[largest]);
		maxHeapify(largest);
	}
}
int main(void)
{
	scanf("%d",&h);
	a = new int [4*h+1];
	for(int i = 1;i <= h;i++) scanf("%d",&a[i]);
	for(int i = h/2;i >= 1;i--) maxHeapify(i);
	for(int i = 1;i <= h;i++) printf(" %d",a[i]);
	printf("\n");
	return 0;
}  


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

#define froop1(a,n) for(long long i = a;i < n;i++)
#define froop2(a,n) for(long long i = a;i > n;i--)
int main(){
	long long N;
	cin >> N;
  vector<long long> a(N);
  vector<long long> bit(200,0);
  vector<vector<long long>> e(N);
  froop1(0,N){
    cin >> a.at(i);
  }
  long long d = a.at(0);
  long long k = 0;
  while(d > 0){
    bit.at(k) += d % 2;
    e.at(0).push_back(d % 2);
    d /= 2;
    k++;
  }
  froop1(1,N){
   d = a.at(i);
    long long kd = 0;
   while(d > 0){
   	 bit.at(kd) += (d % 2);
     e.at(i).push_back(d % 2);
     d /= 2;
     kd++;
   }
  }
  froop1(0,bit.size()){
   bit.at(i) %= 2; 
  }
  froop1(0,N){
    long long sum = 0;
    long long b = 1;
    for(int j = 0;j < bit.size();j++){
    if(j < e.at(i).size()){
     sum += (bit.at(j) + e.at(i).at(j)) % 2 * b;
    }else{
     sum += bit.at(j) * b; 
    }
     b *= 2;
    }
      cout << sum;
    if(i != N - 1) cout << ' ';
    else cout << endl;
  }
return 0;
}

Measured memory_bytes: 62428
#include <cstdio>
#include <map>
#define mod 1000000007
#define LL long long
using namespace std;
map< pair<LL,LL>,pair<int,int> > mp;
LL gcd(LL a,LL b){
	return b?gcd(b,a%b):a;
}
LL quick_pow(LL a,LL b){
	LL ret=1;
	while(b){
		if(b&1)ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret%mod;
}
int main(){
	int n,i;
	LL a,b,d,zero=0,sum=1;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%lld%lld",&a,&b);
		if(!a&&!b){zero++;continue;}
		d=gcd(a,b);
		a/=d,b/=d;
		if(b<0)a=-a,b=-b;
		if(a<=0)mp[make_pair(b,-a)].second++;
		else mp[make_pair(a,b)].first++;
	}
	for(map< pair<LL,LL>,pair<int,int> >::iterator it=mp.begin();it!=mp.end();it++)
		sum=(quick_pow((LL)2,(LL)it->second.first)-1+quick_pow((LL)2,(LL)it->second.second)-1+1)%mod*sum%mod;
	sum=(sum+zero-1)%mod;
	sum=(sum%mod+mod)%mod;
	printf("%lld\n",sum);
	return 0;
}

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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define tab cout<<endl;
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second

typedef long long ll;
typedef pair<ll, ll> pii;
const ll MAX = 1000005;
const ll INF = 1e9+7;
const ll LINF = 1e18 + 7;

/***************************************************************************/
int main()
{
    ll n,m;
    cin>>n>>m;
    ll ar[n],ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    sort(ar, ar+n);
    for(int i=0;i<n;i++)
    {
        if(m>=ar[i])
        {
            m-=ar[i];
            ans++;
        }
    }
    if(m>0 && ans==n)
    {
        ans--;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    for (i in 1..n) {
        var list = readLine()!!.split(" ").map(String::toInt)
        list = list.sorted()
        if ((list[2] * list[2]) == ((list[1] * list[1]) + (list[0] * list[0])))
            println("YES")
        else
            println("NO")
    }
}


Measured memory_bytes: 32136
m,d=map(int,input().split())
ans=0
for i in range(2,m+1):
  for j in range(22,d+1):
    s=str(j)
    if int(s[1])<2:
      continue
    if i==int(s[0])*int(s[1]):
      ans+=1
print(ans)

Measured memory_bytes: 68656
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

constexpr ll INF = 1e18;
 
struct edge{
    int from, to, cost;
};
 
using edges = vector<edge>;

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

  ll n, m;
  cin >> n >> m;
  edges es(m);
  REP(i, m){
    cin >> es[i].from >> es[i].to >> es[i].cost;
    es[i].from--;
    es[i].to--;
    es[i].cost *= -1;
  }

  ll res = INF;

  vector<ll> d(n, INF); //頂点0からの距離
  d[0] = 0;

  
  REP(i, 3 * n){
    for(auto& e : es){
      if(d[e.to] > d[e.from] + e.cost){
        //負閉路検出
        if(e.to == n - 1 && i >= n){
          cout << "inf" << endl;
          return 0;
        }
        d[e.to] = d[e.from] + e.cost;
      }
    }
  }

  cout << -d[n - 1] << endl;
  return 0;
}


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

int main(){
  string s;
  cin>>s;
  size_t n=s.length();
  for(int i=0;i<(n-1)/2;i++){
    if(s[i]!=s[(n+1)/2+i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val n = scanner.nextInt()
	val t = mutableListOf<Int>()
	var aBef = scanner.nextInt()
	for (i in 2..n){
		val ai = scanner.nextInt()
		if (ai==aBef+1) {
			t.add(aBef)
		}
		aBef = ai
	}
	var m = 0;
	for (i in 1..n){
		m += scanner.nextInt()
	}
	for (i in 1..n-1){
		val c = scanner.nextInt()
		if (t.contains(i)){
			m += c
		}
	}
	println(m)
}

Measured memory_bytes: 29592
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

template<typename T, int len>
struct BIT
{
    array<T, len + 1> val;
    BIT() { val.fill(0); }
    void add(int pos, T v)
    {
        while (pos > 0 && pos <= len)
        {
            val[pos] += v;
            pos += pos & -pos;
        }
    }
    T sum(int pos)
    {
        T res = 0;
        while (pos > 0)
        {
            res += val[pos];
            pos -= pos & -pos;
        }
        return res;
    }
};

int N, M, Q;
using tpl = tuple<int, int, int>;

int main()
{
    cin >> N >> M >> Q;

    tpl query[300000];
    REP(m, M)
    {
        int l, r;
        cin >> l >> r;
        query[m] = tpl(r, -1, l);
    }
    REP(q, Q) {
        int l, r;
        cin >> l >> r;
        query[M + q] = tpl(r, q, l);
    }
    sort(query, query + M + Q);

    BIT<int, 500> bit;
    array<int, 100000> ans;

    REP(i, M + Q) {
        int l, r, q;
        tie(r, q, l) = query[i];
        if (q < 0)
            bit.add(l, 1);
        else {
            ans[q] = bit.sum(r) - bit.sum(l - 1);
        }
    }
    REP(q, Q) cout << ans[q] << endl;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100000+10;
#define ll long long
int n,m,to[MAXN<<1],nex[MAXN<<1],beg[MAXN],Black[MAXN],White[MAXN],p[MAXN],e;
ll cnt0,cnt1,cnt2;
queue<int> q;
inline void read(int &x)
{
	int data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=(data<<3)+(data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
inline void insert(int x,int y)
{
	to[++e]=y;
	nex[e]=beg[x];
	beg[x]=e;
}
inline void paint()
{
	q.push(1);
	p[1]=1;
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		p[x]=0;
		if(Black[x])
			for(register int i=beg[x];i;i=nex[i])
				if(!White[to[i]])
				{
					White[to[i]]=1;
					if(!p[to[i]])
					{
						p[to[i]]=1;
						q.push(to[i]);
					}
				}
		if(White[x])
			for(register int i=beg[x];i;i=nex[i])
				if(!Black[to[i]])
				{
					Black[to[i]]=1;
					if(!p[to[i]])
					{
						p[to[i]]=1;
						q.push(to[i]);
					}
				}
	}
}
int main()
{
	read(n);read(m);
	for(register int i=1;i<=m;++i)
	{
		int u,v;
		read(u);read(v);
		insert(u,v);insert(v,u);
	}
	Black[1]=1;
	paint();
	for(register int i=1;i<=n;++i)
		if(Black[i]&&White[i])cnt0++;
		else if(Black[i])cnt1++;
		else cnt2++;
	ll ans=cnt1*cnt2+cnt0*cnt1+cnt0*cnt2+cnt0*(cnt0-1)/2-m;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3456
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);
    auto as = a.enumerate.array.sort!"a[1] < b[1]"();
    debug {
        writeln(as);
    }
    auto ans = new int[](n);
    foreach (i ; 0 .. n) {
        if (i < n / 2) {
            ans[as[i][0]] = as[n/2][1];
        }
        else {
            ans[as[i][0]] = as[n/2 - 1][1];
        }
    }

    foreach (i ; 0 .. n) {
        writeln(ans[i]);
    }
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 15792
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking interest
*******************************
Higher, higher, even higher, to the point you won’t even be able to see me
https://www.a2oj.com/Ladder16.html
*******************************
NEVER DO 300IQ CONTESTS EVER
300IQ AS WRITER = EXTRA NONO
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      static double MAX = 1000000000000000000.00;
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         long[] arr = readArr2(N, infile, st);
         long res = 1L;
         for(long x: arr)
            if(x == 0)
            {
               System.out.println(0);
               return;
            }
         for(long x: arr)
         {
            if(res > MAX/x)
            {
               System.out.println(-1);
               return;
            }
            res *= x;
         }
         if(res > 1000000000000000000L)
            res = -1;
         System.out.println(res);
      }
      public static long[] readArr2(int N, BufferedReader infile, StringTokenizer st) throws Exception
      {
         long[] arr = new long[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Long.parseLong(st.nextToken());
         return arr;
      }
   }

Measured memory_bytes: 48408
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string();
    let mut prev_chars: Vec<char> = Vec::new();
    let mut counter = 0;
    
    for c in s.chars(){
        if prev_chars.is_empty(){
            prev_chars.push(c);
            continue
        }
        if (*prev_chars.last().unwrap() == '0' && c == '1') ||
            (*prev_chars.last().unwrap() == '1' && c == '0'){
                counter += 1;
            prev_chars.pop();
            continue;
        }
        
        //if we cannnot remove any cubes
        prev_chars.push(c);
    }
    println!("{}", counter*2);
}


Measured memory_bytes: 4352
def main():
	N, C, K = map(int, input().split())
	
	T = [int(input()) for _ in range(N)]
	T = sorted(T)

	num_bus = 1
	num_passenger = 1
	first_passenger = T[0]

	for i in range(1, N):
		if first_passenger + K < T[i]:
			first_passenger = T[i]
			num_passenger = 1
			num_bus += 1
		elif num_passenger == C:
			first_passenger = T[i]
			num_passenger = 1
			num_bus += 1
		else:
			num_passenger += 1

	print(num_bus)
		

 
if __name__ == "__main__":
  	main()

Measured memory_bytes: 14040
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cout << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;

int N;
int a[100002];

void solve() {
}

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

  ll ans = 0;
  ll mo = 0;
  cin >> N;
  REP(i, N) {
    int t;
    cin >> t;
    if (mo > 0) {
      ans += MIN(mo, t);
      t -= MIN(mo, t);
    }
    ans += t / 2;
    mo = t % 2;
  }

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


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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
	i64 N, M, i;
	cin >> N >> M;
	vi A(N);
	REP(0, N, i) {
		cin >> A[i];
	}
	i64 total = accumulate(all(A), 0LL);
	sort(all(A), greater<i64>());
	
	if(A[M-1] * 4 * M >= total) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1e18;


ll n,m,q;
vec a(50),b(50),c(50),d(50);

ll dfs(vec t) {
  ll res=0;
  if(t.size()==n) {
    for(ll i=0;i<q;i++) {
      if(t[b[i]]-t[a[i]]==c[i]) res+=d[i];
    }
  }
  else {
    if(t.size()==0) {
      t.push_back(1);
    }
    else {
      t.push_back(t[t.size()-1]);
    }
    for(ll i=t[t.size()-1];i<=m;i++) {
      t[t.size()-1]=i;
      res=max(res,dfs(t));
    }
  }
  return res;
}

int main() {
  cin >> n >> m >> q;
  for(ll i=0;i<q;i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  vec t;
  cout << dfs(t) << endl;
}

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

using namespace std;
using ll = long long;

int main(void) {
    int n, m;
    scanf("%d %d", &n, &m);
    vector<bool> is(n, true);
    vector<int> heights(n);
    for (int i = 0; i < n; i++)    
        scanf("%d", &heights[i]);
    for (int i = 0; i < m; i++) {
        int from, to;
        scanf("%d %d", &from, &to);
        --from, --to;
        if (heights[from] < heights[to])
            is[from] = false;
        else if (heights[from] == heights[to])
            is[from] = is[to] = false;
        else
            is[to] = false;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (is[i])
            ++ans;
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;

int main(void){
    int N,D;
    cin>>N>>D;
    vector<vector<int>> X(N,vector<int>(D));
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin>>X[i][j];
        }
    }
    int count=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            double sum=0.0;
            for(int k=0;k<D;k++){
                sum+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
            sum=sqrt(sum);
            int temp=(int)sum;
            if(sum==temp) count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

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

long long MOD = 1e9 + 7;

int main() {

    long long n, k;
    cin >> n >> k;

    long long ans;
    ans = (k - n - 2) * (2 * k * k - k * (n + 2) - n * n - n - 6) / 6 % MOD;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    ll N;
    cin >> N;


    vector<ll> A(N + 2);
    A[0] = 0;
    A[N + 1] = 0;
    for(int i=1;i<=N;i++){
        cin >> A[i];
    }

    ll s = 0;
    for(int i=1;i<N+2;i++){
        s += abs(A[i] - A[i - 1]);
    }

    for(int i=1;i<N+1;i++){
        ll diff = abs(A[i - 1] - A[i + 1]) - (abs(A[i] - A[i - 1]) + abs(A[i] - A[i + 1]));
        cout << s + diff << endl;
    }

    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;
//階乗できるよ
ll kaizyo(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  string s; cin >> s;
  int counta = 0, countb = 0, countc=0; 
  rep(i,s.size()) {
    if(s.at(i) == 'a') counta++;
    else if(s.at(i) == 'b') countb++;
    else if(s.at(i) == 'c') countc++;
  }

  // if(counta + countb + countc == 1){
  //   cout << "YES" << endl;
  //   return 0;
  // }
  // 
  // if(counta == countb && counta == countc) {
  //   cout << "YES" << endl;
  //   return 0;
  // }

  int sa_ab = abs(counta - countb);
  int sa_bc = abs(countb - countc);
  int sa_ca = abs(countc - counta);

  //cout << sa_ab << ' ' << sa_bc << ' ' << sa_ca << endl;

  // if(counta == countb) {
  //   if(sa_ca == 1 || sa_ca == 0){
  //     cout << "YES" << endl;
  //     return 0;
  //   }
  // }
  // else if(countb == countc) {
  //   if(sa_ab == 1 || sa_ab == 0){
  //     cout << "YES" << endl;
  //     return 0;
  //   }
  // 
  // }
  // else if(countb == countc) {
  //   if(sa_bc == 1 || sa_bc == 0){
  //     cout << "YES" << endl;
  //     return 0;
  //   }
  // 
  // }

  if(sa_ab < 2 && sa_bc < 2 && sa_ca < 2){
    cout << "YES" << endl;
    return 0;
  }

  cout << "NO" << endl;
  return 0;
}



Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        final int MOD = (int) 1e9 + 7;
        long ans = 0;
        for (int i = k; i <= n + 1; i++) {
            long b = (i - 1L) * i / 2L;
            long a = (n * (n + 1L) / 2L) - ((n - i) * (n - i + 1L) / 2L);
            ans += a - b + 1L;
            ans %= MOD;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35692
#include <bits/stdc++.h>
using namespace std;
long f(long x){
    return x*(x-1)/2;
}
int main(void){
    long a,n; cin >> a;
    vector<int> v(200001);
    vector<int> w(a);
    for(int i=0;i<a;i++){
        cin >> n; v[n]++;
        w[i] = n;
    }
    long sum = 0;
    for(auto x:v)sum += f(x);
    for(auto y:w)cout << sum - f(v[y]) + f(v[y]-1) << endl;
}

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

using namespace std;

typedef long long ll;

ll power(ll a, ll b){
    ll ans = 1;
    for (int i = 0; i < b; i++){
        ans *= a;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    if (k % 2 == 1)
        cout << power(n / k, 3) << endl;
    else
        cout << power(n / k, 3) + power((n + k / 2) / k, 3) << endl;
}

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

int main(){
    int N;
    cin >> N;
    if(N/1000 == 1){
        cout << "ABD" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }
    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  int flag =0;
  for(int i=0;i<s.size();i++)
  {
    if(s[i] == '7')
      flag =1;
  }
  if(flag == 1)
    cout << "Yes";
  else
    cout << "No";
  }


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for (int i=a;i<=b;i++)
#define Rep(i,a,b) for (int i=b;i>=a;i--)
#define mo 1000000007
using namespace std;
int n;
int a[1010];
ll ans;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int main()
{
	n=read();
	ans=1;
	For(i,1,n)
	{
		int p=i;
		for(int j=2;j*j<=p;j++)if(p%j==0)
		{
			while(p%j==0)a[j]++,p/=j;
		}
		if(p)a[p]++;
	}
	For(i,2,n)ans=(ans*(a[i]+1))%mo;
	cout<<ans<<endl;
	return 0;
}
/*
%%%rxd
%%%jyt
%%%zyy
%%%xza
%%%axs
%%%szb
%%%lzh
%%%lzq
%%%jzq
%%%cqz
%%%lbc
*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<pi>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}


double memo[301][301][301];
double f(int i, int j, int k, int n) {
    if(i + j + k == 0) return 0.0;
    if(memo[i][j][k] != 0.0) return memo[i][j][k];
    int s = i + j + k;
    double ret = n - s;
    if(i) ret += (f(i - 1, j, k, n) + 1) * i;
    if(j) ret += (f(i + 1, j - 1, k, n) + 1) * j;
    if(k) ret += (f(i, j + 1, k - 1, n) + 1) * k;
    ret /= s;
    memo[i][j][k] = ret;
    return ret;
}



int main(){
    int n, r, a = 0, b = 0, c = 0;
    setp(12);
    cin >> n;
    rep(i, n) {
        cin >> r;
        if (r == 1) a ++;
        else if (r == 2) b ++;
        else c ++;
    }
    co(f(a, b, c, n));
}



Measured memory_bytes: 111224
#include <iostream>
#include <cmath>
#include <cstring>


using namespace std;


int A[100000];
int lft[100000];

int main(void)
{
    int N;
    cin >> N;

    memset(lft, 0, sizeof(lft));
    int m = N % 2 == 0 ? N / 2 : N / 2 + 1;
    for (int i = 0; i < m; i++) {
        int tmp = N - 2 * i - 1;
        lft[tmp] = tmp == 0 ? 1 : 2;
    }

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

        if (--lft[tmp] < 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    for (int i = 0; i < N; i++) {
        if (lft[i] != 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    unsigned long long ans = 1;
    for (int i = 0; i < N / 2; i++) {
        ans = (ans * 2) % (1000000000ULL + 7);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int[] a = sc.nextIntArray(3);
		
		Arrays.sort(a);
		
		int res = 0;
		
		while(true) {
			int max = a[2];
			if(a[0] < max && a[1] < max) {
				a[0]++;
				a[1]++;
			}else if(a[0] < max && a[1] == max){
				a[0]+=2;
			}else if(a[0] == max && a[1] < max){
				a[1]+=2;
			}else{
				break;
			}
			Arrays.sort(a);
			res++;
		}
		
		out.println(res);
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21204
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()

    println(abc158a(s))
}

private fun abc158a(s: String): String {
    if (s.equals("AAA") || s.equals("BBB")) {
        return "No"
    }

    return "Yes"
}

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

using namespace std;

int main() {
 int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> dp(n, INT_MAX);
  
  dp[0] = 0;
  dp[1] = abs(a[1] - a[0]);
  
  for (int i = 2; i < n; i++) {
   dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2])); 
  }
  
  cout << dp[n - 1];
  
}


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

int main()
{
  int64_t a, b, c;
  cin >> a >> b >> c;
  int64_t x = c - a - b;
  cout << (x > 0 and 4 * a * b < x * x ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
vector<long long>a(n);
vector<long long>sum(n+1);
for(int i=0;i<n;i++){
cin >> a.at(i);}
  sum.at(0)=0;
for(int i=1;i<n+1;i++){
sum.at(i)=sum.at(i-1)+a.at(i-1);}
  long long dif;
  dif=10000000000000;
for(int i=0;i<n+1;i++){
  long long diff=sum.at(n)-sum.at(i);
  if(abs(diff-sum.at(i))<=dif){dif=abs(diff-sum.at(i));}
}
  cout << dif <<endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007


//priority_queue<int,vector<int>, greater<int> > q2;


int modpow(int a, int p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {

		int halfP = p / 2;
		int half = modpow(a, halfP);

		return half * half % mod;
	}
	else {

		return a * modpow(a, p - 1) % mod;
	}
}

long long modinv(long long a) {
	return modpow(a, mod - 2);
}

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

	int N; cin >> N;
	VI A(N); REP(i, N)cin >> A[i];
	VI a = A;
	map<int, int>mp;

	REP(i, N) {
		int l = 2;
		VI so, shi;
		while (l*l <= A[i]) {
			int cnt = 0;
			while (A[i]%l == 0) {
				cnt++;
				A[i] /= l;
			}
			if (cnt > 0) {
				shi.push_back(cnt);
				so.push_back(l);
			}
			l++;
		}
		if (A[i] != 1) {
			shi.push_back(1);
			so.push_back(A[i]);
		}
		REP(j, so.size()) {
			//cout << i << " " << so[j] << " " << shi[j] << endl;
			chmax(mp[so[j]], shi[j]);
		}
	}
	int LCM = 1;
	REP(i, 1000010) {
		LCM *= modpow(i, mp[i]);
		LCM %= mod;
	}
	//cout << LCM << endl;
	int ans = 0;
	REP(i, N) {
		ans += LCM * modinv(a[i])%mod;
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 62976