akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>


using namespace std;
int main() {
    int b,n,i,j;
    cin>>n;
    vector<int> a(n);
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=n-1;i>=0;i--){
        cout << a[i] ;
        if(i!=0) cout << " ";
    }
    cout<<endl;


    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#include<map>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define MAXN   10001
#define MOD 1000000007
#define X first
#define Y second
ll t,n,i,j;
int main()
{
    cin>>n;
    vector <ll > v(n);
    vector <ll > r;
    for(i=0;i<n;i++)
        cin>>v[i];
    r=v;
    ll cnt=0;
    sort(v.begin(),v.end());
    for(i=0;i<n;i++){
        if(v[i]!=r[i])
            cnt++;
    }
    if(cnt>2)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		StringTokenizer st = new StringTokenizer(str, " ");
		int W = Integer.parseInt(st.nextToken());
		int H = Integer.parseInt(st.nextToken());
		int x = Integer.parseInt(st.nextToken());
		int y = Integer.parseInt(st.nextToken());
		int r = Integer.parseInt(st.nextToken());

		if(x - r < 0 || y - r < 0 || x + r > W || y + r > H) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}



Measured memory_bytes: 24420
#include<iostream>
#include<string>
#include<set>

using namespace std;

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

	string luckyNumber;
	getline(cin, luckyNumber);
	getline(cin, luckyNumber);

	set<string> result;
	set<char> firstDone;
	set<char> secondDone;
	set<char> thirdDone;
	for (int firstIndex = 0; firstIndex < length - 2; firstIndex++) {
		const char firstNum = luckyNumber[firstIndex];
		if (firstDone.count(firstNum) > 0) {
			continue;
		}
		firstDone.insert(firstNum);

		secondDone.clear();
		for (int secondIndex = firstIndex + 1; secondIndex < length - 1; secondIndex++) {
			const char secondNum = luckyNumber[secondIndex];
			if (secondDone.count(secondNum) > 0) {
				continue;
			}
			secondDone.insert(secondNum);

			thirdDone.clear();
			for (int thirdIndex = secondIndex + 1; thirdIndex < length; thirdIndex++) {
				const char thirdNum = luckyNumber[thirdIndex];
				if (thirdDone.count(thirdNum) > 0) {
					continue;
				}
				thirdDone.insert(thirdNum);

				string secNum;
				secNum += firstNum;
				secNum += secondNum;
				secNum += thirdNum;
				result.insert(secNum);
			}
		}
	}
	cout << result.size() << endl;

	return 0;
}


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

int main(){
	
	int n; cin>>n;
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			if(i * j == n) { cout<<"Yes"<<"\n"; return 0;}
		}
	}
	
	cout<<"No"<<"\n";
	
	
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second

const int L = 2*80*80;
bool dp[80][80][2*L];

int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m));
	for (auto &i : a)
		for (auto &j : i)
			cin >> j;
	auto b = a;
	for (auto &i : b)
		for (auto &j : i)
			cin >> j;

	dp[0][0][L + a[0][0] - b[0][0]] = true;
	dp[0][0][L - a[0][0] + b[0][0]] = true;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			for (int k = 0; k < 2*L; ++k)
				if (dp[i][j][k])
				{
					if (i+1 < n)
					{
						dp[i+1][j][k + a[i+1][j] - b[i+1][j]] = true;
						dp[i+1][j][k - a[i+1][j] + b[i+1][j]] = true;
					}
					if (j+1 < m)
					{
						dp[i][j+1][k + a[i][j+1] - b[i][j+1]] = true;
						dp[i][j+1][k - a[i][j+1] + b[i][j+1]] = true;
					}
				}

	int ans = 1<<30;
	for (int k = 0; k < 2*L; ++k)
		if (dp[n-1][m-1][k])
			ans = min(ans, abs(k-L));
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 159104
x, n = map(int, input().split())
p = list(map(int, input().split()) )

cnt = 0
while True:
    big = x + cnt
    small = x - cnt
    if small not in p:
        print(small)
        exit()
    if big not in p:
        print(big)
        exit()
    cnt += 1


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

using namespace std;

int main(){
	long long a,b,c,d;
	cin>>a>>b;
	c = a;
	d = b;
	if(a>b) swap(a,b);
	while(a){
		b %= a;
		swap(a,b);
	}
	cout<<c*d/b<<endl;
}

Measured memory_bytes: 256
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

map < ll, ll > mp;
ll arr[200005];

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n)
    {
		mp.clear();

		for(i = 1; i <= n; i++) slld(arr[i]);

		for(i = 1; i <= n; i++)
		{
			mp[i - arr[i]]++;
		}

		ans = 0;

		for(i = 1; i <= n; i++)
		{
			mp[i - arr[i]]--;

			ll x = i + arr[i];

			ans += mp[x];
		}

		printf("%lld\n", ans);
    }


}





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


int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (int i = 0; i < h; i++) {
		cin >> s.at(i);
	}

	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s.at(i)[j] != '.') {
				continue;
			}
			int key = i * 100 + j;

			vector<vector<int>> dist(h, vector<int>(w, -1));
			queue<int> que;

			dist.at(i).at(j) = 0;
			que.push(key);

			while (!que.empty()) {
				int num = que.front();
				que.pop();

				//上をチェック
				if ((num / 100) > 0) {
					if (dist.at((num / 100) - 1).at(num % 100) == -1 && s.at((num / 100) - 1)[num % 100] == '.') {
						dist.at((num / 100) - 1).at(num % 100) = dist.at(num / 100).at(num % 100) + 1;
						que.push(num - 100);
					}
				}
				//下をチェック
				if ((num / 100) < h - 1) {
					if (dist.at((num / 100) + 1).at(num % 100) == -1 && s.at((num / 100) + 1)[num % 100] == '.') {
						dist.at((num / 100) + 1).at(num % 100) = dist.at(num / 100).at(num % 100) + 1;
						que.push(num + 100);
					}
				}
				//左をチェック
				if ((num % 100) > 0) {
					if (dist.at(num / 100).at((num % 100) - 1) == -1 && s.at(num / 100)[(num % 100) - 1] == '.') {
						dist.at(num / 100).at((num % 100) - 1) = dist.at(num / 100).at(num % 100) + 1;
						que.push(num - 1);
					}
				}
				//右をチェック
				if ((num % 100) < w - 1) {
					if (dist.at(num / 100).at((num % 100) + 1) == -1 && s.at(num / 100)[(num % 100) + 1] == '.') {
						dist.at(num / 100).at((num % 100) + 1) = dist.at(num / 100).at(num % 100) + 1;
						que.push(num + 1);
					}
				}
			}
			for (auto dist_ele : dist) {
				for (int dist_ele_ele : dist_ele) {
					if (dist_ele_ele > ans) {
						ans = dist_ele_ele;
					}					
				}
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>

using namespace std;



string tranceRPN(string in_formula, string out_formula, stack<char> st){
    
    if(in_formula.size() == 0){
        while(!st.empty()){
            out_formula+=st.top();
            st.pop();
        }
        //cout<<st.top()<<endl;;;
        return out_formula;//処理終了
    }
    
    char top = in_formula[0];
    in_formula.erase(0,1);
    //cout<<in_formula<<endl;
    
    if(top=='=')return tranceRPN(in_formula,out_formula,st);
    
    if(('0'<=top&&top<='9')||top==' ')out_formula+=top;
    else if(top==')'){
        while(1){
            if(st.top()=='('){
                st.pop();
                break;
            }
            out_formula+=st.top();
            st.pop();
        }
    }else if(top=='(')st.push(top);
    else if(st.empty())st.push(top);
    else if(((st.top()=='*'||st.top()=='/')&&(top=='+'||top=='-'))
            ||((st.top()=='*'||st.top()=='/')&&(top=='*'||top=='/'))
            ||((st.top()=='+'||st.top()=='-')&&(top=='+'||top=='-'))
            ){
        out_formula+=st.top();
        st.pop();
        in_formula=top+in_formula;
    }else{
        st.push(top);
    }
    return tranceRPN(in_formula,out_formula,st);
    
    
}

int RPN(string s){
    int x=0;
    stack<int> st;
    bool flag=false;
    while(1){
        if(s.size()==0){
            break;
        }else if('0'<=s[0]&&s[0]<='9'){
            x=x*10+s[0]-'0';
            flag=true;
            s.erase(0,1);
        }else if(s[0]==' '&&flag){
            flag=false;
            st.push(x);
            x=0;
            s.erase(0,1);
        }else if(s[0]=='+'){
            s.erase(0,1);
            int y,z;
            y=st.top();
            st.pop();
            z=st.top();
            st.pop();
            st.push(y+z);
        }else if(s[0]=='-'){
            s.erase(0,1);
            int y,z;
            y=st.top();
            st.pop();
            z=st.top();
            st.pop();
            st.push(z-y);
        }else if(s[0]=='*'){
            s.erase(0,1);
            int y,z;
            y=st.top();
            st.pop();
            z=st.top();
            st.pop();
            st.push(y*z);
        }else if(s[0]=='/'){
            s.erase(0,1);
            int y,z;
            y=st.top();
            st.pop();
            z=st.top();
            st.pop();
            st.push(z/y);
        }else{
            s.erase(0,1);
        }
    }
    return st.top();
}
/*
(1+4)*(3+7)/5
 
 
*/

int main(){
    
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        string s,rs;
        stack<char> st;
        cin>>s;
        
        for(int i=0; i<s.length(); i++){
            if(s[i]=='+'||s[i]=='*'||s[i]=='-'||s[i]=='/'||s[i]==')'||s[i]=='('||s[i]=='=')s.insert(i++, " ");
        }
        s+=" ";
        //cout<<s<<endl;
        
        rs=tranceRPN(s,rs,st);
        //cout<<rs<<endl;
        
        cout<<RPN(rs)<<endl;
    }
    
    
    
}

Measured memory_bytes: 1372
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

string s;

int32_t main()
{
	IOS;
	cin >> s;
	int carry = 0, ans = 0;
	for(int i = s.size() - 1; i >= 0; i--)
	{
		int val = s[i] - '0';
		val += carry;
		carry = val / 10;
		val %= 10;
		if(val >= 6)
		{
			ans += (10 - val);
			carry = 1;
		}
		else if(val == 5)
		{
			if(i - 1 >= 0 && s[i - 1] >= '5')
			{
				ans += (10 - val);
				carry = 1;
			}
			else
				ans += val;
		}
		else
			ans += val;
	}	
	cout << ans + carry;
	return 0;
}


Measured memory_bytes: 1948
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
 
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


//printf("? %d\n", p); fflush(stdout);

long long tonum(string str) {
  istringstream sin(str);
  long long res = 0;
  sin >> res;
  return res;
}

string tostr(long long num) {
  stringstream ss;
  ss << num;
  return ss.str();
}

string padding(string str) {
    while (str.size() < 16) str += "9";
    return str;
}


long long N = 189043;

int main() {
    string res = "";
    string ans = "";
    for (int digit = 0; digit < 10; ++digit) {
        int left = 1, right = 10;
        if (digit > 0) left = 0;
        while (right - left > 1) {
            int mid = (left + right) / 2;
            string tmp = padding(res + tostr(mid - 1));
            cout << "? " << tmp << endl; fflush(stdout);
            cin >> ans;
            if (ans == "Y") right = mid;
            else left = mid;
        }
        res += tostr(left);
        
        if (res.back() != '9') {
            cout << "? " << tonum(res) + 1 << endl; fflush(stdout);
            cin >> ans;
            if (ans == "Y") {
                cout << "! " << res << endl;
                return 0;
            }
        }
        else {
            cout << "? " << (tonum(res) - 1) * 10 << endl; fflush(stdout);
            cin >> ans;
            if (ans == "N") {
                cout << "! " << res << endl;
                return 0;
            }
        }
    }
}


















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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll a,b,t,ans=0;
    cin >> a >> b >> t;
    for(ll i=a;i<=t;i+=a){
        ans += b;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
    long long int n, a, b, sum = 0, re, amari, ans = 0;
    cin >> n >> a >> b;
    sum = a + b;
    re = n / sum;
    if(n - sum * re > a){
        amari = a;
    }
    else{
        amari = n - sum * re;
    }
    ans = re * a + amari;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)
const int O1 = 1004535809;
const int O2 = 998244353;
int O, W, _W;
const int maxN = 250007;
typedef long long LL;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

int pwr(int x, int t) {
	int res = 1;
	for (; t > 0; t >>= 1, x = 1LL * x * x % O)
		if (t & 1) res = 1LL * res * x % O;
	return res;
}

inline int inv(int x) { return pwr(x, O-2); }

int n;
char s[maxN];
int ps[2][maxN], hsh[2][maxN];

void init(int *ps, int *hsh) {
	hsh[0] = 0, ps[0] = 1;
	rep (i, 1, n) {
		if (s[i] == '+') {
			ps[i] = ps[i-1];
			hsh[i] = (hsh[i-1] + ps[i]) % O;
		}
		else if (s[i] == '-') {
			ps[i] = ps[i-1];
			hsh[i] = (hsh[i-1] + O - ps[i]) % O;
		}
		else if (s[i] == '<') {
			ps[i] = 1LL * ps[i-1] * _W % O;
			hsh[i] = hsh[i-1];
		}
		else if (s[i] == '>') {
			ps[i] = 1LL * ps[i-1] * W % O;
			hsh[i] = hsh[i-1];
		}
		else assert(false);
	}
}

void solve() {
	map<pair<int, int>, int> mp;
	LL res = 0;
	rep (i, 0, n) {
		if (i > 0) res += mp[pair<int,int>(hsh[0][i], hsh[1][i])];
		if (i < n) ++mp[pair<int,int>((hsh[0][i] + 1LL * hsh[0][n] * ps[0][i]) % O1, (hsh[1][i] + 1LL * hsh[1][n] * ps[1][i]) % O2)];
	}
	printf("%lld\n", res);
}

int main() {

	n = ri();
	scanf("%s", s+1);

	O = O1, W = 131, _W = inv(W);
	init(ps[0], hsh[0]);
	O = O2, W = 1000003, _W = inv(W);
	init(ps[1], hsh[1]);
	solve();

	return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
  int n, k, i;
  long double sum=0.0;
  cin >> n >>k;
  for(i=1; i<=n; i++){
    sum+=powl(0.5,max(0.0,ceil(log2(k*1.0/i))));
  }
  cout <<setprecision(16) << sum/n;
  return 0;
}

Measured memory_bytes: 640
import sys
from collections import deque

A = deque()

Q = int(sys.stdin.readline().rstrip())
for _ in range(Q):
    s = sys.stdin.readline().rstrip().split()
    if s[0] == "0":  # pushback
        if s[1] == "0":
            A.appendleft(s[2])
        else:
            A.append(s[2])
    elif s[0] == "1":  # randomAccess
        print(A[int(s[1])])
    else:
        if s[1] == "0":
            A.popleft()
        else:
            A.pop()



Measured memory_bytes: 34644
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int n;
		int i, j;
		int ct[];
		float h;
		
		ct = new int[6];
		
		n = input.nextInt();
		
		for (i = 0; i < n; i++){
			h = input.nextFloat();
			if (h < 165.0){
				ct[0]++;
			}
			else if (h < 170.0){
				ct[1]++;
			}
			else if (h < 175.0){
				ct[2]++;
			}
			else if (h < 180.0){
				ct[3]++;
			}
			else if (h < 185.0){
				ct[4]++;
			}
			else {
				ct[5]++;
			}
		}
		
		for (i = 0; i < 6; i++){
			System.out.print(i + 1 + ":");
			for (j = 0; j < ct[i]; j++){
				System.out.print("*");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 27484
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define sort(ss) sort(ss.begin(), ss.end())
#define rsort(ss) sort(ss.rbegin(), ss.rend())
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return acos(-1.0);
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	int n,m,sr,star,ans,i;
	while(1){
		cin>>n>>m;
		if(n==0&&m==0) break;
		else{
			vi ss(n,1);
			ans=0;
			sr=n;
			star=0;
			while(1){
				int count=0;
				for(i=star;count<=m;i++){
					if(sr==1) break;
					if(i<=n){
						if(ss[i]==1){
							count++;
							if(count==m) break;
						}
					}
					else{
						if(ss[i-n]==1){
							count++;
						}
					}
					if(i==n) i=-1;
				}
				if(sr==1) break;
				ss[i]=0;
				if(i<=n) star=i;
				else{
					star=i-n;
				}
				sr--;
			}
			for(i=0;i<n;i++){
				if(ss[i]==1){
					ans=i+1;
					break;
				}
			}
			cout<<ans<<endl;
		}
	}
}

Measured memory_bytes: 1196
import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import lru_cache
sys.setrecursionlimit(10**9)


def main():
    H,N = map(int,input().split())
    A = list(map(int,input().split()))
    A_sorted = sorted(A, reverse = True)

    sum = 0
    for a in A_sorted:
        sum += a
        if sum >= H:
            print("Yes")
            exit()

    print("No")


if __name__ == "__main__":
  main()


Measured memory_bytes: 22948
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x;
    string s,s1,s2;
    cin >> s;   
    rep(i,4){
        if(s[i] == '+') c++;
        else c--;
    }
    cout << c << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 320
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
	while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return f?x:-x;
}
int cnt[N], a[N][N], ans = 1 << 30, at[N], del[N];
int main(int argc, char const *argv[]) {
	int n = read(), m = read();
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			a[i][j] = read();
	for (int i = 1; i <= n; i++)
		cnt[a[i][at[i] = 1]] ++;
	for (int i = 1; i <= m; i++) {
		int * mx = max_element(cnt + 1, cnt + m + 1);
		ans = min(ans, * mx);
		// printf("%d %d %d %d %d\n", cnt[1], cnt[2], cnt[3], cnt[4], cnt[5]);
		// printf("it %d => del %d, %d\n", i, mx - cnt, *mx);
		if (i == m) break;
		del[mx - cnt] = 1;
		for (int j = 1; j <= n; j++) {
			cnt[a[j][at[j]]] --;
			while (del[a[j][at[j]]])
				++ at[j];
			cnt[a[j][at[j]]] ++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 640
n, m = map(int, input().split())
temp = list(map(int, input().split()))
temp = set(temp[1:])
for i in range(n-1):
	temp2 = list(map(int, input().split()))
	temp2 = set(temp2[1:])
	temp = temp.intersection(temp2)
print(len(temp))

Measured memory_bytes: 3060
n = int(input())


def solve(n):
    res = 0
    for d in range(2, n):
        if d * d > n:
            break

        degree = 0
        while n % d == 0:
            n /= d
            degree += 1

        i = 1
        while degree >= i:
            degree -= i
            i += 1
            res += 1

    if n > 1:
        res += 1
    return res


print(solve(n))


Measured memory_bytes: 9256
import heapq
n,m,s,t = map(int, input().split())
s -= 1
t -= 1
edges1 = [[] for i in range(n)]
edges2 = [[] for i in range(n)]
#  1 real world
#  2 snuuk world
for i in range(m):
    u,v,a,b = map(int, input().split())
    u -= 1
    v -= 1
    # real
    edges1[u].append((v,a))
    edges1[v].append((u,a))
    # snuuk
    edges2[u].append((v,b))
    edges2[v].append((u,b))

def dijkstra(N,edges,s):
    q = []
    heapq.heapify(q)
    INF = 10**20

    from datetime import datetime as dt
    x = dt.now()
    cost = [INF] * N
    heapq.heappush(q,(0,s))
    while len(q) > 0:
        c_v,v = heapq.heappop(q)
        # すでに確定しているものは何もしない
        if cost[v] != INF: continue
        # 確定していなければ、最小を更新しつつ、
        # そのnodeから到達する辺とコストをheapqにpush
        else: cost[v] = c_v
        for u,c_u in edges[v]:
            if cost[u] != INF:continue
            c_upd = c_v + c_u
            heapq.heappush(q,(c_upd,u))
    # print(cost)
    return cost


cnt1 = dijkstra(n,edges1,s)
cnt2 = dijkstra(n,edges2,t)
zs = [c1+c2 for c1,c2 in zip(cnt1,cnt2)]
mn = 10**20
ans = []
for z in zs[::-1]:
    mn = min(mn,z)
    ans.append(10**15-mn)

for a in ans[::-1]:
    print(a)

Measured memory_bytes: 126568
#include <stdio.h>
#include <math.h>

int main(void) {
  double x1, y1, r1, x2, y2, r2, t, a, b;
  int n;
  
  while (scanf("%d", &n) != EOF) {
    while (n--) {
      scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &r1, &x2, &y2, &r2);

      t = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
      a = (r1 > r2) ? r1 : r2;
      b = (r1 < r2) ? r1 : r2;
      if (a - b > t) {
	if (r1 > r2)
	  printf("2\n");
	else
	  printf("-2\n");
      }
      else if (a + b < t)
	printf("0\n");
      else
	printf("1\n");
    }
  }
  return 0;
}

Measured memory_bytes: 620
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int n;
  std::cin >> n;

  vector<long long> a(n);
  for(int i=0; i<n; i++){
    std::cin >> a[i];
  }

  sort(a.begin(), a.end(), greater<long long>());

  long long ans = 0;
  for(int i=1; i<a.size(); i++){
    ans += a[i/2];
  }

  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 4500
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B, C, D, E;
    
    cin >> N >> A >> B >> C >> D >> E;
    N--;
    int k = min({A, B, C, D, E});
    cout << 5 + N/k << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
 
using namespace std;
 
const double eps=1e-10;

int main()
{
	string s;

	map<char,int> trans;
	trans['I']=1;
	trans['V']=5;
	trans['X']=10;
	trans['L']=50;
	trans['C']=100;
	trans['D']=500;
	trans['M']=1000;

	while(cin>>s){
		long res=0;
		for(int i=0;i<s.size()-1;i++){
			if(trans[s[i]]>=trans[s[i+1]]) res+=trans[s[i]];
			else res-=trans[s[i]];
		}
		res+=trans[s[s.size()-1]];
		cout<<res<<endl;
	}


	return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 r,D,x;
    cin>>r>>D>>x;
    for(int i=0;i<10;i++){
        x=r*x-D;
        cout<<x<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <list>
#include <iterator>

#include <cstdio>
#include <cmath>

#define DIM 2
#define EPS (5*10e-4)

typedef std::vector<double> Vec;
typedef std::vector<Vec> Mat;
typedef std::pair<Mat,Vec> Eq;

double removeMinusZero(double x){
	if ( fabs(x)< EPS ){
		return 0.0;
	}
	else {
		return x;
	}
}

int main(void){
	using namespace std;

	list<Eq> input;

	double a,b,c,d,e,f;

	cout << fixed << setprecision(3);

	while(cin >> a >> b >> c >> d >> e >> f){
		Vec m1, m2;
		m1.push_back(a);
		m1.push_back(b);
		m2.push_back(d);
		m2.push_back(e);

		Vec vec;
		vec.push_back(c);
		vec.push_back(f);

		Mat mat;
		mat.push_back(m1);
		mat.push_back(m2);

		Eq eq = make_pair(mat,vec);

		input.push_back(eq);
	}

	for(auto itr = input.begin(); itr!=input.end(); ++itr){
		auto mat = itr->first;
		auto vec = itr->second;

		Vec output(DIM);

		auto det = mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0];

		mat[0][1] = -mat[0][1];
		mat[1][0] = -mat[1][0];
		swap(mat[0][0],mat[1][1]);

		for (int i=0; i<DIM; i++){
			output[i] = inner_product(vec.begin(), vec.end(), mat[i].begin(), 0);
		}
		std::transform(output.begin(), output.end(),output.begin(), std::bind2nd(divides<double>(),det));
		cout << removeMinusZero(output[0]) << " " << removeMinusZero(output[1]) << endl;
	}

}

Measured memory_bytes: 1304
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  vll S(2);
  ll s;
  cin >> s;
  S[0] = -1;
  S[1] = s;

  ll idx = 1;
  for (;;) {
    ll next = 0;
    if (S[idx] % 2 == 0) {
      next = S[idx] / 2;
    } else {
      next = 3 * S[idx] + 1;
    }
    idx++;
    if (find(S.begin(), S.end(), next) != S.end()) {
      cout << idx << endl;
      return 0;
    }
    S.emplace_back(next);
  }

  return 0;
}


Measured memory_bytes: 256
s = input()

s = s[::-1]

tmp = 0
for i in range(len(s)):
    #print(tmp)
    if tmp == len(s):
        print('YES')
        exit()
    if s[tmp:tmp+6] == 'resare':
        tmp += 6
        continue
    if s[tmp:tmp+5] == 'esare':
        tmp += 5
        continue
    if s[tmp:tmp+5] == 'maerd':
        tmp += 5
        continue
    if s[tmp:tmp+7] == 'remaerd':
        tmp += 7
        continue
    else:
        print('NO')
        exit()
        


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

int n,m;
std::vector<int> a,b;
std::vector<std::vector<bool>> hen;
std::vector<bool> visited;

void dfs(int v){
    visited[v] = true;
    for(int v2 = 0; v2 < n; v2++){
        if(hen[v][v2] == false)continue;
        if(visited[v2] == true)continue;
        dfs(v2);
    }
}


int main()
{
    std::cin >> n >> m;
    a.resize(m);b.resize(m);
    hen.resize(n,std::vector<bool>(n));
    visited.resize(n);
    for(int i = 0; i < m; i++){
        std::cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        hen[a[i]][b[i]] = hen[b[i]][a[i]] = true;
    }

    int ans = 0;
    for(int i = 0; i < m; i++){
        visited.resize(n);
        hen[a[i]][b[i]] = false;
        hen[b[i]][a[i]] = false;
        for(int j=0; j<n; j++) visited[j]=false;

        dfs(0);

        bool bridge = false;
        for(int j = 0; j < n; j++)if(visited[j] == false)bridge = true;
        if(bridge)ans++;
        hen[a[i]][b[i]] = true;
        hen[b[i]][a[i]] = true;
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
"""
for i in range(N):
    print("{:}".format(A.index(i+1)+1),end=" ")"""
a = list(range(1,N+1,1))
#print(a)
A_ = dict(zip(A,a))
#print(A_)

A__ = sorted(A_.items())
#print(A__)

for i in range(N):
    print("{:}".format(A__[i][1]),end=" ")

Measured memory_bytes: 25784
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
int n,m;
char a[2005][2005];
int r[2005][2005],c[2005][2005];
int t[2005];
int ans;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	for(int i=1;i<=n;i++)
	{
		int st=0,k=0;
		memset(t,0,sizeof(t));
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]=='.'&&(j==1||a[i][j-1]=='#'))
			{
				st=j;
				k=0;
			}
			if(a[i][j]=='.')
				k++;
			if(a[i][j]=='.'&&(j==m||a[i][j+1]=='#'))
			{
				t[st]+=k;
				t[j+1]-=k;
			}
		}
		for(int j=1;j<=m;j++)
			r[i][j]=r[i][j-1]+t[j];
	}
	for(int j=1;j<=m;j++)
	{
		int st=0,k=0;
		memset(t,0,sizeof(t));
		for(int i=1;i<=n;i++)
		{
			if(a[i][j]=='.'&&(i==1||a[i-1][j]=='#'))
			{
				st=i;
				k=0;
			}
			if(a[i][j]=='.')
				k++;
			if(a[i][j]=='.'&&(i==n||a[i+1][j]=='#'))
			{
				t[st]+=k;
				t[i+1]-=k;
			}
		}
		for(int i=1;i<=n;i++)
			c[i][j]=c[i-1][j]+t[i];
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			ans=max(ans,r[i][j]+c[i][j]-1);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 35584
import sys

p=10**9+7

x,y=map(int,input().split())

if (x+y)%3!=0 or x>2*y or y>2*x:
    print(0)
    sys.exit()

a=(-x+2*y)//3
b=(2*x-y)//3

A=1
for i in range(1,a+1):
    A=A*i
    A=A%p
B=1
for i in range(1,b+1):
    B=B*i
    B=B%p

AB=1
for i in range(1,a+b+1):
    AB=AB*i
    AB=AB%p

C=(AB*pow(A,p-2,p)*pow(B,p-2,p))%p

print(C)

Measured memory_bytes: 40556
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>

using namespace std;

int main(void) {

	int sum = 0;

	string str;
	cin >> str;

	int kiri = (int)(str[0] - '0');
	for (int i = 0; i < str.size(); i++) {
		int test = (int)(str[i] - '0');
		if ( test == kiri) {
			//none;
		}
		else {
			sum++;
		}
		kiri = kiri^1;
	}

	cout << sum << endl;

	return 0;
}

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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

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

    int N,M;cin >> N >> M;
    int sum = 100*(N-M)+1900*M;
    int beki = pow(2,M);
    cout << beki*sum << endl;
}


Measured memory_bytes: 4124
N = int(input())
A = list(map(int,input().split()))
b = sorted([a-i for i,a in enumerate(A,1)])

minus = 0
plus = 0
for c in b:
    if c <0:
        minus +=1
    elif c >0:
        plus +=1

m1 = b[N//2]
m2 = b[0] if N==1 else b[N//2+1]
out = min(sum([abs(c-m1) for c in b]),sum([abs(c-m2) for c in b]))
print(out)

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

class Program
{
	static void Main(string[] args)
	{
		var Xt = Console.ReadLine().Split().Select(int.Parse);
		int X = Xt.First(), t = Xt.Last();
		Console.WriteLine(Math.Max(X - t, 0));
	}
}

Measured memory_bytes: 11348
def fib(n, fib_table):
    if n == 0 or n == 1:
        return 1
    if fib_table[n] != None:
        return fib_table[n]
    fib_table[n] = fib(n-1, fib_table) + fib(n-2, fib_table)
    return fib_table[n]

n = int(input())
fib_table = [None]*(n+1)
fib_table[0] = 1
fib_table[1] = 1

print(fib(n, fib_table))

Measured memory_bytes: 7692
#include <bits/stdc++.h>
using namespace std;
int DP[100000];
int main() {
  int n,m;
  cin >> n >> m;
  vector<int> d(m);
  for(int i = 0;i < m;i++)cin >> d[i];
  queue<int> que;
  que.push(0);
  while(que.size()){
      for(int i = 0;i < d.size();i++){
        if(!DP[que.front()+d[i]] && que.front()+d[i] <= 50000){
          DP[que.front()+d[i]] = DP[que.front()]+1;
          que.push(que.front()+d[i]);
        }
      }
      que.pop();
  }
  cout <<DP[n] << endl;
}


Measured memory_bytes: 3428
try:
    while True:
        a,b,c,d,e,f=map(float, input().split())
        x=(c*e-b*f)/(a*e-b*d)
        y=(a*f-c*d)/(a*e-b*d)
        if x==0:
            x=0
        if y==0:
            y=0
        x=round(x,3)
        y=round(y,3)
        print("{0:.3f}".format(x),"{0:.3f}".format(y))
except EOFError:
    pass

Measured memory_bytes: 7464
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp> // for use cpp_int
#include <boost/multiprecision/cpp_dec_float.hpp> // for use cpp_dec_float_100
#include <boost/date_time/gregorian/gregorian.hpp> // for use date
using namespace std;
using namespace boost::multiprecision;
using namespace boost::gregorian;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    cpp_int x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if ((x - k * d) >= 0) {
        cout << (x - k * d) << endl;
        return 0;
    }
    cpp_int cnt = x / d;
    if ((k - cnt) % 2 == 0) {
        cout << (x - cnt * d) << endl;
    }
    else {
        cout << ((cnt + 1) * d - x) << endl;
    }
    return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<vector<int>> vv(n, vector<int>(26, 0));
	rep(i, n){
		string s;
		cin >> s;
		vector<bool> c(26, false);
		rep(j, s.size()){
			int add = s[j] - 'a';
			vv.at(i).at(add)++;
		}
	}
	rep(i, 26){
		int add = 100;
		rep(j, n){
			add = min(add, vv.at(j).at(i));
		}
		rep(j, add){
			char out = 'a' + i;
			cout << out;
		}
	}
	cout << endl;
	return 0;
}

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

int main() {
    int A, B, C, X; cin >> A >> B >> C >> X;
    int ans = 0;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            for (int k = 0; k <= C; k++) {
                if (500 * i + 100 * j + 50 * k == X) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


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

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



int main(){
  while(1){
  int n,m;
  cin >> n >> m;
  if (n==0)break;
  vector<int> h(n),w(m);
  rep(i,n)cin>>h[i];
  rep(i,m)cin>>w[i];

  vector<long long>cum_ver(n+1),cum_hor(m+1);
  map<long long,int> mp_ver,mp_hor;
  rep(i,n+1){
    if(i==0){
      cum_ver[i] = 0;
    } else {
      cum_ver[i] = cum_ver[i-1]+h[i-1];
    }
  }
  rep(i,m+1){
    if(i==0){
      cum_hor[i] = 0;
    } else {
      cum_hor[i] = cum_hor[i-1]+w[i-1];
    }
  }

  rep(l,n){
    for(int r=l+1;r<=n;r++){
      double width = cum_ver[r]-cum_ver[l];
      auto itr = mp_ver.find(width);
      if (itr == mp_ver.end()){
        mp_ver[width] = 1;
      } else {
        mp_ver[width]++;
      }
    }
  }
  rep(l,m){
    for(int r=l+1;r<=m;r++){
      double width = cum_hor[r]-cum_hor[l];
      auto itr = mp_hor.find(width);
      if (itr == mp_hor.end()){
        mp_hor[width] = 1;
      } else {
        mp_hor[width]++;
      }
    }
  }
  long long sum = 0;
  for (auto itr = mp_ver.begin();itr!=mp_ver.end();++itr){
    auto itr2 = mp_hor.find(itr->first);
    if (itr2 != mp_hor.end()){
      sum += (itr->second)*(itr2->second);
    }
  }
  cout << sum << endl;
  }
  return 0;
}



Measured memory_bytes: 38716
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;

int main(){
   int a,b; cin>>a>>b;
  
   int sum=1,res=0;
   
   while(sum<b){
     sum+=a-1;
     res++;
   }
   cout<<res<<endl;
}


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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            double[] number = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
            double x1 = number[0];
            double y1 = number[1];
            double x2 = number[2];
            double y2 = number[3];

            double dist2 = System.Math.Pow(x2 - x1, 2) + System.Math.Pow(y2-y1,2);
            double dist = System.Math.Sqrt(dist2);
            Console.WriteLine(dist);
        }
    }
}


Measured memory_bytes: 18472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[214514],cnt[214514];
int main(){
	ll n;
	cin>>n;
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
		cnt[a[i]]++;
	}
	ll q;
	cin>>q;
	for(int i=0;i<q;i++){
		ll b,c;
		cin>>b>>c;
		sum+=cnt[b]*(c-b);
	  cnt[c]+=cnt[b];
		cnt[b]=0;
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 5156
#include<stdio.h>

int search(int A[], int n, int key)
{
	int i = 0;
	A[n] = key;
	while(A[i] != key) i++;
	return i != n;
}

int main()
{
	int i,n, A[10000+1], q, key, sum = 0;
	scanf("%d", &n);
	for(i = 0; i < n; i++) scanf("%d", &A[i]);
	scanf("%d", &q);
	for(i = 0; i < q; i++) 
	{
		scanf("%d", &key);
		if(search(A, n, key)) sum++;
		
	}
	printf("%d\n", sum);
	return 0;
}

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

using namespace std;

int main() {
    int n; cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    vector<int> ans;
    ans.push_back(1);
    int len = 1;
    for (int i = 1; i < n; i++) {
        if (arr[i] <= arr[i - 1]) ans[len - 1]++;
        else {
            ans.push_back(1);
            len++;
        }
    }
    int res = 0;
    for (int i = 0; i < len; i++) res = max(res, ans[i]);
    cout << res - 1;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll k ; 
    cin >> k ;
    ll a , b;
    cin >> a>> b;
    ll i;
   for( i = a ; i <=b ; i+=1){
       if( (i%k) == 0 ){
           cout <<"OK";
           break;
       }
   }
   if( i == b+1){
       cout <<"NG";
   }
}

Measured memory_bytes: 3620
#include <stdio.h>
int main(void){
  int i,j,N,M,C,ans=0,temp;
  if(scanf("%d%d%d",&N,&M,&C)<3) return 1;
  int A[N][M],B[M];
  for(i=0;i<M;i++){
    if(scanf("%d",&B[i])<1) return 1;
  }
  for(i=0;i<N;i++){
    for(j=0;j<M;j++){
      if(scanf("%d",&A[i][j])<1) return 1;
    }
  }
  for(i=0;i<N;i++){
    temp=C;    
    for(j=0;j<M;j++){
      temp += A[i][j] * B[j];
    }
    if(temp > 0) ans++;
  }
  printf("%d",ans);

  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// 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();
}

//
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

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

  int N, M;
  cin >> N >> M;

  vector<int> p(M);
  vector<vector<int>> s(M, vector<int>());
  map<int, int> mp;
  rep(i, M) {
    int k;
    cin >> k;

    rep(j, k) {
      int x;
      cin >> x;
      x--;
      s[i].push_back(x);
    }
  }

  rep(i, M) { cin >> p[i]; }

  int ans = 0;
  int tmp[10] = {0};  //電球
  for (int bit = 0; bit < 1 << N; bit++) {
    rep(i, 10) tmp[i] = 0;
    for (int i = 0; i < N; i++) {
      if (bit >> i & 1) {
        for (int j = 0; j < M; j++) {
          for (int k = 0; k < s[j].size(); k++) {
            if (s[j][k] == i) tmp[j]++;
          }
        }
      }
    }
    bool flag = true;
    rep(i, M) {
      if (tmp[i] % 2 != p[i]) flag = false;
    }
    if (flag) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 300 + 5;

int dp[maxn][maxn][maxn];
vector<pair<int, int> > Op[maxn];

bool chk(int r, int g, int b) {
    int p = max(r, max(g, b));
    for(auto x : Op[p]) {
        int cnt = 0;
        if(x.first <= r) ++cnt;
        if(x.first <= g) ++cnt;
        if(x.first <= b) ++cnt;

        if(cnt != x.second) return false;
    }
    return true;
}
int main() {

    int n, m;
    //freopen("data.txt", "r", stdin);

    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; i++) {
        int l, r, x;
        cin >> l >> r >> x;
        Op[r].push_back(make_pair(l, x));
    }

    dp[0][0][0] = 1;

    int v, ans = 0;
    for(int i = 0; i <= n; i++) 
        for(int j = 0; j <= n; j++)
            for(int k = 0; k <= n; k++) if((v = dp[i][j][k]) && chk(i, j, k)) {

                int p = max(i, max(j, k));
                if(p == n) (ans += v) %= mod;
                else {
                    ++p;
                    (dp[p][j][k] += v) %= mod;
                    (dp[i][p][k] += v) %= mod;
                    (dp[i][j][p] += v) %= mod;
                }
            }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 110848
#include<stdio.h>

int main(void)
{
  int N,i,S;
  char A[100],B[100],C[100];
  scanf("%d\n%s\n%s\n%s",&N,&A,&B,&C);
  
  S=0;
  for(i=0;i<=N-1;i++){
    if(A[i]==B[i]){
      if(B[i]!=C[i]){
        S++;
      }
    }else if(A[i]==C[i]){
      S++;
    }else if(B[i]==C[i]){
      S++;
    }else{
      S=S+2;
    }
  }
  
  printf("%d",S);
  
  return 0;
}

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

int main() {
	ll n; scanf("%lld", &n);
	ll A = 1, B = 1;
	rep(i, n) {
		ll t, a; scanf("%lld%lld", &t, &a);
		ll n = max(ceil(A, t), ceil(B, a));
		A = t*n; B = a*n;
	}
	printf("%lld\n", A + B);
}

Measured memory_bytes: 256