akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int field[220][220][220];
int height[220][220];
int roll5[4]={1,3,6,4};
int roll6[4]={5,3,2,4};
int roll4[4]={1,5,6,2};

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

int koro(int t,int f,int num){
  if(num==t || 7-num==t){
    return -1;
  }
  if(f==num){
    return 3;
  }
  if(f==7-num){
    return 4;
  }
  if(num==5){
    for(int i=0;i<4;i++){
      if(roll5[i]==t && roll5[(i+1)%4]==f){
	return 5;
      }
    }
    return 2;
  }
  if(num==4){
    for(int i=0;i<4;i++){
      if(roll4[i]==t && roll4[(i+1)%4]==f){
	return 5;
      }
    }
    return 2;
  }
  if(num==6){
    for(int i=0;i<4;i++){
      if(roll6[i]==t && roll6[(i+1)%4]==f){
	return 5;
      }
    }
    return 2;
  }
  
}

void seta(int t,int f,int x,int y){
  field[x][y][height[x][y]]=t;
  height[x][y]++;
  return;
}

int drop(int t,int f,int x,int y){
  if(height[x][y]==0){
    seta(t,f,x,y);

    return 0;
  }
  
  for(int i=6;i>=4;i--){
    int to=koro(t,f,i);
    if(to==-1) continue;

    int tox=x+dx[to];
    int toy=y+dy[to];
    if(height[tox][toy]>=height[x][y]){
      continue;
    }
    int pret=t;
    t=7-i;
    if(dx[to]==1){
      f=pret;
    }
    if(dx[to]==-1){
      f=7-pret;
    }
    return drop(t,f,tox,toy);
  }

  seta(t,f,x,y);
  return 0;
}


int main(){
  int n;
  while(cin>>n,n){
    for(int i=0;i<220;i++){
      for(int j=0;j<220;j++){
	for(int k=0;k<220;k++){
	  height[i][j]=0;
	  field[i][j][k]=0;
	}
      }
    }
    for(int i=0;i<n;i++){
      int t,f;
      cin>>t>>f;
      drop(t,f,110,110);
    }
    vector<int> ans(6,0);
    for(int i=0;i<220;i++){
      for(int j=0;j<220;j++){
	if(height[i][j]!=0){
	  ans[field[i][j][height[i][j]-1]-1]++;
	}
      }
    }
    for(int i=0;i<6;i++){
      cout<<ans[i];
      if(i!=5) cout<<" ";
      else cout<<endl;
    }
  }

  return 0;
}

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int X, N;
        cin >>X >>N;
        vector<bool> p(102, false);
        Rep0(i, N) {
                int pp;
                cin >>pp;
                p.at(pp)=true;
        }
        int S=111;
        int XX=0;
        for(int i=0; i<=101; i++) {
                if (!p.at(i)) {
                        if (S>abs(i-X)) {
                                S=abs(i-X);
                                XX=i;
                        }
                }
        }
        cout <<XX <<endl;
        return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int h, a;
    cin >> h >> a;

    int res;
    if(h%a == 0) res = h/a;
    else res = h/a + 1;
    
    cout << res << endl;
}

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

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 58;
typedef pair< int64, int > Pi;

struct edge
{
  int to, cost;
};

vector< edge > g[100001];
int64 dp[100001][10];

int main()
{
  int N, M, R, Q;
  cin >> N >> M >> R >> Q;


  for(int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    g[b].push_back((edge) {a, c});
  }

  fill_n(*dp, 100001 * 10, INF);
  priority_queue< Pi, vector< Pi >, greater< Pi > > que[11];
  for(int i = 1; i <= N; i++) {
    que[i % R].emplace(0, i);
    dp[i][i % R] = 0;
  }
  for(int i = 0; i < R; i++) {
    while(!que[i].empty()) {
      auto p = que[i].top();
      que[i].pop();
      if(p.first > dp[p.second][i]) continue;
      for(auto &e : g[p.second]) {
        if(p.first + e.cost >= dp[e.to][i]) continue;
        dp[e.to][i] = p.first + e.cost;
        que[i].emplace(dp[e.to][i], e.to);
      }
    }
  }

  int64 ret = 0;
  while(Q--) {
    int64 X, Y, Z;
    cin >> X >> Y >> Z;
    int64 cost = 0;
    for(int i = 0; i < R; i++) {
      cost = max(cost, Z - dp[X][i] - dp[Y][i]);
    }
    ret += cost;
  }
  cout << ret << endl;
}

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

int main(){
  string S;
  cin >> S;
  long long ans=0;
  int N = S.size();
  
  for(int bit=0;bit<(1<<(N-1));bit++){
    string s="";
    for(int i=0;i<N;i++){
      s+=S.at(i);
      if(bit>>i&1){
        ans+=stoll(s);
        s="";
      }
    }
    ans+=stoll(s);
    s="";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3608
/* ex4_2
   shu_t */

#include<stdio.h>
#include<math.h>

int main(void){
  int hour, minute;
  double hour_hand,minute_hand;
  double arg,ans,squared_ans;
  //input length of hour_hand and minute_hand
  //input hour and minute
  scanf("%lf %lf %d %d",&hour_hand,&minute_hand,&hour,&minute);
  //calculate argument ((60*H+M)/720-M/60)*2π
  arg = (60*hour-11*minute)*M_PI/360;
  //calculate squared_ans
  squared_ans = pow(hour_hand,2)+pow(minute_hand,2)-2*hour_hand*minute_hand*cos(arg);
  //calcurate square root
  ans = sqrt(squared_ans);
  //output the answer
  printf("%.10lf\n",ans);
  return 0;
}


Measured memory_bytes: 2640
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    make(int, n, k);
    cout << min(n % k, k - n % k);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int dy[2] = {1,0};
int dx[2] = {0,1};
int h,w;
vector<string>s(10);


int main(){
    string t;
    cin >> t;
    for(int bit = 0; bit < (1 << 3); bit++){
        vector<int> S = bitSearch(bit, 3);
        int sum = t[0] - '0';
        S.push_back(INF);

        rep(i, 3){
            if(i == *lower_bound( ALL(S), i))sum += t[i+1] - '0';
            else sum -= t[i+1] - '0';
        }

        if(sum == 7){
            cout << t[0];
            rep(i, 3){
                if(i == *lower_bound( ALL(S), i))cout << '+';
                else cout << '-';
                cout << t[i+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }

}



Measured memory_bytes: 256
N, K = map(int, input().split())
l = list(map(str, input().split()))

for i in range (N, 100000): 
	k = str(i)
	counter = 0
	for j in range (0, K):
		if k.find(l[j]) >= 0:
			counter+=1
	if counter == 0:
		print(i)
		exit()

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int n,m; 
	cin>>n>>m; 
	int p = 1;
	for(int i=1;i<=m;i++)p*=2;
	int ans = p*(n*100+m*1800);
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  
  int N=0;
  
  cin >> N;
  
  vector<int> v(N);
  
  for(int i=0; i<N; i++) {
    
    cin >> v.at(i);
    
  }
  
  int min = N+1;
  int count = 0;
  
  for(int i=0; i<N; i++) {
    
    if(v.at(i)<min) {
      
      count++;
      
      min = v.at(i);
      
    }
    
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 1024
// Problem : C - Connect Cities
// Contest : AtCoder - ACL Beginner Contest
// URL : https://atcoder.jp/contests/abl/tasks/abl_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// Macros

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(x) (int) x.size()
#define mod 1000000007
#define EPS 1e-9
#define inf 1e10
#define PI acos(-1.0)
#define int long long
#define N 100005

// Solution

struct dsu {
  vi p, size;
  dsu(int n) {
    p.resize(n + 1), size.resize(n + 1);
    for (int i = 0; i <= n; i++) size[i] = 1, p[i] = 0;
  }
  int find(int u) {
    if (!p[u]) return u;
    return p[u] = find(p[u]);
  }
  void merge(int u, int v) {
    u = find(u);
    v = find(v);
    if (u != v) {
      if (size[u] < size[v]) swap(u, v);
      p[v] = u;
      size[u] += size[v];
    }
  }
};

void solve() {
  int n, m;
  cin >> n >> m;
  dsu d(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    d.merge(u, v);
  }
  set<int> s;
  for (int i = 1; i <= n; i++) {
    s.insert(d.find(i));
  }
  cout << sz(s) - 1;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

  int tests;
  tests = 1;
  // cin>>tests;

  for (int test = 1; test <= tests; test++) {
    // cout<<"Case #"<<test<<": ";
    solve();
  }

  return 0;
}

Measured memory_bytes: 8372
use proconio::*;
use std::collections::HashMap;

fn main() {
    input! {
        n: i64,
    };

    let mut n = n;
    let mut hm = HashMap::new();
    for i in 2..n {
        if i * i > n {
            break;
        }

        while n % i == 0 {
            hm.entry(i)
                .and_modify(|x| *x += 1)
                .or_insert(1);

            n /= i;
        }
    }

    if n != 1 {
        hm.entry(n)
            .and_modify(|x| *x += 1)
            .or_insert(1);
    }

    let mut ans = 0;
    for (_, v) in hm {
        let mut sum = 0;
        for i in 1..v+1 {
            if sum + i > v {
                break;
            }

            ans += 1;
            sum += i;
        }
    }

    println!("{}", ans);
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int a,b,c;
	cin >> a >> b >> c;

	bool check = false;
	for(int i = a; i <= a*b; i += a)
		if(i%b == c)
			check = true;

	if(check)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理
        int countA = s.replaceAll("[^a]", "").length();
        int countB = s.replaceAll("[^b]", "").length();
        int countC = s.replaceAll("[^c]", "").length();

        int min = Math.min(Math.min(countA, countB), countC);
        boolean judge = isNearly(min, countA) && isNearly(min, countB) && isNearly(min, countC);
        String result = judge ? "YES" : "NO";

        // 出力
        System.out.println(result);
    }

    public static boolean isNearly(int n, int target) {
        return target == n || target == n + 1;
    }
}


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

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

  vector<int> data(N);

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

  int next = 0, result = -1;
  for (int i = 1; i <= N; i++) {
    if (data.at(next) == 2) {
      result = i;
      break;
    }
    
    next = data.at(next) - 1;
  }
  
  cout << result << endl;
}


Measured memory_bytes: 640
import sys
input=sys.stdin.readline
N,T=map(int,input().split())
L=[]
for i in range(N):
    a,b=map(int,input().split())
    L.append((a,b))
L.sort()

dp=[-1 for i in range(6001)]
dp[0]=0
for i in range(N):
    for j in range(T):
        if dp[T-1-j]!=-1:
            dp[T-1-j+L[i][0]]=max(dp[T-1-j+L[i][0]],dp[T-1-j]+L[i][1])
print(max(dp))

Measured memory_bytes: 42588
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	string s;
	cin >> s;
	if(s.back() == 's') s += "es";
	else s += 's';
	cout << s;
}

Measured memory_bytes: 3640
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
n = int(input())
A = list(map(int,input().split()))
A.sort()
index = bisect_left(A,0)
if index == n or index == n-1:
    ans = A[n-1]
    for i in range(n-1):
        ans -= A[i]
    print(ans)
    now = A[n-1]
    for i in range(n-1):
        x = now
        y = A[i]
        print(x,y)
        now -= y
else:
    if A[index] == 0:
        ans = 0
        for i in range(index+1,n):
            ans += A[i]
        for i in range(index):
            ans -= A[i]
        print(ans)
        now = 0
        for i in range(index+1,n):
            x = now
            y = A[i]
            if i != n-1:
                print(x,y)
                now -= y
            else:
                print(y,x)
                now = y-x
        for i in range(index):
            x = now
            y = A[i]
            print(x,y)
            now -= y
    else:
        if A[0] > 0 :
            ans = -A[0]
            for i in range(1,n):
                ans += A[i]
            print(ans)
            now = A[0]
            for i in range(1,n):
                x = now
                y = A[i]
                if i == n-1:
                    print(y,x)
                else:
                    print(x,y)
                    now -= y
        else:
            ans = 0
            for i in range(index):
                ans -= A[i]
            for i in range(index,n):
                ans += A[i]
            print(ans)
            now = A[0]
            for i in range(index+1,n):
                x = now
                y = A[i]
                print(x,y)
                now -= y
            print(A[index],now)
            now = A[index] - now
            for i in range(1,index):
                x = now
                y = A[i]
                print(x,y)
                now -= y
        

Measured memory_bytes: 16072
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    cins(all(a));
    rep(i,k,n){
        Yes(a[i] > a[i-k]);
    }
}


Measured memory_bytes: 4780
using System;

namespace ITP1_6_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int r = int.Parse(strs[0]);
            int c = int.Parse(strs[1]);
            int[,] matrix = new int[r, c];
            int[] vector = new int[c];
            for (int i = 0; i < r; i++)
            {
                string[] row = Console.ReadLine().Split(' ');
                for (int j = 0; j < c; j++) matrix[i, j] = int.Parse(row[j]);
            }
            for (int i = 0; i < c; i++) vector[i] = int.Parse(Console.ReadLine());
            for (int i = 0; i < r; i++)
            {
                int sum = 0;
                for (int j = 0; j < c; j++)
                {
                    sum += matrix[i,j] * vector[j];
                }
                Console.WriteLine(sum);
            }
        }
    }
}

Measured memory_bytes: 9256
#include<bits/stdc++.h>
#define N 100005
#define M 1000000007
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define rep(i,s,e) for(int i=s;i<e;i++)
#define drep(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(0);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a%2 || b%2 || c%2){
        cout<<0<<endl;
        return 0;
    }
    if(a==b&&b==c){
        cout<<-1<<endl;
        return 0;
    }
    ll ca=a,cb=b,cc=c,ans=0;
    while(ca%2==0 && cb%2==0 && cc%2==0){
       a= cb/2 + cc/2;
       b= ca/2 + cc/2;
       c= ca/2 + cb/2;
       ans++;
       ca=a,cb=b,cc=c;
    }       
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

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

int main()
{
  long long N;
  std::cin >> N;
  long long ans = 0;
  for(long long i = 1; i <= N; ++i)
  {
    long long x = N / i;
    ans += (i * (x + 1) * x) / 2;
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 3636
N = int(input())
txy = [list(map(int, input().split())) for _ in range(N)]
T = X = Y = 0
ans = "Yes"
for t, x, y in txy:
  a = (t-T) - (abs(X-x) + abs(Y-y))
  if a % 2 == 0 and abs(X-x) + abs(Y-y) <= t - T:
    T, X, Y = t, x, y
  else:
    ans = "No"
    break
print(ans) 

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

using namespace std;

const int N = 1e5 + 7 ; 

int n , m ; string s; 

bool p(string s ){
    int sz = s.size() ; 
    for(int i = 0 ; i < sz /2  ; i++){
        if(s[i]!=s[sz-1-i])
        return 0 ;
    }
    return 1 ;
}

int main(){
  //  freopen("in.in" , "r" , stdin); 
    cin>>s ; 
    n = s.size() ; 
    if(p(s) && p(s.substr(0 ,n/2 )) && p(s.substr( n - n/2, n/2) )){
        cout<<"Yes";
    }
    else 
    cout<<"No";

    return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define nl "\n"
using namespace std;

void solve()
{
	int x, y;
	scanf("%d %d",&x, &y);
	if(2*x > y)
		printf("No\n");
	else
	{
		int r = y-2*x;
		if(r%2 == 0 && r<=2*x)
			printf("Yes\n");
		else
			printf("No\n");
	}
}
int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 3732
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_list_of_float():
    return [float(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


YPB = 380000.0


# inputs
N = 0
X = [0.0]
U = [""]


def set_inputs():
    global N, X, U
    N = get_int()
    X = []
    U = []
    for _ in range(N):
        x, u = get_str().split()
        X.append(float(x))
        U.append(u)


def main():
    set_inputs()
    sum = 0.0
    for i in range(N):
        u = 1
        if U[i] == 'BTC':
            u = YPB
        sum += X[i] * u
    print(sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cassert>
#include <string.h>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n-1;i>=0;i--)///n-1番目からn回
#define  REP(i,a,b) for(int i=a;i<b;i++) ///a番目からb回
#define  RREP(i,a,b) for(int i=a;i<b;i--)
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;



//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///*min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();

int gcd(int a,int b);
int main() {

	ll n, ans = 0,cnt=0, tmp = 0,sum=0;
	cin >> n;
	vi a(n),b(n);
	rep(i,n) {
		cin >> tmp;
		if (tmp < 0) {
			cnt++;
			sum += abs(tmp);
			b[i]=abs(tmp);
		}
		else {
			sum += tmp;
			a[i] = tmp;
			b[i]=tmp;
		}
	}
	if(cnt%2==0)
		ans=sum;
	else
		ans=sum-2*(*min_element(b.begin(),b.end()));
	cout<<ans<<endl;
		return 0;
}







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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mk make_pair
int main(){
    string str;
    cin>>str;
    if(str[0]=='R' && str[1]=='R' && str[2]=='R')
     cout<<3<<endl;
    else if((str[0]=='R' && str[1]=='R') ||(str[1]=='R' && str[2]=='R'))
     cout<<2<<endl;
    else if(str[0]=='R' || str[1]=='R' || str[2]=='R')
     cout<<1<<endl;
    else
     cout<<0<<endl;
}


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

using i64 = std::int64_t;

namespace io {
  using i64 = std::int64_t;
  constexpr int is = 1 << 17;
  char ib[is], *ip = ib + is, it;
  inline char getc() {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    return *ip++;
  }
  inline i64 scan() {
    i64 r = 0;
    if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
    else while ((it = *ip++) & 16) r = r * 10 + it - '0';
    return r;
  }
  constexpr int os = 1 << 17;
  char ob[os], *op = ob, ot;
  inline void putc(const char c) {
    *op++ = c;
    if (op == ob + os) { write(STDOUT_FILENO, ob, os); op = ob; }
  }
  /* x shoud be greater than or equal to zero */
  inline void print(i64 x) {
    char d[20];
    int i = 0;
    while (true) {
      d[i] = x % 10 + 48;
      x /= 10;
      ++i;
      if (x <= 0) break;
    }
    while (i--) {
      putc(d[i]);
    }
  }
  inline void flush() {
    write(STDOUT_FILENO, ob, op - ob);
  }
}

signed main() {
  using namespace io;
  i64 h = scan();
  i64 n = scan();
  i64 s = 0;
  for (int i = 0; i < n; i++) {
    i64 a = scan();
    s += a;
  }
  if (s >= h) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 384
w,h,n = map(int,input().split())
l = [[0] * w for i in range(h)]
z = [list(map(int,input().split())) for i in range(n)]
x,y,a = [list(i) for i in zip(*z)]

for i in range(n):
    if a[i] == 1:
        for j in range(h):
            for k in range(x[i]):
                l[j][k] = 1
    if a[i] == 2:
        for j in range(h):
            for k in range(x[i],w):
                l[j][k] = 1
    if a[i] == 3:
        for j in range(y[i]):
            for k in range(w):
                l[j][k] = 1
    if a[i] == 4:
        for j in range(y[i],h):
            for k in range(w):
                l[j][k] = 1

t = 0
for i in range(h):
    t += l[i].count(0)

print(t)

Measured memory_bytes: 9180
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <random>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}

#define MOD 1000000007
#define inf 2000000000

long long resp(vector<int> inp)
{
	long long curr_sum = 0;
	long long ans = 0;
	for (int i = 0; i < inp.size(); i++)
	{
		curr_sum += inp[i];
		if (i % 2 == 0 && curr_sum <= 0)
		{
			ans += 1 - curr_sum;
			curr_sum = 1;
		}
		else if (i % 2 == 1 && curr_sum >= 0)
		{
			ans += curr_sum + 1;
			curr_sum = -1;
		}
	}

	return ans;
}

int main() {

#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin >> n;

	vector<int> vec(n), vec2(n);
	for (int i = 0; i < n; i++)
	{
		cin >> vec[i];
		vec2[i] = -vec[i];
	}
	
	cout << min(resp(vec), resp(vec2));


	return 0;
}


Measured memory_bytes: 1792
def main():
    c = [[0] * 3] * 3

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

    if (c[0][0] - c[1][0]) == (c[0][1] - c[1][1]) == (c[0][2] - c[1][2]):
        if (c[1][0] - c[2][0]) == (c[1][1] - c[2][1]) == (c[1][2] - c[2][2]):
            if (c[0][0] - c[2][0]) == (c[0][1] - c[2][1]) == (c[0][2] - c[2][2]):
                print('Yes')
                exit()
    print('No')

main()

Measured memory_bytes: 38384
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  long double X;
  cin >> X;
  ll N=100;
  ll cnt = 0;
  while(N<X){
    N*=1.01;
    cnt++;
  }
  cout << cnt;

  return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
const int N = 102;

int n;
int a[N];
int p[N], s[N];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = 1; i <= n; ++i)
        p[i] = p[i - 1] + a[i];
    for (int i = n; i >= 1; --i)
        s[i] = s[i + 1] + a[i];
    int ans = 1000000009;
    for (int i = 1; i < n; ++i)
        ans = min(ans, abs(p[i] - s[i + 1]));
    cout << ans << endl;
    return 0;
}


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

int main() {
    ll x, c500 = 0, c5 = 0;
    cin >> x;
    while (x >= 500){
        x -= 500;
        c500++;
    }
    while (x >= 5){
        x -= 5;
        c5++;
    }

    cout << 1000 * c500 + 5 * c5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int k, s;
  cin >> k >> s;
  
  int ans0 = 0;
  int ans1 = 0;
  int ans2 = 0;
 
  for (int x = 0; x <= k; x++) {
    int y = 0;
    for (; y <= k - 1; y += 2) {
      int z = 0;
      for (; z <= k - 1; z += 2) {
        ans0 += x+y+z == s-0; 
        ans1 += 2*(x+y+z == s-1);
        ans2 += x+y+z == s-2; 
      }

      for (; z <= k; z++) {
        ans0 += x+y+z == s;
        ans1 += x+y+z == s-1;
      }
    }
    
    for (; y <= k; y++) {
      int z = 0;
      for (; z <= k - 1; z += 2) {
        ans0 += x+y+z == s-0; 
        ans1 += x+y+z == s-1;
      }

      for (; z <= k; z++) {
        ans0 += x+y+z == s;
      }
    }
  }

  int ans = ans0+ans1+ans2;

  cout << ans << endl;
}


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

int main() {
  int a;
  string s;
  cin >> a;
  cin >> s;
  if (a >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
  
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
  }

#[fastout]
fn main() {
    input!{
        n: usize,
        a: [usize;n],
    }

    let mut sum = 0;
    for i in 1..n {
        sum += a[i];
    }
    debug!(sum);
    let inf = 10_0000_0000 + 7;
    sum %= inf;

    let mut ans = 0;
    for i in 0..n-1 {
        ans += a[i]*sum;
        ans %= inf;
        sum = sum + inf - a[i+1];
        sum %= inf;
        debug!(sum);
        debug!(ans);
    }

    println!("{}", ans);

}


Measured memory_bytes: 11392
N = int(input())
M = 0
num = 1
for i in range(1, N+1):
    count = 0
    while i % 2 ==0:
        i = i / 2
        count = count + 1
    if count > M:
        M = count
        num = i * (2 ** count)
print(int(num))



Measured memory_bytes: 2940
import java.util.*;
class Main {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int a = sc.nextInt();
            String d = sc.next();
            int b = sc.nextInt();
            if(d.equals("?")) break;
            if(d.equals("+")) System.out.println(a + b);
            if(d.equals("-")) System.out.println(a - b);
            if(d.equals("*")) System.out.println(a * b);
            if(d.equals("/")) System.out.println(a / b);
        }
    }
}


Measured memory_bytes: 26432
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll N;
        cin>>N;
        ll x=0;
        ll y=0;
        ll t=0;
        rep(i,N){
            ll T,X,Y;
            cin>>T>>X>>Y;
            if(abs(X+Y-x-y)>T-t||abs(X+Y-x-y)%2!=(T-t)%2){
                cout<<"No"<<endl;
                return 0;
            }
            x=X;
            y=Y;
            t=T;
        }
        cout<<"Yes"<<endl;
    }

Measured memory_bytes: 256
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )

using namespace std;

int N;
int C[25], V[25];

int main(void) {

	scanf("%d", &N);

	REP(i, 0, N) scanf("%d", &V[i]);
	REP(i, 0, N) scanf("%d", &C[i]);

	int ans = 0;

	REP(i, 0, N) {
		if (V[i] > C[i]) ans = ans + V[i] - C[i];
	}

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

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using str = string; using cstr = const str;
using ll = long long; using ull = unsigned long long; using cint = const int; using cll = const ll;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7;
static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int32_t main(int32_t argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef _DEBUG
    vs args(argv, argv+argc);
    string sample = make_sample(args, 1);
    ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#endif


    int N, M; cin>>N>>M;
    vi A(N); REP(i,N) cin>>A[i];

    int sum=0;
    REP(i,N) sum+=A[i];

    int cnt = 0;
    // if (A[i] >= sum/4M)
    REP(i,N) {
        if (A[i] * 4 * M >= sum) cnt++;
    }
    string ans = cnt>=M ? "Yes" : "No";

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
H,W = list(map(int,input().split()))
S = [list(input().replace('.','0')) for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '#': continue
        for k in [-1,0,1]:
            for l in [-1,0,1]:
                if 0 <= i+k <= H-1 and 0 <= j+l <= W-1 and S[i+k][j+l] == '#':
                    S[i][j] = str(int(S[i][j])+1)
for s in S:
    print(''.join(s))

Measured memory_bytes: 3316
import scala.io.StdIn._
import scala.math._

object Main extends App with StdInHelper {
  val n = readLine()

  println(if (n.contains("7")) "Yes" else "No")
}

trait StdInHelper {
  def readInts = readLine.split(" ").map(_.toInt)
  def readLongs = readLine.split(" ").map(_.toLong)
}


Measured memory_bytes: 54468
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> // Common file
#include<ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
ll t = 1, tt;
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (x*y)%hell;}
inline ll powMod(ll base,ll expo){
	ll ans=1;
	expo%=(hell-1);
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base);
		expo>>=1;
	}
	return ans;
}
void solve(){
	ll n, m;
	cin>>n>>m;
	rep(i,0,m){
		ll x;
		cin>>x;
		n-=x;
	}
	if(n<0)cout<<"-1";
	else
		cout<<n;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <iostream>
#include<math.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; }
int main()
{
    int64_t N, C, K;
    cin >> N >> C >> K;
    vector<int64_t>vec(N);
    for (int64_t i=0; i<N; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end(), greater<int64_t>());
    int64_t sum_bus_count = 1;
    int64_t til_can_wait = vec[0] - K;
    int64_t ninzuu = 1;
    for (int64_t i=1; i<N; i++) {
        int64_t time = vec[i];
        if (til_can_wait > time || ninzuu >= C) {
            sum_bus_count += 1;
            til_can_wait = time - K;
            ninzuu = 1;
        } else {
            ninzuu += 1;
        }
    }

    cout << sum_bus_count << endl;
    return 0;
}

Measured memory_bytes: 4052
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    static int[] xl = {-1,-1,-1,0,0,1,1,1};
    static int[] yl = {-1,0,1,-1,1,-1,0,1};
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] map = new char[h][w];
        for(int i = 0; i < h; i++){
            map[i] = sc.next().toCharArray();
        }
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(map[i][j] == '#') continue;
                int a = checkCount(map,i,j,h,w);
                map[i][j] = String.valueOf(a).charAt(0);
            }
        }
        for(int i = 0; i < h; i++){
            System.out.println(new String(map[i]));
        }
    }
    
    public static int checkCount(char[][] map, int y, int x, int h, int w){
        int ans = 0;
        for(int i = 0; i < 8; i++){
            if(check(y+yl[i], x+xl[i], h, w) && map[y+yl[i]][x+xl[i]] == '#'){
                ans++;
            }
        }
        return ans;
    }
    
    public static boolean check(int y, int x, int h, int w){
        return (0 <= y && y < h && 0 <= x && x < w);
    }
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  ll ans = n*(n-1)/2;
  cout << ans<< endl;
  return 0;
}


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

int main(){
    int n, m;
    while(scanf("%d%d", &n, &m)!=EOF){
        vector<int> foo(n, 0);
        for(int i=0; i<m; i++){
            int u, v;
            scanf("%d%d", &u, &v);
            u--;
            v--;
            foo[u]^=1;
            foo[v]^=1;
        }
        int sum=0;
        for(const int x : foo){
            sum+=x;
        }
        if(!sum){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define mp make_pair
#define F(i, a, n, b) for(int i=a;i<n;i+=b)
#define REVF(i, a, b, c) for(int i=a;i>=b;i-=c)
#define REP(i, n) F(i, 0, n, 1)
#define REP1(i, n) F(i, 1, n+1, 1)
#define REV(i, n) REVF(i, n, 0, 1)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define MOD 1000000007

typedef long long ll;

const int MAX = 3e6 + 5;

int n,l[MAX],cnt = 0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	REP(i,n){
		cin>>l[i];
	}
	sort(l,l+n);
	REP(a,n){
		F(b,a+1,n,1){
			F(c,b+1,n,1){
				if(l[c] < l[a] + l[b])
					cnt++;
			}
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;






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

	int H[200000];

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

	int ans = 1;

	for (int j = N - 1; j >= 1; j--) {
		if (H[j] == H[j + 1] + 1) { H[j] = H[j] - 1; }
		else if (H[j] > H[j + 1] + 1) { ans = 0; }
	}

	if (ans == 1) { cout << "Yes"; }
	else { cout << "No"; }

	system("PAUSE");


}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}
int main(){
	
	ll x; cin>>x; ll a = -1,b= -1;
	for(int i = 0; i <= 10000; i++){
		ll need = binpow(i,5)-x;
		ll l = 0; ll r = 10000;
		ll mid;
		bool flag = false;
		while(l <= r){
			mid = l + (r-l)/2;
			if(binpow(mid,5) == abs(need)) {flag = true; break;}
			else if(binpow(mid,5) < abs(need)) l = mid+1;
			else r = mid-1;
		}
		if(flag){
			a = i; 
			if((need < 0)) b = mid*-1;
			 else b = mid; 
			 break;
		}
	}
	cout<<a<<" "<<b<<"\n";
}

Measured memory_bytes: 3652
def main
  gets
  as = gets.chomp.split(' ').map(&:to_i)
  bs = gets.chomp.split(' ').map(&:to_i)
  cs = gets.chomp.split(' ').map(&:to_i)

  score = 0
  pre_i = -2
  as.each do |a|
    i = a-1
    score += bs[i]
    if i - pre_i == 1
      score += cs[i-1]
    end
    pre_i = i
  end
  puts score
end

main if $0 == __FILE__


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

int k;
vector<long long> nums;
string num;

void generate(int cnt, bool zero){
	if(zero && cnt < 10)
		for(char i = '0'; i <= '9'; i++){
			num += i;
			generate(cnt + 1, i == '0');
			num.pop_back();
		}
	else if(cnt < 10)
		for(char i = max('0', (char)(num.back() - 1)); i <= min('9', (char)(num.back() + 1)); i++){
			num += i;
			generate(cnt + 1, false);
			num.pop_back();
		}
	else nums.push_back(stoll(num));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> k;
	generate(0, true);
	sort(nums.begin(), nums.end());
	cout << nums[k] << "\n";
	return 0;
}

Measured memory_bytes: 2420