akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.txt");ofstream coutt("out.txt");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Use __builtin_popcountll for ll;
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 


signed main(){
    FASTER;
    int n,d;cin>>n>>d;
    cout<<ceil(n,2*d+1);
}



Measured memory_bytes: 3620
#include<iostream>
using namespace std;
            
int main(){

    
    for(int x = 1; x <= 9; ++x){
	    for(int y = 1; y <= 9; ++y){
            cout << x << "x" << y << "=" << ( x * y ) << endl;
	    }  
	}
	return 0;
}

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

constexpr int nax = 1e5;

int n, l;
int tab[nax];

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

    cin >> n >> l;

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

    int v = -1;

    for (int i = 0; i < n - 1; ++i)
        if (tab[i] + tab[i + 1] >= l)
           v = i;

    if (v == -1)
        return cout << "Impossible" << '\n', 0;

    cout << "Possible" << '\n';

    for (int i = 0; i < v; ++i)
        cout << (i + 1) << '\n';

    for (int i = n - 2; i >= v + 1; --i)
        cout << (i + 1) << '\n';

    cout << (v + 1) << '\n';
}


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

cn = []
for i in range(3):
    cn.append(list(map(int, input().split())))

sum = 0
for (a,b,c) in cn:
    sum += a+b+c

if sum % 3 != 0:
    print('No')
    exit()

for i in range(2):
    for j in range(2):
        sum2 = cn[i][j] + cn[i+1][j] + cn[i][j+1] + cn[i+1][j+1]
        if sum2 % 2 != 0:
            print('No')
            exit()


print('Yes')


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
	int n,x,s=0;
	cin>>n;
	x=n;
	while(x!=0)
	{
	s+=x%10; 
	x=x/10;
    }
    if(n%s==0)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin >>N;
  vector<int> A(N);
  vector<int> B(N);
  for(int i= 0;i < N;++i){
  cin >> A[i];
    B[i] = A[i];
  }
   sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
int Amax = A[0];
int Asecond = A[1];
  
  for(int i=0;i< N;++i){
    if(B[i] == A[0])
      cout << Asecond << endl;
  else
    cout << Amax << endl;
  }
}

Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        if(n<=999)
            printf("ABC\n");
        else 
            printf("ABD\n");
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args) throws IOException{
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int[] data = new int[30];

        for(int i = 0; i < 28; i++){
            data[Integer.valueOf(br.readLine()) - 1] = 1;
        }

        for(int i = 0; i < 30; i++){
            if(data[i] == 0)    System.out.println(i+1);
        }
        
    }
}

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


using namespace std;

const int INF = (int) 1e6 + 1;
const int MAX_V = (int) 100;

struct edge { int to, cap, rev; };

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap) {
    G[from].push_back( (edge) { to, cap, (int) G[to].size() });
    G[to].push_back( (edge) { from, 0, (int) G[from].size() - 1 });
}

int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    for (auto &e: G[v]) {
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

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

    int V, E;
    cin >> V >> E;

    for (int i = 0; i < E; ++i) {
        int u, v, c;
        cin >> u >> v >> c;
        add_edge(u, v, c);
    }

    int flow = 0;
    while (true) {
        memset(used, 0, sizeof(used));
        int f = dfs(0, V - 1, INF);
        if (f == 0) {
            break;
        }
        flow += f;
    }

    cout << flow << '\n';

    return 0;
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> count(N);
  rep(i, K)
  {
    int d;
    cin >> d;
    rep(j, d)
    {
      int A;
      cin >> A;
      A--;
      count[A]++;
    }
  }
  int ans = 0;
  rep(i, N)
  {
    if(count[i] == 0)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);
//const int INF=(1<<29);

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] = 1;
  return ret;
}

int main(){
  ll N;
  cin >> N;

  map<ll,int> mp = prime_factor(N);

  int ans=0;
  for(auto v: mp){
    int n = v.second;


    FOR(i,1,n+1){
      n -= i;
      if(n < 0)break;
      ans ++;
    }

  }
  cout << ans << endl;

}



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

typedef long long ll;

string S;
ll N;
ll K;
vector<ll> A;
ll M;
vector<vector<vector<ll>>> Dp;
const ll MOD = 998244353;
ll Res;

int main() {
  cin >> S >> K;
  N = S.size();
  K = min(N, K);
  reverse(S.begin(), S.end());
  ll now = 0;
  for (char c : S) {
    if (c == '0') {
      A.push_back(now);
      now = 0;
    } else {
      ++now;
    }
  }
  A.push_back(now);
  M = A.size();
  Dp.resize(M + 1);
  for (auto &Dpi : Dp) {
    Dpi.resize(N + 1);
    for (auto &Dpij : Dpi) Dpij.resize(K + 1);
  }
  Dp[0][0][0] = 1;
  for (ll i = 0; i < M; ++i) {
    for (ll j = N; j >= 0; --j) {
      for (ll k = 0; k <= K; ++k) {
        (Dp[i + 1][j][k] += Dp[i][j][k]) %= MOD;
        if (j != N) {
          (Dp[i + 1][j][k] += Dp[i + 1][j + 1][k]) %= MOD;
        }
      }
    }
    for (ll j = 0; j <= N; ++j) {
      for (ll k = 0; k <= K; ++k) {
        for (ll a = 1; a <= A[i] && j + a <= N && k + a <= K; ++a) {
          (Dp[i + 1][j + a][k + a] += Dp[i][j][k]) %= MOD;
        }
      }
    }
  }
  for (ll k = 0; k <= K; ++k) {
    (Res += Dp[M][0][k]) %= MOD;
  }
  cout << Res << endl;
  return 0;
}


Measured memory_bytes: 112184
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String str = sc.next();

        if (N % 2 != 0) {
            System.out.println("No");
        }
        else {
            int n1 = N / 2;
            String s1 = str.substring(0, n1);
            String s2 = str.substring(n1);
            if (s1.equals(s2)) {
                System.out.println("Yes");
            }
            else {
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <time.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef int ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=1e+5 + 1;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=1e+9 + 7;

int main() {
	int m, n;
	while(cin >> m >> n && m){
		int books[128];
		REP(i,n){
			cin >> books[i];
		}
		int lb = 0, ub = INF;
		while(ub - lb > 1){
			int mid = (lb + ub) / 2;
			bool ok = true;
			int now = 1, put = 0;
			REP(i,n){
				if(books[i] > mid){
					ok = false;
					break;
				}
				if(put + books[i] <= mid){
					put += books[i];
				}
				else{
					put = books[i];
					now++;
				}
				if(now > m){
					ok = false;
					break;
				}
			}
			if(ok){
				ub = mid;
			}
			else{
				lb = mid;
			}
		}
		cout << ub << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
public class Main {

  private static void solve() {
    int a = ni();
    int b = ni();
    int c = ni();
    int d = ni();

    boolean t = true;
    while (a > 0 && c > 0) {
      if (t) {
        c -= b;
      } else {
        a -= d;
      }
      t = !t;
    }

    System.out.println(!t ? "Yes" : "No");

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 36760
#include <bits/stdc++.h> // 万能头文件之华丽的开始
using namespace std;

int main() {
    int a, b, c, k;// 定义a、b、c和k。
    cin >> a >> b >> c >> k; // 我们校长都看得懂的输入
    int mx = max(max(a, b), c);
    // 计算2的乘方
    cout << mx * pow(2, k) + a + b + c - mx << endl;//输出和，注意mx是abc中的，还是要减去以免重复的...
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
int main()
{
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		long double xa, ya, ra, xb, yb, rb;
		std::cin >> xa >> ya >> ra >> xb >> yb >> rb;
		long double d = hypot(xa - xb, ya - yb);
		if (d < std::abs(ra - rb))
		{
			std::cout << 2 * (ra < rb ? -1 : 1) << std::endl;
		}
		else if (d <= ra + rb)
		{
			std::cout << 1 << std::endl;
		}
		else
		{
			std::cout << 0 << std::endl;
		}
	}
	return 0;
}


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

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

    int a,b; cin >> a >> b;
    cout << a * b << endl;
}

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

using namespace std;
const int N = 1e5 + 5, MOD = 1e9 + 7;
vector<int> adj[N];
int n, k;
int go(int node, int depth, int c, int parent) {
	int cnt = min(2, depth) + c;
	if (cnt >= k)
		return 0;
	int ret = k - cnt;
	int tmp = 0;
	for (auto child: adj[node])
		if (child != parent)
			ret = (1LL * ret * go(child, depth + 1, tmp++, node)) % MOD;
	return ret;
}
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
#endif
	scanf("%d %d", &n, &k);
	for (int i = 1; i < n; ++i) {
		int u, v;
		scanf("%d %d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	printf("%d\n", go(1, 0, 0, 0));
	return 0;
}

Measured memory_bytes: 11520
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

V<V<int>> to(1e5+1);
map<P, int> d;
V<int> p(1e5+1, 0);
V<bool> saw(1e5+1, false);
bool flag = true;

void dfs (int par, int x) {
    if (saw[x]) return;
    saw[x] = true;
    for (int nx : to[x]) {
        if (nx == par) continue;
        if (saw[nx] && p[nx] != p[x] + d[{x, nx}]) {
            flag = false;
        }
        p[nx] = p[x] + d[{x, nx}];
        dfs(x, nx);
    }
}

int main () {
    int n, m; cin >> n >> m;
    rep(i, m) {
        int l, r, D; cin >> l >> r >> D; l--; r--;
        to[l].emplace_back(r); d[{l, r}] = D;
        to[r].emplace_back(l); d[{r, l}] = -D;
    }
    rep(i, n) dfs(-1, i);
    if (flag) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 41672
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::max;
fn main() {
    input! { n, abc: [(usize, usize, usize); n] };
    let mut dp = vec![vec![0; 3]; n + 1];
    for i in 0..n {
        let &(a, b, c) = &abc[i];
        dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a;
        dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b;
        dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c;
    }
    println!("{}", dp[n].iter().max().unwrap());
}


Measured memory_bytes: 16636
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[]a = new int[n];
        for(int i=1;i<=n;i++){
            a[sc.nextInt()-1]=i;
        }
        for(int i=0;i<n;i++){
            System.out.println(a[i]);
        }
    }
}

Measured memory_bytes: 63404
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifdef STOPIT
#define debug(...) 0
#else
#define debug(...)\
do {\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;\
} while (false)
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::cout << (n - 1) / 2 << std::endl;
  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

ll h,w,d[1010][1010],dx[]={0,0,1,-1},dy[]={1,-1,0,0},ans=0;
string s[1010];

void init(){
	cin>>h>>w;
	rep(i,h)cin>>s[i];
	rep(i,h)rep(j,w)d[i][j]=1e18;
	queue<pair<ll,ll> > Q;
	rep(i,h)rep(j,w)if(s[i][j]=='#'){
		d[i][j]=0;
		Q.push({i,j});
	}
	while(!Q.empty()){
		pair<ll,ll> p = Q.front();Q.pop();
		ll y = p.first,x = p.second;
		// cerr<<y<<","<<x<<endl;
		rep(k,4){
			if(0<=x+dx[k] && x+dx[k]<w && 0<=y+dy[k] && y+dy[k]<h && d[y+dy[k]][x+dx[k]]>d[y][x]+1){
				d[y+dy[k]][x+dx[k]]=d[y][x]+1;
				Q.push({y+dy[k],x+dx[k]});
			}
		}
	}
}

int main(void){
	init();
	rep(i,h)rep(j,w)ans=max(ans,d[i][j]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 25524
#include <iostream>
#include <queue>
#include <array>

const int kSize = 20 + 2;

std::array<int, 4> ways = {-1, -kSize, +1, +kSize};

inline int xy2pos(const int x, const int y){
    return x + y * kSize;
}

std::array<bool, kSize*kSize> Bfs(const std::array<bool, kSize*kSize> &tiles, int pos){
    std::array<bool, kSize*kSize> arrived;
    std::queue<int> q;
    q.push(pos);
    std::fill(arrived.begin(), arrived.end(), false);
    while(!q.empty()){
        pos = q.front();
        q.pop();
        arrived[pos] = true;
        for(int way : ways)
            if(tiles.at(pos + way) && !arrived.at(pos + way))
                q.push(pos + way);
    }
    return arrived;
}

int main(){
    int w,h;
    std::array<bool,kSize*kSize> tiles; ///< true if black
    while((std::cin >> w >> h) && w != 0){
        std::fill(tiles.begin(), tiles.end(), false);
        int pos;
        for(int y=1; y<=h; ++y){
            for(int x=1; x<=w; ++x){
                char c;
                std::cin >> c;
                tiles[xy2pos(x,y)] = (c == '.');
                if(c == '@'){
                    pos = xy2pos(x,y);
                    tiles[pos] = true;
                }
            }
        }
        auto arrived = Bfs(tiles, pos);
        int sum = 0;
        for(bool v : arrived)
            sum += (v) ? 1 : 0;
        std::cout << sum << std::endl;
    }
}


Measured memory_bytes: 4672
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;



int main() {
	cout << fixed << setprecision(18);
	long long int n,x[120]={},mymin=INF,mymax=-INF,sum=0;
	cin>>n;
	while(n!=0){
		mymin=INF;mymax=-INF,sum=0;
		for(int i=0;i<n;i++){
			cin>>x[i];
			mymin=min(mymin,x[i]);
			mymax=max(mymax,x[i]);
			sum+=x[i];
		}
		cout<<(sum-mymax-mymin)/(n-2)<<endl;
		cin>>n;
	}
} 



Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl
#define all(v) v.begin(), v.end()
#define rsort(v) sort(v.rbegin(), v.rend())


int main() {
  int N,X,T;
  cin >> N >> X >> T;
  print(((N-1+X)/X)*T);
  return 0;
}

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

#define FOR(i, l, r) for(size_t i = (l); i < (r); i = i + 1)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    int d, temp;
    int count = N;
    vector<int> A(N, 0);
    REP(i, K) {
        cin >> d;
        REP(j, d) {
            cin >> temp;
            temp--;
            A[temp]++;
            if(A[temp] == 1) {
                count--;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#define n 100
int main() {
    int array[n],i,m;
    scanf("%d", &m);
    for(i = 0; i < m; i++){
        scanf("%d", &array[i]);
    }
    for(i = m - 1; i > 0; i--){
        printf("%d ", array[i]);
    }
    printf("%d\n",array[0]);
    return 0;
}


Measured memory_bytes: 1808
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	a, b, c := scanInts(n), scanInts(n), scanInts(n)

	sort.Ints(a)
	sort.Ints(c)

	sum := 0

	for i := 0; i < n; i++ {
		b_i := b[i]
		a_cnt := sort.Search(len(a), func(i int) bool { return a[i] >= b_i })
		c_cnt := n - sort.Search(len(a), func(i int) bool { return c[i] > b_i })
		sum += a_cnt * c_cnt
	}

	fmt.Println(sum)
}


Measured memory_bytes: 6016
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	static final long MOD=1000000007;//998244353;
	public static void main(String[] args) {
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		int D=sc.nextInt();
		int T=sc.nextInt();
		int S=sc.nextInt();
		if (T*S<D) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
 	}
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
	}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

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

    ll R;
    cin >> R;

    double res = 2*M_PI * R;
    cout << res << endl;
}


Measured memory_bytes: 3800
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;
struct SuffixArray
{
	vector<int> sa,lcp;
	SuffixArray(string& s,int lim=256)
	{
		int n=s.size()+1,k=0,a,b;
		vector<int> x(s.begin(),s.end()+1),y(n),ws(max(n,lim)),rank(n);
		sa=lcp=y;
		iota(sa.begin(),sa.end(),0);
		for(int j=0,p=0;p<n;j=max(1,j*2),lim=p)
		{
			p=j;
			iota(y.begin(),y.end(),n-j);
			for(int i=0;i<n;i++)
				if(sa[i]>=j)
					y[p++]=sa[i]-j;
			fill(ws.begin(),ws.end(),0);
			for(int i=0;i<n;i++) ws[x[i]]++;
			for(int i=1;i<lim;i++) ws[i]+=ws[i-1];
			for(int i=n;i--;) sa[--ws[x[y[i]]]]=y[i];
			swap(x,y);
			p=1;
			x[sa[0]]=0;
			for(int i=1;i<n;i++)
			{
				a=sa[i-1];
				b=sa[i];
				x[b]=(y[a]==y[b]&&y[a+j]==y[b+j])? p-1:p++;
			}
		}
		for(int i=1;i<n;i++) rank[sa[i]]=i;
		for(int i=0,j;i<n-1;lcp[rank[i++]]=k)
			for(k&&k--,j=sa[rank[i]-1];s[i+k]==s[j+k];k++);
	}
};
string minsub(string t,int len)
{
	SuffixArray sufarr(t);
	for(int st:sufarr.sa)
		if(st+len<=(int)t.size()&&st*2<=(int)t.size())
			return t.substr(st,len);
	return "?";
}
int main()
{
	int n,k;
	string s;
	cin>>n>>k>>s;
	if(k==1)
	{
		string t=s;
		reverse(t.begin(),t.end());
		cout<<minsub(s+t,n)<<endl;
		return 0;
	}
	char lo='z';
	for(char c:s) lo=min(lo,c);
	if(k>=20)
	{
		cout<<string(n,lo)<<endl;
		return 0;
	}
	int rek=0,tail=0;
	for(int i=0;i<(int)s.size();)
	{
		if(s[i]!=lo) i++;
		else
		{
			int j=i+1;
			while(j<(int)s.size()&&s[j]==lo) j++;
			rek=max(rek,j-i);
			if(j==(int)s.size()) tail=j-i;
			i=j;
		}
	}
	string ans(n,'z');
	if(tail)
	{
		string ctail;
		long long len=(long long)(tail)<<k;
		if(len>=n) ctail=string(n,lo);
		else
		{
			ctail=string(len,lo);
			for(int i=n-tail;i-->len-tail;) ctail.push_back(s[i]);
		}
		ans=min(ans,ctail);
	}
	if(rek)
	{
		string cmin;
		long long len=(long long)(rek)<<(k-1);
		if(len>=n) cmin=string(n,lo);
		else
		{
			cmin=string(len-rek,lo);
			string t=s;
			reverse(t.begin(),t.end());
			cmin+=minsub(s+t,n-(int)cmin.size());
		}
		ans=min(ans,cmin);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>

using namespace std;

struct Edge {
	int a, b, cost;
};

int n, m;
int root[100], high[100];
Edge e[100000];

void init(int n) {
	for (int i = 0; i < n; i++)root[i] = i, high[i] = 1;
}

int getroot(int n){
	if (n == root[n])return n;
	return root[n] = getroot(root[n]);
}

bool issame(int a, int b) {
	return getroot(a) == getroot(b);
}

void unite(int a, int b) {
	a = getroot(a), b = getroot(b);
	if (a == b)return;
	if (high[a] > high[b])root[b] = a;
	else if (high[a] < high[b])root[a] = b;
	else if (high[a] == high[b])root[a] = b, high[a]++;
}

int main() {
	while (cin >> n >> m, n + m) {
		for (int i = 0; i < m; i++) {
			cin >> e[i].a >> e[i].b >> e[i].cost;
		}
		sort(e, e + m, [](Edge& l, Edge& r) {
			return l.cost < r.cost;
		});
		int ans = 0;
		init(n);
		for (int i = 0; i < m; i++) {
			if (!issame(e[i].a, e[i].b)) {
				unite(e[i].a, e[i].b);
				ans += e[i].cost;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
using namespace std;

typedef long long ll;
const int p=1e8+7;

char ans[20];
int n;
void dfs(int x,int op)
{
    if(x==n){
        printf("%s\n",ans);
        return ;
    }
    for(int i=0;i<op;i++)
    {
        ans[x]='a'+i;
        dfs(x+1,op);
    }
    ans[x]='a'+op;
    dfs(x+1,op+1);
}
int main()
{
    cin>>n;
    ans[0]='a';
    ans[n]='\0';
    dfs(1,1);
}


Measured memory_bytes: 1536
#include<stdio.h>
#include<string.h>
#include<iostream>

using namespace std;

int main(){
	char mes[256];
	cin.getline(mes,256);
	int i;
	for(i=0;i<strlen(mes);i++)
		mes[i]=toupper(mes[i]);
	printf("%s\n",mes);
}

Measured memory_bytes: 1124
n = int(input())
p = [int(i) for i in input().split()]
cnt = 0
for i in range(1, n-1):
    #print('{0},{1},{2}'.format(p[i-1], p[i], p[i+1]))
    if p[i-1] < p[i] and p[i] <= p[i+1]:
        cnt += 1
    elif p[i-1] >= p[i] and p[i] > p[i+1]:
        cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <complex>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/3)
#define PI (2*acos(0.0))
#define EPS (1e-8)

typedef long long ll;
typedef unsigned long long ull;

bool isprime[10001];
vector<int> primelist;

void seive(){
  for(int i = 0; i <= 10000; i++) isprime[i] = true;
  isprime[0] = isprime[1] = false;
  for(int i = 2; i * i <= 10000; i++){
    if(!isprime[i]) continue;
    for(int j = i * i; j <= 10000; j += i){
      isprime[j] = false;
    }
  }
  for(int i = 2; i <= 10000; i++){
    if(isprime[i]) primelist.push_back(i);
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  seive();
  int n;
  while(cin >> n, n != 0){
    int ans = 0;
    for(size_t i = 0; i < primelist.size(); i++){
      if(primelist[i] > n) break;
      int sum = 0;
      for(size_t j = i; j < primelist.size(); j++){
        sum += primelist[j];
        if(sum == n) ans++;
        if(sum > n) break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
    ll n,k,i,ans=0,x;
  cin>>n>>k;
  vector<ll>h;
  
  for(i=0;i<n;i++){
      cin>>x;
      h.push_back(x);
  }
  sort(h.begin(),h.end());
  for(i=0;i<n-k;i++)
  ans+=h[i];
  cout<<ans<<endl;
  
}

Measured memory_bytes: 2420
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;
struct pUF{
    vector<ll> r, par;
    pUF(int n):r(n),par(n,-1){};

    int find(int x){
       if(par[x]<0)
           return x;
       int y = find(par[x]);
       r[x] += r[par[x]];
       return par[x] = y;
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }
    
    ll weight(int x){
       find(x);
       return r[x];
    }

    ll diff(int x,int y){//weigth(y)-weight(x)を出力
        return weight(y)-weight(x);
    }
    
    bool unite(ll c,int x, int y){//weight(y)-weight(x)=cとなるようにつなぐ
        c -= weight(y);
        c += weight(x);
        x = find(x);
        y = find(y);
        if(x!=y){
           par[y] = x;
           r[y] = c;
           return true;
       }
       return false;
    }
};
int main(){
    int n;
    cin>>n;
    pUF uf(n);
    int q;
    cin>>q;
    rep(i,q){
        int t;
        cin>>t;
        if(t){
            int x,y;
            cin>>x>>y;
            if(uf.same(x,y))cout<<uf.diff(x,y)<<endl;
            else cout<<"?"<<endl;
        }
        else {
            int x,y,z;
            cin>>x>>y>>z;
            uf.unite(z,x,y);
        }
    }


   return 0;
}


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

int gcd (int x, int y) {
    int p = x % y;
    while(p){
        x = y;
        y = p;
        p = x % y;
    }
    return y;
}

int main() {
    int R,G,B,N;
    cin >> R >> G >> B >> N;

    int ans = 0;
    for (int i = 0; i < N / R + 1; ++i) { // i個の赤
        int x = N - (i * R);
        for (int j = 0; j < x / G + 1; ++j) { // j個の緑
            int y = x - (j * G);
            if(y % B == 0) ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a=LIST()
    print(max(a)-min(a))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> //tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
  string like_coffee;
  cin >> like_coffee;

  if (like_coffee[2] == like_coffee[3] &&
      like_coffee[4] == like_coffee[5]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
a,b=map(int,input().split())
if a<0 and 0<b:
    print('Zero')
    exit()
minus_num=0
if a<0:
    minus_num=abs(a)
if b<0:
    minus_num=abs(a-b+1)
print('Negative' if minus_num&1 else 'Positive')
    

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

// checkWeight checks if the packages in belt can be loaded onto k trucks without exceeding the maxWeight.
int checkWeight(int maxWeight, int k, int *belt, int n){
  int i, currentWeight = 0, trucksUsed = 1;
  for ( i = 0; i < n; i++ ){
    int nextWeight = currentWeight + belt[i];
    if ( nextWeight > maxWeight ){
      trucksUsed++;
      currentWeight = 0;
      i--;
      if ( trucksUsed > k )
	return 0;
    } else
      currentWeight = nextWeight;
  }
  return 1;
}

int main(){
  int i, n, k, min = 0, max, middle;
  scanf(" %d", &n);
  scanf(" %d", &k);
  
  int *belt = (int *) malloc(sizeof(int[n]));
  for ( i = 0; i < n; i++ )
    scanf(" %d", belt + i);
  
  for ( i = 0; i < n; i++ )
    if ( belt[i] > min )
     min = belt[i];
  
  max = min * n;
  
  if ( checkWeight(min, k, belt, n) ){
    printf("%d\n", min);
    return 0;
  }
  
  while ( min < max-1 ){
    middle = (min + max) / 2;
    if ( checkWeight(middle, k, belt, n) )
      max = middle;
    else
      min = middle;
  }
  printf("%d\n", max);
  free(belt);
  return 0;
}



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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 n,a,b;
  cin >> n >> a >> b;
  int64 ans = 0;
  ans += a * (n / (a + b));
  ans += min(a, n % (a + b));
  ANS(ans);
  return 0;
}

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

int main(){
  int N;cin>>N;
  vector<int> a(N+1),b(N+1,0),c(N+1,0);
  for(int i=1;i<=N;i++){
    cin>>a[i];
  }
  int M=0;
  for(int i=N;i>=1;i--){
    if(a[i]^(c[i]&1)){
      b[i]=1;
      M++;
      for(int j=1;j*j<=i;j++){
        if(i%j==0){
          c[j]++;
          if(j!=i/j) c[i/j]++;
        }
      }
    }
  }
  cout<<M<<endl;
  for(int i=1;i<=N;i++){
    if(b[i]) cout<<i<<' ';
  }
  cout<<endl;
  return 0;
}

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

int main(){
    int n=0;
    int a[n];
    int j=0;
    cin>>n;
    double mother=0;
    for (int i = 0; i < n; i++)
    {
        cin>>j;
        mother += 1.0/j;
    }
    cout << 1/mother << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for(ll i=0; i<N; ++i)

ll max(ll a, ll b) {return a < b ? b : a; }

int main() {
  ll X, Y;
  cin >> X >> Y;
  
  if(abs(X - Y) <= 1) {
    cout << "Brown" << endl;
  } else {
    cout << "Alice" << endl;
  }
  return 0;
}

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
	while(cur != nil && cur->key != key){
		cur = cur->next;
	}
	return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
	if(t == nil)return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
	if(t == nil)return;
	deleteNode(t);
}

void delete(int key){
	deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


Measured memory_bytes: 33092
#include <stdio.h>
int main(void) {
	int n;
	int p[200001];
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &p[i]);
	int count = 0;
	int min = 200001;
	for (int i = 1; i <= n; i++) {
		if (min > p[i]) {
			count++;
			min = p[i];
		}
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

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

  int64_t N, K;
  cin >> N >> K;

  vector<int64_t> A(N);

  for (int64_t i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  int64_t inner_inv = 0;
  for (int64_t i = 0; i < N; i++) {
    for (int64_t j = i + 1; j < N; j++) {
      if (A.at(i) > A.at(j)) {
        inner_inv++;
      }
    }
  }

  int64_t outer_inv = 0;
  for (int64_t i = 0; i < N; i++) {
    for (int64_t j = 0; j < N; j++) {
      if (A.at(i) > A.at(j)) {
        outer_inv++;
      }
    }
  }

  int64_t ans = inner_inv * K % 1000000007; 
  ans += (outer_inv% 1000000007) *( K * (K-1) / 2% 1000000007); 
  ans %= 1000000007; 

  cout << ans; 

  return 0;
}


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

int main() {
  int N, M;
  vector<string> s(100);
  vector<string> t(100);

  cin >> N;
  for (int i = 0; i < N; i++) cin >> s.at(i);
  cin >> M;
  for (int i = 0; i < M; i++) cin >> t.at(i);

  map<string, int> points;
  for (int i = 0; i < N; i++) {
    if (points.count(s.at(i))) points[s.at(i)]++;
    else points[s.at(i)] = 1;
  }
  for (int i = 0; i < M; i++) {
    if (points.count(t.at(i))) points[t.at(i)]--;
    else points[t.at(i)] = -1; 
  }

  int max_point = -100;
  for (int i = 0; i < N; i++) if (max_point < points[s.at(i)]) max_point = points[s.at(i)];

  if (max_point < 0) max_point = 0;
  cout << max_point << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string str;
    int a=0,b=0,o=0,ab=0;
    while(cin>>str){
        if((str[2]=='A'&&str[3]=='B')||(str[3]=='A'&&str[4]=='B')||(str[4]=='A'&&str[5]=='B'))ab++;
        else if(str[2]=='A'||str[3]=='A'||str[4]=='A')a++;
        else if(str[2]=='B'||str[3]=='B'||str[4]=='B')b++;
        else o++;
        //cout<<a<<endl<<b<<endl<<ab<<endl<<o<<endl;
    }
    cout<<a<<endl<<b<<endl<<ab<<endl<<o<<endl;
}

Measured memory_bytes: 1180
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = B[A[0] - 1]
for i in range(1, N):
    ans += B[A[i] - 1]
    if A[i] - A[i - 1] == 1:
        ans += C[A[i - 1] - 1]
print(ans)


Measured memory_bytes: 38256
#include <iostream>
#include<vector>
using namespace std;
int main() {
    string s1;cin>>s1;
    string s2;cin>>s2;
    int n1 = s1.size();
    int n2= s2.size();
    int dp[n1+1][n2+1];
    for(int i=0;i<=n1;i++){
        for(int j=0;j<=n2;j++){
           dp[i][j]=0;
        }
        
    }
    for(int i=1;i<=n1;i++){
        for(int  j=1;j<=n2;j++){
            if(s1[i-1]==s2[j-1]){
                dp[i][j] = max(dp[i-1][j],max(1+dp[i-1][j-1],dp[i][j-1]));

            }
            else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    vector<char>  v;
    int i=n1;
    int j=n2;
    while(i>=1&&j>=1){
        if(s1[i-1]==s2[j-1]){
            v.push_back(s1[i-1]);
            i--;
            j--;
        }
        else if(dp[i][j-1]>=dp[i-1][j]){
            j--;
        }
        else{
            i--;
        }
    }
    int n3 = v.size();
    for(int i=n3-1;i>=0;i--){
        cout<<v[i];
    }

}

Measured memory_bytes: 35456
S_ = input()
T = input()

if len(S_) < len(T):
  print('UNRESTORABLE')
  exit()

i_ = -1

for i in range(len(S_)-len(T)+1):
  for j in range(len(T)):
    if S_[i+j] != T[j] and S_[i+j] != '?':
      break
    if j == len(T) - 1:
      i_ = i

if i_ == -1:      
  print('UNRESTORABLE')
else: 
  if i_ + len(T) == len(S_):
    print(S_[:i_].replace('?','a')+T)
  else:
    print(S_[:i_].replace('?','a')+T+S_[i_+len(T):].replace('?','a'))

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

int main() {
  int n; cin >> n;
  std::vector<int> v(n);
  rep(i,n) cin >> v.at(i);
  sort(v.begin(), v.end(), greater<int>());

  int Alice = 0, Bob = 0;
  rep(i,n) {
    if (i % 2 == 0) Alice += v.at(i);
    else Bob += v.at(i);
  }
  cout << Alice - Bob << endl;
}


Measured memory_bytes: 3580
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] v = new int[N];
        int[] w = new int[N];
        for (int i = 0; i < N; i++) {
            v[i] = sc.nextInt();
            w[i] = sc.nextInt();
        }

        int[] dp = new int[W+1];

        for (int i = 0; i < N; i++) {
            for (int j = w[i]; j < W+1; j++) {
                dp[j] = Math.max(dp[j], dp[j - w[i]] + v[i]);
            }
        }

        System.out.println(dp[W]);
    }
}


Measured memory_bytes: 27284