akhauriyash/Code-Regression huggingface dataset:
import math
const=3500+1
N = int(input())
ans=4/N
flg=False
for h in range(1,const):
    for n in range(h,const):
        tmp=4*h*n-N*n-N*h
        if tmp != 0:
            w = N*h*n/tmp
            if w == int(w) and w>0:
                print(h,n,int(w) )
                flg=True
                break
    if flg==True:
        break



Measured memory_bytes: 40812
#include <stdio.h>

void sumipe(int* a, int* b) {
	if (*a > *b) {
		int t = *a;
		*a = *b;
		*b = t;
	}
}

int main(void) {
	int a, b, c;
	if (scanf("%d%d%d", &a, &b, &c) != 3) return 1;
	sumipe(&a, &b);
	sumipe(&b, &c);
	sumipe(&a, &b); /* 何も考えずにソートを書いたが、よくみたらこれいらないな */
	printf("%d\n", a + b);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
	int H, W;
	int i, n;

	while (1)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)
		{
			break;
		}
		for (i = 0; i < H; i++)
		{
			for (n = 0; n < W; n++)
			{
				printf("#");
			}
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 576
/*input

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll a[maxn],b[maxn];

int main()
{
	//IOS;
	ll n;
	cin>>n;
	REP(i,n) cin>>a[i];
	REP(i,n) b[i]=a[(i+1)%n]-a[i];
	ll tt=0;
	REP(i,n) tt+=a[i];
	{
		ll tmp=(n+1)*n/2;
		if(tt%tmp){
			cout<<"NO\n";
			return 0;
		}
		tt/=tmp;
	}
	REP(i,n){
		ll meow=tt-b[i];
		if(meow%n||meow<0){
			cout<<"NO\n";
			return 0;
		}
	}
	cout<<"YES\n";
	return 0;
}


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

int main()
{
    int n;
    char s[100001]={};
    cin>>n;
    int tag = 0;
    int ans = 0;
    cin>>s;
    for(int i = 0; i < n;i++)
    {
        if(s[i]==s[i+1])
        {
            continue;
        }
        ans++;
    }
    cout <<ans;
    return 0;
}




Measured memory_bytes: 384
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(int argc, char const *argv[]) {
    int z;
    while(cin >> z) {
        if (z == 0) break;
        int maxxy = 0;
        for (int x = 1; x < z; x++) {
            for (int y = 1; y < z; y++) {
                if (x*x*x+y*y*y <= z * z * z) {
                    maxxy = std::max(maxxy, x*x*x+y*y*y);
                }
            }
        }
        cout << z*z*z - maxxy << endl;
    }
    return 0;
}

Measured memory_bytes: 1164
/*
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 25;

/* typedef */

typedef vector<int> vi;

struct Node {
  int id, prt, lc, rc;
  Node(): prt(-1), lc(-1), rc(-1) {}
};

/* global variables */

Node nds[MAX_N];

/* subroutines */

void preorder(int u, vi &v) {
  v.push_back(nds[u].id);
  if (nds[u].lc >= 0) preorder(nds[u].lc, v);
  if (nds[u].rc >= 0) preorder(nds[u].rc, v);
}

void inorder(int u, vi &v) {
  if (nds[u].lc >= 0) inorder(nds[u].lc, v);
  v.push_back(nds[u].id);
  if (nds[u].rc >= 0) inorder(nds[u].rc, v);
}

void postorder(int u, vi &v) {
  if (nds[u].lc >= 0) postorder(nds[u].lc, v);
  if (nds[u].rc >= 0) postorder(nds[u].rc, v);
  v.push_back(nds[u].id);
}

void print_vec(vi &v) {
  for (int i = 0; i < v.size(); i++) printf(" %d", v[i]);
  putchar('\n');
}

/* main */

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

  for (int i = 0; i < n; i++) {
    int id, lc, rc;
    cin >> id >> lc >> rc;

    nds[id].id = id;
    if (lc >= 0) {
      nds[id].lc = lc;
      nds[lc].prt = id;
    }
    if (rc >= 0) {
      nds[id].rc = rc;
      nds[rc].prt = id;
    }
  }

  int root = -1;
  for (int i = 0; i < n; i++)
    if (nds[i].prt < 0) {
      root = i;
      break;
    }

  vi v;

  puts("Preorder");
  v.clear();
  preorder(root, v);
  print_vec(v);
  
  puts("Inorder");
  v.clear();
  inorder(root, v);
  print_vec(v);

  puts("Postorder");
  v.clear();
  postorder(root, v);
  print_vec(v);
return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var n = int.Parse(str);

            var monsters = new List<int>();

            str = Console.ReadLine();
            var strs = str.Split(' ');
            foreach (var item in strs)
            {
                monsters.Add(int.Parse(item));
            }

            monsters = monsters.Distinct().ToList();
            monsters.Sort();
            for (int i = monsters.Count - 1; i > 0; i--)
            {
                monsters[i] %= monsters[i - 1];
            }
            monsters.RemoveAll(x => x == 0);

            while (monsters.Count >= 2)
            {
                monsters = monsters.Distinct().ToList();
                monsters.Sort();
                for (int i = monsters.Count - 1; i > 0; i--)
                {
                    monsters[i] -= monsters[i - 1];
                }
                monsters.RemoveAll(x => x == 0);
            }

            Console.WriteLine(monsters[0]);
        }
    }
}

Measured memory_bytes: 29408
(function(input) {
    var a = parse(input);
    a = a.map(function(e) { return e.map(Number); });
    a.shift();
    for (var i = 0; i < a.length; i++) {
        var r = a[i];
        var s = 0;
        for (var j = 0; j < r.length; j++) {
            s += r[j];
        }
        a[i].push(s);
    }
    var rs = [];
    for (var i = 0; i < a[0].length; i++) {
        var s = 0;
        for (var j = 0; j < a.length; j++) {
            s += a[j][i];
        }
        rs.push(s);
    }
    a.push(rs);
    console.log(build(a));

})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function parse(str, sep, ter) {
    sep = sep || ' ';
    ter = ter || '\n';
    str = str.replace(/\n$/, '');
    var a = str.split(ter);
    for (var i = 0; i < a.length; i++) {
        a[i] = a[i].split(sep);
    }
    return a;
}

function build(a, sep, ter) {
    sep = sep || ' ';
    ter = ter || '\n';
    var lines = [];
    for (var i = 0; i < a.length; i++) {
        lines.push(a[i].join(sep));
    }
    return lines.join(ter);
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> vec(m, vector<int>(2));
  
  for(int i =0; i < m; i++){
    for(int j = 0; j < 2; j++){
     cin >> vec.at(i).at(j);
    }
  }
    
  for(int i = 0; i < n; i++){
    int cnt = 0;
    for(int j = 0; j < m; j++){
      if(vec.at(j).at(0) == i + 1||vec.at(j).at(1) == i + 1){
      	cnt++;
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string s;
  while(cin >>s){
    int log[10];
    for(int i=0; i<10; i++) log[i] = s[i]-'0';
    for(int i=0; i<9; i++){
      for(int j=0; j<9-i; j++) log[j] = (log[j]+log[j+1])%10;
      for(int j=9-i; j<10; j++) log[j] = 0;
    }
    cout <<log[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
void chmax (int &a, int b) {
    if (a < b) a = b;
}

int main() {
    int n; cin >> n;
    vector<vector<int>> h(n, vector<int>(3));
    for (int i=0; i<n; ++i) cin >> h[i][0] >> h[i][1] >> h[i][2];
    vector<vector<int>> dp(n, vector<int>(3));
    dp[0][0] = h[0][0];
    dp[0][1] = h[0][1];
    dp[0][2] = h[0][2];
    for (int i=0; i<n-1; ++i) {
        for (int j=0; j<3; ++j) {
            for (int k=0; k<3; ++k) {
                if (k == j) continue;
                chmax(dp[i+1][k], dp[i][j] + h[i+1][k]);
            }
        }
    }
    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
}

Measured memory_bytes: 11136
def watering( flws )
  ret = 0
  flws.each do |a|
    m = a.min
    ret += m
    a.map!{|x|x-m}
    b = []
    c = []
    a.each do |x|
      if x != 0
        c << x
      else
        if c.size > 0
          b << c
          c = []
        end
      end
    end
    if c.size > 0
      b << c
    end
    if b.size > 0
    	ret += watering( b )
    end
  end
  ret
end

n = STDIN.gets.to_i
h = STDIN.gets.split(/ +/).map(&:to_i)

puts watering( [h] )



Measured memory_bytes: 2044
import sys

n, *A = map(int, sys.stdin.read().split())

def main():
    for a in A:
        if a % 2 == 0:
            if a % 3 == 0 or a % 5 == 0:
                continue
            else:
                return 'DENIED'
    return 'APPROVED'

if __name__ == '__main__':
    ans = main()
    print(ans)

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

int main() {
  int N,K;
  int S=0;
  cin>>N>>K;
  for(int i=0;i<N;i++){
   int x,n;
    cin>>x;
    if(K<=x){
     n=x-K;
    }
    else if(K-x<x){
     n=K-x;
    }
    else{
      n=x; 
    }
    S += n;
  }
  cout<<S*2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string n;
  cin >> n;
  cout << (n[0] == n[2] ? "Yes" : "No") << endl;
}


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  vector<int> vec;
  for (int i = A; i <= B; i++) {
      if(i<=A+K-1||B-K+1<=i) vec.push_back(i);
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < vec.size(); i++) {
      if(i!=0&&vec.at(i-1)==vec.at(i)) continue;
      cout << vec.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
int f(int a, int b) {
  assert(a > 0 && b > 0);
  assert(a > b);
  assert(a >= 2 * b);
  // cerr << "f(" << a << "," << b << ")" << endl;
  // if(a % b == 0) return 3 * b * (a - b) / b;
  if(a % b == 0) return 3 * (a - b);
  // else return ((a - b) / b) * 3 * b + f(b + a % b, a % b);
  else return ((a - b) / b) * 3 * b + f(b + (a - b) % b, a % b);
}
signed main() {
  ios::sync_with_stdio(false);
  int A, B; cin >> A >> B;
  int ans = f(A, min(B, A - B));
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    const int cake_price = 4;
    const int donut_price = 7;
    bool flag = false;
    for (int i = 0;; ++i) {  // cake
        if (i * cake_price > n)
            break;

        for (int j = 0;; ++j) {  // donut
            int price = i * cake_price + j * donut_price;
            if (price == n) {
                flag = true;
                break;
            }
            if (price > n)
                break;
        }
    }
    if (flag)
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

/*
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()
*/

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

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-9;

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    bool ans = false;
    ans = ans || abs(a - c) <= d;
    ans = ans || abs(a - b) <= d && abs(b - c) <= d;
    cout << (ans ? "Yes" : "No") << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
def r(h):
    if all([0 == x for x in h]):
        return 0

    c = 0
    if 0 in h:
        hl = []
        if h.count(0):
            while h.count(0):
                v = h.index(0)
                hl.append(h[0:v])
                del h[0:v+1]
            hl.append(h)
        for hlx in hl:
            c += r(hlx)
    else:
        while 0 not in h:
            h = [x - 1 for x in h]
            c += 1
        c += r(h)

    return c


def main():
    n = int(input())
    h = list(map(int, input().split()))

    print(r(h))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
n, m = map(int, input().split())
like = [0] * (m+1)
answer = []
for i in range(n):
    answer.append(list(map(int, input().split())))
for i in range(n):
    for j in range(1,answer[i][0]+1):
        like[answer[i][j]] += 1
ans = 0
for i in range(1,m+1):
    if like[i] == n:
        ans += 1
print(ans)

Measured memory_bytes: 3064
N = int(input())
A = []
for i in range(2):
  A.append(list(map(int,input().split())))
candy_count = []
for i in range(N):
  count = 0
  count += sum(A[0][:i+1])
  count += sum(A[1][i:])
  candy_count.append(count)
print(max(candy_count))

Measured memory_bytes: 3060
h, w = map(int, input().split())
a = []
for _ in range(h):
    a.append(input())
row = []
col = []
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            break
    else:
        row.append(i)
for i in range(w):
    for j in range(h):
        if a[j][i]=='#':
            break
    else:
        col.append(i)
a = [[e for j, e in enumerate(r) if j not in col] for i, r in enumerate(a) if i not in row]    
for r in a:
    print(''.join(r))

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	if n == 1 {
		if m == 1 {
			fmt.Print(1)
			return
		} else {
			fmt.Print(m - 2)
			return
		}
	}

	if m == 1 && n != 1 {
		fmt.Print(n - 2)
		return
	}

	cal := (n - 2) * (m - 2)
	fmt.Print(cal)
}


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

int main(){
	int d,n,t[200],a[200],b[200],c[200];
	int dp[201][200] = {};
	cin >> d >> n;
	for(int i = 0;i < d;i++) cin >> t[i];
	for(int i = 0;i < n;i++) cin >> a[i] >> b[i] >> c[i];
	for(int i = 1;i <= d;i++){
		for(int j = 0;j < n;j++){
			if(a[j] <= t[i - 1] && t[i - 1] <= b[j]){
				for(int k = 0;k < n;k++){
					if(i >= 2 && a[k] <= t[i - 2] && t[i - 2] <= b[k]) dp[i][j] = max(dp[i][j],dp[i - 1][k] + abs(c[j] - c[k]));
				}
			}
		}
	}
	int ma = 0;
	for(int i = 0;i < n;i++) ma = max(ma,dp[d][i]);
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
void bubblesort (vector<int> &A, vector<char> &B, int N){
    int flag = 1;
    while (flag){
        flag = 0;
        for (int j=N-1; j>0; j--){
            if (A.at(j) < A.at(j-1)){
                //count += 1;
                int t = A.at(j);
                A.at(j) = A.at(j-1);
                A.at(j-1) = t;
                char c = B.at(j);
                B.at(j) = B.at(j-1);
                B.at(j-1) = c;
                flag = 1;
            }
        }
    }
    return;
}

void selectionsort(vector<int> &A, vector<char> &B, int N){
    for (int i=0; i<N; i++){
        int minj = i;
        for (int j=i; j<N; j++){
            if (A.at(j) < A.at(minj)){
                minj = j;
            }
        }
        //if (A.at(i) != A.at(minj)) count += 1;
        int t = A.at(i);
        A.at(i) = A.at(minj);
        A.at(minj) = t;
        char c = B.at(i);
        B.at(i) = B.at(minj);
        B.at(minj) = c;
    }
}

int main(){
    int N;
    cin >> N;
    vector<int> Ai1(N);
    vector<char> Bi1(N);
    for (int i=0; i<N; i++){
        cin >> Bi1.at(i) >> Ai1.at(i);
    }
    vector<int> Ai2 = Ai1;
    vector<char> Bi2 = Bi1;
    bubblesort(Ai1, Bi1, N);
    for (int i=0; i<N; i++){
        if (i != N-1)cout << Bi1.at(i) << Ai1.at(i) << " ";
        else cout << Bi1.at(i) << Ai1.at(i) << endl;
    }
    cout << "Stable" << endl;
    selectionsort(Ai2, Bi2, N);
    for (int i=0; i<N; i++){
        if (i != N-1)cout << Bi2.at(i) << Ai2.at(i) << " ";
        else cout << Bi2.at(i) << Ai2.at(i) << endl;
    }
    if (Bi1 == Bi2)cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    return 0;
}



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

class Program
{
    static void Main()
    {
        Solve();
        return;

    }

    public static string Solve()
    {
        int N = ReadInt();
        int[] b = ReadInts();
        List<int> bList = new List<int>(N);
        bList.AddRange(b);
        List<int> ans = new List<int>(N);
        for(int i=0;i<N;i++)
        {
            for(int j=N-1-i;j>=0;j--)
            {
                if(bList[j]==j+1)
                {
                    ans.Add(j+1);
                    bList.RemoveAt(j);
                    break;
                }
                if(j==0)
                {
                    Console.WriteLine(-1);
                    return "-1";
                }
            }
        }
        for(int i=N-1;i>=0;i--)
        {
            Console.WriteLine(ans[i]);
        }
        return "";
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  unsigned long long int n, y; cin >> n >> y;
  y /= 1000;
  for(unsigned long long int i = 0; i <= n; i++){
    for(unsigned long long int j = 0; j <= n - i; j++){
      if(10 * i + 5 * j + (n - i - j) == y){
        cout << i << " " << j << " " << (n - i - j) << endl;
        return;
      }
      if(10 * i + 5 * j + (n - i - j) > y) break;
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return;
}

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    char c;
    cin >> c;
    if(c == 'A') cout << 'T' << endl;
    if(c == 'T') cout << 'A' << endl;
    if(c == 'C') cout << 'G' << endl;
    if(c == 'G') cout << 'C' << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int debt = 100000;
	int n;
	std::cin >> n;
	for (int i = 0; i < n; ++i) {
		debt = int((debt * 1.05 + 999) / 1000) * 1000;
	}
	std::cout << debt << std::endl;
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
typedef long long ll;
ll dp[100000];
int v[100000];
int main()
{
    int n, k;
    while (scanf("%d%d", &n, &k), n|k) {
        for (int i=0; i<n; ++i) scanf("%d", v+i);
        dp[k-1] = 0;
        for (int i=0; i<k; ++i) dp[k-1] += v[i];
        for (int i=k; i<n; ++i) dp[i] = dp[i-1] - v[i-k] + v[i];
        printf("%lld\n", *std::max_element(dp+k-1, dp+n));
    }
    return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> d(k);
  vector<int> a(n);
  
  for(int i=0;i<k;i++){
    cin >> d.at(i);
    for(int j=0;j<d.at(i);j++){
      int x;
      cin >> x;
      a.at(x-1)++;
    }
  }
  
  int l=0;
  
  for(int i=0;i<n;i++){
    if(a.at(i)==0)
      l++;
  }
  cout << l << endl;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;


int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    
    int ans = 0;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            for(int k=0;k<=c;k++){
                if(500*i + 100*j + 50*k == x){
                    ans++;
                }
            }

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int H, W;
  cin >> H >> W;
  char A[H][W];
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
      cin >> A[i][j];
  }
  int cnt = 0;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (A[i][j] == '#')
        cnt++;
    }
  }
  cout << (cnt == H + W - 1 ? "Possible" : "Impossible") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include <vector>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main()
{
 	boost;
 	string a,b;
 	cin>>a>>b;
 	for(int i=0;i<a.size()||i<b.size();i++)
    {
        if(i<a.size())
        cout<<a[i];
        if(i<b.size())
        cout<<b[i];
    }
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>



int main()
{
	char S[100];
	scanf("%s", &S);

	int k;



	for (k = 1; k < 50; k++) {
		if (S[2 * k-1] == 'R') {
			printf("No");
			return 0;
		}
		else if (S[2 * k - 2] == 'L') {
			printf("No");
			return 0;
		}
		
	}
	printf("Yes");
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] s = new String[n];
    Set<String> set = new HashSet<String>();
    for(int i = 0;i<n;i++){
      s[i] = sc.next();
      set.add(s[i]);
    }
    if(set.size() != n){
      System.out.println("No");
      return;
    }
    for(int i = 0;i<n-1;i++){
      if(!(s[i].substring(s[i].length()-1,s[i].length()).equals(s[i+1].substring(0,1)))){
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  ll l, r;
  cin >> l >> r;
  r = min(r, l + 673);
  int ans = 2018;
  for (ll i = l; i <=r ; ++i) {
    for (ll j = i + 1; j <= r; ++j) {
      int x = i * j % 2019;
      ans = min(ans, x);
    }
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll tmp=1;
    string str="";
    if(N==0)cout << 0;
    while(N!=0){
      if(N%(tmp*2)!=0){
        N=N-tmp;
        str= '1'+str;
      }else{
        str= '0'+str;
      }
      tmp*=-2;
    }
    cout << str;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
n = (n-1)//111
if n == 0:
    print(111)
elif n == 1:
    print(222)
elif n == 2:
    print(333)
elif n == 3:
    print(444)
elif n == 4:
    print(555)
elif n == 5:
    print(666)
elif n == 6:
    print(777)
elif n == 7:
    print(888)
elif n == 8:
    print(999)
elif n == 9:
    print(1111)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll h,w;
    cin >> h >> w;
    vector <vector<ll>> arr(h,vector<ll>(w,0));
    for (int z=0;z<h;z++){
    	string a;
    	cin >> a;
    	for (int x=0;x<a.size();x++){
    		if (a[x] == '#') arr[z][x] = -1;
    	}
    }
    for (int z=0;z<w;z++){
    	if (arr[0][z] == -1){
    		for (;z<w;z++){
    			arr[0][z] = -1;
    		}
    		break;
    	}
    	arr[0][z] = 1;
    }
    for (int z=0;z<h;z++){
    	if (arr[z][0] == -1) {
    		for (;z<h;z++){
    			arr[z][0] = -1;
    		}
    		break;
    	}
    	arr[z][0] = 1;
    }
    for (int z=1;z<h;z++){
    	for (int x=1;x<w;x++){
    		if (arr[z][x] == -1) continue;
    		if (arr[z-1][x] != -1) arr[z][x] += arr[z-1][x];
    		if (arr[z][x-1] != -1) arr[z][x] += arr[z][x-1];
    		arr[z][x] %= ll(1e9+7);
    	}
    }
    cout << arr[h-1][w-1] << endl;
    cin >> h;
}


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

int main()
{
	long long a, b;
	cin >> a >> b;

	long long g = __gcd(a, b);
	long long ans = 0;
	
	long long limit = sqrt(g);
	for(int i = 2; i <= limit; i++)
	{
		if(g % i == 0)
		{
			ans++;
			while(g % i == 0)
				g = g / i;
		}
	}
	if(g != 1)
		ans++;

	cout << ans + 1 << endl;

	return 0;
}

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

#define int         long long
#define pb          push_back
#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 sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	string s;
	cin >> s;
	map<char,int> mp;
	repp(i,0,s.size())
	{
		mp[s[i]]++;
	}
	if(mp.size()!=2)
	{
		cout << "No" << endl;
		return 0;
	}
	sort(all(s));
	s.erase(unique(s.begin(),s.end()),s.end());
	if(mp[s[0]]==2 && mp[s[1]]==2)
	{
		cout << "Yes" << endl;
	 } 
	 else
	 {
	 	cout << "No" << endl;
	 }
}


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

using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)

const ll mod = 1e9+7;

int main(){
	ll a, b, k;
	cin >> a >> b >> k;
	ll cnt = 0;
	REPR(i, a){
		if (a%i==0 && b%i==0){
			cnt += 1;
			if (cnt >= k){
				cout<<i<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstring>	// require memset

using namespace std;

bool watch[20][31];
int score[20];

int main()
{
	int n, m, d;
	
	while (cin >> n && n ){
		memset (watch, false, sizeof (watch ) );
		memset (score, 0, sizeof (score ) );
		map <int, string> mp;

		for (int i = 0; i < n; i++ ){
			cin >> mp[i] >> m;
			for (int j = 0; j < m; j++ ){
				cin >> d;
				watch[i][d] = true;
			} // end for
		} // end for
		for (int j = 0; j <= 30; j++ ){
			int sum = n+1;
			for (int i = 0; i < n; i++ )
				if (watch[i][j] )
					sum--;
			for (int i = 0; i < n; i++ )
				if (watch[i][j] )
					score[i] += sum;
		} // end for

		int minS = *min_element (score, score+n );
		set <string> res; 
		for (int i = 0; i < n; i++ )
			if (minS == score[i] )
				res.insert (mp[i] );

		cout << minS << ' ' << *res.begin() << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
n, k = map(int, input().split())
s = input().rstrip()

#s = "0001111011110"
#n, k = len(s), 1

s="1"+s

k_pt = 0
cur_tail = 0
for cur in range(1, len(s)):
  cur_tail+=1

  if  s[cur-1] == '1' and s[cur] == '0':
    k_pt+=1

  if k_pt <= k:
      cur_tail-=1
  elif  s[cur_tail] == '0' and s[cur_tail+1] == '1':
    k_pt-=1

print(cur-cur_tail)


Measured memory_bytes: 3316
#!/usr/bin/env python3

import sys

DEBUG = False


def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep=" "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    d, t, s = read_list(int)
    if d <= t * s:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61688
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int n,m,x,y;
  int war = 0;
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &x);
  scanf("%d", &y);
  int xn[n];
  int ym[m];
  for (int i = 0; i < n; i++) {
    scanf("%d", &xn[i]);
    // if(xn[i] < x){
    //   war = 1;
    // }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &ym[i]);
    // if(ym[i] > y){
    //   war = 1;
    // }
  }
  int xmax = -101;
  int ymin = 101;
  for (int i = 0; i < n; i++) {
    if(xmax < xn[i]){
      xmax = xn[i];
    }
  }
  for (int i = 0; i < m; i++) {
    if(ymin > ym[i]){
      ymin = ym[i];
    }
  }
  if(xmax < ymin){
    if(x >= ymin){
      war = 1;
    }
    if(y < ymin){
      war = 1;
    }
  }else{
    war = 1;
  }
  if(war == 0){
    printf("No War");
  }else{
    printf("War");
  }
  return 0;
}


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

int main() {
	int n, x = 0, y = 0, t = 0, s, cnt = 0;

	cin >> n;
	
	for(int i = 0; i < n; i++) {
		int xx, yy, tt;
		cin >> tt >> xx >> yy;

		s = abs( xx - x ) + abs( y - yy );

		if( (tt-t >= s && s%2 && (tt-t)%2) || ( tt-t >= s && !(s%2) && !((tt-t)%2) ) ) t = tt, x = xx, y = yy;
		else break;
		cnt++;
	}
	n == cnt ? cout << "Yes\n" : cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
n,k = map(int, input().split())
sunuke = [0]*n
ans = 0
for i in range(k):
    d = int(input())
    tmp = list(map(int,input().split()))
    for j in range(d):
      sunuke[tmp[j]-1] += 1
for item in sunuke:
  if item == 0:
    ans +=1
    
print(ans)

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

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

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
const int MAXL = 1000000001;
typedef pair<int, int> SEG;
typedef pair<SEG, int> S;
//int data[MAXL];
int main(){
  int N;
  while(cin>>N && N){
    //memset(data, -1, sizeof(data));
    vector<S> data;
    data.push_back(S(SEG(-1, 0), -1));
    REP(time, N){
      string cmd; cin>>cmd;
      if(cmd == "W"){
        int l, s; cin>>l>>s;
        vector<S> add;
        REP(i, data.size()-1){
          if(s == 0) break;
          if(data[i].first.second < data[i+1].first.first){
            int fst = data[i].first.second;
            int len = min(s, data[i+1].first.first - fst);
            add.push_back(S(SEG(fst, fst + len), l));
            s -= len;
          }
        }
        if(s > 0){
          int fst = data.back().first.second;
          int len = s;
          add.push_back(S(SEG(fst, fst + len), l));
        }
        REP(i, add.size()) data.insert(upper_bound(data.begin(), data.end(), add[i]), add[i]);
        //sort(data.begin(), data.end());
        /*
        REP(i, MAXL){
          if(S == 0) break;
          if(data[i] == -1){
            data[i] = l;
            S --;
          }
        }
        */
      }else if(cmd == "D"){
        int l; cin>>l;
        //REP(i, MAXL)if(data[i] == l)data[i] = -1;
        vector<S>::iterator it = data.begin();
        while(it != data.end()){
          if(it->second == l){
            it = data.erase(it);
          }else{
            it++;
          }
        }
      }else if(cmd == "R"){
        int P; cin>>P;
        int res = -1;
        REP(i, data.size())if(data[i].first.first <= P && P < data[i].first.second){
          res = data[i].second;
        }
        cout<< res <<endl;
        //cout<<data[P]<<endl;
      }else{
        assert(false);
      }
      //REP(i, data.size())printf("%d:(%d, %d) ", data[i].second, data[i].first.first, data[i].first.second); cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1016
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	mp := make(map[string]int)
	
	N := ScanInt(scanner)
	for i := 0; i < N; i++ {
	    x := ScanText(scanner)
	    mp[x]++
	}
	
	M := ScanInt(scanner)
	for i := 0; i < M; i++ {
	    x := ScanText(scanner)
	    mp[x]--
	}
	
	ans := 0
	for _, v := range mp {
	    ans = Max(ans, v)
	}
	fmt.Println(ans)
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int xs,ys,n,m;
ll a[200003];
ll b[2003];
bool vis[1009][1009];
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
    int k,s,ans=0;
    cin>>k>>s;
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<=k;j++)
        {
            int q=s-(i+j);
            if(q>=0&&q<=k)
                ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3616
import sys
from collections import Counter

input = sys.stdin.readline
P = 10**9 + 7


def main():
    N = int(input())
    S = input().rstrip()

    # Editorial AC
    c = Counter(S)
    ans = 1
    for v in c.values():
        ans = (ans * (v + 1)) % P
    ans = (ans - 1) % P

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int read(){
	int w=0,f=1;
	char c=' ';
	while(c<'0'||c>'9')c=getchar(),f=c=='-'?-1:f;
	while(c>='0'&&c<='9')w=w*10+c-48,c=getchar();
	return w*f;
}
int n;
int a[N], b[N];
int ca[N], cb[N];
signed main(){
	n = read();
	for(int i = 1; i <= n; i++) a[i] = read(), ca[a[i]]++;
	for(int i = 1; i <= n; i++) b[i] = read(), cb[b[i]]++;
	for(int i = 1; i <= n; i++) if(ca[i] + cb[i] > n) return printf("No\n"), 0;
	reverse(b + 1, b + n + 1);
	vector<int> t;
	int cnt = 0, val = 0, len = 0;
	for(int i = 1; i <= n; i++)
	{
		if(b[i] == a[i])
		{
			cnt++;
			val = b[i];
			t.push_back(i);
		}
	}
	len = cnt;
	vector<int> s;
	for(int i = 1; i <= n; i++)
	{
	 if(a[i] == b[i]) continue;
	 if(cnt == 0) break;
	 if(a[i] != val && b[i] != val)
	 {
	 	s.push_back(i);
	 	cnt--;
	 }		
	}
	for(int i = 0; i < len; i++)
	{
		swap(b[s[i]], b[t[i]]);
	}
	printf("Yes\n");
	for(int i = 1; i <= n; i++) printf("%d ", b[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 7376
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  bool flag  = false;
  rep(i,15) {
    rep(j,26) {
      if (i * 7 + j * 4 == n) flag = true;
    }
  }
  string ans;
  if (flag == true) ans = "Yes";
  else ans = "No";
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
const int N = 2e5+5, mod = 1e9+7;
int val[N];
int main() 
{
	int n;
	cin >> n;
	int a[n+1];
	vector<int> vec;
	for(int i=1; i<=n; i++) cin >> a[i];
	for(int i=n; i>0; i--)
	{
		int sum = 0;
		for(ll j=i*2; j<=n; j+=i) sum += val[j];
		if(sum%2 != a[i]) vec.push_back(i), val[i] = 1;
		else val[i] = 0;
	}
	cout << vec.size() << endl;
	for(auto i : vec) cout << i << " ";
	cout << endl;
}

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder
{
  class Program
  {
    static void Main(string[] args)
    {
      int N = int.Parse(Console.ReadLine());
      if(N == 1)
      {
        Console.WriteLine("0");
        Console.ReadLine();
        return;
      }
      Console.WriteLine("1");
      Console.ReadLine();
    }

  }
}

Measured memory_bytes: 27312
import java.util.*;
class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt(),m=sc.nextInt();
        int sum=0;
        int []a=new int[n];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
            sum+=a[i];
        }
        int ans=0;
        for(int i=0;i<n;i++){
            if(!(4*m*a[i]<sum)){
                ans++;
            }
        }
        System.out.println(ans<m?"No":"Yes");
    }
}

Measured memory_bytes: 35688
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};
use std::{cmp, collections::HashMap};

#[fastout]
fn main() {
    input! {
        n: usize,
        l: [i32; n],
    }
    // annotate for rust-analyzer
    let n: usize = n;
    let l: Vec<i32> = l;

    let mut ans = 0;
    let mut map = HashMap::new();
    for i in l {
        *map.entry(i).or_insert(0) += 1;
    }
    let mut keys = map.keys().collect_vec();
    keys.sort();
    for v in keys.into_iter().combinations(3) {
        if v[0] + v[1] > *v[2] {
            ans += map[v[0]] * map[v[1]] * map[v[2]];
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2196
#include <iostream>
using namespace std;
typedef long long ll;

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

    ll X, Y;
    cin >> X >> Y;

    ll dis = X - Y;
    if(dis < 0){
        dis = -dis;
    }
    cout << (dis <= 1 ? "Brown" : "Alice") << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int H, W, N;
    cin >> W >> H >> N;
    int up = H, down = 0, left = 0, right = W;
    FOR(i, 0, N) {
        int x, y ,a;
        cin >> x >> y >> a;
        if (a == 1) {
            left = max(left, x);
        } else if (a == 2) {
            right = min(right, x);
        } else if (a == 3) {
            down = max(down, y);
        } else {
            up = min(up, y);
        }
    }

    int ret = left > right || up < down ? 0 : (right - left) * (up - down);
    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    string s;
    cin >> s;
    vector<int> a(20, 0);
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G')
        {
            a[i + 1] = a[i] + 1;
        }
        else
        {
            a[i + 1] = 0;
        }
    }
    sort(a.begin(), a.end(), greater<int>());
    cout << a[0] << endl;
}


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

int N,K;
long long int  R, S, P;
string T;

long long int dp[4][100005];

int main(void) {

	cin >> N >> K >> R >> S >> P >> T;

	T = "%" + T;

	long long int ans = 0;

	for (int i = 1; i <=K; i++) {
		
		for (int j = 0; i + j*K <= N; j++) {
			for (int k = 1; k <= 3; k++) {
			dp[k][j] = 0;
		}
		}

		if (T[i] == 'r') { dp[3][i] = P; }
		else if (T[i] == 's') { dp[1][i] = R; }
		else if (T[i] == 'p') { dp[2][i] = S; }

		for (int j = 1; i + j*K <= N; j++) {
			dp[1][i + j*K] = max(dp[2][i + (j - 1)*K], dp[3][i + (j - 1)*K]);
			dp[2][i + j*K] = max(dp[1][i + (j - 1)*K], dp[3][i + (j - 1)*K]);
			dp[3][i + j*K] = max(dp[1][i + (j - 1)*K], dp[2][i + (j - 1)*K]);

			if (T[i + j*K] == 'r') { dp[3][i + j*K] += P; }
			else if (T[i + j*K] == 's') { dp[1][i + j*K] += R; }
			else if (T[i + j*K] == 'p') { dp[2][i + j*K] += S; }
		}

		long long int val = 0;
		for (int j = 0; i + j*K <= N; j++) {
			for (int k = 1; k <= 3; k++) { val = max(val, dp[k][i + j*K]); }
		}
		ans += val;
	}

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

Measured memory_bytes: 2812
data = list(map(int,input().split()))
n = data[0]
m = data[1]
c = data[2]
b = list(map(int,input().split()))
a = []
for i in range(n):
        a.append(list(map(int,input().split())))
result = 0
for i in range(n):
        sum_ = c
        for j in range(m):
                sum_ += a[i][j]*b[j]
        if sum_ > 0:
                result += 1
print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

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

vll res;

void calc(int cnt){
    int st=1,en=9;
    while(1){
            //cout<<"St= "<<st<<"En= "<<en<<endl;
        for(int i=st;i<=en;i++){
            ll t=res[i],ld=res[i]%10;
            for(int j=-1;j<2;j++){
                if(ld+j>=0&&ld+j<=9){
                    res.pb((t*10)+(ld+j));
                    cnt++;
                    if(cnt==100003){
                       // cout<<"Ok returning= "<<cnt<<endl;
                        return;
                    }
                }
            }
        }
        st=en+1; en=res.sz-1;
    }
}
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   ll k; cin>>k;
   int cnt=9;
   for(int i=0;i<10;i++){
    res.pb(i);
   }

   calc(9);

   sort(all(res));
   //cout<<res.sz<<endl;
   cout<<res[k]<<endl;
   End;
}


Measured memory_bytes: 1400
#include <stdio.h>

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

    if (m==1 && n==2){


        printf("3\n");

    }

    else if (m==1 && n==3){


        printf("2\n");

    }

    else if (m==2 && n==1){


        printf("3\n");

    }

    else if (m==2 && n==3){


        printf("1\n");


    }

    else if (m==3 && n==1){


        printf("2\n");

    }

    else if (m==3 && n==2){


        printf("1\n");

    }










    return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	int N,W;
	cin >> N >> W;
	ll w[N+1],v[N+1];
	for(int i=1;i<=N;i++){
		cin >> w[i] >> v[i];
	}
	ll dp[N+1][W+1];//dp[i][j] = max value with i items and knapsack capacity of j
	for(int i=0;i<=W;i++)
		dp[0][i] = 0;
	for(int i=0;i<=N;i++)
		dp[i][0] = 0;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=W;j++){
			if(j-w[i] >= 0)
				dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
			else
				dp[i][j] = dp[i-1][j];
		}
	}
	cout << dp[N][W] << "\n";
}

Measured memory_bytes: 82516
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    long long i;
    long long n;
    long long sqrt_n;
    long long ans=LLONG_MAX;

    scanf("%lld", &n);

    sqrt_n = (long long)ceil(sqrt((double)n)+1);

    for ( i=1; i<=sqrt_n; i++ ) {
        if ( n%i != 0 )
            continue;
        if ( ans > i + n/i - 2 )
            ans = i + n/i - 2;
    }

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


Measured memory_bytes: 128