akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

const int MAXN = (int) 1e5;

int arr[MAXN + 1];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, x;
    ios::sync_with_stdio(false);
    cin >> n >> x;
    for(i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    sort(arr + 1, arr + n + 1);
    ll s = 0;
    int cnt = 0;
    for(i = 1; i <= n; i++) {
        if(s + arr[i] <= x) {
            s += arr[i];
            cnt++;
        }
    }
    if(cnt == n && s != x) {
        cnt--;
    }
    cout << cnt;
    //cin.close();
    //cout.close();
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> L(n);
    vector<int> R(n);
    for (int i = 0; i < n; i++) cin >> L[i] >> R[i];
    int l = *max_element(L.begin(), L.end());
    int r = *min_element(R.begin(), R.end());
    int l_r = 1e9; 
    int r_l = 1;
    int max_length = 0;
    bool flag = false;
    for (int i = 0; i < n; i++){
        if (L[i] == l && R[i] == r) flag = true;
        if (L[i] == l) l_r = min(l_r, R[i]);
        if (R[i] == r) r_l = max(r_l, L[i]);
        max_length = max(R[i] - L[i] + 1, max_length);
    }
    if (flag){
        cout << max_length + max(0, r - l + 1) << endl;
        return 0;
    }
    int ans = max_length + max(0, r - l + 1);
    vector<pair<int, int>> z;
    for (int i = 0; i < n; i++) z.push_back({R[i], L[i]});
    sort(z.begin(), z.end());
    vector<int> id;
    vector<int> val;
    int now = 0;
    int tmp = 0;
    for (int i = 0; i < n; i++){
        if (z[i].first != now){
            id.push_back(now);
            val.push_back(tmp);
            now = z[i].first;
        }
        tmp = max(tmp, z[i].second);
    }
    id.push_back(now);
    val.push_back(tmp);
    for (int i = 1; i < id.size(); i++){
        ans = max(ans, max(0, min(l_r, id[i]) - l + 1) + max(0, r - max(r_l, val[i - 1]) + 1));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3060
import java.io.IOException;

public class Main {

	public static void main(String[] args) {
		while (true) {
			int m = nextInt();
			if (m == 0) {
				break;
			}

			int sum = 1;
			int pattern = 0;// パターン数
			for (int j = 2; j < 50; j++) {
				sum += j;
				if ((m - sum) < 0) {
					System.out.println(pattern);
					break;
				} else if ((m - sum) % j == 0) {
					pattern++;
				}
			}
		}

	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

}

Measured memory_bytes: 16852
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int inputInt = scanner.nextInt();
        int inputInt2 = scanner.nextInt();

      if(inputInt < 10 && inputInt2 < 10 ){  
      System.out.println(inputInt * inputInt2);
      } else {
            System.out.println(-1);
      }
    }
}

Measured memory_bytes: 22868
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz

    string s;
    cin>>s;

    if(s == "ABC") cout<<"ARC";
    else cout<<"ABC";
} 

Measured memory_bytes: 3632
N = 300000
a = [((i % 7 ==1)or(i % 7 ==6)) for i in range(N)]
#print(a[11])
a[1]=0
p =[]
for i in range(6,N):
    if a[i]:
        p+=[i]
        for j in range(i * i ,N,i):
            a[j] = 0
 
while True:
    n = int(input())
    if n == 1:
        break
    print(n,end = ":")
    for x in p:
        if n % x ==0:
            print(" "+str(x),end = "") 

    print()



Measured memory_bytes: 9256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <set>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <cassert>

using namespace std;
using ll = long long;

#define nl "\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define trav(x) for(auto& i: x)

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

	int n, k, q;
	cin >> n >> k >> q;
	vector<int> a(q);
	for(int i = 0; i < q; i++) {
		cin >> a[i];
	}
	vector<int> v(n + 1, k);
	for(int i = 0; i < q; i++) {
		v[a[i]]++;
	}
	for(int i = 1; i <= n; i++) {
		if(v[i] - q <= 0) {
			cout << "No" << nl;
		} else {
			cout << "Yes" << nl;
		}
	}
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    int n, a[101];
    int i, j;
    int min, tmp;
    int cnt = 0;

    scanf("%d", &n);

    for (i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    for (i = 0; i < n - 1; i++){
        min = i;
        for (j = i + 1; j < n; j++){
            if (a[j] < a[min]){
                min = j;
            }
        }
        if (min != i){
            tmp = a[i];
            a[i] = a[min];
            a[min] = tmp;
            cnt++;
        }
    }

    for (i = 0; i < n; i++){
        printf("%d", a[i]);
        if (i != n - 1){
            printf(" ");
        }
    }
    printf("\n");
    printf("%d\n", cnt);

    return (0);
}

Measured memory_bytes: 604
import sys

while True:
    n, m = map(int, sys.stdin.readline().split())
    if n == 0 and m == 0:
        break
    route = []
    for i in xrange(n):
        d, p = map(int, sys.stdin.readline().split())
        route.append([p, d])
    route.sort(reverse=True)
    count = 0
    for c, l in route:
        if l < m:
            m -= l
        elif m <= l:
            count += (l - m) * c
            m = 0
    print count

Measured memory_bytes: 5568
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;
const int N=2e5+10;
int n,a[N],bin[31],ans;
map<int,int> mp;
int main()
{
	bin[0]=1;for (int i=1;i<=30;i++) bin[i]=bin[i-1]<<1;
	scanf("%d",&n);for (int i=1;i<=n;i++)scanf("%d",&a[i]),mp[a[i]]++;
	sort(a+1,a+n+1);
	for (int i=n,j;i;i--) if (mp[a[i]])
	{
		mp[a[i]]--;
		for (j=0;bin[j]<=a[i];j++);
		if (mp[bin[j]-a[i]]) mp[bin[j]-a[i]]--,ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 19712
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
//--------------------
#define MOD 1000000007 
using namespace std;
//--------------------

long gcd(long x, long y){

	if (x > y) return gcd(y, x);

	long r;
    
	while (y != 0){
        
		r = x % y;
		x = y;
		y = r;

	}

	return x;
}

int main(){

	string res = "IMPOSSIBLE";
	long N , K ; cin >> N >> K;
	long A[100009]; for (int i = 1; i <= N; i++) cin >> A[i];

	long mygcd = A[1]; for (int i = 2; i <= N; i++) mygcd = gcd(mygcd, A[i]);

	for (int i = 1; i <= N; i++) if (A[i] >= K && abs(A[i] - K) % mygcd == 0) res = "POSSIBLE";

	cout << res << endl;

}

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

int main() {
  int A,B;
  int total = 0;
  cin >> A >> B;

  for(int i=A;i<=B;i++){
    int N1,N2,N3,N4,N5;
    
    N1 = i/10000;
    N2 = (i-N1*10000)/1000;
    N3 = (i-N1*10000-N2*1000)/100;
    N4 = (i-N1*10000-N2*1000-N3*100)/10;
    N5 = (i-N1*10000-N2*1000-N3*100-N4*10);
    
    if(N1==N5 && N2==N4)
      total++;
  }
  cout << total << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		if(a > b) {
			System.out.println("a > b");
		}
		else if (a < b) {
			System.out.println("a < b");
		}
		else {
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 17224
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll n, m;
string s;

int main() {
	ll a, b;
	cin >> a >> b;
	if (a <= b) {

		cout << a;
	}
	else {
		cout << a- 1;

	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    string s;
    cin >> s;
    int halfsize = s.size()/2;
    for(int i=halfsize-1;i>0;i--){
        string t = s.substr(0,i);
        string t_2 = s.substr(0,i*2);
        if(t+t==t_2){
            cout<<i*2<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
  return 0;
}

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

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

  vector<int> w(n);
  vector<ll> v(n);

  for (int i = 0; i < n; ++i) cin >> w[i] >> v[i];

  vector< vector<ll> > dp(n + 1, vector<ll>(W + 1, 0));

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= W; ++j) {
      if (j - w[i] >= 0) {
	dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
      }
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
    }
  }
  cout << dp[n][W] << '\n';
  return 0;
}


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

int n;
long long dp[55][3030];
long long ans;
int x[60];
int A;

int main()
{
	memset(dp,-1,sizeof dp);
	scanf("%d %d",&n,&A);
	for(int i=0;i<n;i++)
	{
		cin>>x[i];
 }
	for(int i=0;i<n;i++)
		for(int j=i+1;j>=0;--j)
			for(int t=0;t<3000;t++)
			{
				if(j==0)
				{
					if(dp[1][x[i]]==-1)	dp[1][x[i]]=1;
					else dp[1][x[i]]++;
					break;
				}
				else
				{
					if(dp[j][t]==-1)	continue;
					if(dp[j+1][t+x[i]]==-1)	dp[j+1][t+x[i]]=dp[j][t];
					else dp[j+1][t+x[i]]+=dp[j][t];
				}
			}
	unsigned	long long ans=0;
	for(int i=1;i<=n;i++)
		for(int j=0;j<3000;j++)
		{
			if(dp[i][j]==-1) continue;
			if(j%i==0&&j/i==A) ans+=dp[i][j];
		}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	public K()
	{
		var N = G[0];
		var A = G;
		WriteLine(FirstBinary(1, N, p => Check(A, p)));
	}
	int FirstBinary(int min, int max, Predicate<int> pred)
	{
		while (min < max)
		{
			var mid = (min + max) / 2;
			if (pred(mid)) max = mid;
			else min = mid + 1;
		}
		return min;
	}
	bool Check(int[] A, int P)
	{
		var S = new Integer(A[0], P);
		foreach (var a in A.Skip(1))
			if (a > S.Length) S.Add(a - S.Length);
			else
			{
				S.Cut(a);
				if (!S.Increment()) return false;
			}
		return true;
	}
}
struct Block
{
	public readonly int Num, Count;
	public Block(int n, int c) { Num = n; Count = c; }
}
class Integer
{
	readonly List<Block> blocks;
	readonly List<int> sum; // sum[n] = Sum(i in [0,n), blocks[i].Count)
	int C;
	public int Length => sum[C];
	public readonly int P;
	public Integer(int n, int p) { blocks = new List<Block> { new Block(0, n) }; sum = new List<int> { 0, n }; C = 1; P = p; }
	public void Add(int c) { Add(new Block(0, c)); }
	Block Pop()
	{
		var x = blocks[C - 1];
		blocks.RemoveAt(C - 1);
		sum.RemoveAt(C);
		C--;
		return x;
	}
	void Add(Block b)
	{
		Block p = b;
		if (C > 0 && blocks[C - 1].Num == b.Num) p = new Block(b.Num, b.Count + Pop().Count);
		blocks.Add(p);
		sum.Add(sum[C] + p.Count);
		C++;
	}
	public void Cut(int c)
	{
		Block b = new Block();
		while (Length > c) b = Pop();
		if (Length < c) Add(new Block(b.Num, c - Length));
	}
	public bool Increment()
	{
		var x = blocks[C - 1].Count;
		if (blocks[C - 1].Num == P - 1 && C == 1) return false;
		// n*p p*x => n*(p-1) (n+1)*1 0*x
		if (blocks[C - 1].Num == P - 1)
		{
			var n = blocks[C - 2].Num;
			var p = blocks[C - 2].Count;
			Pop(); Pop();
			if (p > 1) Add(new Block(n, p - 1));
			Add(new Block(n + 1, 1));
			Add(new Block(0, x));
		}
		// n*x => n*(x-1) (n+1)*1
		else
		{
			var n = blocks[C - 1].Num;
			Pop();
			if (x > 1) Add(new Block(n, x - 1));
			Add(new Block(n + 1, 1));
		}
		return true;
	}
}


Measured memory_bytes: 33628
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]


n = I()
a = LI()
ans = 1
a.sort()
for i in range(n):
    ans *= a[i]
    if ans >= 10**18+1:
        print(-1)
        sys.exit()
    elif ans == 0:
        print(0)
        sys.exit()
print(int(ans))

Measured memory_bytes: 40084
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}
ll const mod = 1e9+7;

// combination
const int MAX = 510000;
const ll MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// べき乗
ll modpow(ll x, ll n) {
    x = x%MOD;
    if(n==0) return 1;  //再帰の終了条件

    else if(n%2==1) {
        return (x*modpow(x, n-1))%MOD;  //nが奇数ならnを1ずらす
    }
    else return modpow((x*x)%MOD, n/2)%MOD;  //nが偶数ならnが半分になる
}

int main() {
  ll c, K;
  cin >> K;
  c=7;
  rep(i,K+K) {
    if (c%K==0) {
      cout << i+1 << endl;
      return 0;
    }
    c = (10*c+7)%K;
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3608
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{BufWriter, Write};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
         a: i64, b: i64, c: i64
    }
    let ans = if (a * b * c) % 175 == 0 { "YES" } else { "NO" };
    puts!("{}\n", ans);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

typedef long long ll;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> pllpl;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;

const double INF = 1e18;

inline ll sq(ll x){
	return x*x;
}

vector<pllpl> titik;
vector<pid> adj[1010];

void make_edge(int x, int y){
	double jar = sqrt(sq(titik[x].first.first - titik[y].first.first) + sq(titik[x].first.second - titik[y].first.second));
	jar -= titik[x].second + titik[y].second;
	jar = max(0.00,jar);
	adj[x].push_back(make_pair(y,jar));
	adj[y].push_back(make_pair(x,jar));
	return ;
}

double jar[1010];

double dijk(int x, int y){
	for(int i=1;i<=y;i++) jar[i] = INF;
	priority_queue<pdi> pq;
	jar[x] = 0.00;
	pq.push(make_pair(0.00,x));
	while(!pq.empty()){
		pdi cur = pq.top(); pq.pop();
		if(cur.second == y) return fabs(cur.first);
		if(jar[cur.second] < -cur.first) continue;
		int now = cur.second;
		double tmp = cur.first;
		for(int i=0;i<adj[now].size();i++){
			int skrg = adj[now][i].first;
			double tmpj = tmp-adj[now][i].second;
			if(jar[skrg] <= -tmpj) continue;
			jar[skrg] = -tmpj;
			pq.push(make_pair(tmpj,skrg));
		}
	}
	return -1;
}

int n;

int main(){
	pll a,b;
	scanf("%lld%lld%lld%lld",&a.first,&a.second,&b.first,&b.second);
	titik.push_back(make_pair(a,0));
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		ll x,y,z;
		scanf("%lld%lld%lld",&x,&y,&z);
		titik.push_back(make_pair(make_pair(x,y),z));
	}
	titik.push_back(make_pair(b,0));
	for(int i=0;i<titik.size();i++){
		for(int j=i+1;j<titik.size();j++){
			make_edge(i,j);
		}
	}
	double ans = dijk(0,titik.size()-1);
	printf("%.10lf\n",ans);
	return 0;
}


Measured memory_bytes: 21616
mod=998244353
inv=pow(2,mod-2,mod)

def xorconv(n,X,Y):
    if n==0:
        res=[(X[0]*Y[0])%mod]
        return res
    x=[X[i]+X[i+2**(n-1)] for i in range(2**(n-1))]
    y=[Y[i]+Y[i+2**(n-1)] for i in range(2**(n-1))]
    z=[X[i]-X[i+2**(n-1)] for i in range(2**(n-1))]
    w=[Y[i]-Y[i+2**(n-1)] for i in range(2**(n-1))]
    res1=xorconv(n-1,x,y)
    res2=xorconv(n-1,z,w)
    former=[(res1[i]+res2[i])*inv for i in range(2**(n-1))]
    latter=[(res1[i]-res2[i])*inv for i in range(2**(n-1))]
    former=list(map(lambda x:x%mod,former))
    latter=list(map(lambda x:x%mod,latter))
    return former+latter

import sys

input=sys.stdin.buffer.readline

N=int(input())

def data():
    edge=[[] for i in range(N)]
    for i in range(int(input())):
        a,b=map(int,input().split())
        if a>b:
            a,b=b,a
        edge[a-1].append(b-1)
    mex=[0 for i in range(N)]
    for i in range(N-1,-1,-1):
        used=[False]*(len(edge[i])+1)
        for pv in edge[i]:
            if mex[pv]<=len(edge[i]):
                used[mex[pv]]=True
        for j in range(len(used)):
            if not used[j]:
                mex[i]=j
                break
    res=[0]*(max(mex)+1)
    for i in range(N):
        res[mex[i]]+=pow(10,18*(i+1),mod)
        res[mex[i]]%=mod

    return res

Xdata=data()
Ydata=data()
Zdata=data()

n=0
m=max(len(Xdata),len(Ydata),len(Zdata))
while 2**n<m:
    n+=1

X=[0 for i in range(2**n)]
Y=[0 for i in range(2**n)]
Z=[0 for i in range(2**n)]

for i in range(len(Xdata)):
    X[i]=Xdata[i]

for i in range(len(Ydata)):
    Y[i]=Ydata[i]

for i in range(len(Zdata)):
    Z[i]=Zdata[i]

ans=0
for i in range(2**n):
    for j in range(2**n):
        ans+=X[i]*Y[j]*Z[i^j]
        ans%=mod

print(ans)


Measured memory_bytes: 106332
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) << ' ' << max(a+b-n,0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define rep(i,b) for(int i = 0 ; i < b; i++)
#define F first
#define S second
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(a) (int)a.size()
#define mod 1000000007
#define dbg(a) cout<<#a<<" = "<<a<<endl
#define dbg2(a,b) cout<<#a<<" = "<<a<<", "<<#b<<" = "<<b<<endl
#define dbg3(a,b,c) cout<<#a<<" = "<<a<<", "<<#b<<" = "<<b<<", "<<#c<<" = "<<c<<endl
#define dbg4(a,b,c,d) cout<<#a<<" = "<<a<<", "<<#b<<" = "<<b<<", "<<#c<<" = "<<c<<", "<<#d<<" = "<<d<<endl
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>

int nex[200004][26];


void solve()
{
    string s,t;cin>>s>>t;
    int a[26];
    rep(i,26) a[i]=-1;
    for(int i=sz(s)-1;i>=0;i--){
        a[s[i]-'a']=i;
        rep(j,26) nex[i][j] = a[j];
    }
    ll ans=0,las=-1;
    rep(j,sz(t)){
        las++;ans++;
        if(las==sz(s)) las=0;
        if(nex[0][t[j]-'a']==-1){
            cout<<-1;
            return;
        }
        int z = nex[las][t[j]-'a'];
        if(z==-1){
            ans+=(sz(s)-las);
            las=0;
            z = nex[las][t[j]-'a'];
        }
        ans+=(z-las);
        las=z;
        // dbg(ans);
    }
    cout<<ans;
}
 
int main()
{   
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << fixed << setprecision(11);
    clock_t beg=clock();
    int t=1, n;
    // cin>>t;
    // n = t;
    while(t--){
        // cout << "Case #" << n-t << ": ";
        solve();
    }
    //
    clock_t end=clock();
    fprintf(stderr, "%lf sec\n", (double)(end-beg)/(CLOCKS_PER_SEC));
    return 0;
}

Measured memory_bytes: 10832
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int a[n];
    map<int,int> mp;
    rep(i,n){
        int x;
        cin>>x;
        mp[x]++;
        a[i]=x;
    }
    sort(a,a+n);
    if(mp.size()>3){
        cout<<"No"<<endl;
    }
    if(mp.size()==3){
        if(n%3){
            cout<<"No"<<endl;
            return 0;
        }
        if((a[0]^a[n/3])!=a[2*n/3]){
            cout<<"No"<<endl;
            return 0;
        }
        set<int> st;
        for(auto e : mp)st.insert(e.second);
        if(st.size()==1){
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }
    if(mp.size()==2){
        if(n%3==0&&a[n/3-1]==0&&a[n/3]!=0){
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }
    if(mp.size()==1){
        if(a[0]==0){
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }
    return 0;
}

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

typedef long long LL;
const LL MOD = 1e9+7;
const int N = 1000000+10;

LL f[N],inv[N];

LL mpow(LL a, LL x) {
    if(x==0) return 1;
    LL t = mpow(a,x/2);
    if(x%2==0) return t*t%MOD;
    return t*t%MOD*a%MOD;
}

void init() {
    inv[0]=f[0]=1;
    for(int i=1;i<N;i++) {
        f[i]=f[i-1]*i%MOD;
        inv[i]=mpow(f[i],MOD-2);
    }
}
LL c(LL n, LL m) {
    if(n<m) return 0;
    return f[n]*inv[m]%MOD*inv[n-m]%MOD;
}

LL g[N];
int main() {
    init();
    LL n; cin >> n;
    LL ret = 0; 

    for(LL k=1;k<=n-1;k++) {
        g[k]=f[k]*c(k-1,n-1-k)%MOD;
        //printf("%lld %lld %lld\n", k, g[k], c(k-1,n-1-k));
        ret = ret + k*( (g[k]-g[k-1]*(n-k))%MOD+MOD )%MOD*f[n-1-k]%MOD;
        ret = (ret % MOD + MOD) % MOD;
    }

    cout<<ret<<endl;
}

Measured memory_bytes: 23680
//by yjz
#include<bits/stdc++.h>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
typedef long long ll;
using namespace std;
const int maxn = 1011;
namespace Flow
{
	const int maxv = 2022;
	const int maxe = 20022;
	const ll inf = 1e18;
	int head[maxv], nxt[maxe], to[maxe], cap[maxe], cost[maxe], tot=1;
	void add_edge(int x, int y, int c, int w)
	{
		nxt[++tot] = head[x];
		head[x] = tot;
		to[tot] = y;
		cap[tot] = c;
		cost[tot] = w;
		swap(x, y);
		nxt[++tot] = head[x];
		head[x] = tot;
		to[tot] = y;
		cap[tot] = 0;
		cost[tot] = -w;
	}
	ll dis[maxv];
	bool inq[maxv];
	int q[maxv], qb, qe;
	void update()
	{
		if (qb==qe) return;
		int lst = qe-1;
		if (lst<0) lst = maxv-1;
		if (dis[q[qb]]>dis[q[lst]]) swap(q[qb], q[lst]);
	}
	void spfa(int S)
	{
		for (int i=0; i<maxv; i++) dis[i] = inf;
		qb = qe = 0;
		q[qe++] = S; inq[S] = true;
		dis[S] = 0;
		while (qb!=qe)
		{
			int x = q[qb++];
			inq[x] = false;
			if (qb>=maxv) qb = 0;
			update();
			for (int i=head[x]; i; i=nxt[i])
			{
				if (cap[i]&&dis[to[i]]>dis[x]+cost[i])
				{
					dis[to[i]] = dis[x]+cost[i];
					if (!inq[to[i]])
					{
						inq[to[i]] = true;
						q[qe++] = to[i];
						if (qe>=maxv) qe = 0;
						update();
					}
				}
			}
		}
	}
	bool vis[maxv];
	int dfs(int x, int T, int f)
	{
		if (x==T) return f;
		int of = f;
		vis[x] = true;
		for (int i=head[x]; i; i=nxt[i])
		{
			int u = to[i];
			if (!vis[u]&&cap[i]&&dis[u]==dis[x]+cost[i])
			{
				int d = dfs(u, T, min(f, cap[i]));
				cap[i] -= d;
				cap[i^1] += d;
				f -= d;
				if (!f) return of;
			}
		}
		return of-f;
	}
	ll min_cost_max_flow(int S, int T)
	{
		ll ret = 0;
		while (true)
		{
			spfa(S);
			if (dis[T]==inf) return ret;
			while (true)
			{
				memset(vis, 0, sizeof(vis));
				int f = dfs(S, T, 233333333);
				if (f==0) break;
				ret += 1ll*f*dis[T];
			}
		}
	}
}
int n;
pair<int,int> a[maxn], b[maxn];
int cnta[maxn], cntb[maxn];

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++) scanf("%d%d%d", &a[i].FF, &a[i].SS, &cnta[i]); 
	for (int i=1; i<=n; i++) scanf("%d%d%d", &b[i].FF, &b[i].SS, &cntb[i]);
	int S = n+n+5, T = n+n+6;
    for (int i=1; i<=n; i++)
	{
		Flow::add_edge(S, i, cnta[i], 0);
		Flow::add_edge(n+i, T, cntb[i], 0);
		Flow::add_edge(i, n+n+1, 1e9, a[i].FF+a[i].SS);
		Flow::add_edge(n+n+1, n+i, 1e9, -b[i].FF-b[i].SS);
		Flow::add_edge(i, n+n+2, 1e9, a[i].FF-a[i].SS);
		Flow::add_edge(n+n+2, n+i, 1e9, -b[i].FF+b[i].SS);
		Flow::add_edge(i, n+n+3, 1e9, -a[i].FF+a[i].SS);
		Flow::add_edge(n+n+3, n+i, 1e9, b[i].FF-b[i].SS);
		Flow::add_edge(i, n+n+4, 1e9, -a[i].FF-a[i].SS);
		Flow::add_edge(n+n+4, n+i, 1e9, b[i].FF+b[i].SS);
	}
	cout<<-Flow::min_cost_max_flow(S, T)<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    string s;
    cin >> s;
    if(s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=1000000007;
inline int ad(int x){return x>=mod?x-mod:x;}
inline int dec(int x){return x<0?x+mod:x;}
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
int fac[2100000],inv[2100000];
inline int C(int n,int m){return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;}
inline int solve(int r,int c){return dec(C(r+c+2,r+1)-1);}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    fac[0]=1;
    for(int i=1;i<=2000010;i++)fac[i]=1LL*fac[i-1]*i%mod;inv[2000010]=power(fac[2000010],mod-2);
    for(int i=2000010;i>=1;i--)inv[i-1]=1LL*inv[i]*i%mod;
    int r1=read(),c1=read(),r2=read(),c2=read();
    pr2(ad(dec(dec(solve(r2,c2)-solve(r1-1,c2))-solve(r2,c1-1))+solve(r1-1,c1-1)));
    return 0;
}

Measured memory_bytes: 16512
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<ll> dqll;

#define MOD 1000000007

int main() {
  ll H, W;

  cin >> H >> W;
  vector<vll> map(H + 1, vll(W + 1));
  vector<vll> visited(H + 1, vll(W + 1, -1));

  ll wcnt = 0;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      char tmp;
      cin >> tmp;
      if (tmp == '.') {
        wcnt++;
        map[i][j] = 0;
      } else {
        map[i][j] = 1;
      }
    }  // j
  }    // i

  queue<P> que;
  visited[1][1] = 0;
  que.push(P(1, 1));
  while (!que.empty()) {
    P tmp = que.front();
    que.pop();
    ll jj = tmp.second;
    ll ii = tmp.first;

    if (jj + 1 <= W && visited[ii][jj + 1] == -1 && map[ii][jj + 1] == 0) {
      que.push(P(ii, jj + 1));
      visited[ii][jj + 1] = visited[ii][jj] + 1;
    }
    if (jj - 1 >= 1 && visited[ii][jj - 1] == -1 && map[ii][jj - 1] == 0) {
      que.push(P(ii, jj - 1));
      visited[ii][jj - 1] = visited[ii][jj] + 1;
    }
    if (ii + 1 <= H && visited[ii + 1][jj] == -1 && map[ii + 1][jj] == 0) {
      que.push(P(ii + 1, jj));
      visited[ii + 1][jj] = visited[ii][jj] + 1;
    }
    if (ii - 1 >= 1 && visited[ii - 1][jj] == -1 && map[ii - 1][jj] == 0) {
      que.push(P(ii - 1, jj));
      visited[ii - 1][jj] = visited[ii][jj] + 1;
    }
  }  // while

  if (visited[H][W] == -1) {
    puts("-1");
    return 0;
  }

  ll ans = wcnt - visited[H][W] - 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  int N;
  cin >> N;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(i*j == N){
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from functools import lru_cache

N, K = map(int,read().split())

@lru_cache(None)
def F(N, K):
    """N以下で0でないものがちょうどK個。0を含める"""
    assert N >= 0
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    q,r = divmod(N,10)
    ret = 0
    if K >= 1:
        # 1の位が nonzero
        ret += F(q, K-1) * r
        ret += F(q-1, K-1) * (9-r)
    # 1の位が zero
    ret += F(q, K)
    return ret

# F(100, 1), F(25, 2), F(314159, 2)

print(F(N, K))


Measured memory_bytes: 3940
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    string a;
    string b;
    cin >> a >> b;
    string c = a + b;
    int n1 = stoi(c);
    int n2 = int(sqrt(n1)) * int(sqrt(n1));
    if (n1 == n2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	cout << fixed << setprecision(18);
	ll n, k;
	cin >> n >> k;

	vector<ll> a(n);
	rep(i, n)
		cin >> a[i];

	ll ans, s, t, next, now;
	vector<ll> l;
	s = 0;
	t = n;
	now = 1;
	vector<bool> f(n, false);
	while(1) {
		next = a[now - 1];
		f[now - 1] = true;
		l.push_back(now);
		if (f[next - 1]) {
			t = l.size() - 1;
			auto is = find(l.begin(), l.end(), next);
			s = is - l.begin();
			break;
		}
		now = next;
	}

	if (s > k)
		ans = l[k];
	else {
		ll tmp = k - s;
		ll tar = tmp % (t - s + 1);
		ans = l[s + tar];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6956
#include<bits/stdc++.h>
using namespace std;
int n,k,snuke[101]={0};
int main() 
{
   cin>>n>>k;
   for(int i=1;i<=k;i++)
   {
      int d;
      cin>>d;
      for(int i=1;i<=d;i++)
      {
         int di;
         cin>>di;
         snuke[di]=1;
      }
   }
   int ans=0;
   for(int i=1;i<=n;i++)
   {
      if(snuke[i]==0) ans++;
   }
   cout<<ans;
}

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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lep(j, n) for (int j = 0; j < (n); j++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define leps(i, n) for (int j = 1; j < (n); j++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define gsort(x, n) sort((x), (x) + (n), greater<int>());
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   string s;
   cin >> s;
   s.insert(4, " ");
   cout << s << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>

using namespace std;

#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

void Main(){
  string n;
  cin>>n;

  (n[0]==n[1] && n[1]==n[2])||(n[1]==n[2] && n[2]==n[3]) ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m;
unordered_map<ll,vector<ll>>seen;
ll dp[100001];
bool visited[100001];
double a[3001];
double memo[3001][3001];
ll taken[3001][3001];
double findans(ll i,ll n,ll h)
{
    if(i==n)
    {
        ll t=n-h;
        if(t<h)
        {
            return 1.0;
        }
        else
        {
            return 0.0;
        }
    }
    if(taken[i][h]!=-1)
    {
        return memo[i][h];
    }
    double p1=0.0,p2=0.0;
    p1=a[i]*findans(i+1,n,h+1);
    p2=(1-a[i])*findans(i+1,n,h);
    taken[i][h]=1;
    return memo[i][h]=p1+p2;
}

int main(){
    // Your code here!
    
    cin>>n;
    
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(ll i=0;i<=3000;i++)
    {
        for(ll j=0;j<=3000;j++)
        {
            taken[i][j]=-1.0;
            memo[i][j]=0;
        }
    }
    cout<<fixed<<setprecision(10)<<findans(0,n,0);
}


Measured memory_bytes: 141696
def main():
	n = int(input())
	mon = list(map(int,input().split()))
	b = list(map(int,input().split()))
	# print(n,mon,b)
	ans = 0
	for i in range(n):
		syori = 0
		if b[i]-mon[i] < 0:
			# print("b[i]-mon[i] < 0")
			ans += b[i]
			# b[i] -= mon[i]
			mon[i] -= b[i]
			syori = 1
			# print("mon[i] = {}".format(mon[i]))
			# print("b[i] = {}".format(b[i]))
		if b[i]-mon[i] >= 0 and syori == 0:
			# print("b[i]-mon[i] >= 0")
			ans += mon[i]
			b[i] -= mon[i]
			mon[i] = 0
			# print("mon[i] = {}".format(mon[i]))
			# print("b[i] = {}".format(b[i]))
			if b[i]-mon[i+1] <0:
				# print("if b[i]-mon[i+1] <0:")
				ans += b[i]
				mon[i+1] -= b[i]
				syori = 1
				# print("mon[i+1] = {}".format(mon[i+1]))
			if b[i] - mon[i+1] >= 0 and syori == 0:
			# else:
				# print("if b[i] - mon[i+1] >= 0:")
				ans += mon[i+1]
				mon[i+1] = 0
				# print("b[i] = {}".format(b[i]))
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 82020
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    string S;
    cin >> S;
    int l = S.length();
    int m = 0;
    for (int i = 0; i < l; ++i) {
        for (int j = i + 1; j < l + 1; ++j) {
            string sub = S.substr(i, j - i);
            bool f = true;
            for (int k = 0; k < sub.length(); ++k) {
                if (sub[k] != 'A' && sub[k] != 'C' && sub[k] != 'G' && sub[k] != 'T') {
                    f = false;
                    break;
                }
            }
            if (f) {
                if (m < sub.length()) m = sub.length();
            }
        }
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <map>
#include <vector>
#include <cmath>

#define INF 1e9

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a.at(i);
    double d = accumulate(a.begin(), a.end(), 0) / double(a.size());
    pair<double, int> ans = {INF, -1};
    for (int i = 0; i < n; ++i) if (abs(d - a.at(i)) < ans.first) ans = {abs(d - a.at(i)), i};
    cout << ans.second << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;


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

    int n,m;
    cin >> n >> m;
    int ans = m;
    if(n <= 12)
        ans = m/2; 
    if(n <= 5)
        ans = 0;

    cout << ans <<'\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace  std;
using ll=long long;
int main(){
int a,b;
string s;
cin>>a>>b>>s;
bool flag=true;
  if(s.size()!=a+b+1)flag=false;
  for(int i=0;flag&&i<a;i++)if(s.at(i)=='-')flag=false;
  if(s.at(a)!='-')flag=false;
    for(int i=a+1;flag&&i<=a+b;i++)if(s.at(i)=='-')flag=false;
if(flag)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


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

int main(void){
	string str;
	cin>>str;
	int n;
	n = str.length();
	ll ans = 0, cur = 0;
	for(int i=0; i<n; i++){
		char it = str[i];
		if(it=='B'){
			cur++;
		}else{
			ans += cur;
		}
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 640
#include<stdio.h>

int find(int,int);

int A[2000], n=0,j=0;

int main(){

  int  q=0, m[2000],i,jud=0;

  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);

  scanf("%d",&q);

  for(i=0;i<q;i++)
    scanf("%d",&m[i]);

 


  for(i=0;i<q;i++){
    
    jud= find(j,m[i]);

    if(jud == 1){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
  
  
  return 0;
}

int find(int j, int m){

  if(m==0)
  return 1;
  
  if(j >= n)
    return 0;
  
  if(find(j+1,m)== 1 || find(j+1,m-A[j])==1){
    return 1;
  }

  j = j + 1;

}

Measured memory_bytes: 588
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

bool IsPrime[60000];

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

    int n;
    cin >> n;
    for(int i = 2; i <= 55555; ++i) IsPrime[i] = true;
    for(int i = 2; i <= 55555; ++i){
        if(!IsPrime[i]) continue;
        for(int j = i + i; j <= 55555; j += i){
            IsPrime[j] = false;
        }
    }
    for(int i = 11; i <= 55555; i += 5){
        if(IsPrime[i]){
            cout << i;
            if(--n > 0)   cout << ' ';
            else{
                cout << '\n';
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3680
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long;
static const double PI = 3.14159265359;

struct Point {
	ll x, y;
	Point() : x(0), y(0) { }
	Point(ll x, ll y) : x(x), y(y) { }
};

ll dot(const Point& a, const Point& b){ return a.x * b.x + a.y * b.y; }
ll cross(const Point& a, const Point& b){ return a.x * b.y - a.y * b.x; }
ll norm(const Point& a){ return a.x * a.x + a.y * a.y; }

int ccw(const Point& a, const Point& b, const Point& c){
	const Point d(b.x - a.x, b.y - a.y);
	const Point e(c.x - a.x, c.y - a.y);
	if(cross(d, e) > 0){ return  1; }
	if(cross(d, e) < 0){ return -1; }
	if(dot(d, e) < 0){ return 2; }
	if(norm(d) < norm(e)){ return -2; }
	return 0;
}

vector<Point> convex_hull(vector<Point> ps){
	const int n = ps.size();
	sort(
		ps.begin(), ps.end(),
		[](const Point& a, const Point& b){
			if(a.x != b.x){ return a.x < b.x; }
			return a.y < b.y;
		});
	vector<Point> ch(2 * n);
	int k = 0;
	for(int i = 0; i < n; ch[k++] = ps[i++]){
		while(k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0){ --k; }
	}
	for(int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--]){
		while(k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0){ --k; }
	}
	ch.resize(k - 1);
	return ch;
}

int main(){
	ios_base::sync_with_stdio(false);
	cout << setiosflags(ios::fixed) << setprecision(10);
	int n;
	cin >> n;
	vector<Point> pts(n);
	for(int i = 0; i < n; ++i){ cin >> pts[i].x >> pts[i].y; }
	const auto ch = convex_hull(pts);
	const int m = ch.size();
	vector<double> angles(m);
	for(int i = 0; i < m; ++i){
		const auto a = ch[(i - 1 + m) % m];
		const auto b = ch[i];
		const auto c = ch[(i + 1) % m];
		const Point d(a.x - b.x, a.y - b.y);
		const Point e(c.x - b.x, c.y - b.y);
		const auto cs = dot(d, e) / (sqrt(norm(d)) * sqrt(norm(e)));
		angles[i] = PI - acos(min(max(-1.0, cs), 1.0));
	}
	double sum = 0.0;
	vector<double> answer(n);
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			if(pts[i].x == ch[j].x && pts[i].y == ch[j].y){
				answer[i] = angles[j] / (2.0 * PI);
				sum += answer[i];
				break;
			}
		}
	}
	for(const auto x : answer){
		cout << x / sum << endl;
	}
	return 0;
}


Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n, q = list(map(int, input().rstrip('\n').split()))
    s = str(input().rstrip('\n'))
    ls = [0] * n
    cnt = 0
    for i in range(1, n):
        if s[i] == "C" and s[i-1] == "A":
            cnt += 1
        ls[i] = cnt
    for i in range(q):
        l, r = list(map(int, input().rstrip('\n').split()))
        print(ls[r-1] - ls[l-1])


if __name__ == '__main__':
    slove()


Measured memory_bytes: 53848
#include<stdio.h>

int main(void)
{
	int n,m,temp;
	int i,j,count[100];
	while(1){
		for(i=0;i<100;i++){
			count[i]=-1;
		}
		scanf("%d %d", &n, &m);
		if(n==0)break;
		
		for(i=0;i<m;i++){
			count[i]=0;
		}
		
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				scanf("%d",&temp);
				if(temp==1)count[j]++;
			}
		}
		temp=0;
		for(i=n;i>=0;i--){
			for(j=0;j<m;j++){
				if(count[j]==i){
					printf("%d",j+1);
					temp++;
					if(temp!=m){
						printf(" ");
					}
				}
				
			}
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 772