akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);

	i64 ans = 0;

	for (int b = k + 1; b <= n; b++)
	{
		int sz = n / b;
		int r = n % b;

		if (r > 0 && r >= k)
		{
			ans += r - k + 1;
			if (k == 0)
				ans--;
		}

		ans += sz * (b - k);
	}

	printf("%lld\n", ans);

	return 0;
}

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

int main(void) {
  int n;
  cin >> n;
  vector<long long> ts(n);
  for (long long &t : ts) cin >> t;

  long long result = ts[0];
  long long t0, t1, t2;
  for (int i = 0; i < n; ++i) {
    t0 = __gcd(result, ts[i]);
    t1 = result / t0;
    t2 = ts[i] / t0;
    result = t0 * t1 * t2;
  }

  cout << result << endl;
  return 0;
}

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


int main(){
    int ans=0;
    int n;
    cin>>n;
    vector<int> l;
    int r[2001]={0};
    int li;
    rep(i,n){
        cin>>li;
        l.pb(li);
        rep2(li+1,j,2001){
            r[j]++;
        }    
    }
    
    sort(l.begin(),l.end());
    //rep(i,n)cout<<l[i]<<endl;
    int a;
    int b;
    rep(i,n-2){
        for(int j=i+1;j<n-1;j++){
            a=l[i];b=l[j];
          //cout<<a<<","<<b<<endl;
          //cout<<r[a+b]<<",,"<<r[b-a+1]<<endl;
            /*
            if(a==b){
                ans+=r[a+b]-r[b+1];
            }else{
                ans+=(r[a+b]-r[b+1]>0)?r[a+b]-r[b+1]:0;
              
            }
            */
           bool check=true;
           for(int k=j+1;k<n,check;k++){
               if(l[k]<a+b && b-a<l[k]){
                   ans++;
               }else{
                   check=false;
               }
           }
            
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  double y, sum;
  string u;
  for (int i = 0; i < n; i++) {
    cin >> y >> u;
    if (u == "BTC") sum += y * 380000.0;
    else sum += y;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
const int N = 1e6 + 10;
 
 
struct Edge{
	int fr , to , v;
}e[N << 1];
int n , m , q , mod , g , z;
 
 
int id[N][2][3] , icnt , par[N * 6];
int can[2][1000010];
 
int find(int x){
	if (par[x] != x){
		return par[x] = find(par[x]);
	}
	return par[x];
}
void merge(int x,int y){
	x = find(x) , y = find(y);
	if (x ^ y){
		par[x] = y;
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&q,&mod);
	for (int i = 1;i <= m;i++){
		scanf("%d%d%d",&e[i].fr,&e[i].to,&e[i].v);
		g = __gcd(g , abs(e[i].v - e[1].v) );
	}
	if (!g) g = mod;
	mod = __gcd(mod , 3 * g);
	z = e[1].v % g;
	
	for (int i = 1;i <= n;i++)
	for (int j = 0;j < 2;j++)
	for (int k = 0;k < 3;k++)
	id[i][j][k] = ++icnt;
	
	
	for (int i = 1;i <= icnt;i++) par[i] = i;
	
	int mul = z;
	for (int i = 0;i <= (mod << 1);i++){
		can[i & 1][mul] = 1;
		mul = 2 * mul % mod;
	}
	
	for (int i = 1;i <= m;i++){
		int more = ((e[i].v - z) / g);
		for (int p = 0;p < 2;p++)
		for (int q = 0;q < 3;q++){
			merge(id[e[i].fr][p][q] , id[e[i].to][p ^ 1][(2 * q + more) % 3]);
			merge(id[e[i].to][p][q] , id[e[i].fr][p ^ 1][(2 * q + more) % 3]);
		}
	}
	while (q--){
		int s , t , r;
		scanf("%d%d%d",&s,&t,&r);
		int ret = 0;
		for(int p = 0;p < 2;p++) 
		for(int q = 0;q < 3;q++) 
		if ( find(id[t][0][0]) == find(id[s][p][q]) ){ 
			ret |= can[p][(r+z+(3-q)*g)%mod];
			if (ret) break;
		}
		puts(ret?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 14720
#include <stdio.h>

int main(int argc, const char * argv[]){
    int n, x, max, a, b, c, ans;
    
    while (1) {
        scanf("%d%d", &n, &x);
        if (n == 0 && x == 0) break;
        
        ans = 0;
        max = x; if (max > n) max = n;
        for (a = 1; a <= max; a++) {
            for (b = a + 1; b <= max; b++) {
                c = x - a - b;
                if (c > b && c <= n) ans++;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2080
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

A, B = map(int, input().split())
S = input()[:-1]
ans = "Yes"
if S.count("-") != 1:
    ans = "No"
elif not S[A] == "-":
    ans = "No"
elif len(S) != A+B+1:
    ans = "No"
print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main{
  static String a, b;

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

    a = sc.next();
    b = sc.next();

    if(a.equals("H")){
      System.out.println(b);
    }
    else{
      if(b.equals("H")){
        System.out.println("D");
      }
      else{
        System.out.println("H");
      }
    }
  }
}

Measured memory_bytes: 21716
import java.util.*;
import java.io.*;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		long T1 = sc.nextLong();
		long T2 = sc.nextLong();
		long A1 = sc.nextLong();
		long A2 = sc.nextLong();
		long B1 = sc.nextLong();
		long B2 = sc.nextLong();
		A1 -= B1;
		A2 -= B2;
		B1 = 0;
		B2 = 0;
		// 何回原点に戻ってくるか？

		if (A1 < 0) {
			A1 *= -1;
			A2 *= -1;
		}
		long d = A1 * T1 + A2 * T2;
		if (d == 0) {
			System.out.println("infinity");
			return;
		} else if (d > 0) {
			System.out.println(0);
			return;
		}
		// long long MAX=9*1e18
		d = Math.abs(d);
		A2 = Math.abs(A2);
		// 始点は 0,-d,-2d,..., -md
		//
		// A1*T1 <= m*dなるdについて2d-1が答え。
		long m = A1 * T1 / d;
		if (A1 * T1 - (m + 1) * d >= 0)
			++m;
		int bonus = 0;
		if (A1 * T1 == m * d)
			++bonus;
		System.out.println(2 * (m + 1) - 1 - bonus);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
string S,T;
int main() {
	cin>>S;
	for(int i=0;i<S.size();i++){
		if(S[i]=='0')T+='0';
		if(S[i]=='1')T+='1';
		if(S[i]=='B' && T.size()>=1)T=T.substr(0,T.size()-1);
	}
	cout<<T<<endl;
	return 0;
}

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

using namespace std;

const int INF = numeric_limits<int>::max() / 2;

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

    int n;
    while(cin>>n,n){
        vector<int> p(n+1,0),t(n+1,0);
        //dp[i][j]:= i番目の風船をj個積載した状態で取得する時の最小移動距離
        vector<vector<int> > dp(n+1,vector<int>(5,INF));
        dp[0][0]=0;
        bool flag=false;
        int idx=INF;
        for(int i=1;i<=n;i++){
            bool update=false;
            cin>>p[i]>>t[i];
            for(int j=0;j<=2;j++){
                if(t[i]-t[i-1]<p[i-1]*(j+2)+p[i]) continue;
                if(dp[i-1][j]==INF) continue;
                dp[i][0]=min(dp[i][0],dp[i-1][j]+p[i-1]+p[i]);
                update=true;
            }
            for(int j=0;j<2;j++){
                int dif=abs(p[i]-p[i-1]);
                if(t[i]-t[i-1]<dif*(j+2)) continue;
                if(dp[i-1][j]==INF) continue;
                dp[i][j+1]=min(dp[i][j+1],dp[i-1][j]+dif);
                //cout<<i<<" "<<j<<" "<<dp[i][j+1]<<endl;
                update=true;
            }
            if(!update){
                flag=true;
                idx=min(idx,i);
            }
        }
        if(flag){
            cout<<"NG "<<idx<<endl;
            continue;
        }
        int res=INF;
        for(int j=0;j<3;j++){
            res=min(res,dp[n][j]+p[n]);
        }
        cout<<"OK "<<res<<endl;
    }
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll A[100];
ll dp[100][2]={1};

int main(){
  int n,p;
  cin>>n>>p;

  for(int i=0;i<n;i++)cin>>A[i],A[i]%=2;
  
  for(int i=0;i<n;i++){
    dp[i+1][0] += dp[i][0];
    dp[i+1][1] += dp[i][1];
      
    if(A[i]) {
      dp[i+1][1] += dp[i][0];
      dp[i+1][0] += dp[i][1];
    }
    else {
      dp[i+1][0] += dp[i][0];
      dp[i+1][1] += dp[i][1];
    }
  }

  cout<<dp[n][p]<<endl;
  return 0;
}


Measured memory_bytes: 256
(defun input (n)
  (let ((A (make-array n)))
    (loop for i below n do (setf (aref A i) (read)))
    A))

(defun solve (n A)
  (labels
    ((func (k state ans)
       (when (>= k n) (return-from func ans))
       (let ((a1 (aref A (1- k)))
             (a2 (aref A k)))
         (case state
           (0 (func (1+ k) (cond ((= a1 a2) 0)
                                 ((> a1 a2) 1)
                                 (t         2)) ans))
           (1 (if (< a1 a2)
                (func (1+ k) 0 (1+ ans))
                (func (1+ k) 1 ans)))
           (2 (if (> a1 a2)
                (func (1+ k) 0 (1+ ans))
                (func (1+ k) 2 ans)))))))
    (func 1 0 1)))

(let* ((n (read))
       (A (input n)))
  (princ (solve n A)))

Measured memory_bytes: 57704
// sala saste wale 2 q chut gaye contest ke dauran :/
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define m_p make_pair
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;

// char alphabet[26] = {'a','b','c','d','e','f','g','h','i',
//        'j','k','l','m','n','o','p','q','r','s','t','u','v',
//        'w','x','y','z'};

int32_t main(){
 	fastIO;
 	int a,b,c,k;cin>>a>>b>>c>>k;
 	int ans=0;
 	ans+=min(a,k);
 	k-=min(a,k);
 	k-=min(k,b);
 	ans-=min(k,c);
 	cout<<ans<<endl;
} 			



Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k-1] << endl;
  
}


Measured memory_bytes: 888
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};


struct Edge{
  int to;
  int cost;
  Edge(int _to,int _cost) : 
    to(_to), cost(_cost) {}
  Edge() : to(0), cost(0) {}
};

vector<Edge> edges[20];
bool visited[20];
int sum;
int max_dist;

void dfs(int current,int prev_cost,int total_cost){
  if(visited[current]) return;

  if(current != 0 && edges[current].size() == 1){
    max_dist = max(max_dist,total_cost - prev_cost);
    return;
  }

  visited[current] = true;
  sum += prev_cost;

  for(int i=0;i<edges[current].size();i++){
    dfs(edges[current][i].to,
        edges[current][i].cost,
        total_cost + edges[current][i].cost);
  }
}

int main(){
  int N;
  while(~scanf("%d",&N)){
    if(N == 0) break;
    for(int i=0;i<20;i++){
      edges[i].clear();
    }

    memset(visited,false,sizeof(visited));
    sum = 0;
    max_dist = 0;

    int total_cost = 0;
    for(int i=0;i<N-1;i++){
      int from,to,cost;
      scanf("%d %d %d",&from,&to,&cost);

      from--; to--;
      edges[from].push_back(Edge(to,cost));
      edges[to].push_back(Edge(from,cost));
    }

    dfs(0,0,0);
    printf("%d\n",2 * sum - max_dist);
  }
}

Measured memory_bytes: 1188
s = list(input())
t = list(input())
dic = {}
flg = 'Yes'
for i in range(len(s)):
    if s[i] in dic.keys():
        if dic[s[i]] != t[i]:
            flg = 'No'
    else:
        dic[s[i]] = t[i]
dic2 = {}
for i in range(len(s)):
    if t[i] in dic2.keys():
        if dic2[t[i]] != s[i]:
            flg = 'No'
    else:
        dic2[t[i]] = s[i]
#print(dic)
print(flg)

Measured memory_bytes: 6704
import math
cou = 0
co = 0
n = int(input())
lis = list(map(int,input().split()))
ave1 = math.ceil(sum(lis)/n)
ave2 = math.floor(sum(lis)/n)
for i in range(n):
  cou += (lis[i]-ave1) ** 2
  co += (lis[i]-ave2) ** 2
print(min(cou,co))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N, M;
	cin >> N >> M;
	vector<vector<int>> s( M );
	vector<int> p( M );
	for( int i = 0; i < M; i++ ) {
		int k;
		cin >> k;
		for( int j = 0; j < k; j++ ) {
			int S;
			cin >> S;
			S--;
			s[i].push_back( S );
		}
	}
	for( int i = 0; i < M; i++ ) {
		cin >> p[i];
	}

	long long ans = 0;
	for( int mask = 0; mask < 1 << N; mask++ ) {
		int flag = 0;
		for( int i = 0; i < M; i++ ) {
			int cnt = 0;
			for( int j = 0; j < s[i].size(); j++ ) {
				int sw = s[i][j];
				if( mask >> sw & 1 ) cnt++;
			}
			if( cnt % 2 == p[i] ) continue;
			else {
				flag = 1;
				break;
			}
		}
		if( flag == 0 ) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {
	int N;

	cin >> N;

	N = N % 10;

	if (N == 3) cout << "bon" << endl;
	else if (N == 0 || N == 1 || N == 6 || N == 8) cout << "pon" << endl;
	else cout << "hon" << endl;

	return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;
    class Main{
        public static void main(String arg[]){
            Scanner scn=new Scanner(System.in);
            String n=scn.next();
            for(int i=0;i<n.length();i++){
                if(n.charAt(i)=='9'){
                    System.out.print('1');
                }else{
                    System.out.print('9');
                }
            }
            System.out.println();
        }
    }

Measured memory_bytes: 21844
#include <cstdio>
#include <utility>
#include <stack>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
//void scan(string &s) {for (char c; !isspace(c = gcu()); s += c);}
inline bool scan(int &n) {int c=gcu();return c==EOF?false:(n=in(c),true);}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
//void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo

struct operation {int p, c;};

int main() {
	int n, r;
	while (scan(n) && scan(r) && (n || r)) {
		stack<operation> op;
		while (r--) {
			int p = in(), c = in();
			op.push({p, c});
		}
		int top = 1;
		while (!op.empty()) {
			auto o = op.top();
			op.pop();
			if (top <= o.c)
				top += o.p - 1;
			else if (top - o.c < o.p)
				top -= o.c;
		}
		out(n - top + 1, '\n');
	}
}


Measured memory_bytes: 2456
#include <bits/stdc++.h>
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
using namespace std;
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        int ct = 0;
        while (i < 3 && s[i] == 'R') {
            ct++;
            i++;
        }
        ans = max(ans, ct);
    }
    cout << ans;
}

Measured memory_bytes: 3568
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int[][] town;
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        town = new int[N][2];
        for (int i = 0; i < town.length; i++) {
            town[i][0] = sc.nextInt();
            town[i][1] = sc.nextInt();
        }
        final int[] perm = new int[N];
        Arrays.fill(perm, -1);
        final double total = perm(perm, 0);
        int fact = 1;
        for (int i = 2; i <= N; i++) {
            fact *= i;
        }
        System.out.println(total / fact);
    }

    static double perm(int[] perm, int depth) {
        if (depth == perm.length) {
            return totalLength(perm, town);
        }
        double ret = 0;
        for (int i = 0; i < perm.length; i++) {
            if (perm[i] != -1) {
                continue;
            }
            perm[i] = depth;
            ret += perm(perm, depth + 1);
            perm[i] = -1;
        }
        return ret;
    }

    private static double totalLength(final int[] perm, final int[][] town) {
        double ret = 0;
        for (int i = 0; i < perm.length - 1; i++) {
            ret += len(town[perm[i]], town[perm[i + 1]]);
        }
        return ret;
    }

    static double len(int[] a, int[] b) {
        return Math.sqrt((a[0]-b[0]) * (a[0]-b[0]) + (a[1]-b[1]) * (a[1]-b[1]));
    }
}


Measured memory_bytes: 24276
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

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

string s;
bool dfs(int posi){
  if (posi == s.size()) return true;
  if (s.substr(posi, 5) == "dream"){
    if (dfs(posi+5)) return true;
  }
  if (s.substr(posi, 5) == "erase"){
    if (dfs(posi+5)) return true;
  }
  if (s.substr(posi, 6) == "eraser"){
    if (dfs(posi+6)) return true;
  }
  if (s.substr(posi, 7) == "dreamer"){
    if (dfs(posi+7)) return true;
  }
  return false;
}

int main(){
  cin >> s;
  if (dfs(0)) cout << "YES" << endl;
  else cout << "NO" <<endl;
}


Measured memory_bytes: 5328
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

n,l = map(int,input().split())
apple = [l+i for i in range(n)]


abm = 100000000000000
index = 0
for i in range(n):
    if abs(apple[i]) < abm:
        index = i
        abm = abs(apple[i])



print(sum(apple)-apple[index])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

bool isContain(int X, int* seq, int N);

int main()
{
    int X,N;
    int seq[100];
    int ans1,ans2;
    int ans_abs,abs1,abs2;
    int ans;
    int count=0;

    cin >> X >> N;
    for (int i=0; i<N; i++){
        cin >> seq[i];
    }

    if (N==0){
        ans=X;
    }else{
        while(1){
            if (!isContain(X+count,seq,N)){
                ans1 = X+count;
                break;
            }
            count++;
        }
        count=0;
        while(1){
            if (!isContain(X-count,seq,N)){
                ans2 = X-count;
                break;
            }
            count++;
        }

        abs1 = abs(X-ans1);
        abs2 = abs(X-ans2);
        

        ans_abs = min(abs1,abs2);
        if (ans_abs == abs1) {
            ans = ans1;
        }else{
            ans = ans2;
        }
        if (abs1 == abs2) ans = ans2;
        
    }

    cout << ans;

    return 0;
}

bool isContain(int X, int* seq, int N)
{
    bool ret = false;
    for (int i=0; i<N; i++){
        if (seq[i] == X) {
            ret = true;
            break;
        }
    }

    return ret;
}


Measured memory_bytes: 3624
n=int(input())
D=len(str(n))
A=["7","5","3"]
ans=0
def sgs(k="",d=0,U=[0,0,0]): #七五三(現在の数(文字列),桁数,使ったかどうか)
    global ans
    if d>0:
        if int(k)<=n and all([u for u in U]):
            ans+=1
    if d<D:
        for i in range(3):
            newU=[0,0,0]
            for j in range(3):
                if i==j:
                    newU[j]=1
                else:
                    newU[j]=U[j]
            sgs(k+A[i],d+1,newU)
        
sgs()
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);

	if (a < b)
	{
		printf("a < b\n");
	}

	if (a > b)
	{
		printf("a > b\n");
	}

	if (a == b)
	{
		printf("a == b\n");
	}

	return 0;
}


Measured memory_bytes: 2052
Option Strict On
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim h As Integer = NextInt()
        Dim w As Integer = NextInt()

        Dim c As String() = New String(h - 1) {}

        For i As Integer = 0 To h - 1
            c(i) = ReadLine()
        Next

        For i As Integer = 0 To h - 1
            For j As Integer = 1 To 2
                WriteLine(c(i))
            Next
        Next

    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


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

int main()
{
	int n,y;
	cin>>n>>y;
	y/=1000;
	
	for (int i=0;i<=n;i++)
		for (int j=0;j<=n-i;j++)
			if (i*10+j*5+(n-i-j)==y){
				cout<<i<<' '<<j<<' '<<n-i-j;
				return 0;
			}
	cout<<-1<<' '<<-1<<' '<<-1;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,i,j,cnt=0,x[100];
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%d",&x[i]);
	}
	for(i=a;i>0;i--){
		cnt=0;
		for(j=0;j<a;j++){
			if(i<=x[j]){
				cnt++;
			}
		}
		if(i<=cnt) break;
	}
	printf("%d\n",i);
	return 0;
}


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

namespace contest_Csharp
{
    class Program
    {


        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var vals = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();

            int N = vals[0];
            int ans = 0;

            List<int> P = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();

            List<int> cost = new List<int>(new int[N * N]);
            List<bool> left = new List<bool>(new bool[N * N]);

            for (int i = 0; i < N*N; i++)
            {
                cost[i] = i / N;
                cost[i] = Math.Min(cost[i], N - 1 - i / N);
                cost[i] = Math.Min(cost[i], i % N);
                cost[i] = Math.Min(cost[i], N - 1 - i % N);
            }

            foreach (var ctm in P)
            {
                ans += cost[ctm - 1];
                Queue<int> bfsQueue = new Queue<int>();
                int point = ctm - 1;
                left[ctm - 1] = true;
                bfsQueue.Enqueue(point);
                do
                {
                    point = bfsQueue.Dequeue();
                    if (point + N < N * N && cost[point + N] >
                        cost[point] + (left[point] ? 0 : 1))
                    {
                        cost[point + N] = cost[point] + (left[point] ? 0 : 1);
                        bfsQueue.Enqueue(point + N);
                    }
                    if (point - N >= 0 && cost[point - N] >
                        cost[point] + (left[point] ? 0 : 1))
                    {
                        cost[point - N] = cost[point] + (left[point] ? 0 : 1);
                        bfsQueue.Enqueue(point - N);
                    }
                    if (point % N != N - 1 && cost[point + 1] >
                        cost[point] + (left[point] ? 0 : 1))
                    {
                        cost[point + 1] = cost[point] + (left[point] ? 0 : 1);
                        bfsQueue.Enqueue(point + 1);
                    }
                    if (point % N != 0 && cost[point - 1] >
                        cost[point] + (left[point] ? 0 : 1))
                    {
                        cost[point - 1] = cost[point] + (left[point] ? 0 : 1);
                        bfsQueue.Enqueue(point - 1);
                    }
                } while (bfsQueue.Count() != 0);



            }

            Console.WriteLine(ans);
            Console.Out.Flush();

        }



    }

}


Measured memory_bytes: 64724
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 5000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	ll N,M,K;
	cin  >> N >> M >> K;

	vector<vector<ll>> fri(N),blo(N);
	rep(i,M){
		ll a,b;
		cin >> a >> b;
		--a;
		--b;
		fri[a].push_back(b);
		fri[b].push_back(a);
	}
	rep(i,K){
		ll a,b;
		cin >> a >> b;
		--a;
		--b;
		blo[a].push_back(b);
		blo[b].push_back(a);
	}

	queue<ll> que;
	vector<ll> group_id(N,INF);
	vector<ll> group_cnt(N);
	rep(i,N){
		if(group_id[i] != INF) continue; // すでにidがあったら次へ
		que.push(i);
		ll id = i;
		group_id[id] = id;
		while (que.size()) { // キューが空になるまでループ
			ll p = que.front(); // 一番上を取り出す
			que.pop();
			group_cnt[id]++;
			rep(j,fri[p].size()){
				if(group_id[fri[p][j]] == INF){
					que.push(fri[p][j]);
					group_id[fri[p][j]] = id;
				}
			}
		}
	}

	// rep(i,N){
	// 	cout << group_id[i] << endl;
	// }


	rep(i,N){
		ans = group_cnt[group_id[i]] -  fri[i].size() - 1;
		rep(j,blo[i].size()){
			if(group_id[i] == group_id[blo[i][j]]) ans--;
		}
		cout << ans << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 15348
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (long long int i = 0; i < (n); i++)
#define rep1(i,n) for (long long int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

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

long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

char a[1000][1000];
int main()
{
    string s; cin >> s;
    ll k;cin >> k;

    int flag = 1;
    int i;
    for(i = 0; i < min((ll)s.length(), k); i++) {
        if (s[i] != '1') {
            cout << s[i] << endl;
            return 0;
        }
    }

    cout << 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int N, D, X;
	cin >> N >> D >> X;

	vector<int> A(N);
	rep(i, N) cin >> A[i];

	int count = X;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 1000; j++) {
			if (j*A[i]+1 > D) {
				break;
			}
			else {
				count++;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
#define rep(i,n,k) for(int i=n;i<k;i++)
#define int long long
#define P make_pair
#define F first
#define S second
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s;
    cin>>n>>m;
    int dp[m+1][n+1];
    int dam[m],con[m];
    rep(i,0,m){
        cin>>dam[i]>>con[i];
    }
    rep(i,0,m+1){
        rep(j,0,n+1){
            if(i==0)
            dp[i][j]=LLONG_MAX;
            else{
                if(j<=dam[i-1])
                dp[i][j]=min(con[i-1],dp[i-1][j]);
                else{
                    dp[i][j]=min(dp[i][j-dam[i-1]]+con[i-1],dp[i-1][j]);
                }
            }
        }
    }
    cout<<dp[m][n]<<endl;
    
}

Measured memory_bytes: 78464
#include<stdio.h>

int main()
{
    int n;
    char s;

    scanf("%d", &n);

    for (int i=0; n > i; i++) {
        scanf("%c", &s);
        if ('Y' == s) {
            printf("Four\n");
            return 0;
        } 
    }

    printf("Three\n");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, 1, 1000001){
        rep(j, 1, 1000001){
            if(i*j >= n) break;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
/*

0014: Integral

*/

#include <stdio.h>

#define N 2001


int main(void){
	
	const int x = 600;
	int i, d;
	int sum;
	
	while(scanf("%d", &d) != EOF){
		
		sum = 0;
		
		for(i=0; i+d<=x; i+=d){
			
			sum += i*i*d;
			
		}
		
		printf("%d\n", sum);
		
	}
		
	return 0;
	
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		while(a % 2==0)
		{
			a /= 2;
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
s = input()
l = len(s)

if len(s) % 2 == 0:
    a = s[:l // 2]
    b = s[-l // 2:][::-1]
else:
    a = s[:l // 2]
    b = s[-(l // 2):][::-1]

ans = 0

for i in range(l//2):
    if a[i] != b[i]:
        ans += 1
        
print(ans)

Measured memory_bytes: 3060
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int num = 0;

        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == '1'){
                num++;
            }
        }
        System.out.println(num);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>

using namespace std;

void solve()
{
	int r, c;
	cin >> r >> c;
	vector<vector<int> > matrix(r, vector<int>(c));
	for (int i = 0; i < r; ++i)
	{
		for (int j = 0; j < c; ++j)
		{
			cin >> matrix[i][j];
		}
	}
	for (int i = 0; i < r; ++i)
	{
		int sum = 0;
		for (int j = 0; j < c; ++j)
		{
			cout << matrix[i][j] << " ";
			sum += matrix[i][j];
		}
		cout << sum << endl;
	}
	int all = 0;
	for (int i = 0; i < c; ++i)
	{
		int sum = 0;
		for (int j = 0; j < r; ++j)
		{
			sum += matrix[j][i];
		}
		cout << sum << " ";
		all += sum;
	}
	cout << all << endl;
}

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

Measured memory_bytes: 1256
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let N:usize = sc.read();
    if N == 3{
        println!("2 5 63");
        return
    }
    if N == 4{
        println!("2 5 20 63");
        return
    }
    let template: Vec< Vec<usize>> = vec![vec![],
                                          vec![3],
                                          vec![0,2],
                                          vec![0,2,3],
                                          vec![0,2,4,6],
                                          vec![0,1,2,3,5],
                                          vec![1,2,3,4,5,7],
                                          vec![0,1,2,3,4,5,6]
    ];
    let mut nums:Vec<usize> = vec![];
    for i in 0..5000{
        nums.push(i*6+2);
        nums.push(i*6+3);
        nums.push(i*6+4);
        nums.push(i*6+6);
    }
    nums.sort();
    let quotient = N/8;
    let remainder = N%8;
    let mut ans:String = "".to_string();
    for i in 0..quotient{
        for j in 0..8{
            ans.push(' ');
            ans.push_str(&nums[i*8+j].to_string());
        }
    }
    for i in 0..remainder{
        ans.push(' ');
        ans.push_str(&nums[quotient*8+template[remainder][i]].to_string());
    }
    println!("{}", ans);
        


}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 4476
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;

ll N,ans;
string A, B, C;


int main(void) {
	
	cin >>N>> A>>B>>C;	
	FOR(i, 0, N) {
		int cur = 0;
		if (A[i] == B[i])cur++;
		if (A[i] == C[i])cur++;
		if (B[i] == C[i])cur++;
		if (cur == 0)ans += 2;
		else if (cur == 1)ans += 1;
	}
	ct(ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = int64_t;
using ld = long double;
using ull = uint64_t;

//#define cerr if (false) cerr


ll a, b;

int main() {
  ios::sync_with_stdio(0);
  cout.precision(10);

  cin >> a >> b;

  ll f = 0, s = 1;
  for (int i = 2; i < 1000; i++) {
    f = s;
    s += i;
    if (f-a == s-b) {
      cout << f-a << endl;
      return 0;
    }
  }

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int n,x,a[1010],b[1010];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n>>x;
	b[0]=0;
	fo(i,0,n){
		cin>>a[i];
		b[i+1]=a[i]+b[i];
	}
	int ans=0;
	fo(i,0,n+1) if(b[i]<=x)ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>
using namespace std;
#define N 3
 
struct Puzzle {
  int f[N*N];
  int space;
  string path;
 
  bool operator < ( const Puzzle &p ) const {
    for(int i=0;i < N*N; i++){
      if(f[i]==p.f[i]) continue;
      return f[i]>p.f[i];
    }
    return false;
  }
};
 
static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const char dir[4]={'u','l','d','r'};
 
bool isTarget(Puzzle p){
  for(int i=0;i<N*N;i++)
    if(p.f[i]!=(i+1)) return false;
  return true;
}
 
string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle,bool> V;
  Puzzle u,v;
  s.path="";
  Q.push(s);
  V[s]=true;
 
  while(!Q.empty()){
    u=Q.front(); Q.pop();
    if(isTarget(u)) return u.path;
    int sx=u.space/N;
    int sy=u.space%N;
    for(int r=0;r<4;r++){
      int tx=sx+dx[r];
      int ty=sy+dy[r];
      if(tx<0||ty<0||tx>=N||ty>=N) continue;
      v=u;
      swap(v.f[u.space],v.f[tx*N+ty]);
      v.space=tx*N+ty;
      if(!V[v]){
    V[v]=true;
    v.path+=dir[r];
    Q.push(v);
      }
    }
  }
  return "unsolvable";
}
 
int main()
{
  Puzzle in;
 
  for(int i=0;i<N*N;i++){
    cin>>in.f[i];
    if(in.f[i]==0){
      in.f[i]=N*N;
      in.space=i;
    }
  }
  string ans=bfs(in);
  cout<<ans.size()<<endl;
 
  return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

ll x;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> x;

	for (ll a = -1000; a <= 1000; a++)
		for (ll b = -1000; b <= 1000; b++)
			if (a * a * a * a * a - b * b * b * b * b == x) {
				cout << a << " " << b << endl;
				return 0;
			}

	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi P(n);
    forn(i, n) cin >> P[i];

    vi A(n+2), B(n+2);
    forn(i, n+2) A[i]=B[i]=i+1;
    reverse(all(B));
    vi lazyA(n+2), lazyB(n+2);

    int d=n;
    for (int x:P) {
        lazyA[x+1]+=d;
        lazyB[x-1]+=d;
        d--;
    }
    reverse(all(B));
    reverse(all(lazyB));
    for (int i=0; i<=n; i++) {
        A[i] += lazyA[i];
        B[i] += lazyB[i];
        lazyA[i+1] += lazyA[i];
        lazyB[i+1] += lazyB[i];
    }
    reverse(all(B));
    for (int i=1; i<=n; i++) cout << A[i] << " \n"[i==n];
    for (int i=1; i<=n; i++) cout << B[i] << " \n"[i==n];
}


Measured memory_bytes: 1024
N = int(input())

mem = [0] * N
for i in range(N):
    s = input()
    x = 0
    y = 0
    for j in range(len(s)):
        if s[j] == '(':
            x += 1
        else:
            x -= 1
            y = min(x, y)
    mem[i] = (x, y)

mem_a = sorted([ele for ele in mem if ele[0] > 0], key=lambda x: -x[1])
mem_b = sorted([ele for ele in mem if ele[0] <= 0], key=lambda x: x[1]-x[0])

ans = True
val = 0
for ele in mem_a:
    if val + ele[1] < 0:
        ans = False
    val += ele[0]
for ele in mem_b:
    if val + ele[1] < 0:
        ans = False
    val += ele[0]


YesNo = lambda tf: print('Yes') if tf else print('No')
YesNo(ans and val == 0)

Measured memory_bytes: 178784
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int ddx[8]={0,0,-1,1,1,1,-1,-1};
int ddy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	if(N==1){
		cout<<1<<endl;
		return 0;	}
	int ans=0,b=0;
	for(int i=1;i<=N;i++){
		int a=i;
		int c=0;
		while(a%2==0){
			a/=2;
			c++;
		}
			if(b<c){
				b=c;
				ans=i;
				//cout<<i<<" "<<b<<endl;
			}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    vector<int> a(S.size(),0);
    int length=0;
    for(int i =0;i<S.size();i++){
        char s =S.at(i);
        if(s=='A'||s=='T'||s=='G'||s=='C'){
            length ++;
            a.at(i)=length;
        }         
        else{
            length=0;
        }
    }
    int ans = 0;
    sort(a.begin(),a.end());
    ans=a.at(S.size()-1);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;


int main(int argc, char const *argv[]) {
  ll n, k, c;std::cin >> n >> k >> c;
  string s;std::cin >> s;
  vll L(n+1, 0), R(n+1, 0);
  for(int i=1;i<=n;i++){
    L[i] = L[i-1];
    if(s[n-i]=='x') continue;
    if(i>=c+1) L[i] = max(L[i], (L[i-c-1] + 1));
    else L[i] = max(L[i], (ll)1);
  }

  if(c==0){
    if(L[n]==k){
      for(int i=0;i<n;i++) if(s[i]=='o') std::cout << i+1 << '\n';
      return 0;
    }else{
      std::cout << '\n';
      return 0;
    }
  }
  vll e;
  for(int i=1;i<=n;i++){
    R[i] = R[i-1];
    if(s[i-1]=='x') continue;
    if(i>=c+1) R[i] = max(R[i], (R[i-c-1] + 1));
    else R[i] = max(R[i], (ll)1);
  }
  for(int i=0;i<n;i++){
    ll tmp = R[i] + L[n-i-1];
    if(s[i]=='o' && tmp<k&&L[n]>=k) e.push_back(i+1);
  }
  /*
  multiset<vll> mp;
  for(int i=0;;i++){
    ll r = n-i-1, l = i-c+1;
    //std::cout << max((ll)0, l) << " " << min(n, max(r, (ll)0)) << '\n';
    ll cos = L[min(n, max(r, (ll)0))]+R[max((ll)0, l)];
    mp.insert(vll{i-c+1, -1, cos});
    mp.insert(vll{i+1, 1, cos});
    if(l==n) break;
  }
  vll ans(n);
  auto itr = mp.begin();
  multiset<ll> t;

  for(int i=0;i<n;i++){
    while(mp.size()&&itr!=mp.end()&&(*itr)[0]<=i){
      //std::cout << (*itr)[0] << " " <<(*itr)[1] << " " << (*itr)[2] << '\n';
      if((*itr)[1]==-1) t.insert((*itr)[2]);
      else{
        auto op = t.find((*itr)[2]);
        t.erase(op);
      }
      itr++;
    }
    ans[i] = (*(--t.end()));
    if(s[i]=='o' && ans[i]<k&&L[n]>=k) e.push_back(i+1);
  }
  */

  for(auto E:e) std::cout << E << '\n';
  if(e.size()==0) std::cout << '\n';
  return 0;
}


Measured memory_bytes: 4988
N = int(input())
cc = list(map(int,input().split()))
count = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if cc[i] != cc[j] and cc[i] != cc[k] and cc[j] != cc[k]:
        if cc[i] + cc[j] > cc[k] and cc[j] + cc[k] > cc[i] and cc[i] + cc[k] > cc[j]:
          count += 1
print(count)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define FF first
#define SS second
#define f(a,b,c) for(int a=b;a<=c;a++)
#define fd(a,b,c) for(int a=b;a>=c;a--)
#define fspr(X) fixed<<setprecision(X)

const ll MOD=1e9+7;

//bool visited[1001][1001];
//char graph[1000][1000];
//int ans=0;
//bool path=false;
ll power(ll x, ll y , ll z)       // returns (x^y)%z
{
	ll res=1,num=x;
	while(y>0)
	{
		if(y&1)res=(res*num)%z;
		num=(num*num)%z;
		y=y>>1;
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    bool flag=0;int sum=0;
    int h,n;cin>>h>>n;int A[n];
	f(i,0,n-1){cin>>A[i];sum+=A[i];if(sum>=h)flag=1;}
    cout<<((flag==1)?"Yes":"No");cout<<endl;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
int n, a, b;

int f(int i) {
  string s = to_string(i);
  int ret = 0;
  for (auto &c : s) ret += c - '0';
  return ret;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> n >> a >> b;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    if (a <= f(i) && f(i) <= b) ans += i;
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
  string s;
  long long k;
  cin >> s >> k;
  int i;
  bool one = true;
  long long a = s.length();
  for(i = 0; i < min(k, a); i++)
  {
    if(s.at(i) != '1')
    {
      cout << s.at(i) << endl;
      one = false;
      break;
    }
  }
  if(one) cout << '1' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    multiset<int> st;

    st.insert(A[0]);
    repd(i, 1, N) {
        auto itr = st.lower_bound(A[i]);
        if (itr == st.begin()) {
            st.insert(A[i]);
        }
        else {
            st.erase(--itr);
            st.insert(A[i]);
        }
    }

    cout << (int)st.size() << endl;
    return 0;
}

Measured memory_bytes: 8220