akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int hours = (h2-h1)*60;
    if(m1 > m2) hours -= (m1-m2);
    else hours += m2-m1;

    cout << hours-k << endl;

    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		//String g = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();
		//long k = sc.nextLong();
		//long l = sc.nextLong();
		//long count=0;

		/*for(int i=1;i<=n;i++) {

		}*/
		if(n<=m) {
			System.out.println(n);
		}else{
			System.out.println(n-1);
		}
		//System.out.println((int)Math.ceil((n+m)/2.0));
		//System.out.println(s.substring(0,1)+t.substring(1,2)+g.substring(2,3));
	}
}




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

M=[0]*(N+1)
M[1]=1

for i in range(2,N+1):
  L=[M[i-1]+1]
  j=0
  while i-6**j>=0:
    L.append(M[i-6**j]+1)
    j+=1
  j=0
  while i-9**j>=0:
    L.append(M[i-9**j]+1)
    j+=1
  M[i]=min(L)
#print(M)

print(M[N])

Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
#define PI 3.14159265358979323846
using namespace std;
typedef long long ll;

#define MAX 1000000000000



int main(void) {
	int n, m; cin >> n >> m;
	rep(i, m) {
		int a; cin >>a;
		n -= a;
	}
	if (n < 0) {
		cout << -1 << endl;
	}
	else {
		cout << n << endl;
	}
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int, int>
#define ff first
#define ss second
#define md 1000000000000000000

int main() {
    int n;
    cin >> n;
    ll mult = 1;
    bool flag = true;
    while (n--) {
    ll x;
    cin >> x;
    if (x == 0) {
        cout << 0;
        return 0;
    }
    else if (x > md / mult) flag = false;
    else mult *= x;
    }
    if (flag) cout << mult;
    else cout << -1;
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 1000000
 
int n,M[MAX][MAX];
 
void dijkstra();
 
int main(){
  int i,j,k,c,u,v;
  scanf("%d",&n);
 
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
    M[i][j] = INFTY;
      } 
    }
 
  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    for(j = 0;j < k; j++){
      scanf("%d%d",&v,&c);
      M[u][v] = c;
    }
  }
 
  dijkstra();
  return 0;
}
  
void dijkstra(){
  int u,minv,i,j,v,sum=0;
  int d[MAX],p[MAX],color[MAX];
  
 for(i = 0; i < n; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
 }
  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    u = -1;
    for(i = 0; i < n; i++){
      if(minv > d[i] && color[i] != BLACK){
    u = i;
    minv = d[i];
      }
    }
     
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0;v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
    if(d[v] > d[u] + M[u][v]){
      d[v] = d[u] + M[u][v];
      color[v] = GRAY;
    }
      }
    }
  }
  for(i=0;i<n;i++){
    if(d[i]==INFTY){ 
      printf("%d -1\n",i);
    }else{
      printf("%d %d\n",i,d[i]);
    }
  }
}

Measured memory_bytes: 636
import java.util.Scanner;

public class Main {
  static final char SEARCH_DONE = '.';
  static final int[] dx = { -1, 0, 1, 0 };
  static final int[] dy = { 0, 1, 0, -1 };
  static int h;
  static int w;
  static char[][] map;

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

    while (true) {
      h = sc.nextInt();
      w = sc.nextInt();
      if (h == 0 && w == 0) {
        break;
      }

      map = new char[h][];
      for (int i = 0; i < h; i++) {
        map[i] = sc.next().toCharArray();
      }

      int count = 0;
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          char current = map[i][j];
          if (current != SEARCH_DONE) {
            depthFirstSearch(i, j, current);
            count++;
          }
        }
      }
      System.out.println(count);
    }
  }

  private static void depthFirstSearch(int y, int x, char target) {
    if (map[y][x] != target) {
      return;
    }

    map[y][x] = SEARCH_DONE;
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i];
      int ny = y + dy[i];

      if (nx < 0 || nx >= w || ny < 0 || ny >= h) {
        continue;
      }

      depthFirstSearch(ny, nx, target);
    }
  }
}

Measured memory_bytes: 28596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  vector<ll> V(N);
  rep(i,N) cin>>V[i];
  sort(all(V));
  ll sum=0;
  rep(i,A) sum+=V[N-1-i];
  double ans=(double)sum/A;
  int U=upper_bound(all(V),V[N-A])-V.begin()-1,L=lower_bound(all(V),V[N-A])-V.begin();
  int S=U-(N-A)+1;
  ll COM[51][51];
  rep(i,51){
    COM[i][0]=1;
    COM[i][i]=1;
  }
  rep(i,51) rep(j,51) if(i&&j&&i>j) COM[i][j]=COM[i-1][j-1]+COM[i-1][j];
  ll C=COM[U-L+1][S];
  if(V[N-A]==V[N-1]) rep(i,min(N-A-L,B-A)) C+=COM[U-L+1][S+i+1];
  cout.precision(10);
  cout<<ans<<endl;
  cout<<C<<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;

    if(a==1) a+=13;
    if(b==1) b+=13;

    if(a>b)
        cout << "Alice" << endl;
    else if(a<b)
        cout << "Bob" << endl;
    else 
        cout << "Draw" << endl;

}




Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  for (;;) {
    auto rd = readln.split.map!(to!int), n = rd[0], x = rd[1];
    if (n == 0 && x == 0) break;

    auto r = 0;
    foreach (i; 1..n+1)
      foreach (j; i+1..n+1) {
        auto k = x - i - j;
        if (k > j && k <= n) ++r;
      }

    writeln(r);
  }
}

Measured memory_bytes: 2440
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	int A, B;
	cin >> A >> B;
	cout << max(A + B, max(A - B, A * B)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
typedef pair<int, int> P;
const long long INF = 1LL << 60;

int N,x[100],y[100];
ll d = 1;
double sum = 0;

int main(){
  cin >> N;
  vector<int> num(N);
  rep(i,N) num[i] = i+1;
  rep(i,N) cin >> x[i] >> y[i];
  for(int i = 1; i < N+1; ++i) d *= i;
  do{
    rep(i,N-1){
      sum += sqrt(pow(x[num[i]-1]-x[num[i+1]-1],2) + pow(y[num[i]-1]-y[num[i+1]-1],2));
    }
  }while(next_permutation(num.begin(),num.end()));
  double ave = sum/d;
  cout << fixed << setprecision(6) << ave << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int H[N];
  int ans = 0;
  for(int i=0; i<N; i++){
    cin >> H[i];
  }
  int tmp = 0;
  for(int i=1; i<N; i++){
    if(H[i-1] >= H[i]){
      tmp++;
    }else{
      tmp = 0;
    }
    ans = max(ans, tmp);
  }

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


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int i=0,n=0;
            int[][] card=new int[12][10];
            while ((line = br.readLine()) != null) {
            	if(first){
            		n=Integer.parseInt(line);
            		first=false;
            	}else{
            		String[] str=line.split(" ");
            		int a=Integer.parseInt(str[0]);
            		int b=Integer.parseInt(str[1]);
            		int c=Integer.parseInt(str[2]);
            		int d=Integer.parseInt(str[3]);
            		card[(a-1)*3+b-1][c-1]+=d;
            		i++;
            		if(i==n){
            			for(int j=0;j<12;j++){
            				for(int l=0;l<10;l++){
            					System.out.print(" "+card[j][l]);
            				}
            				System.out.println("");
            				if((j+1)%3==0&&j!=11){
            					System.out.println("####################");
            				}
            			}
            			break;
            		}
                	
            	}
            }
        }
    }

}

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

int main(void) {
    ll N,Y;cin>>N>>Y;
    for (ll i = 0; i <= N; i++) {
        for (ll j = 0; j <= N; j++) {
            if (i + j > N) break;
            if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
                cout << i << " " << j << " " << N - i - j << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define U (LL)0
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>o;
        v.PSB(o);
    }
    sort(v.B,v.E);
    k=99999999999999;
    for(i=0;i<n-m+1;i++)
    {
        k=min(k,v[i+m-1]-v[i]);
    }
    cout<<k<<endl;


    return 0;

}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//bit全探索
//引数は処理に応じて適宜追加
void bit_search(ll n, vll &a, vector<vector<vll>> &testimony, priority_queue<ll> &ans) {
  vll bits(n, 0);
  for (ll i = 0; i < pow(2, n); i++) {
    vector<vll> truth(0, vll(2));
    for (ll j = 0; j < n; j++) {
      if (bits[j] == 1) {
        for (ll k = 0; k < a[j]; k++) {
          truth.push_back(testimony[j][k]);
        }
      }
    }
    ll liar = 0;
    for (ll j = 0; j < truth.size(); j++) {
      if (bits[truth[j][0] - 1] != truth[j][1]) {
        liar = 1;
        break;
      }
    }
    if (liar == 0) {
      ll cnt = 0;
      for (ll j = 0; j < n; j++) {
        if (bits[j] == 1) cnt++;
      }
      ans.push(cnt);
    }
    if (i == pow(2, n) - 1) return;
    ll x = 0;
    while (bits[n - 1 - x] == 1) {
      bits[n - 1 - x] = 0;
      x++;
    }
    bits[n - 1 - x] = 1;
  }
}

int main() {
  ll n;
  cin >> n;
  vll a(n);
  vector<vector<vll>> testimony(n, vector<vll>(0, vll(2)));
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    for (ll j = 0; j < a[i]; j++) {
      ll a, b;
      cin >> a >> b;
      testimony[i].push_back({a, b});
    }
  }
  priority_queue<ll> ans;
  bit_search(n, a, testimony, ans);
  cout << ans.top() << endl;
}

Measured memory_bytes: 640
#include <cstdio>

using namespace std;

int answer[] = {18, 48, 6, 30, 20, 34, 16};

int main() {
	int i, t, sum;
	char line[10];
	char c, a;

	while(true) {
		t = -1, sum = 0;
		for(i = 0; i < 64; i++) {
			c = getchar();
			if(c == EOF) return 0;
			if(c == '1') {
				if(t == -1) t = i;
				sum += i - t;
			}
			if(i % 8 == 7) getchar();
		}
		getchar();
		for(i = 0; i < 7; i++) {
			if(answer[i] == sum)
			a = 'A' + i;
		}
		printf("%c\n", a);
	}

	return 0;
}

Measured memory_bytes: 932
// quote from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#![allow(unused)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

macro_rules! out {
    ($x:expr) => {
        println!("{}", $x)
    };
}

macro_rules! debug {
    ($x:expr) => {
        println!("{:?}", $x)
    };
}

fn main() {
    input! {
        n: u32,
        v: [u32; n],
    }
    let mut v: Vec<u32> = v;
    let mut sum = 0;
    for i in 0..n as usize {
        for j in i+1..n as usize {
            sum = sum + v[i] * v[j];
        }
    }
    out!(sum)
}



Measured memory_bytes: 4352
#include <iostream>
#include <string.h>
using namespace std;

int main() {
    int n;
    int a[200001];
    int vis[200001];
    memset(vis, 0, sizeof(vis));
    scanf("%d", &n);
    long long nSum = 0;
    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
        vis[a[i]]++;
        nSum += a[i];
    }
    int q;
    scanf("%d", &q);
    for(int i=0; i<q; i++) {
        long long x, y;
        scanf("%lld %lld", &x, &y);
        long long nCount = vis[x];
        vis[y] += nCount;
        vis[x] = 0;
        nSum -= x * nCount;
        nSum += y * nCount;
        printf("%lld\n", nSum);
    } 
    return 0;
}

Measured memory_bytes: 4972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int N, X, Y;
    cin >> N >> X >> Y;
    --X;
    --Y;
  
    map<int, ll> mp;
    rep(i, N - 1){
        for (int j = i + 1; j < N; j++) {
          mp[min(j - i, abs(X - i) + 1 + abs(Y - j))]++;
        }
    }

    REP(i, N - 1){
        cout << mp[i] << endl;
    }
}


Measured memory_bytes: 384
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);

	        long N = sc.nextLong()-1;
	        int[] m = new int[100];
	        int cnt=0;
	        for(int i=0;N>=0;i++) {
	        	m[i]=(int) (N%26);
	        	N=N/26-1;
	        	cnt++;
	        }
	        StringBuffer ans = new StringBuffer();
	        for(int i=cnt-1;i>=0;i--) {
	        	ans.append((char)('a'+m[i]));
	        	
	        }
	        System.out.println(ans);
	    }
	}

Measured memory_bytes: 35792
#include <stdio.h>
#include <stdlib.h>

int ordena(const void * a, const void * b){
  int x= (*(int*)a);
  int y= (*(int*)b);

  if (x<y)
    return 1;
  else
    return -1;
}

int main (){
  int h,n,soma=0;
  int forca[112345];

  scanf("%d%d", &h, &n);

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

  for(int i=0; i<n; i++)
    soma+=forca[i];

  if(soma<h){
    printf("No\n");
  }
  else
  {
    qsort(forca,n,sizeof(int), ordena);

    soma=0;
    for(int i=0; i<n; i++){
      soma+=forca[i];
      if(soma>=h){
        printf("Yes\n");
        break;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 892
#include<stdio.h>
int n,A[50];
int solve(int i,int m)
{
	if(m==0)return 1;
	if(i>=n)return 0;
	int res=solve(i+1,m)||solve(i+1,m-A[i]);
	return res;
}
int main()
{
	int q,M,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&M);
		if(solve(0,M))printf("yes\n");
		else printf("no\n");
	}
	return 0;
}

Measured memory_bytes: 2600
status = 4.times.map{ 3.times.map{ [0] * 10 } }

gets.chomp.to_i.times do
  building, floor, room, tenants = gets.chomp.split.map(&:to_i)
  status[building-1][floor-1][room-1] += tenants
end

puts status.map { |building|
  s_building = building.map { |floor|
    " " + floor.map(&:to_s).join(" ") + "\n"
  }.join("")
}.join("#"*20+"\n")


Measured memory_bytes: 6908
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int i;
  int N;
  long long res = 0;
  rd(N);
  for(i=(1);i<(N+1);i++){
    if(i%3 && i%5){
      res += i;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200412-1

// --- original code ---
// {
//   int N;
//   ll res = 0;
//   rd(N);
//   rep(i,1,N+1) if(i%3 && i%5) res += i;
//   wt(res);
// }


Measured memory_bytes: 3640
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

struct edge { int to, cost; };
int N,M,id=0;
vector<edge> G[500009];
map<pii,int> comid;

int getid(int node,int com){
    pii p={node,com};
    if(comid.find(p)!=comid.end()) return comid[p];
    return comid[p]=id++;
}

void addedge(int u,int v,int uc,int vc,int cost){
    u=getid(u,uc), v=getid(v,vc);
    G[u].push_back({v,cost});
    G[v].push_back({u,cost});
}

int dijkstra(int s, int t, int range) {
    
    vector<int> d(range,INF);
    priority_queue< pii, vector<pii>, greater<pii> > que;   // first:cost second:頂点 cost基準の昇順
    que.push({0,s});
    d[s] = 0;
    
    while(!que.empty()){
        pii p = que.top(); que.pop();
        int v = p.second;
        if(d[v]<p.first) continue;
        rep(i,G[v].size()){
            edge e = G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to] = d[v]+e.cost;
                que.push({d[e.to],e.to});
            }
        }
    }
    return d[t];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>M;
    rep(i,M){
        int u,v,c; cin>>u>>v>>c;
        addedge(u,v,c,c,0);
        addedge(u,u,c,-1,1);
        addedge(v,v,c,-1,1);
    }
    
    int s=getid(1,-1);
    int t=getid(N,-1);
    int ans=dijkstra(s,t,id);
    
    if(ans==INF) ans=-1;
    else ans/=2;
    
    cout1(ans)
}

Measured memory_bytes: 64504
#include<bits/stdc++.h>
#define int long long
#define dd second
#define mp make_pair
#define pb push_back
#define ff first
#define dd second
#define pp pair<int,int>
using namespace std;
int n;

map<int,int> mapa;
main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        int temp; cin >> temp; mapa[temp]++;
    }
    int ans = 0;
    for(auto &x:mapa)
    {
        if(x.dd >= x.ff)
        {
            ans += x.dd-x.ff;
        }
        else
        {
            ans += x.dd;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 6272
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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

  int n; cin >> n;
  int w; cin >> w;

  vector<int> weight(n);
  vector<ll> value(n);
  rep(i, n) {
    cin >> weight[i];
    cin >> value[i];
  }

  ll dp[100005];

  rep(j, 100005) {
    dp[j] = -1;
  }

  dp[0] = 0;

  for(int i=0; i<n; i++) {
    for(int j=w; j>=0; j--) {
      int pos = j-weight[i];
      if (pos >= 0 && dp[pos] >= 0) {
        dp[j] = max(dp[j], dp[pos] + value[i]);
      }
    }
  }

  ll ma = 0;
  for(int j=0; j<=w; j++) {
    ma = max(ma, dp[j]);
  }
  cout << ma << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
int n, k;
int a, b, c;

int main() {
	bool flg = 0;
	cin >> n >> k;
	for(int i = 0; i <= 2000; i++) {
		for(int j = 0; j <= 2000; j++) {
			int tmp = n - i - j;
			if(i * 10000 + j * 5000 + tmp * 1000 == k && tmp >= 0) {
				flg = 1;
				a = i, b = j, c = tmp;
				break;
			}
		}
	}
	if(!flg) puts("-1 -1 -1");
	else printf("%d %d %d\n", a, b, c);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t h,k;
  cin >> h >> k;
  if(h==1 || k==1)cout << 1 << endl;
  else {
    if(h%2==0 || k%2==0)cout << (int64_t)(h*k)/2 << endl;
    else cout << (int64_t)(h*k)/2+1 << endl;
  }
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

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


int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    REP(i, N) cin >> S[i];
    
    int ans = 0;
    REP(root, N){
        vector<int> level(N, -1);
        queue<pair<int,int>> q;
        q.push({root, 0});
        while(!q.empty()){
            auto tmp = q.front(); q.pop();
            int top = tmp.first;
            int curr = tmp.second;
            if(level[top] >= 0) continue;
            level[top] = curr;
            REP(j, N){
                if(S[top][j] == '1') q.push({j, curr+1});
            }
        }
        bool is_ok = true;
        REP(i, N){
            FOR(j, i+1, N){
                if(S[i][j] == '1' and level[i] == level[j]){
                    is_ok = false;
                    break;
                }
            }
            if(!is_ok) break;
        }
        if(is_ok) ans = max(ans, *max_element(level.begin(), level.end())+1);
    }
    if(ans == 0) cout << -1 << endl;
    else cout << ans << endl;


    return 0;
}

Measured memory_bytes: 688
s = gets.chomp!
ls = s.split("").map(&:to_i)
count = 0
for i in 0..ls.length-1
  if ls[i] == ls[i+1]
    count+=1
  end
end
#p ls

#p count
if count >= 1
  print("Bad\n")
else
  print("Good\n")
end

Measured memory_bytes: 1916
// Created by sz
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int k,x;
    cin >> k >> x;
    if(k * 500 >= x){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
    
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < n;i++)

int main()
{
    int A, B;
    cin >> A >> B;
    if(A == B){
        cout << "Draw" << endl;
    }else if(A == 1){
        cout << "Alice" << endl;
    }else if(B == 1){
        cout << "Bob" << endl;
    }else{
        cout << (A > B ? "Alice" : "Bob") << endl;
    }
}

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

#if DEBUG && !ONLINE_JUDGE
    #include "header.h"
#else
    #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
    return;
}
int dp[101][100004];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    preprocess();
    int n, k; cin>>n>>k;
    vi ar(n);
    rep(i,1,n+1) cin>>ar[i];
    //sort(all(ar));
    memset(dp,0,sizeof dp);
    vi pre(k+2,1);
    dp[0][0] = 1;
    int l = 0;
    rep(i,1,n+1) {
        lli sum = 0;
        //pre[0] = 0;
        rep(j,0,k+1) {
            dp[i][j] = pre[j] - (j-ar[i]>0?pre[j-ar[i]-1]:0);
            dp[i][j] %= MOD;
        }
        pre[0] = dp[i][0];
        rep(j,1,k+1) {
            pre[j] = pre[j-1] + dp[i][j];
            pre[j] %= MOD;
        }
    }
    if(dp[n][k] < 0) dp[n][k] += MOD;
    cout<<dp[n][k]<<endl;
}



Measured memory_bytes: 40192
#include<stdio.h>
#define f(x) ((int)(i / 10000) + (int)(i / 1000) % 10 + (int)(i / 100) % 10 + (int)(i / 10) % 10 + i % 10)

int main(void){
  int max, l, h, result = 0;
  int i;

  scanf("%d %d %d", &max, &l, &h);

  for(i = 1; i <= max; i++){
    if(l <= f(i) && f(i) <= h){
      result += i;
    }
  }

  printf("%d\n", result);

  return 0;
}

Measured memory_bytes: 128
# li = [[0] * 4 for i in range(3)]

# A = list.map(int, input().split())

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

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

minn = 0
for i in range(N - 1):
    minn = max(minn, A[i + 1] - A[i])

minn = max(minn, A[0] + K - A[N - 1])

print(K - minn)


Measured memory_bytes: 26444
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N,L;cin >> N >> L;
    vector<int> apples(N);
    int sum = 0;
    rep(i,N){
        apples[i]=L+i;
    }
    int ex = 0;
    if(L+N>0&&L<=0)ex=0;
    else if(L+N>0&&L>0)ex=L;
    else ex=L+N-1;
    rep(i,N){
        if(apples[i]!=ex)sum+=apples[i];
    }
    cout << sum << endl;
    return 0;
}

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

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define st first
#define nd second

#define DMAX 
#define NMAX 
#define MMAX 

using namespace std;

int n, k;

template<class T>
ostream& operator<<(ostream& out, vector<T> v) {
	// out << v.size() << '\n';
	for(auto e : v) out << e << ' ';
	return out;
}

vector <int> ans;
int sum;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;


	if(n == 3) {
		cout << "2 5 63";
		return 0;
	}
	if(n == 4) {
		cout << "2 5 20 63";;
		return 0;
	}
	if(n == 5) {
		cout << "3 6 8 9 10";
		return 0;
	}


	for(int i = 1; i <= 30000; i++) {
		if(i % 2 == 0 || i % 3 == 0) {
			ans.push_back(i);
			sum += i;
			if(ans.size() == n + 2) break;
		}
	}

	if(ans.size() == n + 1) { //19999
		int nr = sum % 6;
		if(nr == 0)  nr = 6;
		dbg(nr);
		for(auto i : ans)
			if(i != nr)
				cout << i << ' ';
		return 0;
	}


	if(ans.size() == n + 2) { //19999
		int nr = sum % 6, nr1, nr2;
		// dbg(nr);
		nr1 = 6, nr2 = nr;
		if(nr == 0) 
			nr2 = 12;
		if(nr == 1) 
			nr1 = 3, nr2 = 4;
		if(nr == 5)
			nr1 = 2, nr2 = 3;

		for(auto i : ans)
			if(i != nr1 && i != nr2)
				cout << i << ' ';
		return 0;
	}

	cout << ans;
	// if(sum % )

}

Measured memory_bytes: 640
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  																						   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;	
const int mod = 1e9+7;																							   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int licznik1 = 0;
	int licznik2 = 0;
	int k;
	cin >> k;
	
	for(int i = 1; i <= k; i++){
		if(i % 2 == 0){
			licznik1++;
		}
		else licznik2++;
	}
						
	cout << licznik1 * licznik2 << endl;
						
	return 0;
}


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

int main()
{
  int N;
  string S;
  cin >> N >> S;
  for (int i = 0; i < S.size(); i++)
  {
    int a = S.at(i) - 'A';
    int b = (a + N) % 26;
    char c = 'A' + b;
    cout << c;
  }
  cout << endl;
}

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

typedef long long ll;

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
typedef pair<int,int> P;

int main(void){
    // Your code here!
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i],a[i] -= i+1;
    Sort(a);
    int b = a[n/2];
    ll ans = 0;
    rep(i,n) ans += abs(a[i]-b);
    cout << ans << endl;
}


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

using namespace std;

int mv[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};

int main(){
    int H,W,answer=0;
    cin >> H >> W;
    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin >> S[i];
    }

    for(int sy=0;sy<H;sy++){
        for(int sx=0;sx<W;sx++){
            if(S[sy][sx]=='#'){
                continue;
            }

            int ans[H][W] = {0};

            memset(ans,-1,sizeof(ans));

            ans[sy][sx] = 0;

            queue<pair<int,int>> Q;
            pair<int,int> P;
            P.first = sy;
            P.second = sx;
            Q.push(P);

            while(!Q.empty()){
                P = Q.front();
                Q.pop();
                //cout << P.first << P.second << endl;
                for(int i=0;i<4;i++){
                    if(P.first+mv[i][0]<H && 0<=P.first+mv[i][0] && P.second+mv[i][1]<W && 0<=P.second+mv[i][1] && ans[P.first+mv[i][0]][P.second+mv[i][1]]==-1 && S[P.first+mv[i][0]][P.second+mv[i][1]]!='#'){
                        ans[P.first+mv[i][0]][P.second+mv[i][1]] = ans[P.first][P.second]+1;
                        Q.emplace(P.first+mv[i][0],P.second+mv[i][1]);
                    }
                }
            }

            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    answer = max(answer,ans[i][j]);
                }
            }
        }
    }

    cout << answer << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int>L(N);
  int count = 0;
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  
  for (int i = 0; i < N-2; i++) {
    for (int j = i+1; j < N-1; j++) {
      for (int k = j+1; k < N; k++) {
        if (L.at(i)+L.at(j) > L.at(k) && L.at(i)+L.at(k) > L.at(j) && L.at(k)+L.at(j) > L.at(i)){
          if (L.at(i) != L.at(j) && L.at(i) != L.at(k) && L.at(k) != L.at(j)){
            count++;
          }
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3636
// Nguyen Anh Tu
#include <bits/stdc++.h>
#define FOR(x,a,b) for(int x=a;x<=b;x++)
#define FORD(x,a,b) for(int x=a;x>=b;x--)
#define maxn 100005
#define maxc 1000000007
#define MOD 1000000007
#define reset(x, y) memset(x,y,sizeof(x))
#define task ""
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define bit(p,x) ((x>>p) & 1)
#define remain(a,b) (a+b >= MOD) ? (a+b - MOD) : (a+b)
using namespace std;
string s;
int main()
{
    ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
    if(fopen(task".inp", "r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    cin >> s;
    for(auto x : s) if(x == '7') return cout << "Yes", 0;
    cout << "No";
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i< (n);i++)
#define rep1(i,n) for(int i=1;i<= (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

const static ll MOD = (1e+9)+7;

int main(){
    int n;cin>>n;
    vector<int> C(n-1),S(n-1),F(n-1);
    rep(i,n-1){
        int c,s,f;cin>>c>>s>>f;
        C[i]=c;S[i]=s;F[i]=f;
    }
    rep(i,n){
        int t = 0;
        for(int j = i;j<n-1;j++){
            if(t < S[j])t = S[j];
            else if(t%F[j]==0)t = t;
            else t = t+F[j] - t%F[j];
            t += C[j];
        }
        cout<<t<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
w,h=map(int, input().split())
p=[int(input()) for i in range(w)]
q=[int(input()) for i in range(h)]
p.append(0)
q.append(0)
p.sort()
p.reverse()
q.sort()
q.reverse()

count=w*h
row=0
line=0
i=0
j=0
ans=0

while count>0:
    if p[i]>=q[j]:
        ans+=p[i]*(h-line)

        count-=h-line
        i+=1
        row+=1

    else:
        ans+=q[j]*(w-row)

        count-=w-row
        j+=1
        line+=1
x=sum(p)*(h+1)+sum(q)*(w+1)
print(x-ans)

Measured memory_bytes: 61528
#include <stdio.h>
#include <stdlib.h>

int main() {
        int a, b, result;
  char op;
        while(1) {

                scanf("%d %c %d", &a, &op, &b);

                if (op == '?') {
                        break;
                }

                switch(op) {
                                case '+' :
                                                result = a + b;
                                                break;
                                case '-' :
                                                result = a - b;
                                                break;
                                case '*' :
                                                result = a * b;
                                                break;
                                case '/' :
                                                result = a / b;
                                                break;
                                default :
                                                break;

                }
                printf("%d\n", result);
        }
}



Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	
	vector<int> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	
	int ans = INT32_MAX;
	for (int l = 0; l <= n - k; l++)
	{
		int r = l + k - 1;
		ans = min(arr[r] - arr[l] + min(abs(arr[r]), abs(arr[l])), ans);
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

typedef long long ll;

using namespace std;


int pow(int n, int k){
	int res = 1;
	for(int i=0;i<k;i++){
		res *= n;
	}
	
	return res;
}

bool solve(){
	
	int num;
	cin>> num;
	
	int ans = 0;
	while(num/10 != 0){
		int tmp = num;
		int k=0;
		while(tmp!=0){
			tmp /= 10;
			k++;
		}
		int res = -1;
		for(int i=0;i<k-1;i++){
			int n = num;
			int a = n / pow(10,i+1);
			int b = n % pow(10,i+1);
			res = max(res, a*b);
		}
		num = res;
		ans++;
	}
	
	cout<< ans<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	int n;
	cin>> n;
	for(int i=0;i<n;i++) solve();

	return 0;
}

 

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
long long x[1000010],y[1000010];
#define int long long
signed main(){
  
  cin.tie(0);
  ios::sync_with_stdio(false);

  for(int i=0; i<3; i++) cin>>x[i];

  sort(x,x+3);
  if(x[0]==5 && x[1]==5 && x[2]==7) cout<<"YES"<<'\n';
  else cout<<"NO"<<'\n';
}


Measured memory_bytes: 2304
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int v = m * 1900 + (n - m) * 100;
		System.out.println(v * power(2, m));
	}
	
	public static int power(int x, int y) {
		if (y == 1) {
			return x;
		} else {
			return x * power(x, y - 1);
		}
	}
}


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

#define ALL(a) (a).begin(), (a).end()
#define debug(x) cerr<<#x<<":"<< (x)<<endl

// dp[i] := i本使って作れる数値の最大値(stringで持つ)
// 遷移
// dp[i] = max(dp[i], dp[i-cost[a[j]]] + a[j])

string dp[10101];
int cost[9]={2,5,5,4,5,6,3,7,6};

int main() {
	int n,m; cin>>n>>m;
	vector<int> a(m);
	for(int i=0;i<m;++i)cin>>a[i];
	sort(ALL(a));
	reverse(ALL(a));

	fill_n(dp,n,"0");
	dp[0]="";
	int sm=0;
	for(int i=0;i<=n;++i){
		for(auto &&ai: a){
			//cerr<<"fuge"<<endl;
			if (i-cost[ai-1]<0) continue;
			if (dp[i-cost[ai-1]]=="0") continue;
			//debug(i);
			//debug(ai);
			string tmp = to_string(ai) + dp[i-cost[ai-1]];
			//cerr<<"hoge"<<endl;
			//debug(cost[ai-1]);
			//cerr<<tmp<< endl<<endl;
			if(dp[i].size() > tmp.size()) continue;
			if(dp[i].size() == tmp.size()) {
				if(dp[i]>tmp) continue;
			}
			//cerr<<tmp<< endl;
			dp[i] = tmp;
			//cerr<<tmp<< endl;
		}
	}
	string ans = dp[n];
	sort(ALL(ans));
	reverse(ALL(ans));
	cout << ans << endl;
  return 0;
}



Measured memory_bytes: 32896
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

ll N, A, B, C;
vll l(20);

ll rec(ll a, ll b, ll c, ll depth)
{
        if (depth == N) {
                if (a == 0 or b == 0 or c == 0) return inf;
                else return abs(A-a) + abs(B-b) + abs(C-c) - 30;
        }

        vll tmp;
        tmp.push_back(rec(a+l[depth], b, c, depth+1) + 10);
        tmp.push_back(rec(a, b+l[depth], c, depth+1) + 10);
        tmp.push_back(rec(a, b, c+l[depth], depth+1) + 10);
        tmp.push_back(rec(a, b, c, depth+1));

        return *min_element(all(tmp));
}

int main()
{

        cin >> N >> A >> B >> C;
        rep(i, 0, N) cin >> l[i];

        cout << rec(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
 
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
#define pb push_back
int n, x, ban[2333];
int main(void) {
  read(n);
  rep (i, n) {
    int t; read(t); x ^= t;
    re0 (k, 31) if (t >> k & 1) {
      ban[k] = true;
      break;
    }
  }
  int ans = 0;
  for (int k = 31; ~k; k --)
    if (x >> k & 1) {
      if (!ban[k]) return puts("-1"), 0;
      ++ ans;
      for (int i = k; ~i; i --)
        x ^= 1<< i;
    }
  cout << ans << "\n";
    
}


Measured memory_bytes: 256