akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
	private static String board = "CODEFESTIVAL2016";
    public static void main(String args[]) {
        Scanner cin = new Scanner(System.in);

        while(cin.hasNext()){
        	int n = cin.nextInt();
        	int a = cin.nextInt();
        	int b = cin.nextInt();
            String s = cin.next();
            count(s,a,b,n);
        }
    }
    public static void count(String s,int a,int b,int n){
    	int pass=0,passb=0;
    	for(int i=0;i<n;i++){
    		if(s.charAt(i)=='c'){
    			System.out.println("No");
    		}else if(s.charAt(i)=='a'){
    			if(pass<a+b){
    				System.out.println("Yes");
    				pass++;
    			}else{
    				System.out.println("No");
    			}
    		}else{
    			if(pass<a+b&&passb<b){
    				System.out.println("Yes");
    				pass++;
    				passb++;
    			}else{
    				System.out.println("No");
    			}
    		}
    	}
    }
}

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

int main(){
  string a,b;
  cin>>a>>b;
  string num=a+b;
  bool root=false;
  for (int i = 1; i < 10000; i++)
  {
    /* code */
    if (i*i==stoi(num))
    {
      /* code */
      root=true;
      break;
    }
    
  }
  if (root)
  {
    /* code */
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  
  
}

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

int main()
{
  ll k,n;
  cin>>k>>n;
  vector<ll>a(n);
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }
  ll mx=LONG_LONG_MIN;
  for(ll i=0;i<n-1;i++)
  {
    mx=max(mx, abs(a[(i+1)%n] - a[i]));
  }
  mx=max(mx, k-a[n-1]+a[0]);
  cout<<k-mx;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int i, red = 0, blue = 0,ans=0;
	for (i = 0; i < s.size(); i++) {
		if (s[i] == '0') {
			if (blue > 0) {
				blue--;
				ans += 2;
			}
			else {
				red++;
			}
		}
		else {
			if (red > 0) {
				red--;
				ans += 2;
			}
			else {
				blue++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9000000000000000000;
const double PI = acos(-1);

int main() {
	string s;
	cin >> s;
	string ss;
	int count = 0;
	vector<pair<char, int>>v;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != 'x') {
			ss = s[i] + ss;
			v.emplace_back(s[i], count);
			count = 0;
		}
		else {
			count++;
		}
	}
	v.emplace_back('#', count);
	for (int i = 0; i < ss.size(); i++) {
		if (ss[i] != ss[ss.size() - 1 - i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	int ans = 0;
	for (int i = 0; i < v.size();i++) {
		if (i > v.size() - 1 - i)break;
		ans += abs(v[i].second - v[v.size() - 1 - i].second);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1528
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
    int a, b,kai;
    int ans = 0;


    cin >> a >> b;
    for (int i = 0; i <= 20; i++) {
       
        if (i == 0) {
            kai = 1;
        }
        else {
            kai = a + (a - 1) * (i - 1);
        }

        if (kai >= b) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
   
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;
struct action {
	int ac;
	int time;
};
int main() {
	while (1) {
		int n, w; cin >> n >> w;
		if (!n)break;
		vector<double>vs;
		vector<int>nums(11);
		int amax = 0;
		int mheight = 0;
		for (int i = 0; i < n; ++i) {
			int v; cin >> v;
			int bar = v / w;
			amax = max(amax,bar);
			nums[bar]++;
			mheight = max(mheight, nums[bar]);
		}
		

		double ans = 0;
		for (int i = 0; i <=amax; ++i) {
			ans += double(nums[i]*(amax-i))/amax;
		}
		ans /= mheight;
		ans += 0.01;
		cout <<fixed<<setprecision(10)<< ans << endl;
	}
	return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a,b;
	cin >> a >> b;
	if(a%2==1 && b%2==1) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>

using namespace std;

typedef long long ll;

typedef int _loop_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 DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n,q,a,b;
int x[252521];
const ll INF = 1e18;

const int MAX = 1<<18;
ll dpa[2*MAX];
ll dpb[2*MAX];
void init(){
  REP(i,2*MAX)dpa[i] = INF;
  REP(i,2*MAX)dpb[i] = INF;
}
void set(int x,ll v){
  int p = x+MAX-1;
  dpa[p] = v+x;
  dpb[p] = v-x;
  while(p>0){
    p = (p-1)/2;
    dpa[p] = min(dpa[2*p+1], dpa[2*p+2]);
    dpb[p] = min(dpb[2*p+1], dpb[2*p+2]);
  }
}
ll get(int x){
  return dpa[x+MAX-1]-x;
}
ll qmin(ll data[2*MAX], int l,int r,int a,int b,int k){
  if(b<=l || r<=a)return INF;
  if(l<=a && b<=r)return data[k];
  int m = (a+b)/2;
  return min(qmin(data,l,r,a,m,2*k+1), qmin(data,l,r,m,b,2*k+2));
}

int main(){
  scanf("%d%d%d%d",&n,&q,&a,&b);
  --a;--b;
  x[0] = b;
  REP(i,q)scanf("%d",x+1+i);
  REP(i,q)x[i+1]--;
  init();
  set(a,0);
  ll addall = 0;
  REP(i,q){
    ll diff = x[i+1] - x[i];
    diff = max(diff,-diff);
    ll mn = get(x[i]);
    CHMIN(mn, qmin(dpb,0,x[i+1],0,MAX,0) + x[i+1]-diff);
    CHMIN(mn, qmin(dpa,x[i+1],n,0,MAX,0) - x[i+1]-diff);
    set(x[i],mn);
    addall += diff;
    // DEBUG(mn);
    // REP(i,n)DEBUG(dpa[i+MAX-1]-i);
    // puts("");
  }
  ll ans = INF;
  REP(i,n)CHMIN(ans,get(i));
  printf("%lld\n",ans+addall);
  return 0;
}


Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(); // 階段の段数
        int M = sc.nextInt(); // 壊れている床番号

        //
        int[] brokenStairs = new int[M];
        for (int i = 0; i < M; i++) {
            brokenStairs[i] = sc.nextInt();
        }

        long[] count = new long[N + 1];
        for (int i = 0; i <= N; i++) {
            count[i] = -1;
        }

        count[0] = 1;
        count[1] = 1;
        for (int i = 0; i < M; i++) {
            count[brokenStairs[i]] = 0;
        }

        for (int stair = 2; stair <= N; stair++) {
            if (count[stair] == -1) {
                count[stair] = count[stair - 1] + count[stair - 2];
                count[stair] %= 1000000007;
            }
        }
        System.out.print(count[N]);
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }

}


Measured memory_bytes: 48644
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int X; 
	cin >> X; 
	if(X == 3 || X == 5 || X == 7) {cout << "YES" << endl;} 
	else {cout << "NO" << endl; }
}

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

#define ankit_2305 cerr<<"\nTime taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<" sec\n";
#define START clock_t
#define TIMER time_p=clock();
#define ll long long

#define MOD 1000000007

using namespace std;

int main(){
    START TIMER
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int x, y, a, b, c;
	cin>>x>>y>>a>>b>>c;
	int p[a], q[b], r[c];
	for(int i=0;i<a;i++)
		cin>>p[i];
	for(int i=0;i<b;i++)
		cin>>q[i];
	for(int i=0;i<c;i++)	
		cin>>r[i];
		
	sort(p, p+a, greater<int>());
	sort(q, q+b, greater<int>());
	sort(r, r+c, greater<int>());
	
	int red = x-1, green = y-1;
	for(int i=0;i<c;i++){
		if(red >=0 && green >= 0){
			if(p[red] < q[green]){
				if(p[red] < r[i]){
					p[red] = r[i];
					red--;
				}
				else
					break;
			}
			else{
				if(q[green] < r[i]){
					q[green] = r[i];
					green--;
				}
				else
					break;
			}
		}
		else if(red >= 0){
			if(p[red] < r[i]){
					p[red] = r[i];
					red--;
				}
				else
					break;
		}
		else if(green >= 0){
			if(q[green] < r[i]){
					q[green] = r[i];
					green--;
				}
				else
					break;
		}
		else 
			break;
	}
	
	ll ans = 0;
	for(int i=0;i<x;i++)
		ans += p[i];
	for(int i=0;i<y;i++)
		ans += q[i];
	
	cout<<ans<<"\n";
    ankit_2305
    return 0;
}


Measured memory_bytes: 1408
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>

#define DEBUG false

typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
int a,b;
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  cin >> N ; 
  cin >> a ; 
  cin >> b ;
  if((a-b) %2 == 0) {
    printf("Alice\n");   
  }else{
    printf("Borys\n");   
  }

  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}
/******** scan **************/
int scanInt(void ){
  int n ;
  if(std::scanf("%d",&n)){
  }else{
    std::printf("scanN error\n");
    std::exit(1);
  }
  return n ;
}
void scanLlArr(ll *a , int n){
  int ireadA ; 
  for (ireadA =  0 ; ireadA < n ; ireadA++){
    if(std::scanf("%lld",&a[ireadA])){
    }else{
      std::printf("readA error\n");
      std::exit(1);
    }
  }
}

string scanString(void){
  string s ;
  if(cin >> s){ 
  }
  else{
    std::printf("scanString error\n");
    std::exit(1);
  }
  return s;
}

void scanCharArr(char *string){
  if(scanf("%s",string))
  {}
  else{
    std::printf("scanCharStr error\n");
    std::exit(1);
  }
}
/************* print **************/
void printInt(int p){
  if(std::printf("%d\n",p)){
  }else{
    std::printf("intPrintf Error\n");
    std::exit(1);
  }
}

void printLlArr(ll *a){
  int i ;
  for(i = 0 ; i < sizeof(a)/sizeof(ll) ; i++){
    if(std::printf("%lld ",a[i] )){
    }else{
      std::printf("intPrintN Error i = %d stopped \n",i);
      std::exit(1);
    }
  }
  std::printf("\n");
}
void printCharArr(char *string){
 for(int i = 0 ; i < sizeof(string)/sizeof(char); i++){
   if(printf("%c",string[i])){
     }
   else{
      std::printf("charStrPrint Error i = %d stopped \n",i);
      std::exit(1);
   }
 }
 printf("\n");
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        string S;
        cin >> S;

        Int sum = 0;
        Int N = S.size();
        vector<Int> dp(N + 1, INFl);
        map<Int, Int> mp;
        dp[0] = 0;
        mp[0] = 0;
        for (int i = 0; i < N; ++i) {
            sum ^= (1ll << (S[i] - 'a'));
            chmin(dp[i + 1], dp[i] + 1);
            if (mp.count(sum)) {
                chmin(dp[i + 1], mp[sum]);
            }

            for (int j = 0; j < 26; ++j) {
                Int tmp = sum ^(1 << j);
                if (mp.count(tmp)) {
                    Int val = mp[tmp] + 1;
                    chmin(dp[i + 1], val);
                }
            }

            mp[sum] = dp[i + 1];
        }
        Int ans = max<Int>(dp[N], 1);
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 14460
H, W, K =  [int(i) for i in input().split()]

masme = []
for i in range(H):
    masme.append(list(input()))

#print(masme)

h_p = []
for h in range(pow(2,H)):
    h_p.append( [int(i) for i in list(str(bin(h))[2:].zfill(H))] )

#print(h_p)

w_p = []
for w in range(pow(2,W)):
    w_p.append( [int(i) for i in list(str(bin(w))[2:].zfill(W))] )

ans_cnt = 0

for h in h_p:
    for w in w_p:
        cnt = 0
        for i in range(H):
            for j in range(W):
                if h[i] * w[j] == 1 and masme[i][j] == "#" :
                    cnt += 1
        if(cnt == K):
            ans_cnt += 1

print(ans_cnt)

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

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            var S = GetStr().ToCharArray();
            S[3] = '8';
            var ans = new string(S);

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

        static void Solve()
        {
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13140
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long[] a = new long[n], sum = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextLong();
            sum[i] = a[i] + (i == 0 ? 0 : sum[i - 1]);
        }
        int ab = 0, cd = 2;
        long ans = Long.MAX_VALUE;
        for (int bc = 1; bc < n - 1; bc++) {
            while (ab < bc - 1 
                && Math.abs(sum[bc] - sum[ab + 1] * 2) 
                <  Math.abs(sum[bc] - sum[ab] * 2)) {
                ab++;
            }
            while (cd < n - 1 
                && Math.abs(sum[n - 1] - sum[cd + 1] * 2 + sum[bc]) 
                <  Math.abs(sum[n - 1] - sum[cd] * 2 + sum[bc])) {
                cd++;
            }
            long[] arr = { sum[ab], sum[bc] - sum[ab], sum[cd] - sum[bc], sum[n - 1] - sum[cd] };
            Arrays.sort(arr);
            ans = Math.min(ans, arr[3] - arr[0]);
        }
        System.out.println(ans);
    }
}


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

long long n, k, m = 1, t, v, u = 1;
const long long M = 1000000007;

int main()
{
	cin >> n >> k;

	if (k > n - 2)
		k = n - 1;

	if (k == 1)
		m = n * (n - 1) % M;
	else {
		for (long long i = 1; i <= k; i++) {
			t = i;
			v = 1;

			for (int j = 0; (1ull << j) < M - 1; j++) {
				if ((1ull << j) & (M - 2))
					v = v * t % M;

				t = t * t % M;
			}

			v = v * v % M;
			u = ((u * (n - i + 1) % M) * (n - i) % M) * v % M;
			m = (m + u) % M;
		}
	}

	cout << m << endl;

	return 0;
}



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

int main(){
	int n;
	bool flag = 0;
	cin >> n;
	for(int i = 1;i <= n;i++){
		char s;
		cin >> s;
		if(s == 'Y') flag = 1;
	}
	if(flag) cout << "Four";
	else cout << "Three";
}

Measured memory_bytes: 256
n = $stdin.gets.chomp.to_i
str = $stdin.gets.chomp

if n % 2 == 1
    puts "No"
    exit
end

ans = "Yes"

for i in 1..n/2
    if str[i-1] != str[n/2-1+i]
        ans = "No"
    end 
end

puts ans

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

#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define deb(x) cerr<<#x" = "<<x<<nl
#define in() ( { int a ; scanf("%d",&a); a; } )

const int N = 3e5 + 9;
const int mod = 1e9 + 7;

int32_t main()
{
    int n=in();
    int ans=1;
    for(int i=1; i<=n; i++){
        int k=in();
        if(k==ans) ans++;
    }
    if(ans==1) ans=-1;
    else ans=n-ans+1;
    cout<<ans<<nl;
    return 0;
}


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

void chmax( int &a, int b){ if( a < b){ swap(a,b);} return;}

int main(){
  int N; cin >> N;
  int dp[100100]; // dp[i]で、長さがちょうどiのメロディの最高得点を表す -1は未更新
  vector<int> s(N); vector<int> l(N); vector<int> p(N);
  vector<int> w(N);
  for(int i = 0; i < 100100; i++){ dp[i] = -1;}
  
  dp[0] = 0;
  
  for(int i = 0; i < N; i++){ 
    cin >> s[i] >> l[i] >> p[i];}
  
  for(int i = 0; i < 10010; i++){
    for(int j = 0; j < N; j++){
      if( dp[i] == -1){ continue;} 
      for(int k = s[j]; k <= l[j]; k++){
        if( k+i < 100100){
        chmax( dp[i+k] , dp[i]+p[j]);}
      }
    }
  }

    
  
  int M; cin >> M;
  vector<int> ans;
  for(int j = 0; j < M; j++){ 
    int w; cin >> w;
    int a = dp[w];
    if( a == -1){ cout << -1 << endl; return 0;}
    ans.push_back(a);
  }
  
  for(auto ne: ans){ cout << ne << endl;}
  
  return 0;}
   
  
  


Measured memory_bytes: 3540
#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

ll res;
ll n;
vector<pair<ll, ll>> edges;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    // res = (n * (n - 1))/2 * n;
    for(ll i = 0; i < n; ++i){
        res += (n - i) * (i + 1);
    }
    // cout << res << "\n";
    for(int i = 0; i < n - 1; ++i){
        ll u, v; cin >> u >> v; u--, v--;
        if(v < u) swap(u, v);
        edges.pb({u, v});
    }
    for(int i = 0; i < n - 1; ++i){
        // cout << edges[i].f << " " << edges[i].s << "\n";
        res -= (edges[i].f + 1) * (n - edges[i].s);
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 7416
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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

int dp[100005][13];

signed main(void) {
    string s;
    cin >> s;
    int n = s.size();
    dp[0][0] = 1;
    rep(i,n)rep(j,13)if(dp[i][j]){
        rep(x,10){
            if(s[i] != '?' && s[i]-'0' != x)continue;
            (dp[i+1][(10*j+x)%13] += dp[i][j]) %= MOD;
        }
    }
    int ans = dp[n][5];
    cout << ans % MOD << endl;
}


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

constexpr char NL = '\n';
constexpr int MOD = 1e9 + 7;

struct safe_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

void solve()
{
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    ll tallest = v[0], ans = 0;
    for (int i = 1; i < n; ++i) {
        if (v[i] > tallest) {
            tallest = v[i];
        } else {
            ans += tallest - v[i];
        }
    }
    cout << ans << NL;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

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

using namespace std;

int n;
int arr[2000000][20];
int a,b;
int VA[20];
int VB[20];

int bit(int A, int bt){
  if(A%(1<<(bt+1))<(1<<bt))return 0;
  return 1;
}
int sol[1000000];
set<int>pos;
void build(int lo, int hi, int A, int B){
  //cout<<lo<<" "<<hi<<" "<<A<<" "<<B<<endl;
  //for(auto t:pos)cout<<t<<" ";
  //cout<<endl;
  sol[lo]=A;
  sol[hi]=B;
  if(hi-lo==1)return;
  for(auto bt:pos){
    if(bit(A,bt)!=bit(B,bt)){
      //cout<<bt<<endl;
      int mid=(lo+hi)/2;
      pos.erase(bt);
      int next_A=A;
      bool DONE=false;
      set<int>::iterator it=pos.begin();
      int bt2=*it;
      //for(auto D:pos)cout<<D<<" ";
      //cout<<endl;
      if(bit(next_A,bt2)){
	next_A-=(1<<bt2);
      }else next_A+=(1<<bt2);
      //cout<<DONE<<endl;
      build(lo,mid,A,next_A);
      if(bit(next_A,bt)==1)next_A-=(1<<bt);
      else next_A+=(1<<bt);
      build(mid+1,hi,next_A,B);
      pos.insert(bt);
      return;
    }
  }
  
}
int main(){
  scanf("%d %d %d",&n,&a,&b);
  int cnt=0;
  int save_A=a;
  int save_B=b;
  for(int i=0;i<n;i++){
    VA[i]=a%2;
    VB[i]=b%2;
    a/=2;
    b/=2;
    cnt+=VA[i]+VB[i];
    cnt%=2;
  }
  
  if(cnt==0){
    cout<<"NO"<<endl;
    return 0;
  }
  cout<<"YES"<<endl;
  for(int i=0;i<n;i++)pos.insert(i);
  build(0,(1<<n)-1,save_A,save_B);
  for(int i=0;i<(1<<n);i++){
    printf("%d ",sol[i]);
  }printf("\n");
  return 0;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<cstring> 
char s[15];
int main()
{
	int num=0;
	scanf("%s",s+1);
	int lens=strlen(s+1);
	if(s[1]!='A') 
	{
		printf("WA\n");
		return 0;
	}
	if(s[2]=='C'||s[lens]=='C')
	{
		printf("WA\n");
		return 0;
	}
	for(int i=2;i<=lens;i++)
	{
		if(s[i]=='C')
		{
			num++;
			continue;
		}
		//if(s[i]=='A') continue;
		if(s[i]<97||s[i]>122)
		{
			printf("WA\n");
			return 0;
		}
	}
	if(num!=1) printf("WA\n");
	else printf("AC\n");
	
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
using namespace std;

void set_reset(set<int> &s) {
    set<int> s2;
    s = s2;
}

int main(void){
    int H, W, M;
    cin >> H >> W >> M;
    vector<int> h(M), w(M);
    vector<int> hzt(H), vtc(W);
    for (int i = 0; i < M; i++) {
        cin >> h[i] >> w[i];
        h[i]--; w[i]--;
    }
    for (int i = 0; i < M; i++) {
        vtc[w[i]]++;
        hzt[h[i]]++;
    }
    int vtc_max = 0;
    set<int> vtc_n;
    for (int i = 0; i < W; i++) {
        if (vtc_max < vtc[i]) {
            vtc_max = vtc[i];
            set_reset(vtc_n);
            vtc_n.insert(i);
        }
        else if (vtc_max == vtc[i]) {
            vtc_n.insert(i);
        }
    }
    int hzt_max = 0;
    set<int> hzt_n;
    for (int i = 0; i < H; i++) {
        if (hzt_max < hzt[i]) {
            hzt_max = hzt[i];
            set_reset(hzt_n);
            hzt_n.insert(i);
        }
        else if (hzt_max == hzt[i]) {
            hzt_n.insert(i);
        }
    }
    int cross_bomb_count = 0;
    for (int i = 0; i < M; i++) {
        if (hzt_n.count(h[i]) && vtc_n.count(w[i])) {
            cross_bomb_count++;
        }
    }
    if (cross_bomb_count == vtc_n.size() * hzt_n.size()) cout << vtc_max + hzt_max - 1 << endl;
    else cout << vtc_max + hzt_max << endl;
}

Measured memory_bytes: 35932
#include<iostream>
using namespace std;
int main()
{
	long long n,i,j,sum;
	long long c[550],s[550],f[550];
	while(cin>>n)
	{
		for(i=1;i<n;i++)
		{
			cin>>c[i]>>s[i]>>f[i];
		}
		
		for(i=2;i<n;i++)
		{
			sum=c[i-1]+s[i-1];
			for(j=i;j<n;j++)
			{
				if(s[j]>=sum) sum=c[j]+s[j];
				else
				{
					if((sum-s[j])%f[j]==0)
					{
						sum+=c[j];
					}
					else
					{
						sum+=c[j]+(f[j]-(sum-s[j])%f[j]);
					}
				}
			}
			cout<<sum<<endl;
		}
		if(n!=1)
		{
			cout<<c[n-1]+s[n-1]<<endl;
		}
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] l = new int[N];

		for(int i=0; i<N; i++) {
			l[i] = sc.nextInt();
		}Arrays.sort(l);

		int length = 0;

		for(int j=0; j<K; j++) {
			length += l[N-1-j];
		}

		System.out.println(length);

	}

}


Measured memory_bytes: 20688
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>
#include <cmath>
#include <map>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
namespace mp = boost::multiprecision;
typedef long long ll;
const ll M = 1000000007;

int main(){
	string a,b;
	cin >> a >> b;
	cout << b+a;

	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll a[N];
ll ps[N];
ll ss[N];
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	a[0] = 0;
	ps[0] = 0;
	for(int i = 1; i <= n; i++) ps[i] = ps[i - 1] + abs(a[i] - a[i - 1]);
	ss[n + 1] = 0;
	for(int i = n; i >= 1; i--) ss[i] = ss[i + 1] + abs(a[i] - a[i + 1]);
	for(int i = 1; i <= n; i++) cout << ps[i - 1] + ss[i + 1] + abs(a[i - 1] - a[i + 1]) << '\n'; 
	return 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
using pi=pair<int,int>;
#define mp make_pair
signed main(){
  int n,t;
  cin>>n>>t;
  vector<pi> v(n);
  for(auto& i:v)cin>>i.first>>i.second;
  vector<vector<int>> dpl(n,vector<int>(t,0)),dpr;
  dpr=dpl;
  
  for(int i=v[0].first;i<t;++i)dpl[0][i]=v[0].second;
  for(int i=v[n-1].first;i<t;++i)dpr[n-1][i]=v[n-1].second;
  
  for(int i=1;i<n;++i){
    for(int j=0;j<t;++j)dpl[i][j]=dpl[i-1][j];
    for(int j=v[i].first;j<t;++j){
      dpl[i][j] = max(dpl[i][j],dpl[i-1][j-v[i].first]+v[i].second);
    }
  }
  
  for(int i=n-2;i>=0;--i){
    for(int j=0;j<t;++j)dpr[i][j]=dpr[i+1][j];
    for(int j=v[i].first;j<t;++j){
      dpr[i][j] = max(dpr[i][j],dpr[i+1][j-v[i].first]+v[i].second);
    }
  }
  
  int res=0;
  for(int i=0;i<n;++i){
    int resi = 0;
    for(int j=0;j<t;++j){
      resi = max(resi,(i-1<0?0:dpl[i-1][j])+(i+1>=n?0:dpr[i+1][t-1-j]));
    }
    res=max(res,resi+v[i].second);
  }
  cout<<res;
}

Measured memory_bytes: 141184
# -*- coding: utf-8 -*-
import math
import collections

n = input()

# 階乗を計算する
N = math.factorial(int(n))

# 試し割り方で素因数分解を行う
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a = prime_factorize(N)

# 素因数の値と個数を辞書型にする
c = collections.Counter(a)

# 個数だけをリストで取得
d = list(c.values())

# 個数+1の総積が約数の個数となる
e = 1
for i in range(len(d)):
    e = e*(d[i]+1)

# 求められていた値の出力
print(e % 1000000007)



Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) 
{ v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i]; }
template<class T, class U> void read_n(vector<pair<T, U>>& v, size_t n)
{ v = vector<pair<T, U>>(n); 
  for (lli i=0; i<n; ++i) cin >> v[i].first >> v[i].second; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

string s, t;
int main() {
  cin >> s >> t;
  sort(begin(s), end(s));
  sort(begin(t), end(t), greater<char>());
  auto ans = s < t ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}


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

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


int main() {
	vector<vector<int>> C(3, vector<int>(3));

	// 入力 (2重ループを用いる)
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> C.at(i).at(j);
		}
	}

	int diff1 = C.at(0).at(0) - C.at(0).at(1);
	int diff2 = C.at(0).at(1) - C.at(0).at(2);

	if (diff1 != (C.at(1).at(0) - C.at(1).at(1)) || diff2 != (C.at(1).at(1) - C.at(1).at(2))) {
		cout << "No" << endl;
		exit(0);
	}

	if (diff1 != (C.at(2).at(0) - C.at(2).at(1)) || diff2 != (C.at(2).at(1) - C.at(2).at(2))) {
		cout << "No" << endl;
		exit(0);
	}

	cout << "Yes" << endl;
}


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

int main() {
	int n, x, y;
	cin >> n >> x >> y;
	vector<int> numOfRoots(n + 10, 0);
	for (int i = 1; i <= n - 1; i++)
	{
		for (int j = i + 1; j <= n; j++) 
	 	{
			 int withoutXY = j - i;
			 int withXY = min(abs(x-i) + abs(y-j) + 1, abs(y-i) + abs(x-j) + 1);
			 int minDistance  = min(withoutXY, withXY);
			 numOfRoots[minDistance]++;
		}	 
	}
	for (int i = 1; i < n; i++) cout << numOfRoots[i] << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var K = cin.ReadInt;
            var Q = cin.ReadInt;

            var arrayAns = new List<int>();

            for(var i=0; i<N; i++)
            {
                arrayAns.Add(K-Q);
            }

            for(var i=0; i<Q; i++)
            {
                var A = cin.ReadInt;
                arrayAns[A - 1]++;
            }

            for (var i = 0; i < N; i++)
            {
                if (arrayAns[i] <= 0)
                    WriteLine("No");
                else
                    WriteLine("Yes");
            }

        }

        static long GcdArray(long[] array)
        {
            var ans = array[0];
            for(var i=1; i<array.Length; i++)
            {
                ans = Gcd(ans, array[i]);
            }
            return ans;
        }

        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }

        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 17464
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
inline int read(){
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    write(a); puts("");
}
char an[4];
int n,m,d;
int main(){
	an[0]='R'; an[1]='Y'; an[2]='G'; an[3]='B';//R, Y, G or B
    n=read(); m=read(); d=read();
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			int t1=((i+j)/d)&1,t2=((i+m-1-j)/d)&1;
			putchar(an[t1*2+t2]);
		}
		puts("");
	}
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

pair<long long, long long> p[51],P[51];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k;
    cin >> n >> k;

    for(int i = 0; i < n; ++i)
        cin >> p[i].first >> p[i].second;
    for(int i = 0; i < n; ++i)
        P[i] = make_pair(p[i].second, p[i].first);

    sort(p, p + n); sort(P, P + n);

    long long area = -1;
    for(int a = 0; a < n; ++a){
        long long lx = p[a].first;
        for(int c = 0; c < n; ++c){
            long long ly = P[c].first;
            for(int b = a + k - 1; b < n; ++b){
                long long rx = p[b].first;
                for(int d = c + k - 1; d < n; ++d){
                    long long ry = P[d].first;
                    if(area != -1 && (rx - lx) * (ry - ly) >= area) break;
                    int cnt = 0;
                    for(int i = 0; i < n && cnt < k; ++i){
                        if(p[i].first > rx) break;
                        if(lx > p[i].first) continue;
                        if(ly > p[i].second || p[i].second > ry) continue;
                        ++cnt;
                    }
                    if(cnt == k) area = (rx - lx) * (ry - ly);
                }
            }
        }
    }

    cout << area;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
 int a,b,d,e,f=0;
 cin>>a>>b;
 int c[b];

 for(d=0;d<=b-1;d=d+1){
 cin>>c[d];
}

 for(d=0;d<=b-1;d=d+1){
 f=f+c[d];
}

e=f%(a+1);

if(e!=0){
cout<<1+f/(a+1)<<endl;
}else{
cout<<f/(a+1)<<endl;
}

}


Measured memory_bytes: 3120
import sys

N, M = map(int, input().split())

x = []
y = []
z = []

for i in range(M):
    s1, c1 = map(int, input().split())
    if s1 == 1:
        x.append(c1)
    elif s1 == 2:
        y.append(c1)
    elif s1 == 3:
        z.append(c1)

if N == 1:
    if len(set(x)) > 1:
        print('-1')
        sys.exit()

    if len(x) == 0:
        x.append(0)

    print(str(x[0]))
    sys.exit()

elif N == 2:
    if len(x) == 0:
        x.append(1)

    if len(set(x)) > 1 or len(set(y)) > 1:
        print('-1')
        sys.exit()

    if len(y) == 0:
        y.append(0)

    if x[0] == 0 and len(x) == 1:
        print('-1')
        sys.exit()
    elif x[0] == 0 and len(x) > 1:
        print(str(x[1]) + str(y[0]))
        sys.exit()

    print(str(x[0]) + str(y[0]))
    sys.exit()

elif N == 3:
    if len(x) == 0:
        x.append(1)

    if len(set(x)) > 1 or len(set(y)) > 1 or len(set(z)) > 1:
        print('-1')
        sys.exit()

    if len(y) == 0:
        y.append(0)
    if len(z) == 0:
        z.append(0)

    if x[0] == 0 and len(x) == 1:
        print('-1')
        sys.exit()
    elif x[0] == 0 and len(x) > 1:
        print(str(x[1]) + str(y[0]) + str(z[0]))
        sys.exit()

    print(str(x[0]) + str(y[0]) + str(z[0]))
    sys.exit()

print('-1')


Measured memory_bytes: 3192
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var fs_1 = __importDefault(require("fs"));
var input = fs_1.default.readFileSync('/dev/stdin', 'utf8').split('\n');
var k = +input[0];
var a = +input[1].split(' ')[0];
var b = +input[1].split(' ')[1];
var result = 'NG';
for (var i = 0; i < 1000; i++) {
    if (a <= i * k && i * k <= b && result === 'NG') {
        result = 'OK';
    }
}
console.log(result);

Measured memory_bytes: 29640
#include <stdio.h>

int main() {
	char ch;
	int tmp;

	while (true) {
		ch = getchar();
		if (ch == '0') break;

		tmp = ch - '0';
		while ((ch = getchar()) != '\n'){
			tmp += (ch - '0');
        }
		printf("%d\n", tmp);

	}

	return 0;
}


Measured memory_bytes: 2688
#include <stdio.h>
int main(){
  int n,x,l,s=0,i;
  scanf("%d%d",&n,&x);
  for(i=0;i<n;i++){
    scanf("%d",&l);
    s+=l;
    if(s>x){
      s-=l;
      break;
    }
  }
  printf("%d",i+1);
  return 0;
}

Measured memory_bytes: 128
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ; 
    cin >> n ;
    map<string,int> mp ;
    int fre = 0 ;
    for(int i = 0; i < n; i++){
        int x ;
        cin >> x ;
        if ( x < 400 ){
            mp["gray"]++;
        }
        else if ( x < 800 ) {
            mp["brown"]++;
        }
        else if ( x < 1200 ) {
            mp["green"]++;
        }
        else if ( x < 1600 ) {
            mp["cyan"]++;
        }
        else if ( x < 2000 ) {
            mp["blue"]++;
        }
        else if ( x < 2400 ) {
            mp["yellow"]++;
        }
        else if ( x < 2800 ) {
            mp["orange"]++;
        }
        else if ( x < 3200 ) {
            mp["red"]++;
        }
        else {
            fre++ ;
        }
    }
    if ( fre == n ) {
        cout << 1 << ' ' << fre << endl;
    }
    else{
        cout << mp.size() << ' ' << fre + (int)mp.size() << endl;
    }
    return 0; 
}

Measured memory_bytes: 3668
a,b,c,d = map(int, input())

nl = [a,b,c,d]

import itertools
op =["+","-"]
opl = list(itertools.product(op, repeat=3))

for i in range(8): #加減パターン
    res = nl[0]
    opp = opl[i]
    for j in range(3):
        if opp[j]=="+":
            res += nl[j+1]
        else:
            res -= nl[j+1]
    if res ==7:
        print(str(nl[0])+opp[0]+str(nl[1])+opp[1]+str(nl[2])+opp[2]+str(nl[3])+"=7")
        exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int t=0,n=0,k=0,count=0,j=0;
  cin >> n >> k;
  t = k;
  long long int arr[n+1];
  memset(arr,0,sizeof(arr));
  while(t--){
  	long long int z=0,i=0,y=0;
    cin >> z;
    for(i=0;i<z;i++){
    	cin >> y;
      	arr[y]++;
    }
    
    
  }
  for(j=1;j<=n;j++){
    if(!(arr[j])){count++;}
    }
	cout << count << endl;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 200010
#define INF 2000000000
#define MO 1000000007
#define LL long long
int c[MAXN],w[MAXN],mn[MAXN],cnt[MAXN],Mn1,Mn2,cp,sum;
int n,x,y;
LL fac[MAXN],inv[MAXN],ans;
LL PowMod(LL a,int b)
{
	LL ret=1;
	while(b)
	{
		if(b&1) ret=ret*a%MO;
		a=a*a%MO;
		b>>=1;
	}
	return ret;
}
void Pre()
{
	fac[0]=1;
	for(int i=1;i<=sum;i++)
		fac[i]=fac[i-1]*i%MO;
	inv[sum]=PowMod(fac[sum],MO-2);
	for(int i=sum-1;i>=0;i--)
		inv[i]=(i+1)*inv[i+1]%MO;
}
int main()
{
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<=n;i++) mn[i]=INF;
	Mn1=INF,Mn2=INF;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&c[i],&w[i]);
		mn[c[i]]=min(mn[c[i]],w[i]);
	}
	for(int i=1;i<=n;i++)
		if(mn[i]<=Mn1)
		{
			Mn2=Mn1;Mn1=mn[i],cp=i;
		}
		else if(mn[i]<Mn2) Mn2=mn[i];
	for(int i=1;i<=n;i++)
		if(w[i]+mn[c[i]]<=x)
			w[i]=mn[c[i]];
	for(int i=1;i<=n;i++)
		if(cp!=c[i]&&w[i]+Mn1<=y)
			cnt[c[i]]++,sum++;
		else if(cp==c[i]&&w[i]+Mn2<=y)
			cnt[c[i]]++,sum++;
	Pre();
	ans=fac[sum];
	for(int i=1;i<=n;i++)
		ans=ans*inv[cnt[i]]%MO;
	printf("%lld\n",ans);
}

Measured memory_bytes: 6272
#include <iostream>
#include <stdlib.h>
#define MAX 251
using namespace std;

int T[MAX];

int left(int i) { return 2 * i;}
int right(int i) {return 2 * i + 1;}
int parent(int i) {return i/2;}



void print(int i, int n)
{
	cout << "node " << i << ": key = " << T[i] << ", ";
	if(parent(i) >= 1) cout << "parent key = " << T[parent(i)] << ", ";
	if(left(i) <= n) cout << "left key = " << T[left(i)] << ", ";
	if(right(i) <= n) cout << "right key = " << T[right(i)] << ", ";
	cout << endl;
}


int main() {
	int n;
	cin >> n;
	for(int i = 1; i < n+1; i++)
	{
		cin >> T[i];
	}
	
	for(int i=1; i < n+1; i++)
	{
		print(i, n);
	}
	
//	system("pause");
	return 0;
}


Measured memory_bytes: 3096
lis = list(map(int, input().split()))
filtered_list_5 = list(filter(lambda x: x == 5, lis))
filtered_list_7 = list(filter(lambda x: x == 7, lis))
if len(filtered_list_5) == 2 and len(filtered_list_7) == 1:
    print('YES')
else:
    print('NO')


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

struct Item {
    long long w, v;
    bool operator<(const Item &rhs) const {
        if(w == rhs.w)
            return v > rhs.v;
        return w > rhs.w;
    }
};
long long ans = 0;
Item items[120];
vector<Item> vec[4];
long long n, W;
long long sum_w[4][120], sum_v[4][120];
void dfs(int cur, long long sum_w, long long sum_v) {
    if(sum_w > W) {
        return ;
    }
    if(cur == 4) {
        ans = max(ans, sum_v);
        return ;
    }
    dfs(cur + 1, sum_w, sum_v);
    for(int i = 0;i < vec[cur].size();++i) {
        dfs(cur + 1, sum_w + ::sum_w[cur][i], sum_v + ::sum_v[cur][i]);
    }
}
int main() {
    cin >> n >> W;
    for(int i = 0; i < n; ++i) {
        cin >> items[i].w >> items[i].v;
        vec[ items[i].w - items[0].w ].push_back(items[i]);
    }
    sort(vec[0].begin(), vec[0].end());
    sort(vec[1].begin(), vec[1].end());
    sort(vec[2].begin(), vec[2].end());
    sort(vec[3].begin(), vec[3].end());
    for(int i = 0; i < 4; ++i) {
        for(int j = 0; j < vec[i].size(); ++j) {
            if(j == 0) {
                sum_w[i][j] = vec[i][j].w;
                sum_v[i][j] = vec[i][j].v;
            } else {
                sum_w[i][j] = sum_w[i][j - 1] + vec[i][j].w;
                sum_v[i][j] = sum_v[i][j - 1] + vec[i][j].v;
            }
        }
    }
    dfs(0, 0, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long a,b,c;
int main(){
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0){
		cout<<0<<endl;
		return 0;
	}
	else{
		cout<<min(a*b,min(a*c,b*c))<<endl;
		return 0;
	}
}

Measured memory_bytes: 256