akhauriyash/Code-Regression huggingface dataset:
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    ll ar[401],dp[401][401],sum[401];
    
    ll func(int i,int j)
    {
        if(dp[i][j]!=-1)
            return dp[i][j];
        dp[i][j]=1e18;
        if(i==j)
            return dp[i][j]=0;
        for(int k=i;k<j;++k)
            dp[i][j]=min(dp[i][j],func(i,k)+func(k+1,j)+sum[j]-sum[i-1]);
        //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
        return dp[i][j];
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j;
            cin>>n;
            mem(dp,-1);
            for(i=1;i<=n;++i)
            {
                cin>>ar[i];
                sum[i]=sum[i-1]+ar[i];
            }
            cout<<func(1,n)<<endl;
        }
        return 0;
    }


Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

struct Edge {
  int to, money, cost;
  Edge(){}
  Edge(int to, int money, int cost) : to(to), money(money), cost(cost){}
};

signed main() {
  int N, M, S;
  cin >> N >> M >> S;

  vector<vector<Edge>> graph(N);
  REP(i, M){
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    graph[u].emplace_back(v, a, b);
    graph[v].emplace_back(u, a, b);
  }

  vector<int> c(N), d(N);
  REP(i, N) cin >> c[i] >> d[i];

  int MAX = N*50;
  chmin(S, MAX);

  vector<vector<int>> dp(N, vector<int>(MAX+1, INF));
  dp[0][S] = 0;

  using P = pair<int, int>;
  using PP = pair<int, P>;
  priority_queue<PP, vector<PP>, greater<PP>> q;
  q.push({0, {0, S}});

  while(!q.empty()){
    auto p = q.top(); q.pop();
    int time = p.first;
    int v = p.second.first;
    int s = p.second.second;
    if(time > dp[v][s]) continue;

    if(s+c[v] <= MAX){
      if(chmin(dp[v][s+c[v]], time+d[v])){
        q.push({time+d[v], {v, s+c[v]}});
      }
    }

    for(auto e : graph[v]){
      if(s-e.money >= 0) if(chmin(dp[e.to][s-e.money], time+e.cost)){
        q.push({time+e.cost, {e.to, s-e.money}});
      }
    }
  }

  FOR(i, 1, N){
    int ret = INF;
    REP(j, MAX) chmin(ret, dp[i][j]);
    cout << ret << "\n";
  }

  return 0;
}

Measured memory_bytes: 7216
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

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

    int ans = 0;
    for (int r = 0; R*r <= n; ++r) {
        for (int g = 0; R*r+G*g <= n; ++g) {
            if ((n - R*r - G*g) % B == 0) ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
L = gets.split.map(&:to_i)

puts L.combination(3).count { |a, b, c|
  cond1 = a != b && a != c && b != c
  a, b, c = [a, b, c].sort
  cond2 = (a + b) > c
  cond1 && cond2
}


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

int main() {
  long long N;
  cin >> N;
  vector<long long> a(N);
  for (long long i=0;i<N;i++) {
    cin >> a.at(i);
  }
  
  long long back=0,same=1,magic=0;
  for (long long i=0;i<N;i++) {
    if (a.at(i)==back) {
      same++;
    }
    else {
      same=1;
    }
    
    if (same>0 && same%2==0) {
      magic++;
    }
    back = a.at(i);
  }
  
  cout << magic << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define szxb 14
#define F find
/*#define L length()
#define S(a,b) substr(((a.L)-(b)),(b))
using namespace std;
string s;
signed main()
{
	getline(cin,s);
	puts((((s.S(s,5)=="dream")||(s.S(s,6)=="dreamer")||(s.S(s,5)=="erase")||(s.S(s,6)=="eraser"))?("YES"):("NO")));
	return 0;
}*/
using namespace std;
string s,a[szxb]={"maerd","remaerd","esare","resare"};
signed main()
{
	getline(cin,s);string t("");bool flag(1);
	for(register int i(0);i^s.length();i++)
	{
		t+=s[s.length()-i-1];
		if((!(a[0].F(t)))&&(!(a[1].F(t)))&&(!(a[2].F(t)))&&(!(a[3].F(t)))){flag=0;goto endreturn;}
		if((t==a[0])||(t==a[1])||(t==a[2])||(t==a[3])){t="";}
	}
	flag=(t=="");
	endreturn:puts(((flag)?("YES"):("NO")));return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mapp[350][350];
ll dp1[350][350];
ll dp2[350][350];
int n;
bool flag;
int main()
{
    cin>>n;
    flag=true;
    ll tot=0;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            cin>>mapp[i][j];
            dp1[i][j]=mapp[i][j];
            dp2[i][j]=mapp[i][j];
            tot+=mapp[i][j];
        }
    }
    tot/=2;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=i; j++)
        {
            if(i==j&&mapp[i][j]!=0)
            {
                flag=false;
                break;
            }
            else
            {
                if(mapp[i][j]!=mapp[j][i])
                {
                    flag=false;
                    break;
                }
            }
        }
        if(!flag)
            break;
    }
    ll ans=0;
    for(int i=1; i<=n; i++)
    {
        for(int j=i+1; j<=n; j++)
        {
            for(int k=1; k<=n; k++)
            {
                dp1[i][j]=min(dp1[i][k]+dp1[k][j],dp1[i][j]);
                //dp2[i][j]=max(dp2[i][k]+dp2[k][j],dp2[i][j]);
                //ans=max(ans,dp2[i][j]);
                //cout << dp1[i][j] <<endl;
                //cout << i << " " << k << " " << j << endl;
                //cout << dp1[i][k] << " " << dp1[k][j] << endl;
                //cout << dp2[i][j] <<endl;
                //cout <<endl;
            }
        }
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=i+1; j<=n; j++)
        {
            //cout << i <<  " " << j << endl;
            //cout << dp1[i][j] <<endl;
            if(dp1[i][j]<mapp[i][j])
            {
                flag=false;
                break;
            }
        }
        if(!flag)
            break;
    }
    //cout<< tot << endl;
    if(flag)
    {
        for(int i=1; i<=n; i++)
        {
            for(int j=i; j<=n; j++)
            {
                for(int k=1; k<=n; k++)
                {
                    if(k!=i&&k!=j&&mapp[i][j]==mapp[i][k]+mapp[k][j])
                    {
                        tot-=mapp[i][j];
                        break;
                    }
                }
            }
        }
        ans=tot;
        cout << ans << endl;
    }
    else
        cout << -1 << endl;
    //cout << "Hello world!" << endl;
    return 0;
}
/*
3
0 1 3
1 0 2
3 2 0
*/
/*
5
0 21 18 11 28
21 0 13 10 26
18 13 0 23 13
11 10 23 0 17
28 26 13 17 0
*/
/*
3
0 1000000000 1000000000
1000000000 0 1000000000
1000000000 1000000000 0
*/


Measured memory_bytes: 2304
import sys
input = sys.stdin.readline
import collections


def main():
    N = int(input())
    A = list(map(int, input().split()))
    v_freq = collections.Counter(A)
    v_sum = 0
    for v, freq in v_freq.items():
        v_sum += v * freq
    Q = int(input())
    for _ in range(Q):
        B, C = map(int, input().split())
        if B in v_freq:
            v_sum -= (B - C) * v_freq[B]
            if C in v_freq:
                v_freq[C] += v_freq[B]
            else:
                v_freq[C] = v_freq[B]
            del v_freq[B]
            print(v_sum)
        else:
            print(v_sum)


if __name__ == '__main__':
    main()


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

int main()
{
    long long n,m;
    cin>>n>>m;
    long long  p =(n*m);
    if(n==1||m==1)cout<<1<<endl;
   else if(p%2==0)cout<<p/2<<endl;
    else cout<<(p/2)+1<<endl;
}


Measured memory_bytes: 256
using System;

namespace AOJ0501
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                int N = int.Parse(input);
                if (N == 0)
                {
                    return;
                }
                char[] before_list = new char[N];
                char[] after_list = new char[N];

                for (int i = 0; i < N; i++)
                {
                    input = Console.ReadLine();
                    string[] tmp = input.Split(' ');
                    before_list[i] = char.Parse(tmp[0]);
                    after_list[i] = char.Parse(tmp[1]);
                }

                input = Console.ReadLine();
                int M = int.Parse(input);
                if (M == 0)
                {
                    continue;
                }
                char[] sentence = new char[M];

                for (int i = 0; i < M; i++)
                {
                    sentence[i] = char.Parse(Console.ReadLine());
                    for (int j = 0; j < N; j++)
                    {
                        if (sentence[i] == before_list[j])
                        {
                            sentence[i] = after_list[j];
                            break;
                        }
                    }
                }

                Console.WriteLine(new String(sentence));
            }
        }
    }
}

Measured memory_bytes: 9404
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
int a[5];
int main()
{
  int t=1;
  //cin>>t;
  while(t--)
  {
     string s,t,ans;
     int i,n,j;
     cin>>n;
     cin>>s>>t;
     for(i=0;i<n;i++)
     {
      cout<<s[i]<<t[i];
     }
  } 
  cout<<endl;
 
  return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>


const int toll[][8] = {
    {0, 300, 500, 600, 700, 1350, 1650},
    {300, 0, 350, 450, 600, 1150, 1500},
    {500, 350, 0, 250, 400, 1000, 1350},
    {600, 450, 250, 0, 250, 850, 1300},
    {700, 600, 400, 250, 0, 600, 1150},
    {1350, 1150, 1000, 850, 600, 0, 500},
    {1650, 1500, 1350, 1300, 1150, 500, 0}
};

const int dist[][8] = {
    {0, 6, 13, 18, 23, 43, 58},
    {6, 0, 7, 12, 17, 37, 52},
    {13, 7, 0, 5, 10, 30, 45},
    {18, 12, 5, 0, 5, 25, 40},
    {23, 17, 10, 5, 0, 20, 35},
    {43, 37, 30, 25, 20, 0, 15},
    {58, 52, 45, 40, 35, 15, 0}
};

int main(void) {
    int sic, sh, sm, gic, gh, gm, t, st, gt;

    while (scanf("%d", &sic) == 1 && sic) {
        scanf("%d%d", &sh, &sm);
        scanf("%d", &gic);
        scanf("%d%d", &gh, &gm);

        t = toll[sic-1][gic-1];
        st = sh * 100 + sm;
        gt = gh * 100 + gm; 
        if (((1730 <= st && st <= 1930) ||
             (1730 <= gt && gt <= 1930)) &&
            dist[sic-1][gic-1] <= 40) {
            t = ((t / 100) + (t % 100 > 0)) * 50;
        }
        printf("%d\n", t);
    }
    return 0;
}

Measured memory_bytes: 600
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    # key[i]:10進数でiを開けれる鍵の値段
    key = []
    for _ in range(m):
        a,b = map(int, input().split())
        c = list(map(int, input().split()))
        binary = 0
        for i in c:
            binary += 2**(i-1)
        key.append((binary, a))

    # dp[i]:10進数で宝iを開けてる時の最小値段
    dp = [inf]*(1<<n)
    dp[0] = 0
    for i, a in key:
        for s in range(1<<n):
            if (i|s) == s:
                continue
            dp[i|s] = min(dp[i|s], dp[s]+a)
    print(dp[-1] if dp[-1] != inf else -1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42716
#include<stdio.h>
#define N 10000

int main(void){
  int i,num;
  double q,nq,x[N];

  for(i=0;;i++){
    scanf("%lf",&q);
    if(q==-1)
      break;
    nq=q/2;
    for(;;){
      nq=nq-(nq*nq*nq-q)/(3*nq*nq);
      if((-q/100000<(nq*nq*nq-q)) &&
          (q/100000>(nq*nq*nq-q)))
        break;
    }
    x[i]=nq;
  }
  num=i;
  for(i=0;i<num;i++){
    printf("%0.6f\n",x[i]);
  }
  return 0;
}

Measured memory_bytes: 0
s = input()

ans1 = 0
ans2 = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            ans1 += 1
        else:
            ans2 += 1
    if i % 2 == 1:
        if s[i] == '0':
            ans2 += 1
        else:
            ans1 += 1
print(min(ans1, ans2))

Measured memory_bytes: 39740
#include<bits/stdc++.h>
#define reg register
#define ll long long
#define inf 0x3f3f3f3f
#define iinf 0x3f3f3f3f3f3f3f3fll
using namespace std;
int n;
char op; 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	string s;
	cin>>s;
	for(reg int i=0;i<s.length();i++)
	{
		if(s[i]=='+')n++;
		else n--;
	}
	cout<<n<<endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a.at(i);
	}
	int sum =0;
	for (int i = 0; i < n; ++i)
	{
		sum = sum+a.at(i);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	int b = sum/(4*m);

	int count;
	if(sum%4*m==0){
	for (int i = 0; i < n; ++i)
	{
		if(a.at(i)>=b){
			count++;
		}
		else{
			break;
		}
	}
	}
	else{
		for (int i = 0; i < n; ++i)
		{
			if(a.at(i)>b){
				count++;
			}
			else{
				break;
			}
		}
	}

	if(count>=m){
	    cout << "Yes" << endl;
	}
	else{
	    cout << "No" << endl;
	}
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	sl := make([]map[int]int, n)

	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		sl[i] = map[int]int{}
		for j := 0; j < a; j++ {
			var x, y int
			fmt.Scan(&x, &y)
			sl[i][x-1] = y
		}
	}

	var max int
	for bit := 0; bit < (1 << uint(n)); bit++ {
		correct := true
		for i := 0; i < n; i++ {
			if (bit>>uint(i))&1 == 1 {
				for k, v := range sl[i] {
					if v^((bit>>uint(k))&1) == 1 {
						correct = false
						break
					}
				}
			}
		}
		if correct {
			cnt := onesCount(bit)
			if cnt > max {
				max = cnt
			}

		}

	}
	fmt.Println(max)
}

func onesCount(bit int) int {
	var num int
	for ; bit != 0; bit &= bit - 1 {
		num++
	}
	return num
}


Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;

int N,M,S;

typedef long long int ll;
typedef pair<int,int> state;//vertex coins

const ll INF=1e16;

vector<int> graph[55];
pair<ll,ll> moveCost[55][55];
pair<ll,ll> exchangeCost[55];

int Amax=0;
ll  minimalTimeTo[55][2600];
bool visited[55][2600];
ll ans[55];

typedef pair<ll,state> edge_t;
typedef priority_queue<edge_t,vector<edge_t>,greater<edge_t>> min_heap;

void dij(){
    int limit=Amax*(N-1);
    min_heap q;
    q.push(pair<ll,state>(0,state(1,min(S,limit))));

    while (!q.empty()){
        auto head=q.top().second;//vert coins
        auto dist=q.top().first;
        q.pop();

        auto &hasVisited=visited[head.first][head.second];
        if (hasVisited) continue;
        // printf("cost=%lld vert=%d coins=%d\n",dist,head.first,head.second);
        hasVisited=true;

        minimalTimeTo[head.first][head.second]=min(minimalTimeTo[head.first][head.second],dist);

        ans[head.first]=min(ans[head.first],dist);
        for(auto adj:graph[head.first]){
            auto &costToAdj=moveCost[head.first][adj];
            if (head.second<costToAdj.first) continue;
            q.push(pair<ll,state>(dist+costToAdj.second,state(adj,head.second-costToAdj.first)));
        }

        auto &exCost=exchangeCost[head.first];
        q.push(
            pair<ll,state>(dist+exCost.second,
            state(head.first,
                min((ll)limit,head.second+exCost.first))
            )
        );

    }

}

int main(){
    scanf("%d%d%d",&N,&M,&S);

    for(int i=1;i<=M;i++){
        int s,e,A;
        ll B;
        scanf("%d%d%d%lld",&s,&e,&A,&B);
        graph[s].push_back(e);
        graph[e].push_back(s);
        moveCost[s][e].first=A;
        moveCost[s][e].second=B;
        moveCost[e][s].first=A;
        moveCost[e][s].second=B;
        Amax=max(Amax,A);
    }

    for(int i=1;i<=N;i++){
        ll C,D;
        scanf("%lld%lld",&C,&D);
        exchangeCost[i].first=C;
        exchangeCost[i].second=D;
        ans[i]=INF;
    }

    dij();

    for(int v=2;v<=N;v++) printf("%lld\n",ans[v]);

    return 0;
}

Measured memory_bytes: 8108
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int[] a = new int[n];
        int c = 0;
        for(int i=0; i<n; i++)
        {
            a[i] = s.nextInt();
            if(a[i]%2==0)
                c++;
        }
        int ch=0;
        for(int i=0; i<n; i++)
        {
            if(a[i]%2==0)
            {
                if(a[i]%3==0||a[i]%5==0)
                {
                    ch++;
                }
            }
        }
        if(ch==c)
        {
            System.out.println("APPROVED");
        }
        else System.out.println("DENIED");
        }
    }

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(2000010);

int main(){
    ll S;
    cin >> S;
    ll N = S/3;
    mint ans = 0;
    if(N == 0){
        cout << 0 << endl;
        return 0;
    }
    REP(i,1,N+1){
        ll r = S - 3*i;
        ans += comb(i+r-1,r);
    }
    cout << ans << endl;
}

Measured memory_bytes: 34216
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<algorithm>
#include<iostream>
#include<bitset>
#include<functional>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<random>
#include<ctime>
#include<complex>
using namespace std;
typedef long long LL;
mt19937 gene(233);
typedef complex<double> Complex;
#define fi first
#define se second
#define ins insert
#define pb push_back
inline char GET_CHAR(){
	const int maxn = 131072;
	static char buf[maxn],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++;
}
inline int getInt() {
	int res(0);
	char c = getchar();
	while(c < '0') c = getchar();
	while(c >= '0') {
		res = res * 10 + (c - '0');
		c = getchar();
	}
	return res;
}

inline LL fastpo(LL x, LL n, LL mod) {
	LL res(1);
	while(n) {
		if(n & 1) {
			res = res * (LL)x % mod;
		}
		x = x * (LL) x % mod;
		n /= 2;
	}
	return res;
}

inline string itoa(int x, int width = 0) {
  string res;
  if(x == 0) res.push_back('0');
  while(x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}
template<const LL mod> struct MI{
	LL a;
	MI operator + (const MI & b) {
		MI res{a + b.a};
		if(res.a >= mod) res.a -= mod;
		return res;
	}
	MI operator - (const MI & b) {
		MI res{a - b.a};
		if(res.a <= 0) res.a += mod;
		return res;
	}
	MI operator * (const MI & b) {
		return MI{a * b.a % mod};
	}
	MI operator / (const MI & b) {
		return MI{a * fastpo(b.a, mod - 2, mod) % mod};
	}
};
const int N = 300033;
const int LOG = 20;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int n, m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
	cin >> n >> m;
  cout << n * m << endl;
}






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

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

  int a[n][m], b[m][l];
  rep(i, n)
    rep(j, m) cin >> a[i][j];
  rep(i, m)
    rep(j, l) cin >> b[i][j];

  rep(i, n) {
    rep(j, l) {
      long c = 0;
      rep(k, m) {
	c += a[i][k] * b[k][j];
      }
      cout << c;
      if(j != l-1) cout << " ";
    }
    cout << endl;
  }

  // rep(i, n) {
  //   rep(j, l) {
  //     c =
  
  return 0;
}



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

int main(){
    int w,h,x,y,r;

    cin >> w >> h >> x >> y >> r;

    if( x - r < 0 || x + r > w || y - r < 0 || y + r > h){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}



Measured memory_bytes: 3116
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    long long N,H,W;cin >> N >> H >> W;
    int ans = 0;
    for(int i = 0;i<N;i++){
        long long a,b; cin >> a >> b;
        if(a >= H && b >= W) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1<<18;
int a[maxn];
int rec(int l, int r){
	if(l == r) return a[l];
	int mid = (l + r) >> 1;
	int x = rec(l, mid);
	int y = rec(mid + 1, r);
	if(x > y) return x - y;
	if(x == y) return x;
	if(x < y) return y - x;
	return -1;
}
int main(){
	int n; cin >> n;
	for(int i = 0; i < 1<<n; i++) cin >> a[i];
	cout << rec(0, (1<<n) - 1) << endl;
	return 0;
}


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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int main(){
  int K,N;
  int i,j;
  int max=0;
  
  scanf("%d %d",&K,&N);
  
  int A[N+1];
  int X[N+1];
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<N-1;i++){
    X[i] = A[i+1] - A[i];
  }
  X[i] = K-A[i]+A[0];
  
  for(i=0;i<N;i++){
    if(max < X[i]) max=X[i];
  }
  
  printf("%d\n",K-max);
  
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define LL long long
#define pii pair<int,int>
#define MEM(x) memset(x,0,sizeof(x))
using namespace std;
int X[4]={0,0,1,-1};
int Y[4]={1,-1,0,0};
int dis[1005][1005];
int vis[1005][1005];
char c[1005][1005];
void solve(){
    int h,w;
    scanf("%d %d",&h,&w);
    pii s,t;
    scanf("%d %d %d %d",&s.x,&s.y,&t.x,&t.y);
    for(int i = 1;i<=h;i++)scanf("%s",c[i]+1);
    deque<pii> q;
    q.pb(s);
    for(int i = 1;i<=h;i++){
        for(int j =1;j<=w;j++)dis[i][j]=1e9;
    }
    dis[s.x][s.y]=0;
    while(!q.empty()){
        pii p=q.front();
        q.pop_front();
        if(vis[p.x][p.y])continue;
        vis[p.x][p.y]=1;
      //  printf("%d %d\n",p.x,p.y);
        for(int i = 0;i<4;i++){
            int x=p.x+X[i],y=p.y+Y[i];
          //  printf("%d %d %d \n",x,y);
            if(x>=1&&x<=h&&y>=1&&y<=w&&c[x][y]=='.'&&dis[x][y]>dis[p.x][p.y]) {
                dis[x][y]=dis[p.x][p.y];
                q.push_front(mp(x,y));
            }
        }
        for(int i = -2;i<=2;i++){
            for(int j = -2;j<=2;j++){
                int x=p.x+i,y=p.y+j;
                if(x>=1&&x<=h&&y>=1&&y<=w&&c[x][y]=='.'&&dis[x][y]>dis[p.x][p.y]+1) {
                    dis[x][y]=dis[p.x][p.y]+1;
                    q.pb(mp(x,y));
                }
            }
        }
    }
    if(dis[t.x][t.y]==1e9)dis[t.x][t.y]=-1;
    printf("%d\n",dis[t.x][t.y]);
}
int main()
{
    int t=1;
    //scanf("%d",&t);
    int T=1;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 12644
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;
 
 
int main() {
    long long n, max1 = 0, max2 = 0, ans = 0;
    cin >> n;
    vector<long> as(n);
    vector<long> bs(n - 1);
    for (int i = 0; i < n - 1; i++){
        cin >> bs[i];
    }
    as[0] = bs[0];
    for (int i = 1; i < n - 1; i++){
        as[i] = min(bs[i - 1], bs[i]);
    }
    as[n - 1] = bs[n - 2];
    for (int i = 0; i < n; i++){
        ans += as[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def warshall_floyd(n, dists):
    prev = [t.copy() for t in dists]

    for k in range(n):
        current = [t.copy() for t in prev]
        prev_k = prev[k]
        for i in range(n):
            prev_i, current_i = prev[i], current[i]
            prev_i_k = prev_i[k]
            for j in range(n):
                current_i[j] = min(prev_i[j], prev_i_k + prev_k[j])
        prev = current

    return prev


def solve(n, links, total_d, odd_vertices):
    if not odd_vertices:
        return total_d

    d_table = warshall_floyd(n, links)
    d_table = [[d for oj, d in enumerate(d_table[oi]) if oj in odd_vertices] for ni, oi in enumerate(odd_vertices)]
    ndt = len(d_table)
    bit_dict = {1 << i: i for i in range(ndt)}

    def minimum_pair(remains):
        if not remains:
            return 0
        b = remains & -remains
        remains ^= b
        i = bit_dict[b]
        return min(minimum_pair(remains ^ (1 << j)) + d_table[i][j] for j in range(ndt) if remains & (1 << j))

    return total_d + minimum_pair((1 << ndt) - 1)


v, e = map(int, input().split())

dists = [[float('inf')] * v for _ in range(v)]
for i in range(v):
    dists[i][i] = 0
odd_vertices = [0] * v
total_d = 0

for _ in range(e):
    s, t, d = map(int, input().split())
    dists[s][t] = min(dists[s][t], d)
    dists[t][s] = min(dists[t][s], d)
    odd_vertices[s] ^= 1
    odd_vertices[t] ^= 1
    total_d += d

print(solve(v, dists, total_d, [i for i, v in enumerate(odd_vertices) if v]))

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

using namespace std;

const int N = 2e5 + 100;
const int Mod = 998244353;

int n, k;
int Dp[N];
int BIT[N];
vector <pair<int, int>> ranges;

void update(int idx, int val = 1) {
	idx++;
	while (idx <= n + 1) {
		BIT[idx] = (BIT[idx] + val) % Mod;
		idx += (idx & -idx);
	}
}

int query(int idx) {
	idx++;
	int res = 0;
	while (idx > 0) {
		res = (res + BIT[idx]) % Mod;
		idx -= (idx & -idx);
	}
	return res;
}

int query(int L, int R) {
	if (L > R)
		return 0;
	return (query(R) - query(L - 1) + Mod) % Mod; 
}

int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 0; i < k; i++) {
		int L, R;	scanf("%d%d", &L, &R);
		ranges.emplace_back(L, R);
	}

	Dp[n] = 1;
	update(n);
	for (int cell = n - 1; cell >= 1; cell--) {
		for (auto [L, R] : ranges) 
			Dp[cell] = (Dp[cell] + query(cell + L, min(n, cell + R))) % Mod;
		
		update(cell, Dp[cell]);
	}

	printf("%d\n", Dp[1]);
	return 0;
}


Measured memory_bytes: 5340
#include <iostream>
#include <string.h>

#define MAX_LINE 8
#define MAXA_DATA 50

using namespace std;

// プロトタイプ宣言
void searchString(string box);

int main() {
    int i, count = 0;
    int max = MAX_LINE * MAXA_DATA;
    char str[8];
    string box;
    for (i=0; i<max; i++) {
        cin >> str;
        box.append(str);
        //cout << str << endl;
        count++;
        if(count%8 == 0){
            //cout << box << endl << endl;
            // 文字列チェック
            searchString(box);
            box = "";
        }
        if((string)str == "finish"){
            break;
        }
    }
}

void searchString(string box){
    string A("1100000011");
    string B("1000000010000000100000001");
    string C("1111");
    string D("1000000110000001");
    string E("11000000011");
    string F("100000001100000001");
    string G("110000011");
    if (box.find(A) != std::string::npos) {
        cout << "A" << endl;
    }
    else if(box.find(B) != std::string::npos) {
        cout << "B" << endl;
    }
    else if(box.find(C) != std::string::npos) {
        cout << "C" << endl;
    }
    else if(box.find(D) != std::string::npos) {
        cout << "D" << endl;
    }
    else if(box.find(E) != std::string::npos) {
        cout << "E" << endl;
    }
    else if(box.find(F) != std::string::npos) {
        cout << "F" << endl;
    }
    else if(box.find(G) != std::string::npos) {
        cout << "G" << endl;
    }
}


Measured memory_bytes: 3000
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
using namespace std;
vector<bool> era(1000010, true);
void makePrimeTable(int n)
{
	era[0] = false; era[1] = false;
	for (int i = 2; i <= n; i++)
	{
		if (era[i]) { for (int j = i * 2; j <= n; j += i) { era[j] = 0; } }
	}
}
int main()
{
	makePrimeTable(200000);
	int N, P; while (cin >> N >> P && N != -1)
	{
		vector<int> dat(0);
		vector<int> prm(0);
		if (P > 100) { P = P / 10; }
		while (1)
		{
			N++;
			if (era[N]) { prm.push_back(N);}
			if (prm.size() == P) { break; }
		}
		for (int i = 0; i < P; i++) for (int j = i; j < P; j++) { dat.push_back(prm[i] + prm[j]); }
		sort(all(dat)); 
		printf("%d\n", dat[P - 1]);
	}
	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    char t[s.size()];
    rep(i, s.size())
    {
        if (i % 2 == 0)
            t[i] = '0';
        else
            t[i] = '1';
    }
    int ans = 0;

    rep(i, s.size())
    {
        if (s[i] != t[i])
            ans++;
    }
    int cnt = 0;
    rep(i, s.size())
    {
        if (i % 2 == 1)
            t[i] = '0';
        else
            t[i] = '1';
    }
    rep(i, s.size())
    {
        if (s[i] != t[i])
            cnt++;
    }
    ans = min(ans, cnt);
    OP(ans);

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int number = Integer.parseInt(sc.nextLine());
        String valueStr = sc.nextLine();
        int[] values = changeStrToNums(valueStr, number);
        String costStr = sc.nextLine();
        int[] costs = changeStrToNums(costStr, number);

        int max = 0;
        for (int i = 0; i < number; i++) {
            int diff = values[i] - costs[i];
            if (diff > 0) {
                max += diff;
            }
        }
        System.out.print(max);
    }

    private static int[] changeStrToNums (String input, int count) {
        String[] numStrs = input.split(" ");
        int[] nums = new int[count];
        for (int i = 0; i < count; i++) {
            nums[i] = Integer.parseInt(numStrs[i]);
        }
        return nums;
    }
}


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

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

    //good luck kittu!
    int n; cin>>n;
    vector<int> a(n);
    int x, y, sum = 0;
    for(int i = 0; i<n; i++){
        cin>>a[i];
        sum += a[i];
    }

    x = sum/n;
    y = (sum+n-1)/n;
    ll x1 = 0, y1 = 0;
    for(int i = 0; i<n; i++){
        x1 += (x-a[i])*(x-a[i]);
        y1 += (y-a[i])*(y-a[i]);
    }

    cout<<min(x1, y1);
    return 0;
}

Measured memory_bytes: 256
local N = io.read("*n")
local t, x, y = {}, {}, {}
t[0], x[0], y[0] = 0, 0, 0
for i = 1, N do
    t[i], x[i], y[i] = io.read("*n", "*n", "*n")
end

local is_impossible = false
local abs = math.abs
for i = 1, N do
    local delta_t = t[i] - t[i - 1]
    local delta_xy = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])

    if delta_t < delta_xy then
        is_impossible = true
        break
    end
    if delta_t%2 ~= delta_xy%2 then
        is_impossible = true
        break
    end
end

print(is_impossible and "No" or "Yes")

Measured memory_bytes: 3584
x, y = map(int, input().split())

if y >= x:
    if x >= 0:
        print(y-x)
    elif y >= 0:
        if y >= abs(x):  
            print(min(y-x, y+x+1))
        else:
            print(min(-y-x+1, y-x))
    else:
        print(-x+y)
else:
    if y >= 0:
        print(min(x-y+2, y+x+1))
    elif x >= 0:
        if x >= abs(y):  
            print(min(x-y, x+y+1))
        else:
            print(-y-x+1)
    else:
        print(-y+x+2)
    


Measured memory_bytes: 9184
#include<stdio.h>
int main(void){
    int a,b,c;
	int count=1;
	while(scanf("%d %d",&a,&b)!=EOF){
	c=a+b;
	while(c>=10){
	c=c/10;
	count++;
	}
	printf("%d\n",count);
	count=1;
}
return 0;
}

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

int main() {
    ll N,Y;
	cin >> N >> Y;
    // ここまで入力
    int A = 10000;
    int B = 5000;
    int C = 1000;
    ll x = -1;
    ll y = -1;
    ll z = -1;

    for(ll a=0;a<=N;a++){
        for(ll b=0;b<=N;b++){
            ll maisu = a+b;
            ll kingaku = a*A+b*B;
            ll c = N-maisu;
            if(c>=0 && c*C == Y-kingaku){
                x = a;
                y = b;
                z = c;
            }
        }
    }
    cout << x << " " << y << " " << z << endl;
    return 0;
}


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

#define MAXN 10
#define INF ( 1U << 30 )

typedef long long ll;

using namespace std;

int E[MAXN][MAXN];
int D[MAXN][MAXN];

void warshall ( void )
{
  for ( int i = 0; i < MAXN; ++i ) for ( int j = 0; j < MAXN; ++j ) D[i][j] = E[i][j];

  for ( int k = 0; k < MAXN; ++k ) {
    for ( int i = 0; i < MAXN; ++i ) {
      for ( int j = 0; j < MAXN; ++j ) {
        D[i][j] = min ( D[i][j], D[i][k]+D[k][j] );
      }
    }
  }

}

int main()
{
  int H,W;
  ll ans = 0;

  cin >> H >> W;
  for ( int i = 0; i < MAXN; ++i ) for ( int j = 0; j < MAXN; ++j ) scanf("%d", &E[i][j]);

  warshall();


  for ( int i = 0; i < H; ++i )
    for ( int j = 0; j < W; ++j ) {
      int tmp;
      scanf("%d", &tmp);
      if ( tmp > -1 ) {
        ans += D[tmp][1];
      }
    }


  cout << ans << "\n";
}


Measured memory_bytes: 384
import heapq

def solve():
  N,M = map(int, input().split())
  A = list(map(int, input().split()))
  A.sort()
  ret = sum(A)
  CB = {}
  C_heap = []
  for _ in range(M):
    b,c  = map(int, input().split())
    if c in CB:
      CB[c] += b
    else:
      CB[c] = b
      heapq.heappush(C_heap, -c)

  c = (-1)*heapq.heappop(C_heap)
  for a in A:
    if CB[c] == 0:
      if not C_heap: break

      c = (-1)*heapq.heappop(C_heap)
    
    if c <= a:
      break

    ret += c-a
    CB[c] -= 1

  print(ret)
  
solve()

Measured memory_bytes: 26224
package main

import (
	"fmt"
)

func main() {
	var a,b,c,ans int
	fmt.Scan(&a,&b,&c)
	
	if a == b {
		ans = c
	} else if (a == c) {
		ans = b
	} else {
		ans = a
	}
	fmt.Println(ans)
}

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


int main(){
  float A, B, H, M;
  cin >> A >> B >> H >> M;

  double wA = (2*M_PI)/(60*12);
  double wB = (2*M_PI)/60;
 
  int elapse = H*60 + M;
  double radA, radB;
  radA = elapse * wA;
  radB = M * wB;
  
  double theta;
/*
  if(radA > radB){
    theta = radA-radB;
  }else{
    theta = radB-radA;
  }
  */
  theta = abs(radB-radA);

  if(theta > M_PI){
    theta = 2*M_PI - theta;
  }
  
  double len = A*A + B*B - 2*A*B*cos(theta);
  //  float len = 9 + 16 - 2*3*4*cos(1.39626);
  cout << std::setprecision(30) << sqrt(len);

  return 0;
}


Measured memory_bytes: 4188
#include<stdio.h>
int main(void){
  int n,count=0,i;
  int V[20],C[20];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&V[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&C[i]);
    if(V[i]>=C[i]){
      count+=V[i]-C[i];
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

#define N 8

class EightQueen{
private:
    char table[N][N];
    bool col[N];
    bool row[N];
    
    bool Check(int x, int y){
        for(int i = y, j = x; i < N && j < N; i++, j++)
            if(table[i][j] == 'Q')
                return false;
        
        for(int i = y, j = x; i >= 0 && j >= 0; i--, j--)
            if(table[i][j] == 'Q')
                return false;
        
        for(int i = y, j = x; i >= 0 && j < N; i--, j++)
            if(table[i][j] == 'Q')
                return false;
        
        for(int i = y, j = x; i < N && j >= 0; i++, j--)
            if(table[i][j] == 'Q')
                return false;
        
        return true;
    }
    
public:
    EightQueen(){
        int n, c, r;
        
        for(int i = 0; i < N; i++){
            col[i] = false;
            row[i] = false;
            for(int j = 0; j < N; j++)
                table[i][j] = '.';
        }
        
        cin >> n;
        if(!(0 <= n && n <= 8))
            exit(1);
        
        for(int i = 0; i < n; i++){
            cin >> c >> r;
            if(!(0 <= c && c < N) || !(0 <= r && r < N))
                exit(1);
            
            table[c][r] = 'Q';
            col[c] = true;
            row[r] = true;
        }
    }
    
    void print(){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++)
                cout << table[i][j];
            cout << endl;
        }
    }
    
    int Setting(int y){
        if(y == N)
            return 0;
        
        if(col[y])
            return Setting(y + 1);
        
        for(int x = 0; x < N; x++){
            if(!row[x] && Check(x, y)){
                table[y][x] = 'Q';
                row[x] = true;
                col[y] = true;
                
                if(Setting(y + 1) == -1){
                    table[y][x] = '.';
                    row[x] = false;
                    col[y] = false;
                }
                else
                    return 0;
            }
        }
        
        return -1;
    }
};

int main(){
    EightQueen eq;
    
    eq.Setting(0);
    eq.print();
    
    return 0;
}




Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;

#define out(v) cout<<v<<"\n"
#define _overload3(_1,_2,_3,name,...) name
#define _all1(a) (a).begin(),(a).end()
#define _all2(a,n) (a),(a)+n
#define all(...) _overload3(__VA_ARGS__,42,_all2,_all1,)(__VA_ARGS__)
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
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>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

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

  rep(i, 1, 10) {
    if (N % i == 0 && N / i <= 9) {
      out("Yes");
      return 0;
    }
  }
  out("No");

  return 0;
}


Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string o,e;
    cin>>o;
    cin>>e;
    int n = o.length(), m = e.length();
    for(int i=1;i<=n+m;i++){
        if(i%2==1)
            cout<<o[i/2];
        else
            cout<<e[(i/2)-1];
    }
    cout<<"\n";

    return 0;
}



Measured memory_bytes: 256
import Foundation

extension String {
    func split(separator: String) -> [Int] {
        return self.componentsSeparatedByString(separator).map { Int($0)! }
    }
}

let input = readLine()!.split(" ")
let A = input[0]
let B = input[1]
let C = input[2]

var ans: Int!
ans = B / A
if ans > C {
    ans = C
}

print(ans)

Measured memory_bytes: 7908
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        int a = int.Parse(input[2]);
        int b = int.Parse(input[3]);*/
//        string temp = ReadLine();
        int a = int.Parse(ReadLine());
        int b = int.Parse(ReadLine());
        int c = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
        a-=b;
        int d = a/c;
        WriteLine(a-(c*d));
    }
}

Measured memory_bytes: 11092