akhauriyash/Code-Regression huggingface dataset:
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Split(' ');

        var A = new int[n + 2];
        for (int i = 1; i < n + 1; i++)
        {
            A[i] = int.Parse(s[i - 1]);
        }

        var sum = 0;
        for (int i = 0; i < n + 1; i++)
        {
            sum += Math.Abs(A[i] - A[i + 1]);
        }

        for (int i = 1; i < n + 1; i++)
        {
            if (A[i - 1] < A[i] && A[i] < A[i + 1])
            {
                Console.WriteLine(sum);
            }
            else
            {
                var x = Math.Abs(A[i - 1] - A[i]) + Math.Abs(A[i] - A[i + 1]);
                var y = Math.Abs(A[i - 1] - A[i + 1]);
                Console.WriteLine(sum - x + y);
            }
        }
    }
}


Measured memory_bytes: 26844
S = map(int, input())

a, b = 0, 1
for s in S:
    a, b = a + s if a + s < b + 10 - s else b + 10 - s, a + (s + 1) if a + (s + 1) < b + 10 - (s + 1) else b + 10 - (s + 1)

print(a)

Measured memory_bytes: 5492
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SZ(v) (int((v).size()))
#define ALL(vec) (vec).begin(),(vec).end()
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
using namespace std;
template<typename T, typename V = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, V, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; // find_by_order(), order_of_key()

using ll = long long int;
using i64 = long long int;
template <typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template <typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}

void err(__attribute__((unused)) istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl;
  err(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& os, const pair<T1, T2>& buf) {
  return os << "(" << buf.first << ": " << buf.second << ")";
}
template<typename T>
inline ostream &operator << (ostream & os,const vector<T>& v) {
  bool first = true;
  os << "[";
  for (const auto &e: v) {
    if(!first) os << ", ";
    os << e;
    first = false;
  }
  return os << "]";
}
template<typename T>
inline ostream &operator << (ostream & os,const set<T>& v) {
  bool first = true;
  os << "{";
  for (auto ii = v.begin(); ii != v.end(); ++ii) {
    if(!first) os << ", ";
    os << *ii;
    first = false;
  }
  return os << "}";
}
template<typename T>
inline ostream &operator << (ostream & os,const unordered_set<T>& v) {
  bool first = true;
  os << "{";
  for (const auto &x : v) {
    if(!first) os << ", ";
    os << x;
    first = false;
  }
  return os << "}";
}
template<typename T1, typename T2>
inline ostream &operator << (ostream & os,const map<T1, T2>& v) {
  bool first = true;
  os << "{";
  for (const auto &e : v) {
    if(!first) os << ", ";
    os << e;
    first = false;
  }
  return os << "}";
}
template<typename T>
ostream &operator << (ostream & os,const vector<vector<T>>& v) {
  for (auto &u: v) os << '\n' << u;
  return os;
}
template<typename T>
void finish(T ans) {cout << ans << '\n'; exit(0);}
const int MOD = 1e9 + 7;
const long long INF = 1e18;
const double EPS = 1e-6;
#define PI 3.14159265358979323846
/***********************************************************************/
inline int add(int a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
}
inline int sub(int a, int b) {
    a -= b;
    if (a < 0) a += MOD;
    return a;
}
inline int mul(int a, int b) {
    return (long long) a * b % MOD;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> cnt(26, 1);
  for (char c: s) cnt[c - 'a']++;
  int ans = 1;
  for (int x: cnt) ans = mul(ans, x);
  ans = sub(ans, 1);
  cout << ans << '\n';
  
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#define ll long long
using namespace std;

int main () {
  ll x, y, z, k;
  cin >> x >> y >> z >> k;
  ll a[x], b[y], c[z];
  ll ab[3000];
  for (ll i = 0; i < 3000; i++) ab[i] = 0;
  for (ll i = 0; i < x; i++) cin >> a[i];
  for (ll i = 0; i < y; i++) cin >> b[i];
  for (ll i = 0; i < z; i++) cin >> c[i];
  if (x * y * z <= 3000) {
    priority_queue<ll> box;
    for (ll i = 0; i < x; i++) {
      for (ll j = 0; j < y; j++) {
        for (ll l = 0; l < z; l++) {
          box.push(a[i] + b[j] + c[l]);  
        }  
      }  
    }  
    for (ll i = 0; i < k; i++) {
      cout << box.top() << endl;
      box.pop();  
    }
  }
  else {
    priority_queue<ll> box;
    for (ll i = 0; i < x; i++) {
      for (ll j = 0; j < y; j++) {
        box.push(a[i] + b[j]);  
      }  
    }  
    for (ll i = 0; i < k; i++) {
      ab[i] = box.top();
      box.pop();  
    }
    priority_queue<ll> last;
    for (ll i = 0; i < k; i++) {
      for (ll j = 0; j < z; j++) {
        last.push(ab[i] + c[j]);  
      }  
    }
    for (ll i = 0; i < k; i++) {
      cout << last.top() << endl;
      last.pop();  
    }
  }
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() {
    //my-code
    string S; cin >> S;
    if(S[0]=='7' || S[1] == '7' || S[2] == '7') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define MAX INT_MAX
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
void solve() {
 	char x;
 	cin >> x;
 	int z = x - 'a';
 	z++;
 	cout << char(z+97);
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,a,b) for (ll i = (a) ; i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい


void Main(){
	ll N, p;
	cin >> N;

	VI h(N);
	rep(i, N) cin >> h[i];

	p = h[0] - 1;
	rep(i, N-1){
		if(h[i+1] < p){
			cout << "No" << endl;
			return;
		}else if(h[i+1] > p){
			p = h[i+1] - 1;
		}
	}
	cout << "Yes" << endl;





}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


Measured memory_bytes: 3736
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define INF 10000000

int sq[102][102];//y,x
int w,h;
int sum;
int nx[][6]={
	{1,0,-1,-1,-1,0},
	{1,1,0,-1,0,1},//右隣から時計回り
};
	
int ny[6]={0,1,1,0,-1,-1};

void dfs(int y,int x){
	sq[y][x]=-1;
	REP(i,6){
		int npx=x+nx[y%2][i];
		int npy=y+ny[i];
		if(npx>=0&&npx<=w+1&&npy>=0&&npy<=h+1){
			if(sq[npy][npx]==1)sum++;
			else if(sq[npy][npx]==0)dfs(npy,npx);
		}
	}
}

int main(){
	
	cin>>w>>h;
	REP(i,102)REP(j,102)sq[i][j]=0;
	
	
	REP(i,h)REP(j,w){
		cin>>sq[i+1][j+1];
	}
	sum=0;
	dfs(0,0);
	cout<<sum<<endl;
	return 0;
}

/*
8 4
0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0

8 4
0 1 0 0 0 0 0 0
0 1 1 0 0 0 0 0
1 1 1 0 0 0 0 0
0 1 1 0 0 0 0 0

8 4
0 0 0 0 0 1 1 1
0 0 0 0 0 1 0 0
0 0 0 0 1 1 1 1
0 0 0 0 1 0 1 0

*/

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




int main(){
    int n,S[100010],q,T,cnt=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>S[i];
    }
    cin>>q;
    
    int mid,left,right;
    
    
    for(int i=0;i<q;i++){
        cin>>T;
        left=0;right=n;
        
        while(left<right){
            mid=(left+right)/2;
            if(S[mid]==T){
                cnt++;
                break;
            }
            else if(S[mid]>T){
                right=mid;
            }
            else{
                left=mid+1;
            }
        }
        
    }
    cout<<cnt<<endl;
}






Measured memory_bytes: 3392
// ToDo
// Link: https://atcoder.jp/contests/dp/tasks/dp_c
#include <iostream>
#include <climits>
#include <set>
#include <vector>
#include <stdio.h>
#include <map>
#include <stack>
#include <algorithm>
#include <unordered_map>
#define ll long long int
#define fastio ios_base::sync_with_stdio(false)
#define fastcin cin.tie(NULL)
using namespace std;
class Node{
public:
	int a,b,c;
};
int main(){

	fastio;
	fastcin;	
	
    
    // freopen("small_input.txt", "r", stdin);
    
    // freopen("small_output.txt", "w", stdout);
    
    int n;
	cin>>n;
    Node* arr = new Node[n];
	
    for(int i=0;i<n;i++){
    	int a,b,c;
    	cin>>a>>b>>c;
    	arr[i].a = a;
    	arr[i].b = b;
    	arr[i].c = c;
    }

    Node* dp = new Node[n];
    dp[0].a = arr[0].a;
    dp[0].b = arr[0].b;
    dp[0].c = arr[0].c;

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

    	dp[i].a = arr[i].a + max(dp[i-1].b,dp[i-1].c);
    	dp[i].b = arr[i].b + max(dp[i-1].a,dp[i-1].c);
    	dp[i].c = arr[i].c + max(dp[i-1].a,dp[i-1].b); 	
    	
    }
    

    cout<<max(dp[n-1].a,max(dp[n-1].b,dp[n-1].c));
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	int x,y;
	cin  >> x >> y;

	if(y%2 == 0 && 2*x <= y && y <= 4*x)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://atcoder.jp/contests/abc170/tasks/abc170_a


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(T &a){
	cout << a << '\n';
}
int n,a[1000005];

int main(){
	string s; g(s);
	rep(i,2){
		if(s[i] != s[2]){
			puts("Yes"); return 0;
		}
	}
	puts("No");
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int h,m,s,a,b;
	scanf("%d",&a);
	h=a/3600;
	b=a-h*3600;
	m=b/60;
	s=b-m*60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007
// order_of_key and *find_by_order
int32_t main()
{
	fast;
	int n;
	cin >> n;
	int k; cin >> k;
	int a[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	map<int, int > m;
	int st = 1;
	vector<int > v;
	v.push_back(1);
	m[1] = 1;
	st = a[1];
	while (1) {
		//cout << st << " ";
		if (m[st] == 1) {
			break;
		}
		else {
			m[st] = 1;
			v.push_back(st);
			st = a[st];
		}
		//cout << st << " ";
	}
	// for (int i : v) {
	// 	cout << i << " ";
	// }
	// cout << "\n";
	int u = -1;
	for (int i = 0; i < v.size(); i++) {
		if (a[v[v.size() - 1]] == v[i]) {
			u = i;
			break;
		}
	}
	//cout << u << " \n";
	if (k < u ) {
		cout << v[k];
	}
	else {
		vector<int >ans;
		for (int i = u ; i < v.size(); i++) {
			ans.push_back(v[i]);
		}
		// for (int i : ans) {
		// 	cout << i << " ";
		// }
		//cout << "\n";
		k -= u ;
		k %= ans.size();
		cout << ans[k];
	}
	// cout << v.size() << " ";
	// int rem = k % v.size();
	// cout << v[rem];











}

Measured memory_bytes: 19052
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	char c; cin >> c;
	c++;

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

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

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] str = stdR.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        int d = Integer.parseInt(str[2]);
        double colx = n;
        int diff = 1;
        while(diff <= d) {
            colx =  (n - diff) * 2;
            diff++;
        }
        colx = colx / ((long)n * n);
        System.out.println(colx * (m - 1));
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a,b,c,tmp,sum,ans=0;
  cin >> a >> b >> c;
  int N[b];
  rep(i,b){
    cin >> N[i];
  }
  rep(i,a){
    sum = c;
    rep(i,b){
      cin >> tmp;
      sum += tmp * N[i];
    }
    if(sum>0)ans++;
  }
  cout << ans;
}

Measured memory_bytes: 3484
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = 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 );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w; cin >> h >> w;
    vector<ll> s(4);
    s[0] = h * w;
    ll res = INF;
    for(ll i = 0; i < 2; i++){
        for(ll j = 1; j < h; j++){
            s[1] = w * j;
            s[2] = w / 2 * (h - j);
            s[3] = s[0] - s[1] - s[2];
            chmin(res, (max({s[1], s[2], s[3]})) - min({s[1], s[2], s[3]}));
        }
        for(ll j = 1; j < h; j++){
            s[1] = w * j;
            s[2] = (h - j) / 2 * w;
            s[3] = s[0] - s[1] - s[2];
            chmin(res, (max({s[1], s[2], s[3]})) - min({s[1], s[2], s[3]}));
        }
        ll tmp = h; h = w; w = tmp;
    }
    cout << res;
    cout << endl;
    return 0;
}


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

#define rep(i,l,r) for(int i=l;i<=r;++i)

int main()
{
	//freopen("1.in","r",stdin);
	int n,k;
	cin>>n>>k;
	int a;
	cin>>a;
	int mx=a,g=a;
	rep(i,2,n)
	{
		scanf("%d",&a);
		mx=max(mx,a);
		g=__gcd(g,a);
	}
	if(k<=mx&&(mx-k)%g==0)puts("POSSIBLE");
	else puts("IMPOSSIBLE");
}

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;

bool isAbove(pair<double, double> p1, pair<double, double> p2, pair<double, double> p3) {
	if (p1.first == p2.first) {
		return p3.first > p1.first;
	} else {
		return p3.second > p1.second + (p2.second - p1.second) * (p3.first - p1.first) / (p2.first - p1.first);
	}
}

void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	stack<int> st;
	int x;
	while (cin >> x) {
		if (x == 0) {
			cout << st.top() << endl;
			st.pop();
		} else {
			st.push(x);
		}
	}


}




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


	solve();
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

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

int main(){
    int  l,r,d;
    cin >> l >> r >> d;
    int cnt = 0;
    for( int i = l;i < r+1;i++){
        if(i % d == 0){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3592
n=int(input())
a=[[int(i) for i in input().split()] for _ in range(n)]
a=sorted(a,reverse=True,key=lambda x:x[1])

t=a[0][1]
for x in a:
    t=min(x[1],t)-x[0]
print("Yes" if t>=0 else "No")

Measured memory_bytes: 45512
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
using ll=long long;
using namespace std;
int main(){
  ll n,ans=0,tmp=0,tmp2,m=200;
  cin>>n;
  ll h[110];
  rep(i,0,n){cin>>h[i];m=min(m,h[i]);}
  rep(i,0,n)h[i]-=m;
  h[n]=0;
  ans=m;
  while(tmp!=n){
    tmp=n;
    bool p=false;
    rep(i,0,n+1){
      if(h[i]!=0){
        tmp=i,m=h[i],tmp2=i+1;
        rep(j,i+1,n+1){
          if(h[j]==0){tmp2=j;break;}
          m=min(m,h[j]);
        }
      rep(i,tmp,tmp2)h[i]-=m;
      ans+=m;
      p=true;
      }
      if(p)break;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef unsigned long long ll;
#define rep(i, x) for(int i=0;i < (x);i++)

int main() {
    ll H,W;
    cin >> H >> W;
    ll H1 = (W%2 == 1)? W/2 + 1: W/2;
    ll H2 = (W%2 == 1)? H1-1:H1;
    //cout << H1 << ":" << H2 << endl;
    ll H_gusu = H/2;
    ll H_kisu = H - H_gusu;
    //cout << H_gusu << ":" << H_kisu << endl;
    if(H == 1 || W == 1) {
        cout << 1 << endl;
    }else {
        cout << H1 * H_kisu + H2 * H_gusu << endl;
    }
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main{
	public static void main (String[] args){
	
		Scanner standard = new Scanner(System.in);
	
		//Optional : To state what to input (Comment out if needed)
		//System.out.println("Please input 2 integers within -1001=<a, b>= 1001");
	
		int a = 0; 
		int b = 0; 
	
		a = standard.nextInt();
		b = standard.nextInt();
	
			if(a < b){
				System.out.println("a < b"); 
			}else if (a > b){
				System.out.println("a > b");
			}else if (a == b){
				System.out.println("a == b");
			}
	
	}
	
}

Measured memory_bytes: 26296
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,D; cin >> N >> D;
    cout << N/(2*D+1)+ min(1,N%(2*D+1)) << endl;
    return 0;
}


Measured memory_bytes: 3584
import sys
from collections import defaultdict
import bisect
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return sys.stdin.readline()[:-1]

def main():
    s = list(S())
    t = list(S())

    alfa = defaultdict(list)
    for i, c in enumerate(s):
        alfa[c].append(i)
    pre = -1
    ans = 0
    for i, c in enumerate(t):
        index = alfa[c]
        if len(index) == 0:
            print(-1)
            return
        a = bisect.bisect_right(index, pre)
        if a != len(index):
            pre = index[a]
        else:
            pre = index[0]
            ans += len(s)

    print(ans + pre + 1)
if __name__ == '__main__':
    main()

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 2e6 + 123;
const ld pi = 3.1741592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int n, a[N], b[N];
ll t[N], ans; 

void upd(int v, int tl, int tr, int pos, ll val) {
	if(tl == tr) {
		t[v] = val;
		return;
	}

	int tm = (tl + tr) >> 1;

	if(pos <= tm) upd(v + v, tl, tm, pos, val);
	else upd(v + v + 1, tm + 1, tr, pos, val);

	t[v] = max(t[v + v], t[v + v + 1]);
}

ll get(int v, int tl, int tr, int l, int r) {
	if(l > r) return 0;

	if(tl == l && tr == r) return t[v];

	int tm = (tl + tr) >> 1;

	return max(get(v + v, tl, tm, l, min(tm, r)), get(v + v + 1, tm + 1, tr, max(tm + 1, l), r));
}

const int M = 200000;

main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);

//	srand(time(NULL));

	scanf("%d", &n);

	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &b[i]);
		ll cur = get(1, 1, M, 1, a[i] - 1);
		cur += b[i];
		ans = max(ans, cur);
		upd(1, 1, M, a[i], cur);
	}

	cout << ans;
       
    return 0;                                        
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

int main() {
    optimizar_io
 	int K;

 	cin >> K;
 	for (int i = 0; i < K; i++)
 		cout << "ACL";
 	cout << "\n";
 	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vector <int> ans(n, 0);
  for (int i = 1; i <= n - 1; i++) {
	  for (int j = i + 1; j <= n; j++) {
		  int dist = min(j - i, abs(i - x) + 1 + abs(y - j));
		  ans[dist]++;
		}
	}
  REP1(i, n - 1) {
	cout << ans[i] << endl;
  }
  return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll f(ll b, ll n) {
    ll sigma = 0;
    while (n) {
        sigma += n % b;
        n /= b;
    }
    return sigma;
}

ll solve(ll n, ll s) {
    if (n < s) return -1LL;
    if (n == s) return n+1LL;
    // if (s == 1) return n;

    ll sq = sqrt(n);
    for (ll b=2; b<=sq; ++b) {
        if (f(b,n) == s) return b;
    }

    // q + r = s
    // qb + r = n
    // 2桁なので q<√n
    ll bmin = n+1LL;
    for (ll q=1; q<=sq; ++q) {
        ll r = s - q;
        if ((n - r) % q == 0) {
            ll b = (n-r) / q;
            if (f(b,n) == s) {
                bmin = min(bmin, b);
            }
        }
    }

    return (bmin == n+1LL) ? -1 : bmin;
}

int main() {
    ll n, s;
    cin >> n;
    cin >> s;
    cout << solve(n, s) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int[][] h = new int[N][N];
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < N; ++j) {
					h[i][j] = sc.nextInt();
				}
			}
			int[] min = new int[N];
			Arrays.fill(min, Integer.MAX_VALUE);
			int[] max = new int[N];
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < N; ++j) {
					min[i] = Math.min(h[i][j], min[i]);
					max[j] = Math.max(h[i][j], max[j]);
				}
			}
			int ans = 0;
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < N; ++j) {
					if (h[i][j] == min[i] && h[i][j] == max[j] && h[i][j] > ans) ans = h[i][j];
				}
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define rep(i,n) for(int i=0;i<n;i++)

int n,ans,got[20];
double hx,hy,dx,dy,cx[20],cy[20];

void dfs(double t,double x,double y){
	if(ans)return;
	int m=0;
	rep(i,n)m+=got[i];
	if(m==n){ans=1;return;}
	rep(i,n)if(!got[i]&&t+sqrt((cx[i]-x)*(cx[i]-x)+(cy[i]-y)*(cy[i]-y))+EPS>sqrt((cx[i]-dx)*(cx[i]-dx)+(cy[i]-dy)*(cy[i]-dy)))return;
	rep(i,n)if(!got[i]){
		got[i]=1;
		dfs(t+sqrt((cx[i]-x)*(cx[i]-x)+(cy[i]-y)*(cy[i]-y)),cx[i],cy[i]);
		got[i]=0;
	}
}

int main(){
	while(cin>>n>>hx>>hy>>dx>>dy&&(n||hx||hy||dx||dy)){
		rep(i,n)fill(got,got+n,0);
		rep(i,n)cin>>cx[i]>>cy[i];
		ans=0;
		dfs(0.0,hx,hy);
		cout<<(ans?"YES":"NO")<<endl;
	}
}

Measured memory_bytes: 948
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	vector<bool> A(1000000001, false);

	for (int i = 0; i < N; i++)
	{
		lint tmp;
		cin >> tmp;
		if (A[tmp - 1])
		{
			cout << "NO" << endl;
			return;
		}

		else
			A[tmp - 1] = true;
	}

	cout << "YES" << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 122368
function main()
    N, D = parse.(Int, split(readline()))
    x = zeros(Int, N)
    y = zeros(Int, N)
    for i in 1:N
        x[i], y[i] = parse.(Int, split(readline()))
    end
    
    ans = 0
    for i in 1:N
        if sqrt(x[i]^2 + y[i]^2) <= D
            ans += 1
        end
    end

    println(ans)
end

main()

Measured memory_bytes: 213320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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(){

    int n;
    cin >> n;
    vector<pair<ll, ll>> work(n);
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        work[i] = make_pair(b, a);
    }
    sort(work.begin(), work.end());
    ll sum = 0;
    bool ok = true;
    for(int i = 0; i < n; i++){
        sum += work[i].second;
        if(sum > work[i].first) ok = false;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(LL)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

#define INF 1LL << 50

int p[(int)2e5+3];
LL a[(int)2e5+3],b[(int)2e5+3];
int main(){
    LL N;
    cin>>N;
    REP(i,N){
        cin>>p[i];p[i]--;
    }
    REP(i,N){
        a[i]=30000LL*(i+1LL);
        b[i]=30000LL*(N-i);
    }
    LL now=a[p[0]]+b[p[0]];
    FOR(i,1,N){
        b[p[i]]=now+i-a[p[i]];
    }
    REP(i,N)cout<<a[i]<<" ";
    cout<<endl;
    REP(i,N)cout<<b[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  if(!n) pr(0);
  rep(t,1<<16) {
    ll x=n;
    string s="";
    rep(i,32) s+='0';
    rep(i,16) {
      if(t&(1<<i)) {
        x+=1LL<<(i*2+1);
        s[i*2+1]='1';
      }
    }
    rrep(i,16) {
      if(x>=1LL<<(i*2)) {
        x-=1LL<<(i*2);
        s[i*2]='1';
      }
    }
    if(!x) {
      reverse(all(s));
      rep(i,32) {
        if(s[i]=='1') {
          pr(s.substr(i));
          return;
        }
      }
    }
  }
}

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

Measured memory_bytes: 256
n = int(input())
a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

def dfs(s, count):
    if len(s) == n:
        print(s)
        return

    for z in range(count + 1):
        dfs(s + a[z], count + 1 if z == count else count)


dfs("", 0)



Measured memory_bytes: 4412
import math
a,b,h,m=map(int,input().split())
mangle=m*6
hangle=30*h+0.5*m
angle=min(abs(hangle-mangle), 360-abs(hangle-mangle))
length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(angle)))
print(length)

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

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	cout << (a + 9) / 10 * 10 + (b + 9) / 10 * 10 + (c + 9) / 10 * 10 + (d + 9) / 10 * 10 + (e + 9) / 10 * 10 - max({9 - (a + 9) % 10, 9 - (b + 9) % 10, 9 - (c + 9) % 10, 9 - (d + 9) % 10, 9 - (e + 9) % 10 }) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<bitset>
#include<bits/stdc++.h>

#define ll long long int
#define mod 1000000007
using namespace std;

main()
{
	ll k;
	cin>>k;
	
		string ans;
	
	while(k>0)
	{
		k--;
		ll n =k%26;
		
		ans+=('a'+n);
		k=k/26;
	}
	
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;		
	
}

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

typedef long long ll;

ll gcd(ll a, ll b){
return a != 0 ? gcd(b % a, a) : b;
}

int main() {
ll a, b;
while(cin >> a >> b)
cout << gcd(a, b) << " " << a / gcd(a, b) * b << endl;}

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



int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char>> cam(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>cam.at(i).at(j);
    }
  }
  
  vector<int> dx={1,0,-1,0};
  vector<int> dy={0,1,0,-1};
  
  vector<vector<bool>> judge(H,vector<bool>(W,false));
  bool ok=true;
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(cam.at(i).at(j)=='#'){
        for(int k=0;k<4;k++){
          if(0<=i+dx.at(k) && i+dx.at(k)<=H-1 && 0<=j+dy.at(k) && j+dy.at(k)<=W-1){
            if(cam.at(i+dx.at(k)).at(j+dy.at(k))=='#')judge.at(i).at(j)=true;
          }
        }
      }
    }
  }
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(cam.at(i).at(j)=='#' && judge.at(i).at(j)!=true)ok=false;
    }
  }  
  
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int t,n,s[10],f[10],sum = 0;
	while(1){
		sum = 0;
		cin >> t;
		if(t==0)break;
		cin >> n;
		for(int i=0 ; i<n ; ++i){
			cin >> s[i] >> f[i];
			sum += f[i] - s[i];
		}
		if(sum>=t){
			cout << "OK\n";
		}else{
			cout << t-sum << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(void)
{
    int a,b; /* 数の箱*/
    char c, p; /* 文字の箱*/
    do{
        scanf("%d ",&a);
        scanf("%c",&c);/*文字は %c */
        scanf(" %d",&b);
        switch(c){ /* switchの値で判断して実行 */
        case '+':
            printf("%d\n",a+b);
            break;
        case '-':
            printf("%d\n",a-b);
            break;
        case '*':
            printf("%d\n",a*b);
            break;
        case '/':
            printf("%d\n",a/b);
            break;
        case '%':
            printf("%d\n",a%b);
            break;
        default: /*どれにも当てはまらない場合*/
            break;
        }
    }while(c!='?'); /*cが'？'になるまで繰り返す*/
    return 0;
}


Measured memory_bytes: 2664
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s1 := getNextString(scanner)
	s2 := getNextString(scanner)
	n := len(s1)
	m := len(s2)
	dp := makeGrid(n+1, m+1)
	for i := 1; i < n+1; i++ {
		for j := 1; j < m+1; j++ {
			dp[i][j] = math.MaxInt32
		}
	}
	for i := 0; i < n+1; i++ {
		dp[i][0] = cint(i)
	}
	for i := 0; i < m+1; i++ {
		dp[0][i] = cint(i)
	}
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			dp[i+1][j+1].minAs(dp[i+1][j] + 1)
			dp[i+1][j+1].minAs(dp[i][j+1] + 1)
			if s1[i] == s2[j] {
				dp[i+1][j+1].minAs(dp[i][j])
			} else {
				dp[i+1][j+1].minAs(dp[i][j] + 1)
			}
		}
	}
	fmt.Fprintln(writer, dp[n][m])
}
func makeGrid(h, w int) [][]cint {
	index := make([][]cint, h, h)
	data := make([]cint, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

type cint int64

func (ct *cint) minAs(x cint) *cint {
	*ct = ct.min(x)
	return ct
}
func (ct *cint) maxAs(x cint) *cint {
	*ct = ct.max(x)
	return ct
}
func (ct cint) min(x cint) cint {
	if ct > x {
		return x
	}
	return ct
}
func (ct cint) max(x cint) cint {
	if ct < x {
		return x
	}
	return ct
}



Measured memory_bytes: 9540
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
A = LI()

d = defaultdict(int)
d[0] = 1

ans = 0
sum_ = 0
for i in range(N):
    sum_ = sum_ + A[i]
    ans += d[sum_]
    d[sum_] += 1
    
print(ans)

Measured memory_bytes: 103248
<?php

fscanf(STDIN, "%d", $n);
$input = trim(fgets(STDIN));
$w_arr = explode(' ', $input);

$min = array_sum($w_arr);

for ($i = 0; $i < $n - 1; ++$i) {
    $s1 = 0;
    for ($j = 0; $j <= $i; ++$j) {
        $s1 += $w_arr[$j];
    }

    $s2 = 0;
    for ($j = $i + 1; $j < $n; ++$j) {
        $s2 += $w_arr[$j];
    }

    $min = min($min, abs($s1 - $s2));
}

echo $min;


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

void solve(int test_case) {
	int n;cin>>n;
	vi arr(n);
	ull sum = 0;
	for(int &i:arr)cin>>i,sum+=i;
	int m;
	cin>>m;
	while(m--) {
		int p,x;
		cin>>p>>x;
		int diff = arr[p-1]-x;
		cout<<sum-diff<<"\n";
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3636