akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

struct edge {
  ll to, cost;
};

class Dijkstra {
 private:
  ll n_;
  vector<vector<edge> > G_;
  vl d_;

 public:
  Dijkstra(ll n) : n_(n), G_(n), d_(n, INF) {}
  void addEdge(ll v, ll to, ll cost) {
    edge e;
    e.to = to;
    e.cost = cost;
    G_[v].push_back(e);
  }
  void exec(ll s) {
    priority_queue<pll, vector<pll>, greater<pll> > que;
    d_[s] = 0;
    que.push({0, s});

    while (!que.empty()) {
      pll p = que.top();
      que.pop();
      ll v = p.second;
      if (d_[v] < p.first) continue;
      for (auto& e : G_[v]) {
        if (d_[e.to] > d_[v] + e.cost) {
          d_[e.to] = d_[v] + e.cost;
          que.push({d_[e.to], e.to});
        }
      }
    }
  }
  ll dist(ll g) { return d_[g]; }
};

int main() {
  //
  ll h, w;
  cin >> h >> w;
  vector<string> data(h);
  rep(i, h) cin >> data[i];
  int di[] = {1, 0, -1, 0};
  int dj[] = {0, 1, 0, -1};
  Dijkstra g(h * w);
  ll cur = 0;
  rep(i, h) {
    rep(j, w) {
      if (data[i][j] == '.') {
        cur++;
        rep(k, 4) {
          int ni = i + di[k];
          int nj = j + dj[k];
          if (0 <= ni && ni < h && 0 <= nj && nj < w && data[ni][nj] == '.') {
            g.addEdge(i * w + j, ni * w + nj, 1);
          }
        }
      }
    }
  }
  g.exec(0);
  if (g.dist(h * w - 1) == INF) {
    cout << -1 << endl;
    return 0;
  }
  ll opt = g.dist(h * w - 1) + 1;
  cout << cur - opt << endl;
  return 0;
}


Measured memory_bytes: 512
using System;
using System.ComponentModel;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long yokin = 100;
            long X = long.Parse(Console.ReadLine());
            long year = 0;
            while (yokin < X)
            {
                year += 1;
                yokin = (long)(Math.Floor(yokin * 1.01));
            }
            Console.WriteLine(year);
        }
    }
}


Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Maxn 4000007
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    string s;
    cin>>s;
    int n = s.size(), ok=1;
    for(int i = 0; i < n/2; i++){
        if(s[i]!=s[n-i-1]){
            ok=0;
            break;
        }
    }   
    if(!ok)cout<<"No\n";
    else{
        int x = (n-1)/2, y=(n+3)/2;
        for(int i = 0; i < x/2; i++){
            if(s[i]!=s[x-i-1]){
                cout<<"No";
                return;
            }
        }
        for(int i = y; i < n; i++){
            if(s[i]!=s[n-i-1]){
                cout<<"No";
                return;
            }
        }
        cout<<"Yes";
    }
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 256
local n, y = io.read("*n", "*n")
for i = 0, n do
  for j = 0, n - i do
    local k = n - i - j
    if i * 1000 + j * 5000 + k * 10000 == y then
      print(tostring(k) .. " " .. tostring(j) .. " " .. tostring(i))
      return 
    end
  end
end
return print("-1 -1 -1")

Measured memory_bytes: 384
#include<stdio.h>
int main (void){
  int n, i, A[10000], min, max;
  long int sum;
  scanf ("%d", &n);
  for ( i = 0; i < n; i++)
    scanf ("%d", &A[i]);
  min = max = sum = A[0];
  for ( i = 1; i < n; i++){
    if (min > A[i])
      min = A[i];
    if (max < A[i])
      max = A[i];
    sum = sum + A[i];
  }
  printf ("%d %d %ld\n", min, max, sum);
  return 0;
}

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

void solve(long long N, std::vector<long long> a){
    std::priority_queue<ll,vector<ll>,std::greater<ll>> red_queue;
    std::priority_queue<ll,vector<ll>,std::less<ll>> blue_queue;
    std::vector<ll> red_result(N+1);
    std::vector<ll> blue_result(N+1);
    std::vector<ll> result(N+1);
    ll red_sum =0;
    ll blue_sum = 0;
    for(int i=0;i<N;i++){
        red_queue.push(a[i]);
        blue_queue.push(a[2*N+i]);    
        red_sum+=a[i];
        blue_sum+=a[2*N+i];
    }
    red_result[0] = red_sum;
    blue_result[N] = blue_sum;
    for (ll i=0;i<N;i++){
        red_queue.push(a[N+i]);
        ll top = red_queue.top();
        red_sum+=a[N+i]-top;
        red_result[i+1] =red_sum;
        red_queue.pop();

        blue_queue.push(a[2*N-1-i]);
        top = blue_queue.top();
        blue_sum+=a[2*N-1-i]-top;
        blue_result[N-1-i] = blue_sum;
        blue_queue.pop();
    }
    ll maximum =  red_result[0] - blue_result[0];
    for (ll i=1;i<=N;i++){
        if (maximum< red_result[i]-blue_result[i]) maximum = red_result[i]-blue_result[i];
    }
    printf("%lld\n",maximum); 

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(3*N);
    for(int i = 0 ; i < 3*N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 6764
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long p = 1;
    for(long i=2;i<=n;i++){
      p=(p*i)%1000000007;
    }
    System.out.println(p);
  }
}

Measured memory_bytes: 23124
def main():
    N, M = (int(i) for i in input().split())
    X = [int(i) for i in input().split()]
    if N >= M: 
        print(0)
    elif N < M: 
        X.sort()
        diff = [0 for _ in range(M-1)]
        for i in range(M-1):
            diff[i] = X[i+1] - X[i]
        diff.sort(reverse=True)
        
        ans = X[-1] - X[0]
        for i in range(N-1):
            ans -= diff[i]
        print(ans)
if __name__ == "__main__":
    main()

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

#define FOR(i,start,end) for(int i=start; i<(int)(end); i++)
#define REP(i,n) FOR(i,0,n)

int main() {

    double a;
    scanf("%lf", &a);

    printf("%f %f\n", a * a * M_PI, 2 * a * M_PI);

    return 0;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,count = 0;
	int i;
	int A[220];
	cin >> N;
	for(i = 0;i < N;++i) cin >> A[i];
	bool odd_count = false;

	while(!odd_count){
		for(i = 0;i < N;++i) {
			if(A[i] % 2 == 1){
				odd_count = true;
				break;
			}
			else A[i] = A[i] / 2;
		}
		if(!odd_count) ++count;
	}

	cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<map>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<time.h>
#include<vector>
#include<deque>
#define LL long long
#define ll long long
const LL MAX=1e5+10;
LL n,m,x,y,z,t;
LL a[MAX];


int main()
{
    cin>>n;
    if(n<1200)
        cout<<"ABC"<<endl;
    else if(n<2800)
        cout<<"ARC"<<endl;
    else
        cout<<"AGC"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int q;
ll segtree[816225][2],s[225816],t[225816],x[225816];
vector<ll> d;
bool delayed[816225];

void eval(int i, int l, int r){
	if(delayed[i]){
		segtree[i][0] = min(segtree[i][0],segtree[i][1]);
		delayed[i] = false;
		if(r-l>1){
			segtree[2*i+1][1] = min(segtree[2*i+1][1],segtree[i][1]);
			segtree[2*i+2][1] = min(segtree[2*i+2][1],segtree[i][1]);
			delayed[2*i+1] = true;
			delayed[2*i+2] = true;
		}
		segtree[i][1] = INFLL;
	}
}

ll query(int a, int b, int i=0, int l=0, int r=q){
	ll vl,vr;
	eval(i,l,r);
	if(b<=l || r<=a){
		return INFLL;
	}else if(a<=l && r<=b){
		return segtree[i][0];
	}else{
		vl = query(a,b,2*i+1,l,(l+r)/2);
		vr = query(a,b,2*i+2,(l+r)/2,r);
		return min(vl,vr);
	}
}

void update(int a, int b, ll v, int i=0, int l=0, int r=q){
	eval(i,l,r);
	if(b<=l || r<=a){
		return;
	}else if(a<=l && r<=b){
		delayed[i] = true;
		segtree[i][1] = min(segtree[i][1],v);
		eval(i,l,r);
	}else{
		update(a,b,v,2*i+1,l,(l+r)/2);
		update(a,b,v,2*i+2,(l+r)/2,r);
		segtree[i][0] = min(segtree[2*i+1][0],segtree[2*i+2][0]);
	}
}

int main(void){
	int n,i,l,r,j;
	ll v;
	fill(segtree[0],segtree[816225],INFLL);
	cin >> n >> q;
	for(i=0; i<n; ++i){
		cin >> s[i] >> t[i] >> x[i];
		s[i] -= x[i];
		t[i] -= x[i];
	}
	for(i=0; i<q; ++i){
		cin >> v;
		d.push_back(v);
	}
	for(i=0; i<n; ++i){
		l = (int)(lower_bound(d.begin(),d.end(),s[i])-d.begin());
		r = (int)(lower_bound(d.begin(),d.end(),t[i])-d.begin());
		update(l,r,x[i]);
	}
	for(i=0; i<q; ++i){
		v = query(i,i+1);
		cout << ((v==INFLL)?(-1ll):v) << endl;
	}
	return 0;
}


Measured memory_bytes: 22128
import java.util.Arrays;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
 
 
public class Main{
	
	//@paste
	public static long mod_inv(long a, long m){
	    return (a == 1 ? 1 : (1 - m*mod_inv(m%a, a)) / a + m);
	}
	
	//@paste
	public static long chinese_remainder(long[] as, long[] ms){
		long mul = 1;
		for(long m : ms){
			mul *= m;
		}
		
		long ret = 0;
		for(int i = 0; i < ms.length; i++){
			final long m = mul / ms[i];
			final long inv = mod_inv(m, ms[i]);
			
			long a = as[i] - as[i] / mul * mul;
			if(a < 0){
				a += mul;
			}
			
			ret = (ret + m * inv * as[i] % mul) % mul;
		}
		
		return ret;
	}
	
    public static void main(String[] args){
    	final Scanner sc = new Scanner(System.in);
    	
    	final int n = sc.nextInt();
    	
    	long[] as = new long[]{0, 0};
    	long[] ms = new long[]{1810013, 1426969};
    	
    	for(int tt = 0; tt < n; tt++){
    		final int ops = sc.nextInt();
    		final long val = sc.nextLong();
    		
    		for(int i = 0; i < as.length; i++){
    			switch(ops){
    			case 1: // +
    				as[i] += val;
    				as[i] %= ms[i];
    				break;
    			case 2: // -
    				as[i] += ms[i];
    				as[i] -= val;
    				as[i] %= ms[i];
    				break;
    			case 3: // *
    				as[i] *= val;
    				as[i] %= ms[i];
    				break;
    			case 4: // /
    				as[i] *= mod_inv((ms[i] + val) % ms[i], ms[i]);
    				as[i] %= ms[i];
    				break;
    			}
    		}
    	}
    	
    	//System.out.println(Arrays.toString(as));
    	
    	long ret =  chinese_remainder(as, ms);
    	while(ret < Integer.MIN_VALUE){
    		ret += (ms[0] * ms[1]);
    	}
    	while(ret > Integer.MAX_VALUE){
    		ret -= (ms[0] * ms[1]);
    	}
    	System.out.println(ret);
    	
    	sc.close();
    }
     
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    int n,k;
    cin>>n>>k;
    priority_queue<int> Q;
    REP(i,n){
        int a;
        cin>>a;
        Q.push(a);
    }
    while((int)Q.size() > max(0,n-k))Q.pop();
    ll ans = 0;
    while(Q.size()){
        ans += Q.top(); Q.pop();
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
//using Graph = vector<vector<int>>;


const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
ll gcd(ll a,ll b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
ll lcm(ll a,ll b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}









int main() {
  int n;
  cin >> n;
  if (n >= 100 && n <= 111) cout << 111 << endl;
  if (n >= 112 && n <= 222) cout << 222 << endl;
  if (n >= 223 && n <= 333) cout << 333 << endl;
  if (n >= 334 && n <= 444) cout << 444 << endl;
  if (n >= 445 && n <= 555) cout << 555 << endl;
  if (n >= 556 && n <= 666) cout << 666 << endl;
  if (n >= 667 && n <= 777) cout << 777 << endl;
  if (n >= 778 && n <= 888) cout << 888 << endl;
  if (n >= 889 && n <= 999) cout << 999 << endl;

}


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

int main() {
	string S;
	cin >> S;
  if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)){
  	cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

	var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long Q = inputArray[0];

			var lrPairs = createLongTuppleList(Q);

			//えれ何とかの篩で素数のリストを作成
			const int max = 100001;
			var isPrime = Enumerable.Repeat(true, max).ToArray();

			isPrime[1] = false;

			for (int i = 2; i <= Math.Sqrt(max); i++) {

				if (!isPrime[i]) {
					continue;
				}
				var k = i;
				var product = i*k;
				while (product < max) {
					isPrime[product] = false;
					k++;
					product = i * k;
				}
			}

			var like2017Count = Enumerable.Repeat(0, max).ToArray();

			for (int i = 2; i < max; i++) {
				if (i%2==0) {
					like2017Count[i] = like2017Count[i - 1]; 
				}

				if (isPrime[i] && isPrime[(i+1)/2]) {
					like2017Count[i] = like2017Count[i - 1] + 1;
				}
				else {
					like2017Count[i] = like2017Count[i - 1];
				}

			}


			for (int i = 0; i < Q; i++) {
				var pair = lrPairs[i];
				//答えの出力
				var ans = like2017Count[pair.Item2]- like2017Count[pair.Item1-1];
				Console.WriteLine(ans);
			}

		

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


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

const int S = 2e5 + 10;

map<string, int> mp;
int n, val = -1, p = 0;
string s;
set<string> st;
string l[S];

int main() {
	cin >> n;
	while (n--) {
		cin >> s;
		++mp[s];
	}
	bool first = 1;
	for (map<string, int>::iterator iter = mp.begin(); iter != mp.end(); iter++) 
		val = max(val, (*iter).second);
	for (map<string, int>::iterator iter = mp.begin(); iter != mp.end(); iter++) 
		if (val == (*iter).second) l[++p] = (*iter).first;
	for (int i = 1; i <= p; i++)
		cout << l[i] << endl;
	return 0;
}



Measured memory_bytes: 27396
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

int N,M,K,X,Y;
int a,b,c,d;
string S,T;
vector<int> A,B;
void input()
{
    cin>>N;
    A.resize(N);
    rep(i,0,N-1){
        cin>>A[i];
    }
}
int dp[512322];
void solve()
{
    rep(i,1,N+3)dp[i]=INF;
    dp[0] = 0;
    dp[1] = abs(A[1]-A[0]);
    rep(i,2,N-1){
        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]<<endl;



}
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include<algorithm>
#include<iostream>
#include<cstdio>
typedef long long ll;
using namespace std;
struct Node{
	int h,p;
}a[5005];
int n;
ll f[5005][5005];
bool cmp(Node a,Node b){
	return a.h+a.p<b.h+b.p;
}
int main(){
	ios::sync_with_stdio(false);
	int i,j;
	cin>>n;
	fill(f[0],f[0]+n+1,2e9+1);
	for(i=1;i<=n;i++)
		cin>>a[i].h>>a[i].p;
	sort(a+1,a+n+1,cmp);
	f[0][0]=0;
	for(i=1;i<=n;i++)
		for(j=0;j<=n;j++){
			f[i][j]=f[i-1][j];
			if(j&&f[i-1][j-1]<=a[i].h)
				f[i][j]=min(f[i][j],f[i-1][j-1]+a[i].p);
		}
	for(i=n;i>=0;i--)
		if(f[n][i]<=2e9)
			break;
	cout<<i;
	return 0;
}


Measured memory_bytes: 199232
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void Solver(int A,int B,int C)
    {
        int sevenCount = 0;
        int fiveCount = 0;
        if(A == 5)
            fiveCount++;
        if(B == 5)
            fiveCount++;
        if(C == 5)
            fiveCount++;
        if(A == 7)
            sevenCount++;
        if(B == 7)
            sevenCount++;
        if(C == 7)
            sevenCount++;

        if(fiveCount == 2 && sevenCount == 1)
            System.out.println("YES");
        else
            System.out.println("NO");

    }
    public static void main(String[] args) throws IOException {
        Scanner input = new Scanner(System.in);

        Solver(input.nextInt(),input.nextInt(),input.nextInt());
    }
}


Measured memory_bytes: 20564
#include <stdio.h>
typedef long long ll;

ll n, a, b;

int main()
{
    scanf("%lld %lld %lld", &n, &a, &b);

    if (a > b || (a != b &&  n == 1)) {
        puts("0");
        return 0;
    }

    if (a !=  b) {
        printf("%lld\n", (b - a) * (n - 2) + 1);
    }
    else {
        printf("%lld\n", 1);
    }
    
    return 0;
}


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

#define len(x)  (int((x).size()))
#define append push_back
#define pp make_pair
#define ff(a, b)    for (int a = 0; a < int(b); ++a)
#define kk(n)    ff(k, n)
#define xx(n)    ff(x, n)
#define yy(n)    ff(y, n)
#define ii(n)    ff(i, n)
#define fff(a, b, c) for (int a = int(b); a < int(c); ++a)
#define kkk(a, b) fff(k, a, b)
#define xxx(a, b) fff(x, a, b)
#define yyy(a, b) fff(y, a, b)
#define iii(a, b) fff(i, a, b)
#define bb begin()
#define ee end()
#define uu first
#define vv second
#define all(x)  (x).bb, (x).ee
#define ite(v)   decltype((v).bb)
#define fe(i, v) for(ite(v) i = (v).bb; i != (v).ee; ++i)
#define err(...)    { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#define zz(array, byte)   memset(array, byte, sizeof(array));

using LL = long long;
using DD = long double;
using pii = pair<int, int>;



const LL  INFLL  = 0x7f7f7f7f7f7f7f7fLL;
const int INFint = 0x7f7f7f7f;  //Works with memset(..).
 
     




int main() {
    ios_base::sync_with_stdio(false);     cin.tie(NULL);
    //cout << '\n';
    cout.precision(16);
    

    int N, x;
    cin >> N >> x;

    if (x == 2*N-1 || x == 1) {
        cout << "No\n";
        return 0;
    } else if (2 == N) {
        if (x == 2) {
            cout << "Yes\n3 2 1\n";
        } else {
            cout << "No\n";
        }
        return 0;
    }

    vector<int> rr(2*N-1, 0);
    vector<int> taken(2*N, 0);
    taken[x] = 1;
    taken[x+1] = 1;
    taken[x-1] = 1;
    if (2 == x) {
        rr[N-1] = 2;
        rr[N-2] = 1;
        rr[N-3] = 3;
        rr[N] = 4;
        taken[x+2] = 1;
    } else {
        rr[N-1] = x;
        rr[N-2] = x+1;
        rr[N-3] = x-1;
        rr[N] = x-2;
        taken[x-2] = 1;
    }

    cout << "Yes\n";
    int p = 1;
    ii (len(rr)) {
        if (0 != rr[i])
            continue;

        while (taken[p])
            ++p;
        //printf("Putting %d into %d\n", p, i);
        rr[i] = p++;
    }

    ii (len(rr))
        cout << rr[i] << '\n';
    

    return 0;
}



Measured memory_bytes: 3072
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut stack = vec![];
    let mut ans = 0;
    for i in s {
        if let Some(&x) = stack.last() {
            if x == '0' && i == '1' {
                ans += 1;
                stack.pop();
            } else if x == '1' && i == '0' {
                ans += 1;
                stack.pop();
            } else {
                stack.push(i)
            }
        } else {
            stack.push(i)
        }
    }
    println!("{}", ans * 2)
}


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

int main(){
    string s;
    cin >> s;
    string s_re = s;
    reverse(s_re.begin(), s_re.end());

    long long n = s.size();
    string s1 = s.substr(0, (n-1)/2);
    string s2 = s.substr((n+1)/2);

    string s1_re = s1;
    string s2_re = s2;
    reverse(s1_re.begin(), s1_re.end());
    reverse(s2_re.begin(), s2_re.end());

    if(s == s_re and s1 == s1_re and s2 == s2_re) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			String N = scn.next();
			String c = N.substring(N.length()-1);

			if(c.equals("2")
			|| c.equals("4")
			|| c.equals("5")
			|| c.equals("7")
			|| c.equals("9")
			) {
				System.out.println("hon");
			} else if(c.equals("0")
					|| c.equals("1")
					|| c.equals("6")
					|| c.equals("8"))
			{
					System.out.println("pon");
			} else {
				System.out.println("bon");
			}
		}
	}
}

Measured memory_bytes: 27000
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;

  priority_queue<int> p;
  REP(i, A){
    int x; cin >> x;
    p.push(x);
  }
  priority_queue<int> q;
  REP(i, B){
    int x; cin >> x;
    q.push(x);
  }
  priority_queue<int> r;
  REP(i, C){
    int x; cin >> x;
    r.push(x);
  }

  REP(i, X){
    if(p.empty()) break;
    r.push(p.top()); p.pop();
  }
  REP(i, Y){
    if(q.empty()) break;
    r.push(q.top()); q.pop();
  }

  int ans = 0;
  REP(i, X+Y){
    ans += r.top(); r.pop();
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 7920
#include <stdio.h>
int main(void)


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

Measured memory_bytes: 600
count = [0]*4
for i in range(3):
    a, b = list(map(int,input().split()))
    count[a-1] += 1
    count[b-1] += 1
if count[0] == 1 and count[1] == 2 and count[2] == 2 and count[3] == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
n = input()
d = {}
for i in range(n):
    a, b = raw_input().split()
    if a in d: d[a] += int(b)
    else: d[a] = int(b)
d = sorted(d.items())
for ans in sorted(d, key = lambda x: len(x[0])):
     print " ".join(map(str,ans))

Measured memory_bytes: 6616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];
    sort(ALL(L));
    int ans = 0;
    FOR(i, 0, N - 2) FOR(j, i + 1, N - 1) FOR(k, j + 1, N) {
        if (L[i] + L[j] <= L[k]) break;
        else ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	const int mod=1e9+7;
	int n,k;
	vector<int>dp1,dp2;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	dp1.resize(k+1,0);
	dp2.resize(k+1,0);
	dp1[0]=1;
	while(n--) {
		int a;
		cin>>a;
		for(int i=0;i<=k;i++) dp2[i]=((dp1[i]+(i>0?dp2[i-1]:0))%mod-(i-a-1>=0?dp1[i-a-1]:0)+mod)%mod;
		for(int i=0;i<=k;i++) dp1[i]=dp2[i];
	}
	cout<<dp1[k]<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int H,W,K;
cin >> H >> W >> K;
vector<string> fi(H);
rep(i,H) cin >> fi[i];

vvi res(H,vi(W));
int id = 1;
rep(h,H) {
    rep(w,W) {
        if(fi[h][w] == '#') {
            res[h][w] = id;
            id++;
        }
    }
}

rep(h,H) {
    rep(w,W) {
        if(w == 0) continue;
        if(res[h][w] == 0) res[h][w] = res[h][w-1];
    }
    drep(w,W) {
        if(w == W-1) continue;
        if(res[h][w] == 0) res[h][w] = res[h][w+1];
    }
}

rep(w,W) {
    rep(h,H) {
        if(h == 0) continue;
        if(res[h][w] == 0) res[h][w] = res[h-1][w];
    }
    drep(h,H) {
        if(h == H-1) continue;
        if(res[h][w] == 0) res[h][w] = res[h+1][w];
    }
}

rep(h,H) {
    rep(w,W) {
        if(w == W-1) cout << res[h][w];
        else cout << res[h][w] << ' ';
    }
    cout << endl;
}
return 0;
}

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(){
  int n;
   float x1,x2,x3,x4,y1,y2,y3,y4;
  cin >> n;
  for(int i=0;i<n;i++) {
cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
    if( (y2-y1)/(x2-x1) == (y4-y3)/(x4-x3) ) 
      cout<<"YES\n";
    else
      cout<<"NO\n";
  }
  
  return 0;
}



Measured memory_bytes: 3100
#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define Pi pair<int,int>
#define IINF 1e9
#define LINF 1e18
#define vi vector<int>
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 0, 1,0,-1};
int dy[] = { 1, 0,-1,0};
int dx8[] = { -1,-1,-1,0,0,1,1,1};
int dy8[] = { -1,0,1,-1,1,-1,0,1};

unsigned long long sttoi(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

ull gcd(ull a, ull b) {
	if (b > a)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a%b);
}

int comb(int n, int k) {
	int ans = 1;
	for (int i = 0; i < min(k, n - k); i++) {
		ans *= n - i;
		ans /= i + 1;
	}
	return ans;
}

ll mod_pow(ll n,ll p,ll mod){	
	if (p == 0) return 1 % mod;
	if (p < 2) {
		return n % mod;
	}else {
		ll d = 2, value = (n%mod)*(n%mod)%mod;
		while (d*2 < p) { d *= 2;	value *= value;	value %= mod;}
		value %= mod;
		return ((value%mod) * (mod_pow(n, p - d, mod)%mod)) % mod;
	}
}

bool isPrime(int n) {
	if (n <= 1)return false;
	if (n == 2)return true;
	if (n % 2 == 0)return false;
	for (int i = 3; i*i <= n; i += 2) {
		if (n%i == 0)return false;
	}
	return true;
}

void solve() {
	int n, m,pos = 1,ans = 1;
	cin >> n >> m;
	vector<int> v(100100), ball(100100);
	REP(i, 1, n + 1) {
		v[i] = 0;
		ball[i] = 1;
	}
	v[1] = 1;
	rep(i, m) {
		int x, y;
		cin >> x >> y;
		if (v[x] == 1 && ball[x] == 1) {
			v[x] = 0;
			ans--;
			if (v[y] == 0) {
				ans++;
				v[y] = 1;
			}
		}
		else if(v[x] == 1 && ball[x] > 1){
			if (v[y] == 0) {
				ans++;
				v[y] = 1;
			}
		}
		ball[x]--;
		ball[y]++;
	}
	P(ans);
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 1152
S = input()

count = [0] * 4
flag = 0

for j in range(0, 4):
    for i in range(0, 4):
        if S[j] == S[i]:
            count[j] += 1

    if count[j] != 2:
        flag = 1
        break

if flag == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
   string s;
   cin >> s;
   s[3] = '8';
   cout << s << endl;
}


Measured memory_bytes: 256
# include<iostream>
using namespace std;
const int INFTY = (1 << 21);
const int MAX = 100;
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
	int minv;
	int d[MAX], color[MAX];
	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		color[i] = WHITE;
	}

	d[0] = 0;
	color[0] = GRAY;
	while (1) {
		minv = INFTY;
		int u = -1;
		for (int i = 0; i < n; i++) {
			if (color[i] != BLACK && minv > d[i]) {
				minv = d[i];
				u = i;
			}
		}

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

		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK && M[u][v] != INFTY) {
				if (d[v] > d[u] + M[u][v]) {
					d[v] = d[u] + M[u][v];
					color[v] = GRAY;
				}
			}
		}
	}

	for (int i = 0; i < n; i++) {
		cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
	}
}

int main() {
    cin >> n;
	int u, k, v, d;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = INFTY;
		}
	}
	
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> d;
			M[u][v] = d;
		}
	}

	dijkstra();
	return 0;
}


Measured memory_bytes: 3096
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, P: "List[int]", Q: "List[int]"):
    
    from itertools import combinations, permutations
    ans = [''.join(list(map(str, list(v)))) for v in permutations(P, N)]
    ans.sort()
    a = ans.index(''.join(list(map(str, P))))
    b = ans.index(''.join(list(map(str, Q))))
    print(abs(a-b))
    
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    Q = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P, Q)

if __name__ == '__main__':
    main()


Measured memory_bytes: 6152
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define mod 1000000007
#define S second
#define F first
#define int long long
using namespace std;

signed main(){
	string s;
	cin>>s;
	if(s[0]=='a') puts("square1001");
	else puts("e869120");
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = max({a * c, a * d, b * c, b * d});
  cout << ans << endl;
}

Measured memory_bytes: 3644
x1, y1, x2, y2 = map(int, input().split())

x_diff = x1 - x2
y_diff = y2 - y1

x4 = x1 - y_diff
y4 = y1 - x_diff
x3 = x2 - y_diff
y3 = y2 - x_diff

print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <bits/stdc++.h>
using namespace std;

const int N = 2e6 + 12;

#define mkp make_pair
#define sz(s) (int)(s.size())
#define eb emplace_back

#define ll long long

#define int ll

int lcm(int a, int b) {
	return (a * b) / __gcd(a, b);
}

main () {
	clog << "Ready\n";
	
	int a, b;
	cin >> a >> b;
	cout << lcm(a, b);
	cerr << '\n';
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    long long K;
    cin>>N>>K;
    map<long long,long long> p;
    long long a,b;
    rep(i,N){
        cin>>a>>b;
        if(p.count(a)){
            p[a]+=b;
        }else{
            p[a]=b;
        }
    }
    for(auto ab:p){
        if(K<=ab.second){
            cout << ab.first << endl;
            return 0;
        }else{
            K-=ab.second;
        }
    }
    return 0;
}

Measured memory_bytes: 4224
(n, k) = map(int, input().split())
d = []
a = []
for _ in range(k):
    d.append(int(input()))
    a.append(list(map(int, input().split())))

has_snck = {}
for i in range(1, n + 1):
    has_snck[i] = False
for ai in a:
    for aij in ai:
        has_snck[aij] = True

ans = 0
for snk in has_snck.keys():
    if not has_snck[snk]:
        ans += 1
print(ans)


Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    ll x,happy=0;cin>>x;
    happy+=1000*(x/500);
    x%=500;
    happy+=5*(x/5);
    cout<<happy<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, k[100];
    char s[101];
    int i;
    char table[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int c;
    
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        for (i = 0; i < n; i++){
            scanf("%d", &k[i]);
        }
        scanf("%s", s);
        
        i = 0;
        while (s[i] != '\0'){
            c = s[i];
            if ('a' <= c && c <= 'z'){
                c = c - 'a';
            }
            else {
                c = c - 'A' + 26;
            }
            
            c = c - k[i % n] + 52;
            c %= 52;
            
            s[i] = table[c];
            i++;
        }
        
        printf("%s\n", s);
    }
    
    return (0);
}



Measured memory_bytes: 2116
#include<iostream>
using namespace std;
int r[10],l[10];
int data[10];

bool solve(int n,int rt,int lt)
{
	if(n==10)
	{
		for(int i = 1; i <= rt ; ++i)
		{
			if(r[i-1]>r[i]&&r[i]!=0) return false;
		}
		for(int i = 1; i <= lt ; ++i)
		{
			if(l[i-1]>l[i]&&l[i]!=0) return false;
		}
		return true;
	}

	r[rt]=data[n];
	if(solve(n+1,rt+1,lt)) return true;
	r[rt]=0;
	l[lt]=data[n];
	if(solve(n+1,rt,lt+1)) return true;
	l[lt]=0;

	return false;
}

int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		for(int i = 0; i < 10; ++i)
		{
			cin>>data[i];
		}
		cout<<(solve(0,0,0)?"YES":"NO")<<endl;
	}
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int count = 0;
    if (s[0]=='1') ++count;
    if (s[1]=='1') ++count;
    if (s[2]=='1') ++count;
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int dp[1000005][2];

int main(){
  string s;
  cin >> s;
  int n=s.size();
  dp[0][0]=0;dp[0][1]=1;
  rep(i, n){
    int si=s[i]-'0';
    dp[i+1][0]=min(dp[i][0]+si, dp[i][1]+(10-si));
    dp[i+1][1]=min(dp[i][0]+si+1, dp[i][1]+(9-si));
  }
  cout << dp[n][0] << endl;
  return 0;
}


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

using namespace std;

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

  int n, a, b;
  cin >> n >> a >> b;
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    int sum = 0;
    int tmp = i;
    while (tmp > 0) {
      sum += tmp%10;
      tmp /= 10;
    }
    if (sum >= a && sum <= b) res += i;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;
using ll = long long;

int main() {

	uint N;
	cin >> N;

	vector<ull> A(N);
	ull asum = 0;
	for(uint i=0; i<N; i++) {
		cin >> A[i];
		asum += A[i];
	}

	ull ans = ULLONG_MAX;
	ull psum = 0;
	for(uint i=0; i<N; i++) {
		psum += A[i];
		ull qsum = asum - psum;
		ans = min(ans, (ull)abs((ll)psum - (ll)qsum));
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 1792
open Printf open Scanf
open Array

let gi _ = scanf " %d" @@ fun v -> v

let () = scanf " %d %d %d" @@ fun n m c ->
  let b = init m (fun _ -> gi ()) in
  init n (fun _ ->
    let a = init m (fun _ -> gi ()) in
    let w = init m (fun i -> a.(i)*b.(i))
    |> fold_left (+) 0 in
    if w+c > 0 then 1 else 0
  )
  |> fold_left (+) 0
  |> print_int

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

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}
const long long INF = 1e15 ;
map< pair<long long , pair<long long,long long> > , bool> vis ;
long long solve(long long a,long long b,long long c){
    if(vis[{a,{b,c}}]){
        return INF ;
    }
    vis[{a,{b,c}}] = 1 ;
    if(a&1 || b&1 || c&1){
        return 0 ;
    }
    long long aa = a/2 ;
    long long bb = b/2 ;
    long long cc = c/2 ;
    return 1 + solve(bb + cc,aa + cc,aa + bb) ;
}
int main(int argc,char* argv[]) { 
    io() ;
    #ifndef ONLINE_JUDGE
        //freopen("inp.txt", "r", stdin) ;
        // freopen("out.txt", "w", stdout);
    #endif
    long long x,y,z ;
    cin >> x >> y >> z ;
    long long ans = solve(x,y,z) ;
    if(ans >= INF) ans = -1 ;
    cout << ans << endl ;
    return 0 ; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 998244353;

const double PI = acos(-1.0);

ll modpow(ll a, ll n, int mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    int N;
    cin>>N;
    vector<ll> D(N),C(N,0);
    rep(i,N){
        cin>>D[i];
        C[D[i]]++;
    }
    if(D[0] != 0){
        cout<<0<<endl;
        return 0;
    }

    if(C[0]>1){
        cout<<0<<endl;
        return 0;
    }
    sort(all(D));
    rep(i,N-1){
        if(D[i+1]-D[i]>1){
            cout<<0<<endl;
            return 0;
        }
    }
    ll ans = 1;
    rep(i,N-1){
        ans *= modpow(C[i],C[i+1],MOD);
        ans %= MOD;
    }
    cout<<ans<<endl;
}

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

/* 「寿司の種類数xを固定する」という方針
 *  x種類の選び方は「『一番美味しい寿司』が美味しい方から貪欲に選ぶ」のが最適
 *
 *  x種類選ぶときの最善策は以下のような貪欲法となる。

    ・寿司を「その種類で一番美味しいもの」と「その他」に分ける。
    ・前者から、美味しい順にx個食べる。 (x種類の確保)
    ・後者から、美味しい順にK−x個食べる。
 * */

// priority_queueはソートが面倒だから使っているだけで、別にvectorをソートしても何ら問題はない。
int main() {
    int N, K;
    cin >> N >> K;
    int t[N], d[N];

    priority_queue<ll> kind[N];
    rep(i, N){
        int t;
        ll d;
        cin >> t >> d;
        kind[t-1].push(d);
    }

    priority_queue<ll> best, remain;
    // best: 各種類で一番おいしいやつを集めたもの
    // remain: bestのあまり
    rep(i, N){
        if(!kind[i].empty()){
            best.push(kind[i].top());
            kind[i].pop();

            while(!kind[i].empty()){
                remain.push(kind[i].top());
                kind[i].pop();
            }
        }
    }

    vector<ll> bsum = {0};
    // bestの累積和 (bsum[i] = bestの先頭からi個の総和)
    while (!best.empty()) {
        bsum.push_back(bsum.back() + best.top());
        best.pop();
    }

    vector<ll> rsum = {0};
    // remainの累積和
    while (!remain.empty()) {
        rsum.push_back(rsum.back() + remain.top());
        remain.pop();
    }

    ll ans = 0;
    for (ll x = 1; x <= K; ++x) {
        // 種類が多すぎるケース
        if (x >= bsum.size()) break;

        // 種類が少なすぎて、余り物が足りないケース
        if (K - x >= rsum.size()) continue;

        // bestからx個、remainからK-x個貪欲に選ぶ
        ans = max(ans, bsum[x] + rsum[K - x] + x * x);
    }

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


Measured memory_bytes: 8820
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  ll a[20];
  a[0] = 1;
  REP(i, 19)a[i + 1] = a[i] * 2;
  FOR(i, 1, n + 1) {
    int j = 19, tmp = i;
    for(; tmp < k; j--) {
      tmp *= 2;
    }
    ans += a[j];
  }
  cout << setprecision(11) << 1.0 * ans / n / a[19] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n,a[105];
	long long s[105]={0},ans=0;
	scanf("%d%d",&n,&a[0]);
	s[0]=a[0];
	for(int i=1;i<n;i++)
	{
		scanf("%d",&a[i]);
		s[i]=s[i-1]+a[i];
	}
	for(int i=n-1;i>0;i--)
	{
		ans+=a[i]*s[i-1];
	}
	printf("%lld",ans);
	return 0;
}

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

using namespace std;

unordered_map<uint64_t, uint64_t> factorize(uint64_t x) {
  unordered_map<uint64_t, uint64_t> ret;
  while (4 <= x && (x & 1) == 0) {
    ret[2]++;
    x /= 2;
  }
  uint64_t d = 3;
  uint64_t q = x / d;
  while (d <= q) {
    if (x % d == 0) {
      ret[d]++;
      x = q;
    } else {
      d += 2;
    }
    q = x / d;
  }
  ret[x]++;
  return ret;
}

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

  uint64_t n, p;
  cin >> n >> p;
  auto factors = factorize(p);
  uint64_t ans = 1;
  for (auto &e : factors) {
    ans *= pow(e.first, e.second / n);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define per(i,a,b) for(int i=(a);i>=(int)(b);i--)
const int mod = 1e9+7;
const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;
vi g[maxn];
queue<int> q;
int dp[maxn],du[maxn];
int main()
{
    ios::sync_with_stdio(false);cin.tie(nullptr);
    //freopen("in1.txt","r",stdin);
    int n,m;
    cin>>n>>m;
    rep(i,1,m) {
        int u,v;
        cin>>u>>v;
        g[u].pb(v);
        du[v]++;
    }
    rep(i,1,n) {
        if(du[i]==0) q.push(i);
    }
    while(!q.empty()) {
        int now=q.front();q.pop();
        for(int x:g[now]) {
            du[x]--;
            if(du[x]==0) q.push(x);
            dp[x]=max(dp[x],dp[now]+1);
        }
    }
    int Max=0;
    rep(i,1,n) {
        Max=max(Max,dp[i]);
    }
    cout<<Max<<'\n';
    return 0;
}


Measured memory_bytes: 9868