akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

void bubbleSort(int* N, int len){
  int i,j, temp;

  for(i=0; i<len; i++){
    for(j=len-1; j>i; j--){
      if(N[j] < N[j-1]){
        temp = N[j];
        N[j] = N[j-1];
        N[j-1] = temp;
      }
    }
  }
}

bool possibleDraw(int* n, int len) {
    int i,sumOthers = 0;
    
    for(i = 0; i < len - 1; i++) {
        sumOthers += n[i];
    }
    if(n[len-1] < sumOthers) return true;
    else return false;
}



int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！
    int n, i;
    int length[11];
    char str[1000], *t1;
    
    scanf("%d", &n);
    fgets(str, sizeof(str), stdin);
    
    fgets(str, sizeof(str), stdin);
    t1 = strtok(str, " ");
    length[0]= atoi(t1);
    
    for(i = 1; i < n; i++) {
        t1 = strtok(NULL, " ");
        length[i] = atoi(t1);
    }
    
    bubbleSort(length, n);
    
    if(possibleDraw(length, n)) printf("Yes");
    else printf("No");
    

    
    
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int m = Integer.parseInt(scan.next());
		int x = Integer.parseInt(scan.next());
		int[][] ca = new int[n][m+1];
		for (int i = 0;i < n; ++i){
			for (int k = 0;k < m+1; ++k){
				ca[i][k] = Integer.parseInt(scan.next());
			}
		}

		int[] understand = new int[m];
		int ans = -1;
		int money = 0;
		for(int i = 0;i < 1<<n; ++i){
			Arrays.fill(understand, 0);
			money = 0;
			for(int k = 0;k < n; ++k){
				if ((1&i>>k) == 1){
					money += ca[k][0];
					for(int j = 0;j < m; ++j){
						understand[j] += ca[k][j+1];
					}
				}
			}

			//check
			boolean ok = true;
			for(int k = 0;k < m; ++k){
				if (understand[k] < x ){
					ok = false;
					break;
				}
			}
			if(ok){
				if (ans == -1){
					ans = money;
				}else{
					ans = Math.min(ans, money);
				}
			}
		}

		System.out.print(ans);

	}

}


//end

Measured memory_bytes: 36988
H,W=map(int,input().split())
S=[input()for _ in range(H)]

w1=[[]for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j]=='#':
            w1[i].append(j)
    w1[i].append(W)

w2=[[0]*W for _ in range(H)]
for i in range(H):
    k=0
    L=-1
    R=w1[i][k]
    for j in range(W):
        if S[i][j]=='#':
            L=w1[i][k]
            k+=1
            R=w1[i][k]
            continue
        w2[i][j]=R-L-1

h1=[[]for _ in range(W)]
for j in range(W):
    for i in range(H):
        if S[i][j]=='#':
            h1[j].append(i)
    h1[j].append(H)

h2=[[0]*W for _ in range(H)]
for j in range(W):
    k=0
    L=-1
    R=h1[j][k]
    for i in range(H):
        if S[i][j]=='#':
            L=h1[j][k]
            k+=1
            R=h1[j][k]
            continue
        h2[i][j]=R-L-1

print(max(w2[i][j]+h2[i][j]-1 for i in range(H)for j in range(W)))

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

#pragma GCC optimize("Ofast")

using namespace std;
using ll = long long;

#define rep( i, n ) for ( long (i) = 0; (i) < (n); (i)++ )
#define repInRange( i, b, n ) for ( long (i) = (b); (i) < (n); (i)++ )

#define all(x) (x).begin(), (x).end()

#define INF 1000000000000
#define MOD 1000000007

using vl = vector<long>;
using vll = vector<long long>;
using vs = vector<string>;

#define lfn '\n'

void solve() {
	long a, b, t = 1, l = 0;
	cin >> a >> b;
	while (1) {
		if ( t >= b ) {
			cout << l << lfn;
			return;
		}
		t--;
		t += a;
		l++;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


Measured memory_bytes: 3584
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl
#define CE cout<<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010][1010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc;

int main(){
    cin>>a>>b>>x>>y;
    n=x-a;
    m=y-b;
    C x-m<<" "<<y+n<<" ";
    C x-m-n<<" "<<y+n-m E;

}



Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var w string
	fmt.Scan(&w)

	ans := exec(w)

	fmt.Println(ans)
}

func exec(w string) string {
	s := strings.Split(w, "")

	m := make(map[string]int)
	for _, v := range s {
		if _, ok := m[v]; ok {
			m[v]++
		} else {
			m[v] = 1
		}
	}

	for _, v := range m {
		if v%2 != 0 {
			return "No"
		}
	}
	return "Yes"
}


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

using namespace std;

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

  bool canTravel = true;
  int prevT = 0, prevX = 0, prevY = 0;
  int nextT, nextX, nextY;

  for (int i = 0; i < N; i++) {
    cin >> nextT >> nextX >> nextY;

    int duration = nextT - prevT;
    int distance = abs(nextX - prevX) + abs(nextY - prevY);

    if (distance > duration || distance % 2 != duration % 2) {
      canTravel = false;

      break;
    }

    prevT = nextT;
    prevX = nextX;
    prevY = nextY;
  }

  string answer = canTravel ? "Yes" : "No";

  cout << answer << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n;
  cin>>n;
  vector<int> a(n);
  REP(i,n)cin>>a[i];
  sort(ALL(a));
  int al=0,bo=0;
  if(n%2==0){
    for(int i=n-1;i>=0;i--){
      if(i%2==0)bo+=a[i];
      else al+=a[i];
    }
  }else{
    for(int i=n-1;i>=0;i--){
      if(i%2==0)al+=a[i];
      else bo+=a[i];
    }
  }
  cout<<al-bo<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int mod=1e9+7;
const int INF =LONG_LONG_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}
vector<int>adj[100001];
vector<int>visited(100001,0);
vector<int>ans;
int cnt=0;
void dfs(int s)
{
    cnt++;
    visited[s]=1;
    for(int i=0;i<adj[s].size();i++)
    {
        int child=adj[s][i];
        if(!visited[child])dfs(child);
    }
    ans.push_back(s);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin>>n>>m;
    vector<int>degree(n+1,0);
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        degree[y]++;
        adj[x].push_back(y);
    }
    while(cnt<n)
    {
        for(int i=1;i<=n;i++)
        {
            if(degree[i]==0&&!visited[i])
                dfs(i);
        }
    }
   // for(int i=0;i<ans.size();i++)
     //   cout<<ans[i]<<" ";
    //cout<<endl;
    vector<int>dp(n+1,0);
    for(int i=ans.size()-1;i>=0;i--)
    {
        int node=ans[i];
        for(int j=0;j<adj[node].size();j++)
        {
            int child=adj[node][j];
            dp[child]=max(dp[child],dp[node]+1);
        }
    }
    int max1=-1;
    for(int i=1;i<=n;i++)
    {
        max1=max(max1,dp[i]);
    }
    cout<<max1<<endl;
    return 0;
}


Measured memory_bytes: 12148
#include <iostream>
#define ll long long int
using namespace std;

ll gcd(ll x,ll y)
{
	while(x!=y){
		if(x>y)
			x=x-y;
		else
			y=y-x;
	}
	return y;
}

ll gcd(ll a,ll b,ll c)
{
	return gcd(a,gcd(b,c));
}

int main(void)
{
	ll res=0;
	int K;
	cin>>K;
	for(int i=1;i<=K;++i){
		for(int j=1;j<=K;++j){
			for(int p=1;p<=K;++p)
				res+=gcd(i,j,p);
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h> 
#include<vector> 
#include<iterator> 
#include<deque> 
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i <(n) ; i++)
#define rep2(i,s,n) for(long long i = (s); i < (n) ; i++)
#define ll long long
#define INF 9999999999;


int main() {
  int N;
  cin >> N;
  vector<vector<ll>> dp(3,vector<ll>(N+1));
  vector<int> pre(3,0);
  rep(i,3){
    pre[i] = i;
    cin >> dp.at(i).at(0);
    //cout << dp.at(i).at(0) <<endl;
  }


  rep2(j, 1, N) {
    int a, b, c;
    cin >> a >> b>> c;
    dp[0][j] = max(dp[1][j-1],dp[2][j-1]) + a;
    dp[1][j] = max(dp[0][j-1],dp[2][j-1]) + b;
    dp[2][j] = max(dp[0][j-1],dp[1][j-1]) + c;
  }
  
  ll temp = 0;
  rep(i,3){
    if(temp < dp.at(i).at(N-1)) temp = dp.at(i).at(N-1);
  }
  cout << temp <<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int main(){
  int n, s[10001], q, t[500], c = 0, key = 0, i, j;

  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &s[i]);
  scanf("%d", &q);
  for(i = 0; i < q; i++) scanf("%d", &t[i]);

  for(i = 0; i < q; i++){
    key = t[i];
    j = 0;
    s[n] = key;
    while(key != s[j]) j++;
    if(j == n) continue;
    else c++;
  }
  printf("%d\n", c);

  return 0;
}

Measured memory_bytes: 640
'use strict'
function Main(input) {
  input = input.split(" ");
  const N = parseInt(input[0], 10);
  const A = parseInt(input[1], 10);
  const B = parseInt(input[2], 10);
  const div10 = (a) => Math.floor(a / 10);
  let count = 0;
  
  function sum(n){
    let result = 0;
    while(n > 0){
      result += (n % 10);
      n = div10(n);
    }
    return result;
  }
  
  for (let i=1; i<=N; i++){
    const temp = sum(i);
    if (temp >= A && temp <= B){
      count += i;
    }
  }
 
  console.log('%d',count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<int,int> P;
#define Mod 1000000007


int main(){
    ll i,j;


    ll n;
    cin>>n;
    ll h[n];
    for(i=0;i<n;i++) cin>>h[i];

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

    cout<<dp[n-1]<<endl;
    

    
    return 0;
}

Measured memory_bytes: 1792
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Integer, Boolean> a = new HashMap<Integer, Boolean>();
		boolean flag = true; int b = 0;
		for (int i = 0; i < n; i++) {
			b = sc.nextInt();
			if(a.containsKey(b)) {
				flag = false;
				break;
			}else {
				a.put(b, true);
			}
		}
		if(flag)System.out.println("YES");
		else System.out.println("NO");
		sc.close();
	}
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m;

	f(i,n,m){
        int a,b,c,d;
        res=i;
        a=res%10;
        res/=10;
        b=res%10;
        res/=100;

        c=res%10;
        res/=10;
        d=res%10;
        res/=10;

        //cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

        if(a==d && b==c) count++;

	}

	cout<<count<<endl;

}


Measured memory_bytes: 256
let () = Scanf.scanf "%d\n" @@ fun n ->
  let ps = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun p -> p in
  print_endline @@ if
    ( >= ) 2 @@
    Array.fold_left ( + ) 0 @@
    Array.init n @@ fun i ->
      if ps.(i) = i + 1 then 0 else 1
  then "YES"
  else "NO"



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

// graph by adjacency list
template <typename T>
struct Edge {
  int dst; T weight;
  Edge(int dst, T weight) : dst(dst), weight(weight) { }
  bool operator < (const Edge<T> &e) const {
    return weight > e.weight;
  }
};

template <typename T>
struct Graph {
  int V;
  vector<vector<Edge<T>>> E;
  Graph(int V) : V(V) { E.resize(V); }
  void add_edge(int src, int dst, T weight) {
    E[src].emplace_back(dst, weight);
  }
};

template <typename T>
struct HeavyLightDecomposition {
  const Graph<T> g;
  vector<int> vid, head, heavy, parent;
  HeavyLightDecomposition(const Graph<T> g, int root = 0) : g(g), vid(g.V, -1), head(g.V), heavy(g.V, -1), parent(g.V) {
    dfs(root, -1);
    bfs(root);
  }

  int dfs(int v, int par) {
    parent[v] = par;
    int sub = 1, max_sub = 0;
    for (Edge<T> child : g.E[v]) {
      if (child.dst != par) {
        int child_sub = dfs(child.dst, v);
        sub += child_sub;
        if (child_sub > max_sub) {
          max_sub = child_sub;
          heavy[v] = child.dst;
        }
      }
    }
    return sub;
  }

  void bfs(int root = 0) {
    int k = 0;
    queue<int> que({root});
    while (not que.empty()) {
      int r = que.front(); que.pop();
      for (int v = r; v != -1; v = heavy[v]) {
        vid[v] = k++;
        head[v] = r;
        for (Edge<T> child : g.E[v]) {
          if (child.dst != parent[v] and child.dst != heavy[v]) que.emplace(child.dst);
        }
      }
    }
  }

  int lca(int u, int v) {
    while(head[u] != head[v]) {
      if (vid[u] > vid[v]) swap(u, v);
      v = parent[head[v]];
    }
    if (vid[u] > vid[v]) swap(u, v);
    return u;
  }
};

int main() {
  int N; scanf("%d", &N);
  Graph<int> g(N);
  REP(i, N) {
    int k; scanf("%d", &k);
    REP(_, k) {
      int c; scanf("%d", &c);
      g.add_edge(i, c, 1);
      g.add_edge(c, i, 1);
    }
  }

  HeavyLightDecomposition<int> hld(g);

  int Q; scanf("%d", &Q);
  REP(_, Q) {
    int u, v; scanf("%d %d", &u, &v);
    printf("%d\n", hld.lca(u, v));
  }
  return 0;
}

Measured memory_bytes: 24704
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

bool ask(ll n) {
  cout << "? " << n << endl;
  char ans;
  cin >> ans;
  return (ans == 'Y');
}

int findLength() {
  ll cur = 10;
  for (int len = 2; len <= 11; len++) {
    if (!ask(cur)) {
      return len - 1;
    }
    cur *= 10;
  }
  cur = 9;
  for (int len = 1; len <= 10; len++) {
    if (ask(cur)) {
      return len;
    }
    cur = cur * 10 + 9;
  }
  return -1;
}

int main() {
  int len = findLength();
  ll cur = 0;
  for (int i = 1; i <= len; i++) {
    int low = -1, high = 9;
    if (cur == 0) {
      ++low;
    }
    // (low, high]
    while (high - low > 1) {
      int mid = (high + low) / 2;
      ll n = cur * 10 + mid;
      for (int j = i; j < len + 1; j++) {
        n = n * 10 + 9;
      }
      if (ask(n)) {
        high = mid;
      } else {
        low = mid;
      }
    }
    cur = cur * 10 + high;
  }
  cout << "! " << cur << endl;
  return 0;
}


Measured memory_bytes: 596
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  long long all = 0;
  long long p = 1000000007;
  for(int i = 0; i < n; i++){
    all += a[i];
    all = all % p;
  }
  long long ans = 0;
  for(int i = 0; i < n; i++){
    all -= a[i];
    if(all < 0) all += p;
    ans += a[i] * all;
    ans %= p;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4044
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
A=nl()
B=nl()
sumMb=sum(A)

for i in range(N):
    tmp=(min(B[i],A[i]))
    A[i]-=tmp
    B[i]-=tmp
    A[i+1]-=(min(B[i],A[i+1]))

print(sumMb-sum(A))

Measured memory_bytes: 18624
#include <stdio.h>
int main(void)
{
  int A,B,C;
  scanf ("%d %d %d",&A,&B,&C);
  if (A==B&&B!=C) printf ("Yes");
  if (A!=B&&B==C) printf ("Yes");
  if (A==C&&C!=B) printf ("Yes");
  if (A==B&&B==C) printf ("No");
  if (A!=B&&B!=C&&A!=C) printf ("No");
}


Measured memory_bytes: 1692
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=100005;
ll x[maxn];
int n,m;
int main()
{
	int n;
	scanf("%d",&n);

	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x[i]);

	}
	ll sum=0;
	ll ans1=0;
	for(int i=1;i<=n;i++)
	{
		sum+=x[i];
		if(i%2==1)
		{
			if(sum<=0)
			{
				ans1+=(1-sum);
				sum=1;
			}
		}
		else
		{
			if(sum>=0)
			{
				ans1+=(sum+1);
				sum=-1;
			}
		}
	}
	ll ans2=0;
	sum=0;
	for(int i=1;i<=n;i++)
	{
		sum+=x[i];
		if(i%2==0)
		{
			if(sum<=0)
			{
				ans2+=(1-sum);
				sum=1;
			}
		}
		else
		{
			if(sum>=0)
			{
				ans2+=(sum+1);
				sum=-1;
			}
		}
	}
	cout<<min(ans1,ans2)<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,m;
  cin>>n>>m;
  cout<<n*m<<endl;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) ( ((x)&1)==0?0:1 )
#define SIGN(x) ( ((x) > 0) - ((x) < 0)  )
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int h,n;cin>>h>>n;
    FOR(i,n){
        int x;cin>>x;
        h -= x;
        if (h<=0) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";

    return 0;
}



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var ReadString func() string
var ReadLine func() string
var ReadInt64 func() int64
var ReadInt func() int
var ReadIntSlice func(int) []int
var ReadInt64Slice func(int) []int64
var GetIntAbs func(int) int
var Atoi func(string) int
var FindMin func([] int) int
var FindMax func([] int) int

func init() {
	ReadString = newReadString()
	ReadLine = readLine
	ReadInt64 = readInt64
	ReadInt = readInt
	ReadIntSlice = readIntSlice
	FindMin = findMin
	FindMax = findMax
}

func main() {
	n := ReadInt()
	a := ReadIntSlice(n)

	var c int
	for {
		for i, v := range a {
			if v%2 == 1 {
				fmt.Println(c)
				return
			}
			a[i] = v / 2
		}
		c += 1
	}
	fmt.Println(c)
}

/*------ scan ------*/

func newReadString() func() string {
	sc.Buffer(make([]byte, 1024), 2048)
	sc.Split(bufio.ScanWords)
	return func() string {
		if !sc.Scan() {
			panic("scanできなかった")
		}
		return sc.Text()
	}
}

func readLine() string {
	if !sc.Scan() {
		panic("line をscanできなかった")
	}
	return sc.Text()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		fmt.Println("parseInt失敗")
		panic(err.Error())
	}
	return int64(i)
}

func readInt() int {
	i := ReadInt64()
	return int(i)
}

func readIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}

func readInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}

/*------ number util ------*/

func getIntAbs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func atoi(a string) int {
	i, err := strconv.Atoi(a)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func findMin(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	min := arr[0]
	for _, v := range arr {
		if v < min {
			min = v
		}
	}
	return min
}

func findMax(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	max := arr[0]
	for _, v := range arr {
		if v > max {
			max = v
		}
	}
	return max
}


Measured memory_bytes: 640
def fu(st):
    global r,s,p
    if(st=='r'):
        return p
    elif(st=='p'):
        return s
    return r
    

n,k=[int(i) for i in input().split()]
r,s,p=[int(i) for i in input().split()]
t=list(input())


dp = [0]*(10**5+11)
res=0
for i in range(k):
    res+=fu(t[i])
    dp[i]=res

for i in range(k,len(t)):
    if(t[i-k]==t[i]):
        dp[i] = max(dp[i-k],dp[i-1])
        t[i]='0'
    else:
        dp[i] = dp[i-1]+fu(t[i])

print(dp[n-1])


Measured memory_bytes: 7888
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long[] sum = new long[N+1];
		int max = 0;
		sum[0] = 0;
		Map<Long, Integer> count = new HashMap<>();
		count.put(0L, 1);
		for(int i=1; i<=N; i++) {
			sum[i] = sum[i-1] + sc.nextLong();

			if(count.containsKey(sum[i])) {
				int new_c = count.get(sum[i])+1;
				count.put(sum[i], new_c);
				max = Math.max(max, new_c);
			}
			else {
				count.put(sum[i], 1);
				max = Math.max(max, 1);
			}
		}

		long ans = 0;
		for(int value : count.values()) {
			ans += (long)value * (value-1) / 2;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 105388
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()

a = 8
for i in range(8):
    if N < (i + 3) * 200:
        a = 8 - i
        break
print(a)

# a = 8
# if N < 600:
#     a = 8
# elif N < 800:
#     a = 7
# elif N < 1000:
#     a = 6
# elif N < 1200:
#     a = 5
# elif N < 1400:
#     a = 4
# elif N < 1600:
#     a = 3
# elif N < 1800:
#     a = 2
# elif N < 2000:
#     a = 1
# print(a)


#H,N = LI()
#AB = [LI() for _ in range(N)]
#A,B = zip(*AB)
#Ap = np.array(A)
#C = np.zeros(N + 1)

# if ans:
#     print('Yes')
# else:
#     print('No')

Measured memory_bytes: 27212
fun main(args: Array<String>) {
    var input = readLine()!!
    val n = (input.split("")[1]+input.split("")[2]).toInt()
    val k = (input.split("")[3]+input.split("")[4]).toInt()

    var nm = n in 1..12
    var km = k in 1..12
    print(
        if (nm) {
            if (km) "AMBIGUOUS"
            else "MMYY"
        }else{
            if (km) "YYMM"
            else "NA"
        }
    )
}

Measured memory_bytes: 36200
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir [] = {
	{ 0, 1 },{ -1 ,1 },{ -1, 0 },
	{ -1 ,-1 },{ 0,-1 },{ 1 ,-1 },
	{ 1,0 },{ 1 ,1 }
};
double getRadian(double x, double y, double x2, double y2) {
	double radian = atan2(y2 - y, x2 - x);
	return radian;
}
signed main() {
	int k, s;
	scanf("%d %d", &k, &s);
	int ans = 0;
	REP(x, k+1) {
		REP(y, k+1) {
			int z = s - x - y;
			if (0 <= z && z <= k) {
				ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
matrix = []
vector = []
ans = [0 for i in range(n)]
for i in range(n):
    matrix.append(list(map(int,input().split())))
for i in range(m):
    vector.append(int(input()))
for i in range(n):
    for j in range(m):
        ans[i] += matrix[i][j] * vector[j]
    print(ans[i])


Measured memory_bytes: 6020
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)

#define XY(x, y) (((y) << 9) + (x))
#define X(x) ((x) & 511)
#define Y(x) ((x) >> 9)


int sign(int x)
{
  assert(x);
  
  return x > 0 ? 1 : -1;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int H, W, a[555][555];

  std::cin >> H >> W;

  std::vector<int> b;

  for (int i = 0; i < H; i ++)
    for (int j = 0; j < W; j ++)
      std::cin >> a[i][j];

  for (int i = 0; i < H; i ++)
    for (int j = 0; j < W; j ++)
      if (a[i][j] & 1) {
        if (j < W - 1) {
          a[i][j    ] --;
          a[i][j + 1] ++;

          b.push_back(XY(j,     i));
          b.push_back(XY(j + 1, i));
        }
        else if (i < H - 1) {
          a[i    ][j] --;
          a[i + 1][j] ++;

          b.push_back(XY(j, i    ));
          b.push_back(XY(j, i + 1));
        }
      }

  int size = b.size();

  std::cout << size / 2 << std::endl;

  for (int i = 0; i < size; i += 2)
    std::cout <<
      Y(b[i    ]) + 1 << ' ' << X(b[i    ]) + 1 << ' ' <<
      Y(b[i + 1]) + 1 << ' ' << X(b[i + 1]) + 1 <<
      std::endl;

  return 0;
}


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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

    int size = S.size();
    rep(i, size)
    {
        int order = S.at(i) - 'A';
        int new_order = (order + N) % 26;
        S.at(i) = char('A' + new_order);
    }

    cout << S << endl;
}

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

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, l = mi()
    summation = (2 * l + n - 1) * n // 2
    left = l
    right = l + n - 1
    if left <= 0 <= right:
        print(summation)
    elif 0 < left:
        print(summation - left)
    else:
        print(summation - right)

if __name__ == "__main__":
    main()

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define F first
#define S second

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

  mint res = 0;

  ll l = 0;
  ll r = 0;
  rep(i, k-1) {
    l += i;
    r += n - i;
  }

  for(ll i = k; i <= n+1; i++) {
    l += i - 1;
    r += n - i + 1;
    res += r - l + 1;
  }

  cout << res.x << endl;

  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
//#include "toollib.h"
//#include "puzzle.h"
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#pragma warning (disable:4018)
#pragma warning (disable:4244)

using namespace std;
typedef long long int lint;


//***** Main Program *****

int main() {
	stack<int> stk;
	string input;
	getline(cin, input);
	string s = "";
	Loop(i, input.length()) {
		if ('0' <= input[i] && input[i] <= '9') {
			s.push_back(input[i]);
		}
		else if (input[i] == ' ') {
			if (s.length() != 0) {
				stk.push(atoi(s.c_str()));
				s = "";
			}
		}
		else {
			int b = stk.top();
			stk.pop();
			int a = stk.top();
			stk.pop();
			if (input[i] == '+') 	stk.push(a + b);
			else if (input[i] == '-') stk.push(a - b);
			else if (input[i] == '*') stk.push(a*b);
		}
	}
	cout << stk.top() << endl;
	return 0;
}

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

const int MAXN = 100010;
void bye() { std::cout << "No" << std::endl; exit(0); }
int A[MAXN], B[MAXN], n;
int mat[MAXN][3];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int j = 0; j < 3; ++j)
		for (int i = 1; i <= n; ++i)
			std::cin >> mat[i][j];
	for (int i = 1; i <= n; ++i) {
		if (mat[i][0] % 3 == 0) {
			if (mat[i][1] != mat[i][0] - 1) bye();
			if (mat[i][2] != mat[i][1] - 1) bye();
			A[i] = mat[i][0] / 3;
			B[i] = 1;
		} else if (mat[i][0] % 3 == 1) {
			if (mat[i][1] != mat[i][0] + 1) bye();
			if (mat[i][2] != mat[i][1] + 1) bye();
			A[i] = mat[i][2] / 3;
			B[i] = 0;
		} else bye();
	}
	static int tree[MAXN], w[2], v[2];
	for (int i = 1; i <= n; ++i) tree[A[i]] = true;
	for (int i = 1; i <= n; ++i) if (!tree[i]) bye();
	for (int i = 1; i <= n; ++i) if (A[i] % 2 != i % 2) bye();
	for (int T = 1; T <= 2; ++T) {
		memset(tree, 0, sizeof tree);
		for (int i = T; i <= n; i += 2) {
			int C = 0;
			for (int x = A[i]; x <= n; x += x & -x) C += tree[x];
			for (int x = A[i]; x; x &= x - 1) ++tree[x];
			v[T - 1] ^= C; w[T - 1] ^= B[i];
		}
	}
	if (v[1] % 2 != w[0] % 2) bye();
	if (v[0] % 2 != w[1] % 2) bye();
	std::cout << "Yes" << std::endl;
	return 0;
}


Measured memory_bytes: 2560
import sys

def query(A):
    print(*(['?'] + sorted([1+a for a in A])), flush = True)
    return True if input().strip() == 'Red' else False

N = int(input())

zans = query(list(range(N)))
ok = 0
ng = N

while abs(ok-ng) > 1:
    med = (ok+ng)//2
    if query(list(range(med, med+N))) == zans:
        ok = med
    else:
        ng = med

tool1 = list(range(ok+1, ok+N))
st1 = set(tool1)
col = [None]*(2*N)

for i in range(2*N):
    if i in tool1:
        continue
    col[i] = query([i] + tool1)

cr = 0
cb = 0
tool2 = []
for i in range(2*N):
    if col[i] is None:
        continue
    if col[i]:
        if cr < N//2:
            cr += 1
            tool2.append(i)
    else:
        if cb < N//2:
            cb += 1
            tool2.append(i)

for i in tool1:
    col[i] = query(tool2 + [i])

print(''.join(['! '] + ['R' if col[i] else 'B' for i in range(2*N)]), flush = True)



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

int main(void) {
	int n, m, b[100], c[100][100], i, j;
	long int ans;
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			cin >> c[i][j];
		}
	}
	for (i = 0; i < m; i++) {
		cin >> b[i];
	}
	for (i = 0; i < n; i++) {
		for (j = 0, ans = 0; j < m; j++) {
			ans += c[i][j] * b[j];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<iomanip>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 304
#define INF 1e9+7

using namespace std;

ll n,ar[N];
ll cnt[3];
double dp[N][N][N];

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

    cin >> n;

    rep(i,0,n)
    {
        cin >> ar[i];

        cnt[ar[i]]++;
    }

    rep(i,0,n+1)
    {
        rep(j,0,n+1)
        {
            rep(k,0,n+1)
            {
                if(i+j+k > n)
                    continue;

                double s = i+j+k;

                if(s > 0)
                    dp[i][j][k] += n/s;
                if(i > 0)
                    dp[i][j][k] += (dp[i-1][j+1][k])*i/s;
                if(j > 0)
                    dp[i][j][k] += (dp[i][j-1][k+1])*j/s;
                if(k > 0)
                    dp[i][j][k] += (dp[i][j][k-1])*k/s;

                //cout << i << " " << j << " " << k << ": " << dp[i][j][k] << endl;
            }
        }
    }

    cout << fixed << setprecision(10) << dp[cnt[3]][cnt[2]][cnt[1]];

    return 0;
}


Measured memory_bytes: 217344
#include<iostream>
#include<cstdio>
using namespace std;
int n,m;
int main()
{
    scanf("%d%d",&m,&n);
    for(int i=0;i<=m;i++)
     for(int j=0;j<=m;j++)
      for(int k=0;k<=m,i+j+k<=m;k++)
       {
            if(i+j+k==m && i*1000+j*5000+k*10000==n)
            {
                printf("%d %d %d",k,j,i);
                return 0;   
            }
       }
    printf("-1 -1 -1");
    return 0;
}

Measured memory_bytes: 384
class Dice:
  def __init__(self, list1):
    self.f = list1
  def move(self, direct):
    if direct == "N":
        self.f[0], self.f[1], self.f[4], self.f[5] = self.f[1], self.f[5], self.f[0], self.f[4]
        return self.f
    elif direct == "E":
        self.f[0], self.f[2], self.f[3], self.f[5] = self.f[3], self.f[0], self.f[5], self.f[2]
        return self.f
    elif direct == "S":
         self.f[0], self.f[1], self.f[4], self.f[5] = self.f[4], self.f[0], self.f[5], self.f[1]
         return self.f
    elif direct == "W":
        self.f[0], self.f[2], self.f[3], self.f[5] = self.f[2], self.f[5], self.f[0], self.f[3]
        return self.f

data = list(map(int, input().split()))
direction = input()
dice = Dice(data)
for i in direction:
  dice.move(i)
print(dice.f[0])


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

const ll INF = 1000000000;

int n, k;
vector<int> items;

bool ok(int p)
{
    int c = 1;
    int sum = 0;
    rep(i, n)
    {
        if (items[i] > p)
            return false;
        if (sum + items[i] <= p)
        {
            sum += items[i];
        }
        else
        {
            c++;
            sum = items[i];
        }
    }
    if (c > k)
        return false;
    return true;
}

int main()
{
    cin >> n >> k;
    items.resize(n);
    rep(i, n) cin >> items[i];
    int l = 0;
    ll h = INF;
    while (l + 1 < h)
    {
        int m = (l + h) / 2;
        if (ok(m))
        {
            h = m;
        }
        else
        {
            l = m;
        }
    }
    cout << h << endl;
    return 0;
}


Measured memory_bytes: 3116
import sys
INF = 10**18
sys.setrecursionlimit(10**6)
from collections import deque

def li():
    return [int(x) for x in input().split()]


H, W = li()

maze = []
wall_cnt = 0
for i in range(H):
    row = input()
    wall_cnt += row.count("#")
    maze.append(list(row))

seen = [[INF] * W for _ in range(H)]

sx, sy = 0, 0
gx, gy = W - 1, H - 1

todo = deque()

todo.append((sx, sy))
seen[sy][sx] = 0

dist = INF
while len(todo) > 0:
    x, y = todo.popleft()
    if x == gx and y == gy:
        dist = seen[y][x]
        break
    children = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]
    for child in children:
        cx, cy = child
        # validation and seen check
        if 0 <= cx < W and 0 <= cy < H and maze[cy][cx] == '.' and seen[cy][cx] == INF:
            seen[cy][cx] = seen[y][x] + 1
            todo.append((cx, cy))

ans = H * W - wall_cnt - (dist + 1)
print(ans if dist != INF else '-1')

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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
using Graph = vector<vector<char>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}
//各々のマスは一回のみ操作できる
//偶数枚のマスがmaxになるような操作を出力
//元々奇数のマス目のコインを、他の元々奇数のマス目に写す

int main(){
  ll N,K;
  cin >> N >> K;
  ll ans = 0;
  if(K == 0){
    ans = N*N;
    cout << ans << endl;
    return 0;
  }
  for(int b = 1;b <= N;b++){
    if(K > b-1) ans = 0;
    else{
      ans += b-K;
      ans += (N-b+1)/b * (b-K);
      if((N-b+1)%b - 1 >= K) ans += (N-b+1)%b - 1 -K +1;
    }
  }
  cout << ans << endl;
}

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

int findGCD(int a, int b){
    if(b == 0) return a;
    return findGCD(b, a % b);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,k;
    cin >> n >> k;
    
    vector<int> a(n);
    
    int maxv = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        maxv = max(maxv,a[i]);
    }

    int gcd = findGCD(a[0], a[1]);
    for(int i = 2; i < n; i++){
        gcd = findGCD(gcd, a[i]);
    }
    
    bool flag = true;
    if(maxv < k) flag = false;
    if(k % gcd != 0) flag = false;
    
    if(flag) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
// #include <queue>
// #include <cmath>
// #include <string>
// #include <set>
// #include <map>
// #include <iomanip>

// #define MOD 1000000007
// #define INF 1000000001

using namespace std;
// typedef unsigned long long ull;
typedef long long ll;

void p_() {
    cout << "\n";
}
template<class Head, class... Body>
void p_(Head head, Body... body) {
    cout << head << ",";
    p_(body...);
}


int main(int argc, char const *argv[]) {
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    cout << v[0] + v[1] << endl;
    return 0;
}


Measured memory_bytes: 256
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: a,b,c

    read*, a,b,c
    if (a==b) then
        print'(i0)', c
    else if(b==c) then
        print'(i0)', a
    else
        print'(i0)', b
    end if
end program main

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

Measured memory_bytes: 18624
#include <stdio.h>

int main(){
  int N,A,B;
  int ans_1,ans_2;
  scanf("%d %d %d",&N,&A,&B);
  if(A<B)ans_1=A;
  else ans_1=B;
  if(A+B>N)ans_2=A+B-N;
  else ans_2=0;
  printf("%d %d\n",ans_1,ans_2);
}

Measured memory_bytes: 256