akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>ll(b);i--)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
#define INF 1000000000000 
#define MOD 1000000007 
#define MAXR 100000 
#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 
#define Umap unordered_map
#define Uset unordered_set


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

    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> c(H, vector<char>(W));
    REP(i, H) {
        REP(j, W) {
            cin >> c.at(i).at(j);
        }
    }

    int ans=0;
    REP(maskR, (1 << H)) {
        REP(maskC, (1 << W)) {
            int black = 0;
            REP(i, H) {
                REP(j, W) {
                    if ((((maskR)>>i & 1) && (maskC >> j & 1) == 0) && (c[i][j] == '#')) black += 1;
                }
            }
            if (black == K) ans += 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
struct node{
	int x,y;
}a[110],b[110];
int h[110][110],n,p[110],ans,d[110];
bool dfs(int x){
	for(int i=1;i<=n;++i)
		if(!p[i]&&(h[x][i])){
			p[i]=1;
			if((!d[i])||dfs(d[i])){
				d[i]=x;
				return true;
			}
		}
	return false;
}
int main(){
	int i,j,k,m;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d%d",&a[i].x,&a[i].y);
	for(i=1;i<=n;++i)scanf("%d%d",&b[i].x,&b[i].y);
	for(i=1;i<=n;++i)
		for(j=1;j<=n;++j)
			if(a[i].x<b[j].x&&a[i].y<b[j].y)h[i][j]=1;
	for(i=1;i<=n;++i){
		memset(p,0,sizeof(p));
		if(dfs(i))ans++;
	}
	printf("%d",ans);
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int p[100];
    for (int i=0; i<n; i++) {
        cin>>p[i];
    }
    
    for (int i=n; i>0; i--) {
        int cnt=0;
        for (int j=0; j<n; j++) {
            if(p[j]>=i)cnt++;
        }
        if(cnt>=i){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long n;
	cin >> n;
	if(n & 1) {
		cout << 0 << '\n';
		return 0;
	}
	long long x = 0;
	long long t = n;
	while(t) {
		x += t / 10;
		t /= 5;
	}
	cout << x << '\n';
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    s = input()
    ans = ''

    for si in s:
        if si == '0':
            ans += si
        elif si == '1':
            ans += si
        elif si == 'B' and len(ans) == 0:
            pass
        elif si == 'B' and len(ans) > 0:
            ans = ans[:len(ans) - 1]

    print(ans)


if __name__ == '__main__':
    main()


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

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

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var s = cin.ReadLine;
            
            var count0 = 0;
            var count1 = 0;
            var i = 0;

            foreach (var temps in s) {
                if (i%2 == 0) {
                    if (temps == '0') {
                        count0++;
                    } else {
                        count1++;
                    }
                } else {
                    if (temps == '0') {
                        count1++;
                    } else {
                        count0++;
                    }
                }
                i++;
            }
            var ans = count0 < count1 ? count0 : count1;
            WriteLine(ans);
        }

        private double MultipleCeil(double value, double multiple) {return Math.Ceiling(value / multiple) * multiple;}

    }

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

Measured memory_bytes: 13244
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

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

   ll p = 1;

   rep(i,n){
      p *= (i+1);
      p %= (1000000000 + 7);
   }
//   ll ans = p%(1000000000 + 7);
   cout <<  setprecision(10) << p << endl;



   return 0;
}

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

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;

using vqi=vector<queue<int>>;

using vqi=vector<queue<int>>;
using bs=bitset<60>;
using vbi=vector<bs>;
constexpr ll MOD = 1e9 + 7;


int main() {
    int A, B;
    cin >> A >> B;


    cout << 6 - A - B << endl;
    return 0;
}


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

namespace A_Airplane
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = ReadLine();
            string[]array= input.Split(' ');
            int[] n = new int[array.Length];
            for (int i = 0; i < array.Length; i++) {
                n[i]= int.Parse(array[i]);
                       
            }
            int answer = 0;
            int a = n[0] + n[1];
            int b = n[1] + n[2];
            int c = n[2] + n[0];
            if (a < b) {
                answer = a;
            }
            else {
                answer = b;
            }
            if (answer < c) {
            }
            else {
                answer = c;
            }
            WriteLine(answer);
            ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define NUM ((long long)1000000007)
#define int long long

using namespace std;

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

    int a, b;
    cin >> a >> b;
    if (a <= b)
    {
        cout << a << endl;
    }
    else
    {
        cout << a - 1 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define ll long long

ll int func(ll S,ll i,ll sum){
	if(S/i==0){
		return sum+S;
	}
	
	return func(S/i,10,sum+S%i)+func(S,i*10,sum);
}

int main(){
	
	ll int S;
	scanf("%lld",&S);
	
	printf("\n%lld\n",func(S,10,0));
	
	return 0;
}

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

namespace ConsoleApp15
{
    class Class91
    {
        static void Main()
        {
            var X = int.Parse(Console.ReadLine());
            while (true)
            {
                bool frag = true;
                for(int i = 2; i < Math.Sqrt(X); i++)
                {
                    if (X % i == 0) { frag = false;break; }
                }
                if(frag) { Console.WriteLine(X);return; }
                X++;
            }
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0;i < n;i++){
        int l,r;
        cin >> l >> r;
        ans += (r - l + 1);
    }

    cout << ans << endl;
}


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    ll ub = 0, lb = 0; // ub OK, lb NG
    rep(i, n) {
        cin >> a[i];
        if(ub < a[i]) ub = a[i];
    }
    while(ub-lb > 1) {
        ll mid = (ub+lb+1)/2, sum = 0;
        rep(i, n) {
            sum += (a[i]+mid-1)/mid - 1;
        }
        if(sum > k) lb = mid;
        else ub = mid;
    }
    cout << ub << endl;
    
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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

int main() {
	string S;
	cin >> S;
	bool ans = true;
	int cnt = 0;
	int c_index;
	for(int i = 2; i < S.size() - 1; i++){
		if(S.at(i) == 'C'){
			cnt++;
			c_index = i;
		}
	}
	if(S.at(0) != 'A'){
		ans = false;
	}
	else if(cnt != 1){
		ans = false;
	}
	else{
		for(int i = 1; i < S.size(); i++){
			if(i == c_index){
				continue;
			}
			else {
				if('A' <= S.at(i) && S.at(i) <=  'Z'){
					ans = false;
				}
			}
		}
	}
	if(ans){
		cout << "AC" << endl;
	}
	else{
		cout << "WA" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
long gcd(long a, long b){
  if(b==0)
    return a;
  return gcd(b,a%b);
}
int main(){
  int t;
  long a,b,c,d,g;
  scanf("%d",&t);
  for(int i=0;i<t;i++){
    scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
    if(a<b||d<b)
      printf("No\n");
    else if(c>=b)
      printf("Yes\n");
    else{
      g=gcd(b,d);
      if(b-g+(a%g)>c)
        printf("No\n");
      else
        printf("Yes\n");
    }
  }
}

Measured memory_bytes: 128
#include <string.h>
#include <cmath>
#include <stdio.h>

int main(){
	int a;
	char c[10];
	int ans[4];
	ans[0] = 0;
	ans[1] = 0;
	ans[2] = 0;
	ans[3] = 0;
	while(scanf("%d,%s",&a,&c) != EOF){
		if(strcmp(c,"A") == 0){
			ans[0]++;
		}
		if(strcmp(c,"B") == 0){
			ans[1]++;
		}
		if(strcmp(c,"O") == 0){
			ans[2]++;
		}
		if(strcmp(c,"AB") == 0){
			ans[3]++;
		}
	}
	printf("%d\n%d\n%d\n%d\n",ans[0],ans[1],ans[3],ans[2]);
	return 0;
}

Measured memory_bytes: 1024
def main():
    N, A, B, C, D = map(int, input().split())
    S = list(input())
    E = max(C, D)
    cnt = 0
    for i in range(A-1, E):
        if S[i] == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt >= 2:
            print('No')
            return
    if C < D:
        print('Yes')
        return
    cnt = 0
    for i in range(B-2, D+1):
        if S[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt >= 3:
            print('Yes')
            return
    print('No')
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 10684
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		if(s.length() +1 != t.length()) {
			System.out.println("No");
			return;
		}

		if(!s.equals(t.substring(0,t.length()-1))) {
			System.out.println("No");
			return;
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 26960
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define BE(c) c.begin(),c.end()
#define PB push_back
#define F first
#define S second
#define BEB(s) s
using namespace std;
int main(){
	int n,d[5001];
	while(1){
		cin>>n;
		if(n==0)break;
		d[0]=0;
		FOR(i,1,n+1){
			int a;
			cin>>a;
			d[i]=d[i-1]+a;
		}
		int ans=INT_MIN;
		FOR(i,1,n+1)REP(j,i)ans=max(ans,d[i]-d[j]);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}

void solve() {
	ll n;
	cin >> n;
	vl a(n);
	ll xorr = 0;
	rep(i, 0, n) {
		cin >> a[i];
		xorr ^= a[i];
	}
	ll xt = 0;
	rep(i, 0, n) {
		ll xory = xorr;
		xory ^= a[i];
		cout << xory << " ";
	}
}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 4780
n = gets.to_i

solve = ->(str, max_char) {
  if str.length == n
    puts str
  else
    ("a"..max_char).each do |c|
      next_max = (c == max_char) ? max_char.succ : max_char
      solve.(str + c, next_max)
    end
  end
}

solve.("", "a")

Measured memory_bytes: 3068
x1, y1, x2, y2 = map(int, input().split())
x4 = x1 + y1 - y2
y4 = y1 + x2 - x1
x3 = x4 - y1 + y4
y3 = y4 + x1 - x4
print(x3, y3, x4, y4)

Measured memory_bytes: 9112
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    long long A,B;
    cin >> A >> B;
    if(A%2==B%2){
        cout << (A+B)/2;
    }
    else{
        cout << "IMPOSSIBLE";
    }
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,C;
  cin>>N>>M>>C;
  vector<int> B(M);
  for(int i=0;i<M;i++){
  cin>>B.at(i);
  }
  vector<vector<int>> A(N,vector<int>(M));
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>A.at(i).at(j);
    }
  }
  int count_ans=0;
  for(int i=0;i<N;i++){
    int count_judge=C;
    for(int j=0;j<M;j++){
      count_judge+=A.at(i).at(j)*B.at(j);
    }
      if(count_judge>0){
      count_ans++;
      }
  }
  cout<<count_ans<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N; cin >> N;
  vector<vector<int>> G(N);
  vector<int> A;
  vector<int> B;
  vector<int> counter(N,0);
  int a,b;
  rep(i,N-1){
    cin >> a >> b;
    a--; b--;
    A.pb(a); B.pb(b);
    G[a].pb(b);
    G[b].pb(a);
    counter[a]++;
    counter[b]++;
  }
  int K=0;
  rep(i,N){
    K = max(K, counter[i]);
  }
  cout << K << endl;
  vector<bool> chk(N,false);
  vector<int> badnum(N,-1);
  map<pair<int,int>, int> mp;
  queue<int> q;
  q.push(0);
  chk[0]=true;
  int col=1;
  while(!q.empty()){
    int now = q.front(); q.pop();
    chk[now]=true;
    col=1;
    rep(i,(int)G[now].size()){
      if(chk[G[now][i]]) continue;
      q.push(G[now][i]);
      if(badnum[now] == col) col++;
      mp[{min(now,G[now][i]),max(now,G[now][i])}] = col;
      badnum[G[now][i]] = col;
      col++;
    }
  }
  rep(i,N-1){
    cout << mp[{A[i],B[i]}] << endl;
  }
  return 0;
}


Measured memory_bytes: 14288
n = int(input())
data = []
for i in range(n):
    s, t = input().split()
    data.append([s, int(t)])
x = input()
ans = 0
flag = False
for i in range(n):
    if flag:
        ans += data[i][1]
    if x == data[i][0]:
        flag = True
print(ans)

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.setf(ios::fixed);
	cout.precision(4);
	
	int p, q, r;

	cin >> p >> q >> r;

	int ans1 = p + q;
	int ans2 = q + r;
	int ans3 = p + r;

	cout << min(ans1, min(ans2, ans3)) << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}
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; }
 
struct Node{
    int ch;
    int remains[3];
};

int main()
{
    int n;
    string s_;
    cin >> n >> s_;

    vector<Node> s(n);
    int r[3]={};
    rep(i, n){
        if(s_[i]=='R'){
            s[i].ch = 0;
            r[0]++;
        }else if(s_[i]=='G'){
            s[i].ch = 1;
            r[1]++;
        }else if(s_[i]=='B'){
            s[i].ch = 2;
            r[2]++;
        }
    }

    rep(i, n){
        r[s[i].ch]--;
        rep(j, 3) s[i].remains[j] = r[j];
    }

    ll ans=0;

    rep(i, n-2){
        FOR(j, i+1, n-1){
            if(s[i].ch==s[j].ch) continue;
            if(2*j-i<n && s[2*j-i].ch==3-s[i].ch-s[j].ch) ans--;
            ans += (ll)s[j].remains[3-s[i].ch-s[j].ch];
        }
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3740
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

int main() {
	int n, k;
	llint ans = INF;
	cin >> n >> k;
	hei(llint) a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	rep(i, 0, n - k + 1) {
		if (a[i] >= 0)ans = min(ans, a[i + k-1]);
		else {
			if (a[i + k - 1] <= 0)ans = min(ans, -1 * a[i]);
			else {
				int x = min(a[k - 1 + i], -1 * a[i]);
				int y = max(a[k - 1 + i], -1 * a[i]);
				if (ans > (x * 2) + y)ans = (x * 2) + y;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
  string box[11] ={
	"light fly","fly","bantam",
	"feather","light","light welter",
	"welter","light middle","middle",
	"light heavy","heavy",
  };
  double w_in,w[] = {48,3,3,3,3,4,5,6,6,10};
  
  while(cin >> w_in){
	int ans = 0;
	while( w_in > 0 && ans != 11 ){
	  w_in -= w[ans];
	  ans++;
	}
	cout << box[ans-1] << endl;
  }
  return 0;
}

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

int func(string n){
    if(n[0]==n[1]&&n[1]==n[2]&&n[2]==n[3])return -1;
    
    string L,S;
    
    for (int cnt=0; ; cnt++) {
        if(n=="6174")return cnt;
        L=S=n;
        sort(L.begin(), L.end(), greater<char>());
        sort(S.begin(), S.end());
        int x=atoi(L.c_str())-atoi(S.c_str());
        for (int i=0,p=1000; i<4; i++,p/=10) {
            n[i]='0'+x/p;
            x%=p;
        }
    }
}

int main() {
    while (1) {
        string N;
        cin>>N;
        if(N=="0000")break;
        int ans=func(N);
        if(ans==-1){
            cout<<"NA"<<endl;
        }else{
            cout<<ans<<endl;
        }
    }
}

Measured memory_bytes: 3168
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
n,m = map(int,input().split())

uf = UnionFind(n)
for _ in range(m):
  a,b = map(int,input().split())
  uf.union(a-1,b-1)
  
ans = uf.group_count() - 1
print(ans)

Measured memory_bytes: 12772
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;

llint n, m;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	cout<< n*(n-1)/2 + m*(m-1)/2 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B,C,D;
    cin >>A>>B>>C>>D;
    
    cout << min(A,B)+min(C,D) << endl;


    return 0;
    

}

Measured memory_bytes: 3608
s = input()
t = input()
x = len(t)
ans = x
for i in range(len(s)-len(t)+1):
    y = s[i:i+x]
    cnt = 0
    for j in range(x):
        if t[j] == y[j]: cnt += 1
    ans = min(ans, x-cnt)
print(ans)

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

int main() {
   string s;
   while (cin >> s){
       for (int i=0; i<s.size(); i++){
           if (s[i] == '@'){
               for (int j=s[i+1]; j>'0'; j--){
                   cout << s[i+2];
               }
               i+=2;
           }
           else {
               cout << s[i];

           }
            
       }
       cout << endl;

   }return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int n, ans;
int c(int x)
{
	int cnt = 0;
	while (x)
	{
		cnt++;
		x /= 10;
	}
	return cnt;
}



int main() 
{
		int A, B, C, D, E, F;
		cin >> A >> B >> C >> D >> E >> F;
		int total = 100 * A; int sugar = 0;
		for (int a = 0; a <= 30; a++) {
			for (int b = 0; b <= 15; b++) {
				int water = a * A + b * B;
				if (100 * water > F) break;
				for (int c = 0; c <= 3000; c++) {
					for (int d = 0; d <= 1500; d++) {
						int sato = c * C + d * D;
						if (100 * water + sato > F) break;
						if (sato <= water * E && sugar * (sato + 100 * water) < total * sato) {
							sugar = sato; total = sato + 100 * water;
						}
					}
				}
			}
		}
		cout << total << " " << sugar << endl;
}

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

int main() {
    int N, M, O;
    cin >> N >> M >> O;
    if(N == M && M == O && N == O){
      cout << 1 << endl;
    }
    else if(N != M && M != O && N != O ){
        cout << 3 << endl;
    }
    else cout << 2 << endl;
}

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

int main() {
  //
  ll n;
  cin >> n;
  vl a(3 * n);
  rep(i, 3 * n) cin >> a[i];
  sort(ALL(a));
  reverse(ALL(a));
  ll ans = 0;
  rep(i, n) { ans += a[2 * i + 1]; }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n,m;
  cin>>n;
  cin>>m;
  if(n<m)
  {
    string s="";
    for(int i=0;i<(m);i++)
    	s+=n+'0';
  	cout<<s<<endl;
    //cout<<9<<endl;
  }
  else
  {
  string s="";
  for(int i=0;i<n;i++)
    s+=m+'0';
  cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
#define int ll
const int N = 2500+5;
const int INF = 1e18;
const int MOD = 1e9+7;

struct Edge{
	int u, v, w;
	Edge(int a, int b, int c){
		u = a; v = b; w = c;
	}
};

int n, m, p;
vector<Edge> edges;
vector<int> d(N, -INF);
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m >> p;
	for(int i=0; i<m; i++){
		int u, v, w; cin >> u >> v >> w;
		edges.push_back(Edge(u, v, w-p));
	}
	d[1] = 0;
	for(int i=1; i<n; i++) {
		for(auto e:edges){
			if (d[e.u] != -INF) d[e.v] = max(d[e.v], d[e.u] + e.w);
		}
	}
	for(int i=1; i<n; i++){
		for(auto e:edges){
			if (d[e.u] != -INF && d[e.v] < d[e.u] + e.w) {
				d[e.v] = INF;
			}
		}
	}
	if (d[n] == INF) return 0*puts("-1");
	int ans = max(0LL, d[n]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 576
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i*i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) { ret[n]++; }
  return ret;
}

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

  map<int, int> mp;

  for (int i = 2; i <= n; i++) {
    map<ll, int> mp_t = prime_factor(i);
    for (auto it = mp_t.begin(); it != mp_t.end(); it++) {
      mp[it->first] += (it->second);
    }
  }

  ll ans = 1;
  ll mod = (1e9)+7;

  for (auto it = mp.begin(); it != mp.end(); it++) {
    ans *= ((it->second)+1);
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}

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

int main()
{
    vector<int> lst;
    int N, x;
    cin >> N;
    for(int i=0; i<N; i++)
    {
        cin >> x;
        lst.push_back(x);
    }
    int n1 = lst.size();

    int count;
    sort(lst.begin(), lst.end());

    count = std::distance(lst.begin(), std::unique(lst.begin(), lst.end()));

    if(n1==count)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 1400
//c.c C-Grand Garden
#include<stdio.h>

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

    int ans=0,x=0;
    for(int i=0;i<n;++i){
        if(h[i]>x){
            ans += h[i] - x;
        }
        x = h[i];
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
s = input()
t = input()

n = len(s)
n = len(s)
a = [-1]*26
b = [-1]*26
flg = True

for i in range(n):
    snum = ord(s[i]) - 97
    tnum = ord(t[i]) - 97
    if a[snum] >= 0 and a[snum] != tnum:
        flg = False
        break
    if b[tnum] >= 0 and b[tnum] != snum:
        flg = False
        break
    if a[snum] == -1:
        a[snum] = tnum
    if b[tnum] == -1:
        b[tnum] = snum
    
print('Yes') if flg else print('No')

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

int main() {
  
  int N,A;
  cin >> N >> A;
  
  if ( 0 <= N%500 && N%500 <= A ) {
    cout << "Yes" << endl;
  }
   
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<long long, long long>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

int cnt;
int target;
void calc(int c) {
	cnt -= (target / c);
	target %= c;
}

int main() {
	string S;
	cin >> S;
	int ans = 0;
	int length = S.size();
	for (int i = 0; i < length / 2;++i) {
		if (S[i] != S[length - 1 - i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(){
	int n,b;
	scanf("%d%d",&n,&b);
	if(n>=13){
		printf("%d\n",b);
	}else if(6<=n && n<=12){
		printf("%d\n",b/2);
	}else{
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main(){

 int A,B;
 cin >> A >> B;
 string x;
 int m = 0;

 for(int i = A;i <= B;i++){
   x = to_string(i);

   if((x[0] == x[4]) && (x[1] == x[3]))
    m++;
 }

cout << m;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
using namespace std;
static const int MAX = 100;

int n;
int A[MAX];

void selectionSort(){
    int min, num;
    num = 0;
    for (int i = 0; i < n; i++){
        min = i;
        for (int j = i + 1; j < n; j++){
            if (A[min] > A[j]) min = j;
        }
        swap(A[i], A[min]);
        if (i != min) num++;
    }

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

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

    selectionSort();
    return 0;
}


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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for(int i= a; i < b+1; i++){
    if(i % k == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
 cout << "NG" << endl;
}


Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))

if N == 0 and A[0] == 1:
    print(1)
    exit()

if A[0] != 0:
    print(-1)
    exit()
    
sum_leaf = sum(A)
ans = 1
before_top = 1
for i in range(1, len(A)):
    if A[i] <= before_top*2:
        ans += min(sum_leaf, before_top*2)
        before_top = min(sum_leaf, before_top*2) - A[i]
        sum_leaf -= A[i]
    else:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 20116
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>
#include <cfloat>
#include <array>

int main() {
	int n, m; std::cin >> n >> m;
	std::vector<int> votes(n); for (auto& v : votes) std::cin >> v;
	const auto sum = std::accumulate(votes.begin(), votes.end(), 0);
	const auto count = std::count_if(votes.begin(), votes.end(), [m, sum](const int a) {return a * 4 * m >= sum; });
	if (count >= m) {
		std::cout << "Yes\n";
	}
	else {
		std::cout << "No\n";
	}
}


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

#define MAX 1<<30

int cmp_count = 0;

void merge(int* A, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1],R[n2+1];
	for(int i = 0; i < n1; i++) L[i] = A[left + i];
	for(int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] =  MAX;

	int i = 0, j = 0;
	for(int k = left;k < right; k++){
		if(L[i] <= R[j]){
			A[k] = L[i++];
			cmp_count++;
		}else{
			A[k] = R[j++];
			cmp_count++;
		}
	}
}

void mergeSort(int* A, int left, int right){
	if(left+1 < right){
		int mid = (left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main(){
	int n;
	cin >> n;
	int S[n];
	for(int i = 0; i < n; i++) cin >> S[i];

	mergeSort(S,0,n);

	for(int i = 0; i < n; ++i){
		if(i != n - 1)
			cout << S[i] << ' ';
		else
			cout << S[i] << endl;
	}
	cout << cmp_count << endl;
	
	return 0;

}




Measured memory_bytes: 7024
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define oo 100000000000000000
using namespace std;



void _sol(){
    int n,s,t; cin >> n >> s >> t;
    cout << ((n/s)+(n%s!=0))*t;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    _sol();
}


Measured memory_bytes: 3620
n, m = [int(i) for i in input().split()]
ks = [[int(i) for i in input().split()] for _ in range(m)]
p = [int(i) for i in input().split()]
cnt = 0
for i in range(2**n):
  on = set(j + 1 for j in range(n) if i >> j & 1 == 1)
  flag = True
  for j in range(m):
    _, *s = ks[j]
    flag &= len(on & set(s)) % 2 == p[j]
  cnt += flag
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	LL N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;

	if (A > B) {
		swap(A, B);
	}

	B -= A;
	A -= A;
	N -= 1;

	LL up = D*N;
	LL down = C*N;

	bool flag = false;

	REP(i, N) {
		if (down <= B&&B <= up) {
			flag = true;
		}
		down -= D;
		down -= C;
		up -= C;
		up -= D;
	}

	if (flag) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
from sys import stdin
import math


N = int(stdin.readline().rstrip())

A=0
B=N-A


def sum_of_digit(n):
    total = 0
    s = str(n)
    for i in range(len(s)):
        total = total + int(s[i:i+1])

    return total


minimum = 9999999999

for a in range(1,N):
    a_total = sum_of_digit(a)
    b = N - a
    b_total = sum_of_digit(b)
    minimum = min(minimum, a_total + b_total)

print(minimum)


Measured memory_bytes: 3060
import sys
import numpy as np
from scipy.misc import comb
sys.setrecursionlimit(1000000)
 
n = int(input())

a = list(map(int, input().split()))

a.insert(0,0)

list_n = n + 1

box = [0] * (n+1)

one = []

for i in range(list_n-1):
    cnt = n - i
    tmp = 0
    for j in range(list_n):
        #print(cnt)
        if cnt * (j+1) <= n:
            tmp = ( tmp + box[cnt*(j+1)] ) % 2
        elif tmp == a[cnt]:
            box[cnt] = 0
            break
        else:
            box[cnt] = 1
            one.append(cnt)
            break
        
if len(one) == 0:
    print(0)
else:
    print(len(one))
    print(*one)

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

int main()
{
    vector<int> x(2);
    cin >> x[0] >> x[1];
    sort(x.begin(), x.end());
    if (x[0] == 1 && x[1] == 2)
        cout << 3 << endl;
    else if (x[0] == 1 && x[1] == 3)
        cout << 2 << endl;
    else if (x[0] == 2 && x[1] == 3)
        cout << 1 << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


typedef pair<int, int> p;

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

  int x, y;
  vector<p> v(n);
  vector<int> xs(n);
  vector<int> ys(n);
  REP (i, n) {
    cin >> x >> y;
    v[i] = make_pair(x, y);
    xs[i] = x;
    ys[i] = y;
  }

  LL ans = LLONG_MAX;
  REP (i, n) {
    REP (j, n) {
      REP (k, n) {
        REP (l, n) {
          LL x1 = min(xs[i], xs[j]);
          LL x2 = max(xs[i], xs[j]);
          LL y1 = min(ys[k], ys[l]);
          LL y2 = max(ys[k], ys[l]);
          int cnt = 0;
          REP (m, n) {
            if (x1 <= v[m].first && v[m].first <= x2 && y1 <= v[m].second && v[m].second <= y2) {
              cnt++;
            }
          }
          if (cnt >= num) {
            ans = min(ans, (x2 - x1) * (y2 - y1));
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, ans=1;
	cin >> n;
	rep(i,n){
		ans *= (i+1);
		ans%=mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,i,m,t;
    double x[100],y[100],r,c;
    while(scanf("%d",&n)*n){
        for(i=0;i<n;i++)scanf("%lf,%lf",&x[i],&y[i]);
        for(t=0,r=0.;r<=10.;r+=.1){
            for(c=0.f;c<=10.;c+=.1){
                for(m=0,i=0;i<n;i++){
                    if((x[i]-c)*(x[i]-c)+(y[i]-r)*(y[i]-r)<=1.01)m++;
                }
                if(m>t)t=m;
            }
        }
        printf("%d\n",t);
    }
    return 0;
}

Measured memory_bytes: 1068
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>

using namespace std;

int n, m, s;
int c[55], d[55];

struct E {
  int t, a, b;
  E(){}
  E(int t, int a, int b):t(t),a(a),b(b){}
};
vector<E> g[55];

struct S {
  int u, s;
  long long c;
  S(){}
  S(int u, int s, long long c):u(u),s(s),c(c){}
  bool operator >(const S& e) const {
    return c > e.c;
  }
};

long long cost[55][5555];
long long res[55];

int main(void) {
  scanf("%d%d%d", &n, &m, &s);
  for (int i = 0; i < m; i++) {
    int u, v, a, b; scanf("%d%d%d%d", &u, &v, &a, &b); --u; --v;
    g[u].push_back(E(v, a, b));
    g[v].push_back(E(u, a, b));
  }
  for (int i = 0; i < n; i++) {
    scanf("%d%d", c+i, d+i);
  }

  priority_queue<S, vector<S>, greater<S>> q;
  q.push(S(0, min(5000, s), 0));
  memset(cost, -1, sizeof(cost));
  memset(res, -1, sizeof(res));
  cost[0][0] = 0;

  while (!q.empty()) {
    S p = q.top(); q.pop();
    if (cost[p.u][p.s] >= 0 && cost[p.u][p.s] < p.c) continue;
    for (auto&& e : g[p.u]) {
      long long co = p.c + e.b;
      if (p.s >= e.a) {
        int ns = p.s - e.a;
        if (cost[e.t][ns] < 0 || cost[e.t][ns] > co) {
          cost[e.t][ns] = co;
          if (res[e.t] == -1 || res[e.t] > co) res[e.t] = co;
          q.push(S(e.t, ns, co));
        }
      }
      co = p.c + d[p.u];
      int ns = min(5000, p.s + c[p.u]);
      if (cost[p.u][ns] < 0 || cost[p.u][ns] > co) {
        cost[p.u][ns] = co;
        q.push(S(p.u, ns, co));
      }
    }
  }

  for (int i = 1; i < n; i++) {
    printf("%lld\n", res[i]);
  }
  
  return 0;
}


Measured memory_bytes: 9308