akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;

void maze_search(int H,int W,int sx,int sy,vector<vector<char>> maze, vector<vector<int>> &dist) {
	//壁は#で定義
	queue<pair<int, int>> position;
	dist[sy][sx] = 0;

	int dx[4] = { 0,-1,0,1 }, dy[4] = { 1,0,-1,0 };//探索方向

	position.push(make_pair(sy, sx));

	while (!position.empty()) {
		pair<int, int> current_pos = position.front(); 
		int x = current_pos.second;
		int y = current_pos.first;
		position.pop();
		for (int direction = 0; direction < 4; direction++) {
			int x_next = x + dx[direction];
			int y_next = y + dy[direction];
			if (x_next < 0 || x_next >= W || y_next < 0 || y_next >= H)continue;
			if (maze[y_next][x_next] == '#')continue;
			if (dist[y_next][x_next] == -1) {
				position.push(make_pair(y_next, x_next));
				dist[y_next][x_next] = dist[y][x] + 1;
			}
		}
	}
}

int main() {
	int H, W; cin >> H >> W;
	vector<vector<char>> maze(H,vector<char>(W));
	for (int i = 0; i < H; i++)for(int j=0;j<W;j++)cin >> maze[i][j];
	vector<vector<int>>dist(H, vector<int>(W, -1));
	int count_wall = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (maze[i][j] == '#')count_wall++;
		}
	}
	queue<pair<int, int>> position;
	dist[0][0] = 0;
	position.push(make_pair(0, 0));//start_positon

	maze_search(H, W, 0, 0, maze, dist);

	if (dist[H - 1][W - 1] == -1) {
		cout << "-1" << endl;
	}
	else {
		int ans = H * W - 1 - dist[H - 1][W - 1] - count_wall;
		cout << ans << endl;
	}
}

Measured memory_bytes: 3268
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1161&lang=jp

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

vector<int> coefficient;
vector<bool> is_top;

int dfs(int m, int depth, int used, int value) {
	if(depth == m) 
		return ((value == 0) ? 1 : 0);

	int ret = 0;
	rep(i, 10) { 
		if(is_top[depth] && i == 0) continue;
		if(used & (1 << i)) continue;
		ret += dfs(m, depth + 1, used | (1 << i), value + coefficient[depth] * i); 
	}
	return ret;
}

int main() {
	int n;
	while(cin >> n, n) {
		map<char, int> converter;
		
		// アルファベットの種類を数える
		vector<string> s(n, "");
		rep(i, n) {
			cin >> s[i];
			rep(j, s[i].size()) {
				if(!converter.count(s[i][j])) converter.insert(make_pair(s[i][j], converter.size()));
			}
		}

		// 各アルファベットの係数と先頭にあるかを求める
		int m = converter.size();
		coefficient.assign(m, 0);
		is_top.assign(m, false);
		rep(i, n) {
			for(int j = s[i].size() - 1, k = 1; j >= 0; --j, k *= 10) {
				int ctoi = converter[s[i][j]];
				if(j == 0 && s[i].size() > 1) is_top[ctoi] = true;
				coefficient[ctoi] +=  (i == n - 1) ? -k : k;
			}
		}
		
		// 覆面算が成り立つ式を満たす組み合わせを探索
		cout << dfs(m, 0, 0, 0) << endl;
	}
	return 0;
}

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

using namespace std;

int bit(int x){
  if(x)
    return -1;
  else
  	return 1; 
}

int main(){
    int N,M;
    cin >> N >> M;
    long long a[N],b[N],c[N],maxre=0;
    for(int i=0; i < N; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
  	for(int i=0;i<2;i++){
    	for(int j=0;j<2;j++){
      		for(int k=0;k<2;k++){
              	vector<long long>mm;
              	for(int l=0;l<N;l++){
              		mm.push_back(a[l]*bit(i) + b[l]*bit(j) + c[l]*bit(k));
                }
              	sort(mm.begin(),mm.end());
                long long re=0;
              	for(int i=0;i<M;i++){
                    re+=mm.back();
                    mm.pop_back();
                }
                maxre=max(maxre,re);
    		}
    	}
    }
	cout << maxre << endl;
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = 1e9;
  for (int k = 0; k <= max(x, y) * 2; k++) {
    int i = x - k / 2;
    int j = y - k / 2;
    if (i < 0) i = 0;
    if (j < 0) j = 0;
    ans = min(ans, a * i + b * j + c * k);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int x = sc.nextInt();
        int y = sc.nextInt();

        int rest;
        while(true){
            rest = x % y;
            if(rest == 0){
                System.out.println(y);
                break;
            }
            x = y;
            y = rest;
        }
        
    }
}


Measured memory_bytes: 26400
#include <iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
    vector<string>V = { "AC" ,"WA","TLE","RE" };
   
    int n, a = 0, w = 0, t = 0, r = 0; string S;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> S;
        
        
        if (S == V[0])
        {
            a++;
        }
        if (S == V[1])
        {
            w++;
        }
        if (S == V[2])
        {
            t++;
        }
        if (S == V[3])
        {
            r++;
        }
        
    }
    cout << V[0] << " x " << a << endl;
    cout << V[1] << " x " << w << endl;
    cout << V[2] << " x " << t << endl;
    cout << V[3] << " x " << r << endl;

}

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

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

int main() {
    int H, W;
    cin >> H >> W;
    vector <string> vec(H);
    string txt;
    for (int k = 0; k < H; ++k) {
        cin >> vec.at(k);
    }
    for (int i = 0; i < W+2; ++i) {
        txt += "#";
    }
    cout << txt << endl;
    for (int j = 0; j < H; ++j) {
        cout << "#" << vec.at(j) << "#" << endl; 
    }
    cout << txt << endl;
}



Measured memory_bytes: 256
//abc122_b.cpp
//Sat Mar 30 20:50:21 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int ans = 0;
	int flag = 0;
	int temp = 0;
	for (int i=0;i<s.length();i++){
		if (s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C'){
			temp++;
		}else {
			if (ans < temp){
				ans = temp;
			}
			temp = 0;
		}
	}

	if (ans < temp){
		ans = temp;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

int a[100005];

int main()
{
	char s[100005];
	while (~scanf("%s", s))
	{
		int i, c = 0;
		for (i = 1; s[i] != '\0'; i++)
		{
			if (s[i] != s[i - 1])
			c++;
		}
		printf("%d\n", c);
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<int,int>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

/* --------------------------------------- */
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s,t;
	cin >> s >> t;
	ll n = s.size();
	REP(i,n) {
		bool d = true;
		REP(j,n) {
			if(s[(i + j) % n] != t[j]) d = false;
		}
		if(d) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}
/* --------------------------------------- */


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

int main()
{
    int a, c=0;
    char s[200001], t[200001];

    cin>>s>>t;
    for(int i=0; i<strlen(s); i++)
    {
        if(s[i]!=t[i]) c++;

    }
    cout<<c<<endl;
    return 0;
}


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

using namespace std;

const int N = 100005;

int c[] = {100, 101, 102, 103, 104, 105};

bool pos[N];

int main() {
	
	int W;
	cin >> W;
	pos[0] = true;
	for (int x = 0; x <= W; x ++) {
		for (int k = 0; k < 6; k ++) {
			if (pos[x]) pos[x + c[k]] = true;
		}
	}
	cout << ((pos[W]) ? 1 : 0) << '\n';
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
 using namespace std;
int main()
{
	int n;
	string str;
	char c;
	cin>>str;
	n = str.length();
	for (int i = 0; i < n-1; i++) {
		c = str[i];
		if (c == str[i + 1]) {
			cout<<i + 1<<" "<<i + 2;
			return 0;
		}
		else if (c == str[i + 2]) {
			cout<<i + 1<<" "<<i + 3;
			return 0;
		}
	}
	cout<<-1<<" "<<-1<<endl;
	return 0;
}

Measured memory_bytes: 512
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;
 use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;

procedure main is
   X: Integer;
   Y: Integer;
   Z: Integer;
begin
   get(X);
   get(Y);
   get(Z);
   put(Z, 0);
   new_line;
   put(X, 0);
   new_line;
   put(Y, 0);
   new_line;
end main;

Measured memory_bytes: 3596
#include<iostream>

using namespace std;

void swap(int* x, int* y){
    *x += *y;
    *y = *x - *y;
    *x = *x - *y;
}

void trace(int A[], int n){
    cout << A[0];
    for (int i = 1; i < n; i++)
    {
        cout << " " << A[i];
    }
    cout << endl;
}
long long cnt;
void insertion_sort(int A[], int n, int g){
    for (int i = g; i < n; i++)
    {
        int v, j;
        v = A[i];
        j = i-g;
        while (j >= 0 && A[j] > v)
        {
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }

        A[j+g] = v;
    }

}

int G[105];
int make_G(int n){
    G[0] = 1;
    int i = 0, j = 0;
    while (n >= (3 * G[j] + 1) && j < 99)
    {
        G[j+1] = 3 * G[j] + 1;
        j++;
    }
    int m = j+1;
    while (i < j)
    {
        swap(&G[i], &G[j]);
        i++; 
        j--;
    }

    return m;
}

int shell_sort(int A[], int n){
    cnt = 0;
    int m = make_G(n);
    for (int i = 0; i < m; i++)
    {
        insertion_sort(A, n, G[i]);
    }

    return m;
}

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

    int m = shell_sort(A, n);
    cout << m << endl;
    trace(G, m);
    cout << cnt << endl;
    for (int i = 0; i < n; i++)
    {
        cout << A[i] << endl;
    }
    
}


Measured memory_bytes: 6976
#include<bits/stdc++.h>
    using namespace std;
    #define inp(k)           ll k;cin>>k;
    #define in2(n,k)       ll n, k; cin>>n;cin>>k;
    #define in3(n,k,r)       ll n, k,r; cin>>n;cin>>k;cin>>r;
    #define ll long long
    #define dl double
    #define ch char
    #define f(i,a,b) for(ll i=a;i<b;i++)
    #define rf(i,a,b) for(ll i=a-1;i>=b;i--)
    #define Godspeed                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define vpl vector< pair<ll,ll> >
    #define vpi vector< pair<int,int> >
    #define vi vector<int>
    #define vl vector<ll>
    #define vdl vector<dl>
    #define vch vector<char>
    #define pll pair<ll,ll>
    #define pb push_back
    #define mp make_pair
    #define fr first
    #define se second
    #define PI 3.14159265
    /*vl v[10005];
    ll cnt=0;
    ll a[51][51]={0};
    bool visited[10005]={0};
    void dfs(ll u)
    {
        visited[u]=1;
        f(i,0,v[u].size())
        {
            ll f=v[u][i];
            if(!visited[f])
            {
                dfs(f);
            }
        }
    }*/
    const int INF=1e9+5;
    void solve()
    {
        in2(n,k);ll a[n+1];f(i,1,n+1)cin>>a[i];
        ll dp[n+1];
        f(i,1,n+1)dp[i]=INF;dp[0]=0;dp[1]=0;dp[2]=abs(a[1]-a[2]);
        f(i,3,n+1)
        {
            f(j,1,k+1)
            {
                if(i-j>=1)
                dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
            }
        }
        cout<<dp[n];

    }

    int32_t main(void)
    {
        Godspeed;
        int q;
        q=1;
        //cin>>q;
        while (q--)
        {
            solve();cout<<endl;
        }
        return 0;
    }


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

int main(){
    int H, W;
    cin>>H>>W;
    int ch, cw, dh, dw;
    cin>>ch>>cw>>dh>>dw;
    ch--; cw--; dh--; dw--;
    string s[H];
    rep(i, H) cin>>s[i];

    deque<P> q;
    vector<vector<int>> dist(H, vector<int>(W, INF));
    int search[H][W];
    rep(i, H)rep(j, W) search[i][j]=0;
    dist[ch][cw]=0;
    search[ch][cw]=1;
    q.emplace_back(ch, cw);

    while(q.empty()==false){
        int x=q.front().first;
        int y=q.front().second;
        q.pop_front();
        //cost 0
        for(int i=-1; i<=1; i++){
            for(int j=-1; j<=1; j++){
                if(abs(i+j)!=1) continue;
                if(x+i<0) continue;
                if(y+j<0) continue;
                if(x+i>=H) continue;
                if(y+j>=W) continue;
                if(dist[x+i][y+j]<=dist[x][y]) continue;
                if(search[x+i][y+j]==0 && s[x+i][y+j]=='.'){
                    dist[x+i][y+j]=dist[x][y];
                    q.emplace_front(x+i, y+j);
                    search[x+i][y+j]=1;
                }
            }
        }

        //cost 1
        for(int i=-2; i<=2; i++){
            for(int j=-2; j<=2; j++){
                if(x+i<0) continue;
                if(y+j<0) continue;
                if(x+i>=H) continue;
                if(y+j>=W) continue;
                if(dist[x+i][y+j]<=dist[x][y]) continue;
                if(search[x+i][y+j]==0 && s[x+i][y+j]=='.'){
                    dist[x+i][y+j]=dist[x][y]+1;
                    q.emplace_back(x+i, y+j);
                }
            }
        }
    }
    int ans=dist[dh][dw];
    // rep(i, H){
    //     rep(j, W) cout<<dist[i][j]<<" ";
    //     cout<<endl;
    // }
    if(ans==INF) ans=-1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 14016
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;

int n;

int main(){
  cin>>n;
  if (n%2==0) cout<<"0.500000000";
  else{
    double kq=1.0*(n+1)/(2*n);
    cout<<fixed<<setprecision(10)<<kq;
  }
}


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

public class Solution
{
    public static int[] Solve(int days, long[] downs, long[][] scores)
    {
        return Enumerable.Repeat(1, days).ToArray();
    }

    public static void Main()
    {
        var days = int.Parse(Console.ReadLine());
        var downs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var scores = new long[days][];
        for (int i = 0; i < days; i++)
        {
            scores[i] = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        var answer = Solve(days, downs, scores);

        Console.WriteLine(string.Join(Environment.NewLine, answer));
    }
}

Measured memory_bytes: 29032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  int res = 0;
  REP(i, 1, n-1){
    string s1, s2;
    s1 = s.substr(0, i);
    s2 = s.substr(i, n-i);
    set<char> se1, se2;
    rep(j, s1.size()) se1.insert(s1[j]);
    rep(j, s2.size()) se2.insert(s2[j]);
    int cnt = 0;
    for(char c : se1) if(se2.count(c)) cnt++;
    chmax(res, cnt);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    S = input()
    ans = 0
    cnt = 0
    flag = False

    for i in range(len(S)):
        if S[i] in "ACGT":
            flag = True
            cnt += 1

        if S[i] not in "ACGT" or i == len(S) - 1:
            flag = False

        if flag == False and cnt > ans:
            ans = cnt
            cnt = 0

    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
    int N;
    cin >> N;
    int m = 0, a = 0, r = 0, c = 0, h = 0;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        if (s[0] == 'M') m++;
        else if (s[0] == 'A') a++;
        else if (s[0] == 'R') r++;
        else if (s[0] == 'C') c++;
        else if (s[0] == 'H') h++;
    }

    vector<int> nums{m, a, r, c, h};
    vector<bool> v{true, true, true, false, false};

    long long res = 0;
    do {
        long long patterns = 1;
        for (int i = 0; i < 5; i++) {
            if (v[i]) {
                patterns *= nums[i];
            }
        }
        res += patterns;
    } while (prev_permutation(v.begin(), v.end()));

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 764
import java.io.*;
import java.util.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int num=Integer.parseInt(br.readLine());
        int h=num/3600;
        num-=(h*3600);
        int m=num/60;
        num-=(m*60);
        System.out.println(h+":"+m+":"+num);
    }
}

Measured memory_bytes: 24152
sa = raw_input()
sb = raw_input()
sc = raw_input()

current_turn = 'a'

while True:
    if current_turn == 'a':
        if len(sa) == 0:
            print"A"
            break
        current_turn = sa[0]
        sa = sa[1:]
    elif current_turn == 'b':
        if len(sb) == 0:
            print"B"
            break
        current_turn = sb[0]
        sb = sb[1:]
    elif current_turn == 'c':
        if len(sc) == 0:
            print"C"
            break
        current_turn = sc[0]
        sc = sc[1:]

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

class FC{
public:
 int p[31];
 int n;

 bool is_over(){
  return p[1]==p[2] && p[2]==p[3] && p[3]==p[4] && p[4]==p[5] && p[5]==p[6] && p[6]==p[7] && p[7]==p[8] && p[8]==p[9] && p[10]==p[11] && p[11]==p[12] &&p[13]==p[14] && p[14]==p[15] && p[16]==p[17] && p[17]==p[18] && p[19]==p[20] && p[20]==p[21] && p[22]==p[23] && p[23]==p[24] && p[24]==p[25] && p[25]==p[26] && p[26]==p[27] && p[27]==p[28] && p[28]==p[29] && p[29]==p[30];
 }

 void rot1(){
  swap(p[7],p[22]); swap(p[8],p[23]); swap(p[9],p[24]); swap(p[13],p[18]);    swap(p[10],p[12]);
 }

 void rot2(){
  swap(p[1],p[28]); swap(p[2],p[29]); swap(p[3],p[30]); swap(p[15],p[16]);     swap(p[19],p[21]);
 }

 void rot3(){
  swap(p[1],p[24]); swap(p[4],p[27]); swap(p[7],p[30]); swap(p[10],p[21]);    swap(p[16],p[18]);
 }
 
 void rot4(){
  swap(p[3],p[22]); swap(p[6],p[25]); swap(p[9],p[28]); swap(p[12],p[19]);    swap(p[13],p[15]);
 }
};

int main(){
 int N;
 cin >> N;
 for(int i=0; i<N; i++){
  FC now;
  for(int j=1; j<=30; j++){
   cin >> now.p[j];
  }
  now.n = 0;

  queue<FC> que;
  que.push(now);
  
  while(!que.empty()){
   now = que.front();
   que.pop();
 
   if(now.is_over()){
    cout << now.n << endl; break;
   }

   FC nex1 = now; nex1.rot1(); nex1.n++; que.push(nex1);
   FC nex2 = now; nex2.rot2(); nex2.n++; que.push(nex2);
   FC nex3 = now; nex3.rot3(); nex3.n++; que.push(nex3);
   FC nex4 = now; nex4.rot4(); nex4.n++; que.push(nex4);

  }
 }

 return 0;
}

Measured memory_bytes: 13892
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int ans = b / a;
        if(ans > c){
            ans = c;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <cmath>
#include <algorithm>

int main()
{
	long long h, w;
	long long ans = 1000000000000000LL;

	std::cin >> h >> w;

	if (h % 3 == 0 || w % 3 == 0) {
		std::cout << 0 << std::endl;
		return 0;
	}

	for (int i = 1; i < h; i++ ) {
		long long a, b, c;
		a = i * (w / 2);
		b = i * std::ceil(w / 2.0);
		c = (h - i) * w;
		if (a < b) {
			std::swap(a, b);
		}
		if (b < c) {
			std::swap(b, c);
		}
		if (a < b) {
			std::swap(a, b);
		}
		ans = std::min(ans, a - c);
	}

	std::swap(h, w);
	
	for (int i = 1; i < h; i++ ) {
		long long a, b, c;
		a = i * (w / 2);
		b = i * std::ceil(w / 2.0);
		c = (h - i) * w;
		if (a < b) {
			std::swap(a, b);
		}
		if (b < c) {
			std::swap(b, c);
		}
		if (a < b) {
			std::swap(a, b);
		}
		ans = std::min(ans, a - c);
	}

	ans = std::min(w,ans);
	ans = std::min(h,ans);

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var d = new HashSet<long>();
            for (int i = 0; i < N; i++)
            {
                d.Add(ReadLong());
            }

            return d.Count;
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n, m, c;
    cin >> n >> m >> c;

    vector<int> b(m);
    for (int j = 0; j < m; j++) {
        cin >> b[j];
    }

    int r = 0;
    for (int i = 0; i < n; i++) {
        int s = c;
        for (int j = 0; j < m; j++) {
            int a;
            cin >> a;
            s += a * b[j];
        }
        if (s > 0) r++;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 100000007;
const int inf = 100000005;
const int N = 200005, M = N;
int i,j,n,m;

ll cnt , idx;
vi temp;



void solve() {
  ll n,m;
  cin>>n>>m;

  ll x;
  priority_queue<ll>pq;
  fo(i,0,n) cin>>x , pq.push(x);

  while(!pq.empty() && m) {
     ll k = pq.top();
     pq.pop();

     k/=2;
     m--;
     pq.push(k);
  }
    ll ans = 0;
  while(!pq.empty()) {
        ans+=pq.top();
        pq.pop();
  }

  cout<<ans<<"\n";

}

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

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




Measured memory_bytes: 4280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define INF 1e8
double pi = 2 * acos(0.0);
#define ALL(x) x.begin() , x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())


int main()
{
    vl c ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<c[k-1]<<"\n";
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import bisect

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

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
  
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
  
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

B = [[A[i], i] for i in range(n)]
B.sort()

L = Bit(n)
R = Bit(n)
ans = 0
for i in range(n):
    l = -1
    r = n+1
    m = (l+r)//2
    while r-l > 1:
        # print(L.sum(m) , i,l,r,m)
        if L.sum(m) < L.sum(B[i][1]+1):
            l = m
        else:
            r = m
        m = (l+r)//2
    # print(l)
    L.add(B[i][1]+1, 1)
    # print([L.sum(i+1)-L.sum(i) for i in range(n)])
    # print([L.sum(i+1) for i in range(n)])
    LL = l

    rr = n-1-B[i][1]
    l = -1
    r = n+1
    m = (l+r)//2
    while r-l > 1:
        # print(R.sum(m) , i,l,r,m)
        if R.sum(m) < R.sum(rr+1):
            l = m
        else:
            r = m
        m = (l+r)//2
    # print("R", l)
    R.add(n-1-B[i][1]+1, 1)
    # print([R.sum(i+1)-R.sum(i) for i in range(n)])
    RR = l

    ans += B[i][0] * (B[i][1]-LL) * ((n-1-RR)-B[i][1])
    # print("ans", ans)
print(ans)

Measured memory_bytes: 114860
#include<stdio.h>
#define N 500000

int A[N],B[N],count=0;

void Mergesort(int *A,int left,int right){

  int i,j,k,mid;
  if(right > left){

    mid=(right+left)/2;
    Mergesort(A,left,mid);
    Mergesort(A,mid+1,right);

    for(i=mid+1;i>left;i--)
      B[i-1] = A[i-1];

    for(j=mid; j<right; j++)
      B[right+mid-j]=A[j+1];

    for(k=left; k<=right; k++){
      A[k] = (B[i]< B[j])?B[i++]:B[j--];
      count++;
    }
  }
}
 
int main(void){
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  Mergesort(A,0,n-1);
  for(i=0;i<n-1;i++)
    printf("%d ",A[i]);
  printf("%d\n%d\n",A[n-1],count);
  return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n, x, t;
	cin >> n >> x >> t;
	int num = (n + x - 1) / x;
	cout << num * t << endl;
}


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

#define pb push_back
#define F first
#define S second
#define y1 dasdasfasfas
#define x1 wqdadfasfasfas
#define All(c) c.begin(), c.end()
#define SZ(A) (int((A).size()))
#define umap unordered_map
#define __ fflush(stdout)
#define FILENAME ""
#define move kek

typedef long long ll;
typedef long double ld;    

using namespace std;

void FREOPEN() {
	#ifdef LOCAL
		freopen(".in", "r", stdin);
		freopen("1.out", "w", stdout);
	#else
		//freopen(FILENAME".in", "r", stdin);
		//freopen(FILENAME".out", "w", stdout);
	#endif
}

inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }             

const int N = 200500, inf = 1e9 * 2;

const ll MOD = 1e9 + 7ll, INF = 1e18;

char CH[N];

const int dx[] = {1, -1, 0, 0, -1, 1, -1, 1};
const int dy[] = {0, 0, 1, -1, -1, 1, 1, -1};

int n, q;

int d[N];

string s;

char t[N];

bool check_lef(int p) {
	for (int i = 1; i <= q; i++) {
		if (t[i] == s[p - 1]) p += d[i];
		if (p < 1) return 1;
		if (p > n) return 0;
	}
	return 0;
}

bool check_rig(int p) {
	for (int i = 1; i <= q; i++) {
		if (t[i] == s[p - 1]) p += d[i];
		if (p < 1) return 0;
		if (p > n) return 1;
	}
	return 0;
}

int main() {
	FREOPEN();
	cin >> n >> q;
	scanf("\n%s", CH);
	s = CH;
	for (int i = 1; i <= q; i++) {
		char dir;
		scanf("\n%c %c", &t[i], &dir);
		if (dir == 'L') d[i] = -1;
		else d[i] = 1;
	}
	int l = 1, r = n;
	int left = 0;
	while (l <= r) {
		int mid = (l + r) / 2;
		if (check_lef(mid)) left = mid, l = mid + 1;
		else r = mid - 1; 
	} 
	l = 1, r = n;
	int right = n + 1;
	while (l <= r) {
		int mid = (l + r) / 2;
		if (check_rig(mid)) right = mid, r = mid - 1;
		else l = mid + 1; 
	}
	printf("%d ", max(0, right - left - 1));
	return 0;
}


Measured memory_bytes: 1664
def main():
    n = int(input())
    a = list(map(int, input().split()))
    max_val = pow(10, 18)
    if 0 in a:
        print(0)
    else:
        answer = 1
        for aa in a:
            answer *= aa
            if max_val < answer:
                print(-1)
                break
        else:
            print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 21704
#include <iostream>
#include <algorithm>
using namespace std;
int n, d[3003][3003], mod = 1000000007;
string s;
int main() {
    cin >> n >> s;
    for (int i = 1; i <= n; i++) d[1][i] = 1;
    for (int i = 2; i <= n; i++) {
        if (s[i - 2] == '<') {
            for (int j = 1; j <= n - i + 1; j++) {
                d[i][j] = (d[i][j - 1] + d[i - 1][j]) % mod;
            }
        } else {
            for (int j = n - i + 1; j; j--) {
                d[i][j] = (d[i][j + 1] + d[i - 1][j + 1]) % mod;
            }
        }
    }
    cout << d[n][1] << '\n';
}

/*
 
 */


Measured memory_bytes: 35200
#pragma region template 1.0
#pragma region def
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion enddef

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

    ll ans = INF;
    N %= K;
    REP(i, 1000)
    {
        N = abs(N - K);
        ans = min(ans, N);
    }
    OUT(ans);
}
#pragma endregion template

Measured memory_bytes: 256
import * as fs from 'fs';
const input = fs.readFileSync("/dev/stdin", "utf8").split('');

// B - バイナリハックイージー
let resultArray = new Array<string>();

input.forEach(x => {
    switch (x) {
        case '1':
            resultArray.push(x);
            break;
        case '0':
            resultArray.push(x);
            break;
        case 'B':
            resultArray.pop();
    }
});

let result = '';

resultArray.forEach(x => {
    result += x;
});

console.log(result);

Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => long.Parse(elem)).ToArray();
            var K = items[0];
            var N = items[1];
            var A = Console.ReadLine().Split().Select(elem => long.Parse(elem)).ToArray();
            var S = new List<long>();
            var sum = 0L;
            for (var i = 0L; i < N; i++)
            {
                sum += A[i];
                S.Add(sum);
            }

            var distance = long.MaxValue;
            for (var i = 0L; i < N; i++)
            {
                if (i == 0)
                {
                    var start = i;
                    var end = N - 1;
                    distance = Math.Min(distance, A[end] - A[start]);
                }
                else
                {
                    var start = i;
                    var end = i - 1;
                    distance = Math.Min(distance, K + A[end] - A[start]);
                }
            }

            Console.WriteLine(distance);
        }
    }
}


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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define MOD 1000000007
#define PI 3.14159265359
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;

void test()
{
	int n;
	cin>>n;

	int h[n+1];

	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
	}

	long dp[100002];

	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	// dp[3] = min(dp[2] + abs(h[3] - h[2]), dp[1] + abs(h[3] - h[1]));

	for(int i=3;i<=n;i++)
	{
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	}

	cout<<dp[n]<<endl;
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

// cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

Measured memory_bytes: 4716
import numpy as np
A, B,H,M = map(int,input().split())
time = H*60.0+M
long_w = 360.0/12/60
long_w = np.deg2rad(long_w)
short_w = 360.0/60
short_w =np.deg2rad(short_w)
long_x = A * np.cos(time*long_w)
long_y = A * np.sin(time*long_w)
short_x,short_y =B * np.cos(time*short_w),B * np.sin(time*short_w)
s = np.array([long_x, long_y])
t = np.array([short_x, short_y])
u = s-t
print(np.linalg.norm(u))

Measured memory_bytes: 27300
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

int memo[5][5][5][5];

int f(int a, int b, int c, int d) {
	if (a >= 5) a = 0;
	if (b >= 5) b = 0;
	if (c >= 5) c = 0;
	if (d >= 5) d = 0;
	if (a > b) swap(a, b);
	if (c > d) swap(c, d);
	int& ans = memo[a][b][c][d];
	if (ans) return ans;
	if (!b) return ans = 2;
	if (!d) return ans = 1;
	if (a && c && f(c + a, d, a, b) == 2) return ans = 1;
	if (b && c && f(c + b, d, a, b) == 2) return ans = 1;
	if (a && d && f(c, d + a, a, b) == 2) return ans = 1;
	if (b && d && f(c, d + b, a, b) == 2) return ans = 1;
	return ans = 2;
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = f(a, b, c, d);
	cout << (x == 1 ? "ISONO" : "NAKAJIMA") << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    vector <long long> v;
    map<string, int> n;
    double a,b,c,d=0,e=0,i,f=0,g=0,j,k=0,l=0,r=0,z,m,h,p;
    string y,t,s,x;
    double q,u;
    cin>>a>>b>>c>>d>>e;
    r=c*60+d-a*60-b;
    if(r<0){
        r+=1440;
    }
    cout<<max(r-e,k);
}

Measured memory_bytes: 3812
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)

vector<vector<int> >vvi;
vector<vector<vector<int> > >vvvi;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	
	int W,H,N;
	cin>>W>>H>>N;
	vvi=vector<vector<int> >(W,vector<int>(H,0));
	REP(i,N){
		int a,b,c;
		cin>>a>>b>>c;
		if(c==1){
			REP(j,a){
				REP(k,H)
					vvi[j][k]=1;
			}
		}
		else if(c==2){
			for(int j=a;j<W;j++){
				REP(k,H)
					vvi[j][k]=1;
			}
		}
		else if(c==3){
			REP(j,W){
				REP(k,b)
					vvi[j][k]=1;
			}
		}
		else{
			REP(j,W){
				for(int k=b;k<H;k++)
					vvi[j][k]=1;
			}
		}
	}
	int ans=0;
		REP(j,W){
			REP(k,H){
				if(vvi[j][k]==0) ans++;
			}
		}
	cout<<ans<<endl;
			
	return 0;
}

Measured memory_bytes: 892
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
bool flag[300001];
void sieve(){
	for(int i = 0;i <300001;i++){
		if((i%7==1)||(i%7==6)){
			flag[i] = true;
		}
		else flag[i] = false;
	}
	flag[1] = false;
	for(int i = 0;i <300001;i++){
		if(flag[i]){
			for(int j = i*2;j <300001;j+=i){
				flag[j] = false;
			}
		}
	}
}
int main(){
	sieve();
	while(cin>>n){
		if(n==1){
			break;
		}
		cout <<n<<":";
		for(int i = 1;i <=n;i++){
			if(flag[i]&&n%i==0)
				cout <<" "<<i;
		}
		cout <<endl;
	}
	return 0;
}

Measured memory_bytes: 1452
#include<stdio.h>
#define N 101
#define W 0
#define B 1
#define INF 2001
int n,a[N][N],d[N];

void mst(){
  int i,j;
  int u,v;
  int pi[N],c[N];
  int mincost;
  for(u=1;u<=n;u++){
    d[u]=INF;
    pi[u]=NULL;
    c[u]=W;
  }
  d[1]=0;
  for(i=1;i<=n;i++){
    mincost = INF;
    for(j=1;j<=n;j++){
      if(c[j]!=B&&d[j]<=mincost){
	u = j;
	mincost = d[j];
      }
    }
    for(v=1;v<=n;v++){
      if(a[u][v]!=-1&&c[v]!=B &&a[u][v]<d[v]){
	pi[v] = u;
	d[v] = a[u][v];
      }
    }
     c[u]=B;
  }
}

int main(){
  int i,j;
  int sum = 0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&a[i][j]);
    }
  }
  mst();
  for(i=1;i<=n;i++) sum += d[i];
  printf("%d\n",sum); 
  return 0;
}

Measured memory_bytes: 640
A, B, C, X, Y = map(int, input().split())

low = 100000*2*C

for i in range(100000):
    if (2*C*i + max(0, X-i)*A + max(0, Y-i)*B) < low:
        low = (2*C*i + max(0, X-i)*A + max(0, Y-i)*B)

print(low)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
	int a, b,x;
	cin >> a >> b;
	if ((a + b) % 2 == 0) {
		x = (a + b) / 2;
	}
	else {
		x = (a + b + 1) / 2;
	}
	cout << x << endl;
}

Measured memory_bytes: 256
k = int(input())
f = 7
r = f % k
r_10 = 10 % k
r_7 = 7 % k
n = pow(10, 6)
ans = False
if k % 2 == 0:
    print(-1)
else:
    for i in range(1, n+1):
        if r % k == 0:
            ans = True
            break
        r = (r*r_10 + r_7) % k

    if ans:
        print(i)
    else:
        print(-1)

Measured memory_bytes: 9192
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
typedef long long LL;

int main() {
  double N; cin >> N;
  int X, T; cin >> X >> T;
  int num = ceil(N/X);
  cout << num * T << endl;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int t[114],p[114],x[114];
signed main(){
	int n,m,ans=0;
	cin>>n;
	rep(i,n)cin>>t[i];
	cin>>m;
	rep(i,m)cin>>p[i]>>x[i];
	rep(i,m){
		rep(j,n){
			ans+=t[j];
		}
		cout<<ans-(t[p[i]-1]-x[i])<<endl;
		ans=0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>


using namespace std;

bool check(int low, int high, string& s)
{
  bool palin = true;
   while(low < high)
    {
       if(s[low] != s[high]) palin = false;
      ++low;
      --high;
    }
  return palin;
}

int main()
{
	string s; cin >> s;
	int n = s.length();
  	bool palin = check(0, n-1, s);
    int mid = n / 2;
    int low = 0;
    int high = mid - 1;
    palin = palin and check(low, high, s);
    low = mid + 1;
    high = n - 1;
    palin = palin and check(low, high, s);
	cout << (palin ? "Yes" : "No");

    return 0;
}


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

int main()
{
	long long n,m,d,t;
	bool b=true;
	map<long long, long long> ma;
	cin >> n;
	for (int i=0;i<n;++i) {
		cin >> d;
		ma[d]++;
	}
	cin >> m;
	for (int i=0;i<m;++i) {
		cin >> t;
		if (ma[t] == 0) b=false;
		ma[t]--;
	}
	if (!b) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 12800
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n,a,b;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>a>>b;
    ll temp=n/(a+b);
    ll temp1=min(a,n-temp*(a+b));
    cout << temp*a+temp1 << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
bool f[100001];
int c[100002];
int N, L, R;
int main()
{
    for (int i = 2; i <= 100000; i++)
        if (!f[i])
            for (int j = i + i; j <= 100000; j += i)
                f[j] = true;
    for (int i = 3; i <= 100000; i += 2)
        if (!f[i] && !f[(i + 1) / 2])
            c[i]++;
    for (int i = 3; i <= 100000; i++)
        c[i] += c[i - 1];
    scanf("%d", &N);
    while (N--)
    {
        scanf("%d%d", &L, &R);
        printf("%d\n", c[R] - c[L - 1]);
    }
}

Measured memory_bytes: 1024
import math
a,b,h,m=map(int,input().split())
def crad(x):
    return 2*math.pi*x/360%(2*math.pi)
ad=30*h+m/2
bd=6*m
ad=crad(ad)
bd=crad(bd)
sa=min(abs(ad-bd),abs(bd-ad))
print(math.sqrt((a**2+b**2-2*a*b*math.cos(sa))))

Measured memory_bytes: 9516
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  int n,x;
  cin >> n >> x;
  int m[n];

  int c = 0;
  int minimum = 1000000;
  FOR(i, 0, n){
    cin >> m[i];
    x -= m[i];
    c += 1;
    minimum = min(minimum, m[i]);
  }

  cout << c + (x/minimum) << endl;

  return 0;
}


Measured memory_bytes: 256
import heapq

N = int(input())
a_list = list(map(int, input().split()))

max_score = - float("inf")

red_list = a_list[:N]
blue_list = [-a for a in a_list[2 * N:]]
heapq.heapify(red_list)
heapq.heapify(blue_list)
red_sum = [sum(red_list)]
blue_sum = [sum(blue_list)]

for i in range(N, 2 * N):
    heapq.heappush(red_list, a_list[i])
    item = heapq.heappop(red_list)
    red_sum.append(red_sum[-1] + a_list[i] - item)

for i in range(2 * N - 1, N - 1, -1):
    heapq.heappush(blue_list, -a_list[i])
    item = heapq.heappop(blue_list)
    blue_sum.append(blue_sum[-1] - a_list[i] - item)

for i in range(N+1):
    score = red_sum[i] + blue_sum[-(i + 1)]
    if max_score < score:
        max_score = score
print(max_score)


Measured memory_bytes: 40340
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<cctype>
#include<sstream>
#include<stack>
using namespace std;
typedef long long ll;

int main()
{
    ll a;
    while(~scanf("%lld",&a)){
        ll b=a,sum=0;
        while(b){
            sum+=(b%10);
            b/=10;
        }
        if(a%sum==0) printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
//Betweenaandb.cpp (B)
#include <iostream>
using namespace std;

int main(){
  long long a,b,x,ans;
  cin >> a >> b >> x;
  if(a%x==0) ans = ((b-b%x) - (a-a%x))/x + 1;
  else ans = ((b-b%x) - (a+x-a%x))/x + 1;
  printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

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

    int N = S.length();
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] != S[N - i - 1]) ans++;
    }

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


Measured memory_bytes: 256