akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> mm(n);
    for(int i = 0; i < n; i++)
        cin >> mm[i];
    vector<vector<int>> m2(n+2, vector<int>(m+2, 0));
    vector<vector<int>> ans(n+2, vector<int>(m+2, 0));
    vector<vector<int>> dp(n+2, vector<int>(m+2, 0));
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if (mm[i-1][j-1] == '.')
                m2[i][j] = 1;
            dp[i][j] = dp[i][j-1] * m2[i][j] + m2[i][j];
            ans[i][j] += dp[i][j];
        }
        dp[i] = vector<int>(m+2, 0);
        for(int j = m; j >= 1; j--) {
            dp[i][j] = dp[i][j+1] * m2[i][j] + m2[i][j];
            ans[i][j] += dp[i][j];
        }
        dp[i] = vector<int>(m+2, 0);
    }

    for(int j = 1; j <= m; j++) {
        vector<int> tmp(n+2, 0);
        for(int i = 1; i <= n; i++) {
            tmp[i] = tmp[i-1] * m2[i][j] + m2[i][j];
            ans[i][j] += tmp[i];
        }
        tmp = vector<int>(n+2, 0);
        for(int i = n; i >= 1; i--) {
            tmp[i] = tmp[i+1] * m2[i][j] + m2[i][j];
            ans[i][j] += tmp[i];
        }
    }
    int res = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if (m2[i][j] == 1)
                res = max(res, ans[i][j]);
        }
    }
    cout << res -3 << endl;
    return 0;
}




Measured memory_bytes: 53760
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

const int MAX_V = 300;

int V;
bool G[MAX_V][MAX_V];
int match[MAX_V];
bool used[MAX_V];

bool dfs(int v) {
	used[v] = true;
	for(int i = 0; i < V; i++) {
		if(!G[v][i]) continue;
		int u = i, w = match[u];
		if(w < 0 || (!used[w] && dfs(w))) {
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bipartite_matching() {
	int res = 0;
	memset(match, -1, sizeof(match));
	for(int v = 0; v < V; v++) {
		if(match[v] < 0) {
			memset(used, 0, sizeof(used));
			if(dfs(v)) {
				res++;
			}
		}
	}
	return res;
}

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

	int X, Y, E;
	cin >> X >> Y >> E;
	V = 200;
	for(int i = 0; i < E; i++) {
		int x, y;
		cin >> x >> y;
		y += 100;
		G[x][y] = G[y][x] = true;
	}

	cout << bipartite_matching() << endl;
}

Measured memory_bytes: 3296
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef int in;
typedef vector<in> VI;
typedef vector<VI> VVI;
in zr;
VVI bst;
VVI nh;
in h,w;
in wtg(VI a, VI b){
  reverse(all(a));
  reverse(all(b));
  forv(i,nh){
    forn(j,h+3)
      nh[i][j]=0;
  }
  forn(i,h){
    forn(j,h){
      if(a[i]==b[j]){
	++nh[j-i+zr][h-j];
      }
    }
  }
  forv(i,nh){
    for(in j=1;j<h+3;++j)
      nh[i][j]+=nh[i][j-1];
  }
  forn(i,h+1)
    bst[0][i]=bst[i][0]=0;
  for(in i=1;i<=h;++i){
    for(in j=1;j<=h;++j){
      bst[i][j]=min(bst[i-1][j],bst[i][j-1])+nh[i-j+zr][j];
    }
  }
  return bst[h][h];
}
VVI mar;
string inp;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>h>>w;
  zr=h+5;
  nh.resize(2*zr,VI(h+3));
  bst.resize(h+1,VI(h+1));
  mar.resize(w,VI(h));
  forn(i,h){
    cin>>inp;
    forn(j,w)
      mar[j][i]=inp[j]-'a';
  }
  in sm=0;
  forn(i,w-1)
    sm+=wtg(mar[i],mar[i+1]);
  cout<<sm<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

vector< vector<int> > Graph;
vector< int > value;





bool ProductDay(int month,int day10,int day1) {
    if(day10*day1 == month) return true;
    else return false;
}



int main(int argc, const char * argv[]) {
    
    
    
    string s; cin >> s;
    string t; cin >> t;
    int ans = 0;
    rep(i,3){
        if(s[i]==t[i]) ans++;
    }
    
    cout << ans << endl;
    
    
    


    
    

    
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

sn = lambda : stdin.readline().rstrip()
an = lambda : map(int, stdin.readline().split())
ni = lambda : int(sn())

def main():
  n = ni()
  s = sn()

  i, j = 0, 1
  ans = 0
  while j < n:
    if s[i:j] in s[j:]:
      ans = max(ans, len(s[i:j]))
      j += 1
    else:
      i += 1
    if i == j:
      i += 1
      j += 2
  print(ans)

main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(void)
{
    ll a,b,c;
    cin >> a >> b >> c;
    if(c-a-b > 0 && (c-a-b)*(c-a-b) - 4* a* b > 0){
        printf("Yes\n");
    }
    else{
        printf("No\n");

    }



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
 
using ll = long long;
using pll = pair<ll,ll>;
const ll INF = 1ll<<60;
 
void chmax (pll &a, pll b) {
    if (a.first < b.first) {
        a.second = max(a.first, b.second);
        a.first = b.first;
    }
    else a.second = max(a.second, b.first);
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n; scanf("%d", &n);
    vector<ll> a(1<<n);
    vector<pll> dp(1<<n);
    rep(i,1<<n) {
        scanf("%lld", &a[i]);
        dp[i] = pll(a[i], -INF);
    }
 
    // 高速ゼータ変換
    rep(j,n) rep(i,1<<n) if (i & 1<<j) chmax(dp[i], dp[i^(1<<j)]);
 
    ll ans = -INF;
    rep(i,1<<n) {
        ans = max(ans, dp[i].first + dp[i].second);
        if (i) printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 9528
M = input()
MM = list(M)
count = 0
x = len(MM)
while count == 0:
  if len(MM)%2 ==1:
    MM.pop(-1)
  else:
    a = int(len(MM)/2)
    
    if MM[:a] == MM[a:] and len(MM) != x:
        count =1
    else:
      MM.pop(-1)
print(len(MM))

Measured memory_bytes: 9128
A,B = map(int,input().split())

H = W = 100
Ans = ["#"*100 for i in range(50)] + ["."*100 for i in range(50)]
count = 0
i = 0
j = 0
while count < A-1:
    count += 1
    Ans[i] = Ans[i][:j] + "." + Ans[i][j+1:]
    if j == 98:
        i += 2
        j = 0
    else:
        j += 2

count = 0
i = 0
j = 0
while count < B-1:
    count += 1
    Ans[99-i] = Ans[99-i][:j] + "#" + Ans[99-i][j+1:]
    if j == 98:
        i += 2
        j = 0
    else:
        j += 2
print(*[H,W])
for i in range(H):
    print(Ans[i])

Measured memory_bytes: 38384
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    writeln(0);
    stdout.flush();
    auto f = readln.chomp;
    if (f == "Vacant") return;
    int l = 0, r = N;
    for (;;) {
        auto m = (l+r)/2;
        writeln(m);
        stdout.flush();
        auto x = readln.chomp;
        if (x == "Vacant") {
            return;
        } else if (m%2 == 0 && x == f || m%2 == 1 && x != f) {
            l = m;
        } else {
            r = m;
        }
    }
}

Measured memory_bytes: 852
// Exception Handling - atcoder.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;

const int N = 2e5 + 6;
int arr[N], tempp[N] , n ;
int main()
{
	cin >> n; 

	int prevMax = 0, curMax =0 ;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		tempp[i] = arr[i];
	}

	sort(tempp, tempp + n);
	prevMax = tempp[n - 2];
	curMax = tempp[n - 1];

	for (int i = 0; i < n; i++)
	{
		if (arr[i] == curMax)
			cout << prevMax << endl;
		else
			cout << curMax << endl;
	}
}


Measured memory_bytes: 3200
import numpy as np
inf=10000007

n,k=map(int,input().split())
h=np.array(list(map(int,input().split())))
dp = np.zeros(n,dtype=int)
dp[0]=0

for i in range(1,n):
    l=max(0,i-k)

    dp[i] = np.min(dp[l:i] + abs(h[l:i] - h[i]))




##print(li)
print(dp[-1])


Measured memory_bytes: 22732
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define PI acos(-1)
#define ld long double
//mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1e9+7, N = 2e5+5;

int a[N], n, m, k;

void solve(int test_case){
	int i, j;
	cin >> n;
	if(n >= 30){
		cout << "Yes";
	}else {
		cout << "No";
	}
	return;
}

signed main(){
	FASTIO;
#define MULTITEST 0
#if MULTITEST
	int ___T;
	cin >> ___T;
	for(int T_CASE = 1; T_CASE <= ___T; T_CASE++)
		solve(T_CASE);
#else
	solve(1);
#endif
	return 0;
}



Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k; ll s;
    cin >> n >> k >> s;

    vector<int> ans(n, 0);
    for(int i=0;i<n;++i) {
        if(i < k) {
            ans[i] = s;
        } else {
            if(s == 1000000000) {
                ans[i] = s-1;
            } else {
                ans[i] = s+1;
            }
        }
    }

    for(int i=0;i<n;++i) {
        if(i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=1e5+1;
int main() {
    quick
int n; cin>>n; long long ans=0;
for(int i=1;i<=n;i++){
    string temp=to_string(i);
    if(temp.size()%2){ans++;}
}
cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define vec vector
#define sz(x) ((int) x.size())
#define rd(type, ...) type __VA_ARGS__; sc(__VA_ARGS__)
#define rdv(type, v, n) vector<type> v(n); rep(i, 0, n) cin >> v[i]
#define prv(v) rep(i, 0, sz(v)) {if (i) cout << ' '; cout << v[i];} cout << '\n'
#define rdm(type, v, h, w) vector<vector<type>>(h, vector<type>(w)) v; rep(i, 0, h) rep(j, 0, w) cin >> v[i][j]
#define prm(v) rep(i, 0, v.size()) {rep(j, 0, v[i].size()) {if (j) {cout << ' ';} cout << v[i][j];} cout << '\n';}
typedef long long ll;
void solve();
int main() {ios::sync_with_stdio(false); cin.tie(0); solve(); return 0;}
template<typename T> void sc(T& x) {cin >> x;}
template<typename Head, typename... Tail> void sc(Head& head, Tail&... tail) {cin >> head; sc(tail...);}
template<typename T> void pr(const T& x) {cout << x << '\n';}
template<typename Head, typename... Tail> void pr(const Head& head, const Tail&... tail) {cout << head << ' '; pr(tail...);}

void solve() {
  rd(int, h, w);
  vec<string> a;
  rep(i, 0, h) {
    rd(string, x);
    a.pb(x);
  }
  vec<vec<int>> c(w);
  vec<vec<int>> r(h);
  rep(i, 0, w) {
    c[i].pb(0);
    c[i].pb(h + 1);
  }
  rep(i, 0, h) {
    r[i].pb(0);
    r[i].pb(w + 1);
  }
  rep(i, 0, h) {
    rep(j, 0, w) {
      if (a[i][j] == '#') {
        c[j].pb(i + 1);;
        r[i].pb(j + 1);
      }
    }
  }
  rep(i, 0, w) {
    sort(c[i].begin(), c[i].end());
  }
  rep(i, 0, h) {
    sort(r[i].begin(), r[i].end());
  }
  int ans = 1;
  rep(i, 0, h) {
    rep(j, 0, w) {
      if (a[i][j] != '#') {
        int col_bound = lower_bound(c[j].begin(), c[j].end(), i + 1) - c[j].begin();
        int row_bound = lower_bound(r[i].begin(), r[i].end(), j + 1) - r[i].begin();
        ans = max(ans, c[j][col_bound] - c[j][col_bound - 1] + r[i][row_bound] - r[i][row_bound - 1] - 3);
      }
    }
  }
  pr(ans);
}

Measured memory_bytes: 38656
s = input()
mod = 2019
dic = [0] * mod
dic[0] += 1

tmp = 0
d = 1
for i in reversed(range(len(s))):
    tmp += int(s[i]) * d
    tmp %= mod
    d *= 10
    d %= mod
    dic[tmp] += 1

ans = [i * (i-1) / 2 for i in dic]
print(int(sum(ans)))

Measured memory_bytes: 9180
N = int(input())
cnt = 0
flag = True
for i in range(N):
    S = input()
    if(S == 'A'):
        cnt += 1
    elif(S == 'Un'):
        cnt -= 1
        if(cnt < 0):
            flag = False
if(flag == False):
    print('NO')
else:
    if(cnt == 0):
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define INF 1000000009
int n;
int h[MAX];
int dp[MAX];
int main()
{
    cin >> n;
    for(int i=1;i<=n;i++)cin >> h[i];
    dp[1] = 0;
    for(int i=2;i<=n;i++)
    {
        dp[i] = INF;
        if(i-1>=1)
        {
            dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1])); 
        }
        if(i-2>=1)
        {
            dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
        }
    }

    cout << dp[n];
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
	char A[12],B[12];
int main(){

	scanf("%s%s",A,B);
	int n= strlen(A);
    int i=0;
    for(i=0;i<n;i++){
      
      if(A[i]!=B[i]){
        printf("No\n");
        return 0;
      }
    }
  	if(B[n]>0){
      printf("Yes\n");
      return 0;
    }
  
	printf("No\n");
	return 0;
}


Measured memory_bytes: 1664
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=12;
int n,a[MAXN];
int dfs(int pos,int lim) {
	if (pos>n) return lim;
	int ans=0;
	for (int i=a[pos]-1;i<=a[pos]+1;++i)
		ans+=dfs(pos+1,lim||(!(i&1)));
	return ans;
}
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	printf("%d\n",dfs(1,0));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

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

  vector<uint64_t> A(N);
  N_TIMES(n, N) { cin >> A[n]; }
  reverse(A.begin(), A.end());

  const uint64_t INF = static_cast<uint64_t>(-1);
  vector<uint64_t> B(N, INF);
  N_TIMES(i, N) {
    auto itr = upper_bound(B.begin(), B.end(), A[i]);
    uint64_t j = distance(B.begin(), itr);
    B[j] = A[i];
  }

  uint64_t C = 0;
  N_TIMES(i, N) {
    if (B[i] == INF) { break; }
    ++C;
  }
  cout << C << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int w=0;string s;
    cin>>s;
    cin>>w;
    for(int i=0;i<s.length();i+=w)
    	cout<<s[i];
    cout<<endl;
}

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

a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

temp = -1
score = 0

for i in a:
    score += b[i-1]
    if i == temp+1:
        score += c[temp-1]
    temp = i
    
print(score)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 13

int N,M,X;
int POW[SIZE],a[SIZE];
int b[SIZE][SIZE],c[SIZE];
int main(){
	POW[0] = 1;
	for(int i = 1; i < SIZE; i++){
		POW[i] = POW[i-1]*2;
	}
	scanf("%d %d %d",&N,&M,&X);
	for(int i = 0; i < N; i++){
		scanf("%d",&a[i]);
		for(int k = 0; k < M; k++){
			scanf("%d",&b[i][k]);
		}
	}	
	int ans = BIG_NUM;
	bool FLG;
	for(int state = 0; state < POW[N]; state++){
		memset(c,0,sizeof(c)); 
		int sum = 0;
		for(int loop = 0; loop < N; loop++){
			if(state & POW[loop]){
				sum += a[loop];
				for(int k = 0; k < M; k++){
					c[k] += b[loop][k];
				}
			}
		} 
		FLG = true;
		for(int i = 0; i < M; i++){
			if(c[i] < X){
				FLG = false;
				break;
			}
		}
		if(FLG) ans = min(ans,sum);
	}
	if(ans == BIG_NUM) printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main(){
    long long N;
    string S;
    long long ans=0;
    int i,j,k;

    long long r=0,g=0,b=0;

    cin>>N;
    cin>>S;

    for(i=0;i<N;i++){
        if(S[i] == 'R')r++;
        if(S[i] == 'G')g++;
        if(S[i] == 'B')b++;
    }

    ans=r*g*b;

    for(i=1;i<=N;i++){
        for(j=i;j<=N;j++){
            k=j+j-i;
            if(k <= N && i<=k){
                if(S[i-1] == S[j-1])continue;
                if(S[i-1] == S[k-1])continue;
                if(S[j-1] == S[k-1])continue;
                ans=ans-1;
            }
            
        }
    }
    
    cout<<ans<<endl;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x = 0;
    int ans = 0;
    rep(i,n) {
        x += (s[i] == 'I') + (s[i] == 'D')*(-1);
        ans = max(x, ans);
    }
    cout << ans << endl;
}

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

int main() {
   long long N,D;
   cin >> N >> D;
   int count=0;
   for (int i=0; i<N; i++) {
       long long x,y;
       cin >> x >> y;
       if (D*D>=x*x+y*y) count++;
   }
   cout << count << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll int a,b,c,d;
  cin>>a>>b>>c>>d;
ll int n=b-a+1;
 ll int x1=a/c;
 ll int y1=b/c;
 ll int x2=a/d;
 ll int y2=b/d;
 ll int c1,c2,c3;
  if(x1*y1==0 || a%c!=0)
    c1=y1-x1;
  else
    c1=y1-x1+1;
  if(x2*y2==0 || a%d!=0)
    c2=y2-x2;
  else
    c2=y2-x2+1;
  ll int l=(c*d)/__gcd(c,d);
    ll int x3=a/l;
  ll int y3=b/l;
  if(x3*y3==0 || a%l!=0)
    c3=y3-x3;
  else
    c3=y3-x3+1;
  cout<<n-c1-c2+c3;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(all(a));
	cout << abs(a[0] - a[n-1]) << endl;


	return 0;
}

Measured memory_bytes: 256
i,a[100],k,m,t;main(n){while(scanf("%d%d",&n,&m),n){while(i<n*m)scanf("%d",&t),a[i++%m]+=t;n=m;while(n--){for(t=i=0;i<m;++i)t=t<a[i]?a[k=i]:t;printf("%d%c",k+1,n?32:10),i=a[k]=0;}}}

Measured memory_bytes: 412
#include<stdio.h>
int main(){
    long long  number,total[10000],sum=0;
    long long box=0,i,j;

    scanf("%lld",&number);       //ｎ個の数のｎを代入

    for(i=0;i<number;i++)      //配列に数を代入
        scanf("%lld",&total[i]);

    for(i=0;i<number;i++){     //降順ソート
        for(j=i+1;j<number;j++){
            if(total[i]>total[j]){
            box=total[j];
            total[j]=total[i];
            total[i]=box;
         }
      }
    }


    for(i=0;i<number;i++)       //sumにすべて足す
        sum += total[i];

    printf("%lld %lld %lld\n",total[0],total[number-1],sum);  //出力

    return 0;
}



Measured memory_bytes: 2144
#include<iostream>
#include<string>
#include<map>
using namespace std ;

string s ;

string f( int a , int b ){
	string z(1,s[a]) ;
	for( int i=a+1 ; i<=b ; i++ ){
		z += s[i] ;
	}
	return z ;
}
string f_r( string a ){
	string z(1,a[a.size()-1]) ;
	for( int i=a.size()-2 ; i>=0 ; i-- ){
		z += a[i] ;
	}
	return z ;
}

int main(){
	
	int n ;
	
	cin >> n ;
	for( int i=0 ; i<n ; i++ ){
		cin >> s ;
		
		int cnt = 1 ;
		map<string,int> train ;
		train[s] = 1 ;
		
		for( int j=1 ; j<s.size() ; j++ ){
			string x = f(0,j-1) ;
			string y = f(j,s.size()-1) ;
			string x_r = f_r(x) ;
			string y_r = f_r(y) ;
			string p ;
			
			
			//----------------------
			p = x + y_r ;
			if( train[p] != 1 ){
				cnt++ ; train[p] = 1 ;
			}
			p = x_r + y ;
			if( train[p] != 1 ){
				cnt++ ; train[p] = 1 ;
			}
			p = x_r + y_r ;
			if( train[p] != 1 ){
				cnt++ ; train[p] = 1 ;
			}
			//-----------------------
			p = y + x ;
			if( train[p] != 1 ){
				cnt++ ; train[p] = 1 ;
			}
			p = y + x_r ;
			if( train[p] != 1 ){
				cnt++ ; train[p] = 1 ;
			}
			p = y_r + x ;
			if( train[p] != 1 ){
				cnt++ ; train[p] = 1 ;
			}
			p = y_r + x_r ;
			if( train[p] != 1 ){
				cnt++ ; train[p] = 1 ;
			}
		}
		
		cout << cnt << endl ;
	}
	
return 0 ;
}

Measured memory_bytes: 1328
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define int long long

signed main(){
    int a, b;
    cin >> a >> b;
    if(a + b >= 10){
        cout << "error" << endl;
    }
    else{
        cout << a + b << endl;
    }
}

Measured memory_bytes: 256
<?php
    fscanf(STDIN, '%d', $s);
    $times[0] = floor($s / 60 / 60);
    $times[1] = floor(($s - ($times[0] * 60 * 60)) / 60);
    $times[2] = $s - ($times[0] * 60 * 60) - ($times[1] * 60);
    echo implode(':', $times), PHP_EOL;

Measured memory_bytes: 6552
def inpl(): return map(int, input().split())
from itertools import accumulate
from bisect import bisect, bisect_left
from collections import Counter, deque
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor

from sys import setrecursionlimit
setrecursionlimit(10**9)
 
import sys
#input = sys.stdin.readline
from collections import Counter
def inpl(): return list(map(int, input().split()))

MOD = 10**9 + 7
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


size = 2 * 10**5
g1, g2, inverse = [0]*size, [0]*size, [0]*size
 
g1[:2] = [1, 1] # 元テーブル
g2[:2] = [1, 1] #逆元テーブル
inverse[:2] = [0, 1] #逆元テーブル計算用テーブル
 
for i in range(2, size):
    g1[i] =  ( g1[i-1] * i ) % MOD 
    inverse[i] = (-inverse[MOD % i] * (MOD//i) ) % MOD 
    g2[i] =  (g2[i-1] * inverse[i]) % MOD



N, K = inpl()
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = inpl()
    G[a-1].append(b-1)
    G[b-1].append(a-1)
C = [0]*N
P = [0]*N
searched = [0]*N
searched[0] = 1

"""
def count(p):
    global C, searched
    cnt = 0
    for q in G[p]:
        if not searched[q]:
            P[q] = p
            searched[q] = 1
            cnt += 1
            count(q)
    C[p] = cnt
count(0)"""

Q = deque([0])
while Q:
    p = Q.popleft()
    for q in G[p]:
        if not searched[q]:
            P[q] = p
            searched[q] = 1
            C[p] += 1
            Q.append(q)


ans = K * cmb(K-1, C[0], MOD) * g1[C[0]] % MOD
for i in range(1, N):
    if C[i] == 0:
        continue
    ans = ans * cmb(K-2, C[i], MOD) * g1[C[i]] % MOD

print(ans%MOD)

Measured memory_bytes: 75296
h, w = map(int, input().split())
s = [input() + '#' for _ in range(h)] + ['#' * (w + 1)]
l1 = [[0] * (w + 1) for i in range(h + 1)]
l2 = [[0] * (w + 1) for i in range(h + 1)]
for i in range(h):
    tmps = 0
    for j in range(w + 1):
        if s[i][j] == '#':
            l1[i][tmps] += j - tmps
            l1[i][j] -= j - tmps
            tmps = j + 1
for i in range(h):
    for j in range(w):
        l1[i][j + 1] += l1[i][j]
for j in range(w):
    tmps = 0
    for i in range(h + 1):
        if s[i][j] == '#':
            l2[tmps][j] += i - tmps
            l2[i][j] -= i - tmps
            tmps = i + 1
for j in range(w):
    for i in range(h):
        l2[i + 1][j] += l2[i][j]
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, l1[i][j] + l2[i][j])
print(ans - 1)

Measured memory_bytes: 123224
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

template<typename T>
int bitCount(T bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}

int H, W, K;
char C;
int S[10][1001];
int main(void){
    cin >> H >> W >> K;
    REP(h, H) REP(w, W) {
        cin >> C;
        if(C == '1') S[h][w+1] = 1;
        S[h][w+1] += S[h][w];
    }

    int res = INF;
    for (int h = 0;h < (1 << (H-1));h++){
        int tmp_res = bitCount(h);
        bool br2 = false;
        int last_cut = 0;
        for (int w=1;w <= W; w++){
            int num_white = 0;
            bool br = false;
            for(int b=0;b<H;b++){
                num_white += S[b][w] - S[b][last_cut];
//                cout << "t:" << h << ' ' << tmp_res  << ' ' << num_white << ' ' << w << ' ' << last_cut << endl;

                if(num_white > K) {
                    br = true;
                    if(w - last_cut == 1){
                        br2 = true;
                        break;
                    }
                    last_cut = --w;
                    num_white = 0;
                    tmp_res++;
                    break;
                }

                if((h>>b)&1) num_white = 0;
            }
            if(br2) break;
        }
//        cout << "r:" << h << " " << tmp_res << " " << br2 << endl;
        if(!br2) res = min(res, tmp_res);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
class TreeNode:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None

class BST:
    def __init__(self):
        self.root = None

    def insert(self, v):
        x = TreeNode(v)
        if not self.root:
            self.root = x
            return

        r = self.root
        while r is not None:
            parent = r
            if x.val < r.val:
                r = r.left
            else:
                r = r.right

        if x.val < parent.val:
            parent.left = x
        else:
            parent.right = x

    def in_order(self):
        def helper(node):
            if not node:
                return
            helper(node.left)
            res.append(node.val)
            helper(node.right)

        res = []
        helper(self.root)
        return res

    def pre_order(self):
        def helper(node):
            if not node:
                return
            res.append(node.val)
            helper(node.left)
            helper(node.right)

        res = []
        helper(self.root)
        return res


test = BST()
n = int(input())
for _ in range(n):
    order = input()
    if order.startswith("insert"):
        i, x = order.split()
        test.insert(int(x))
    else:
        print(" ",end="")
        print(*test.in_order())
        print(" ",end="")
        print(*test.pre_order())



Measured memory_bytes: 116668
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

vector<ll> B, P;

ll rec(int N, ll X) {
    if (X < 1) return 0;
    else if (N == 0) return 1;
    else if (X <= 1 + B[N - 1]) return rec(N - 1, X - 1);
    else if (X == 2 + B[N - 1]) return P[N - 1] + 1;
    else if (X <= 2 + 2 * B[N - 1]) return P[N - 1] + 1 + rec(N - 1, X - 2 - B[N - 1]);
    else return P[N - 1] * 2 + 1;
}

int main() {
    int N; ll X; cin >> N >> X;
    
    B.resize(N); P.resize(N);
    B[0] = P[0] = 1;
    REP(i, 1, N) {
        B[i] = B[i - 1] * 2 + 3;
        P[i] = P[i - 1] * 2 + 1;
    }

    cout << rec(N, X) << endl;
    return 0;
}

Measured memory_bytes: 3568
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c = map(int, input().split())
    k = int(input())

    while k and a >= b:
        b *= 2
        k -= 1

    while k and b >= c:
        c *= 2
        k -= 1

    print("Yes" if a < b < c else "No")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 


int main()
{
    long N,M;
    std::cin >> N >> M;
    std::vector<long> A;
    long sum=0;
    for(long i=0; i<N; i++){
        long temp;
        std::cin >> temp;
        A.push_back(temp);
        sum+=temp;
    }
    std::sort(A.begin(),A.end());
    bool flag=true;
    for(long i=0; i<M; i++){
        if(A[N-1-i]<(double)sum/(double)(4*M)){
            flag=false;
            break;
        }
    }
    if(flag){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000") //  (UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")  // $ (UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\

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

#define endl "\n"
#define int long long
#define ll long long
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define fi first
#define se second
#define vi vector<int>
#define vii vector< vector<int> >
#define vpi vector< pair<int,int> >
#define pair <int, int> pii

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
    ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

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

const long long inf = 2e18 ;
const int mod = 1e9+7 ;
// const int mod = 998244353 ;
const int N = 1e5 + 10 ;

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

        int n ; 
	cin >> n ; 
	//vector< pair<int, int> > v ; 
	int ans = INT_MAX ; 
	bool ok = false ; 
	ans = n-1 ; 
	for(int i=2 ; i*i<=n ; i++)
	{
		if(n%i==0)
		{	
			ok = true ; 
			ans = min(ans, abs(i-1) + abs(n/i-1)) ; 
		}
	}
	if(!ok)
	{
		ans = n-1 ; 
	}

	cout << ans << endl; 
return 0 ;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

dist = []

for i in range(N):
    dist.append(A[i] - (i + 1))

b = sorted(dist)[N//2]

ans = 0
for i in range(N):
    ans += abs(A[i] - (i + 1) - b)

print(ans)


Measured memory_bytes: 25196
#include<stdio.h>

int H,A[5000001];

void buildMaxHeap(int *);
void maxHeapify(int *,int);
int left(int);
int right(int);
main()
{
  int i;
  scanf("%d",&H);
  for(i=1;i<H+1;i++)/*?????????1?§???????*/
    {
      scanf("%d",&A[i]);
    }
  buildMaxHeap(A);
  for(i=1;i<H+1;i++)
    {
      printf(" %d",A[i]);
    }
  printf("\n");
  return 0;
}

void buildMaxHeap(int* A)
{
  int i;
  /*H = A.length;*/

  for(i=H/2;i>=1;i--)
    {
      maxHeapify(A,i);/*i?????????????????????????????????*/
    }

}

void maxHeapify(int* A,int i)
{
  int l,r,largest,imm;
  
  l = left(i);
  r = right(i);
  if(l <= H && A[l] > A[i])largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i)
    {
      imm = A[i];
      A[i] = A[largest];
      A[largest] = imm;
      maxHeapify(A,largest);/*?????°*/
    }

}


int left(int i)
{
  return 2*i;
}

int right(int i)
{
  return (2*i+1);
}

Measured memory_bytes: 2552
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int N,A[1000001];
vector<int> G;
int cnt;
int insert(int *A,int N,int g){
  for(int i=g;i<N;i++){
    int v=A[i];
    int j=i-g;
    while(j>=0 && A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }
    A[j+g]=v;
  }
}
int shell(int *A,int N){
  int h=1;
  while(h<=N){
    G.push_back(h);
    h=3*h+1;
  }
  for(int i=G.size()-1;i>=0;i--)insert(A,N,G[i]);
}
int main(){
  
  cin >> N;
  for(int i=0;i<N;i++)cin >> A[i];
  
  shell(A,N);

  cout << G.size() << endl;
  for(int i=G.size()-1;i>=0;i--){
    cout << G[i];
    if(i)cout << " " ;
  }
  cout << endl;
  cout << cnt << endl;
  for(int i=0;i<N;i++)cout << A[i] << endl;
  return 0;
}

Measured memory_bytes: 6992
#include <stdio.h>

int main()
{
    int N;
    int num[28]={0};
    char ch;
    scanf("%d",&N);
    getchar();
    for(int i=0;i<N;i++)
    {
        scanf("%c",&ch);
        getchar();
        num[ch-'A']=1;
    }
    if(num['P'-'A']==1&&num['Y'-'A']==1&&num['W'-'A']==1&&num['G'-'A']==1)
        printf("Four\n");
    else printf("Three\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
using namespace std;

int N, M, ans = 0;
vector<int> a(30);
vector<int> b(30);
vector<int> c(9,1);
int m[9][9] = {0};
vector<int> homon(9,0);

void dfs(int cd){
  bool flag1 = true;
  for(int i = 1; i <= N;i++){
    if(homon[i] == 0)
      flag1 = false;
  }
  if(flag1){
    ++ans;
  }
  else{
    for(int i=2; i <=N; i++){
      if(m[cd][i] == 1 && homon[i] ==0){
        homon[i] = 1;
        dfs(i);
        homon[i] = 0;
      }
    }
  }

}

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

  for(int i = 0; i < M; i++){
    cin >> a[i] >> b[i];
    m[a[i]][b[i]]=1;
    m[b[i]][a[i]]=1;
  }

  homon[1] = 1;
  dfs(1);
  cout <<ans << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    var H = sc.nextLong()
    var count = 1L
    var ans = 0L
    while (H > 0) {
        ans += count
        H /= 2
        count *= 2
    }
    println(ans)
}


Measured memory_bytes: 31260
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  vector<long> data;
  long flag, ans = 1;
  for(int i = 2; i <= N;i++) {
    flag = 0;
    for(int j = 2; j < i; j++) {
      if (i % j == 0) {
        flag = 1;
        break;
      }
    }
    if (flag == 1) continue;
    else data.push_back(i);
  }
  vector<long> sub(data.size());
  long a;
  for(int i = 1; i <= N;i++) {
    a = i;
    for(int j = 0; a != 1; j++) {
      if(a % data.at(j) == 0) {
        sub.at(j)++;
        a /= data.at(j);
      }
      if(j == data.size() - 1) j = -1;
    }
  }
  for(int i = 0; i < sub.size(); i++) {
    if(sub.at(i) != 0) ans *= sub.at(i) + 1;
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

ll n,a,b;
ll dp[100010][2];
ll s[100010];
int len[100010];

int main() {
    scanf("%lld%lld%lld",&n,&a,&b);
    if (a>b) swap(a,b);
    for (int i=1;i<=n;i++) {
        scanf("%lld",s+i);
    }
    s[0]=-1e18;
    dp[1][0]=dp[1][1]=1;
    for (int i=2;i<=n;i++) {
        if (s[i]-s[i-1]>=a) len[i]=len[i-1]+1;
        if (s[i]-s[i-2]>=a) dp[i][0]=(dp[i][0]+dp[i-1][1])%MOD;
        if (s[i]-s[i-1]>=a) dp[i][0]=(dp[i][0]+dp[i-1][0])%MOD;
        if (s[i]-s[i-1]>=b) dp[i][1]=(dp[i-1][0]+dp[i-1][1])%MOD;
        else if (s[i]-s[i-2]>=b) dp[i][1]=dp[i-1][0]%MOD;
        else {
            int pos=upper_bound(s,s+i,s[i]-b)-s;
            if (i-1-len[i-1]<=pos) dp[i][1]=dp[pos][0];
        }
    }
    ll ans=(dp[n][0]+dp[n][1])%MOD;
    printf("%lld\n",ans);
}

Measured memory_bytes: 2944
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main()
 {
  int a,b,c,sum=0 ;
  char s[911];
  scanf("%s",s) ;
  if((s[2]==s[3])&&(s[4]==s[5]))
  {
      printf("Yes") ;
  }
  else
  {
      printf("No") ;
  }
  return 0 ;
 }


Measured memory_bytes: 128
using System;

namespace aoj6d
{
    class Program
    {
        static void Main(string[] args)
        {
            string [] nm = (Console.ReadLine()).Split(' ');
            int n = int.Parse(nm[0]);
            int m = int.Parse(nm[1]);
            int[,] A = new int[n,m];
            int[] B = new int[m];

            /*??????A?????????*/
            for(int i = 0; i < n; i++)
            {
                string[] line = (Console.ReadLine()).Split(' ');

                for(int j = 0; j < m; j++)
                {
                    A[i, j] = int.Parse(line[j]); 
                }
            }

            /*????????????B?????????*/
            for (int i = 0; i < m; i++)
            {
                B[i] = int.Parse(Console.ReadLine());
            }

            /*?¨?????????????????????¨???*/
            for (int i = 0; i < n; i++)
            {
                int sum = 0;
                for (int j = 0; j < m; j++)
                {
                    sum += A[i, j] * B[j];
                }
                Console.WriteLine(sum);
            }

        }
    }
}

Measured memory_bytes: 9360
#include<stdio.h>
#include<math.h>
 
#define PI 3.14159265359
 
int main() {
    int a, b, c;
    double s, l, h;
    scanf("%d %d %d", &a, &b, &c);
    h = sin(((double)c/180) * PI) * (double)b;
    s = (h * (double)a) / 2;
    l = hypot(h, (double)a - cos(((double)c/180) * PI) * (double)b) + (double)a + (double)b;
    printf("%f\n%f\n%f\n", s, l, h);
    return 0;
}


Measured memory_bytes: 2132
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
const int N_MAX = 100010;

int main(){
    int N;
    int t[N_MAX],x[N_MAX],y[N_MAX],dist[N_MAX],time[N_MAX];
    cin >> N;
    for(int i = 1; i < N+1; i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    t[0] = x[0] = y[0] = 0;
    bool cant_move = 0;
    for(int i = 0; i < N; i++){
        time[i] = t[i+1] - t[i];
        dist[i] = (int)(abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]));
        if((dist[i] > time[i]) || (dist[i]%2 != time[i]%2)){
            cant_move = 1;
            break;
        }
    }
    if(cant_move == 1) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

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

  int N;
  cin >> N;
  vector<int> b(N);
  for (auto &x: b) cin >> x;

  for (int i = 0; i < N; i++) {
    if (b[i] > i+1) {
      cout << -1 << endl;
      return 0;
    }
  }

  stack<pair<vector<int>, vector<int> > > st;
  st.emplace(b, vector<int>());
  while (!st.empty()) {
    auto now = st.top();
    st.pop();
    if (now.first.size() == 0) {
      reverse(now.second.begin(), now.second.end());
      for (auto &x: now.second) cout << x << endl;
      return 0;
    }
    for (int i = 0; i < now.first.size(); i++) {
      if (now.first[i] == i+1) {
        auto newVec1 = now.first;
        newVec1.erase(newVec1.begin() + i);
        auto newVec2 = now.second;
        newVec2.push_back(i+1);
        st.emplace(newVec1, newVec2);
      }
    }
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
using namespace std;

typedef pair<int, int> P;
void loop(int x, int y, int n, vector<P> spr);

int n;
string ans = "NA";

int main(){
    int firx, firy;
    while(cin >>firx >>firy){
        if(firx == 0 && firy == 0) break;
        ans = "NA";
        cin >>n;
        vector<P> spr;
        for(int i = 0; i < n; i++){
            int tmpx, tmpy;
            cin >>tmpx >>tmpy;
            spr.push_back( make_pair(tmpx, tmpy) );
        }
        loop(firx, firy, 0, spr);
        cout <<ans <<endl;
    }
    return 0;
}

void loop(int x, int y, int nspr, vector<P> spr){
    int movex[] = {-1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2}, movey[] = {-2, -2, -2, -1, 0, 1, 2, 2, 2, 1, 0, -1};
    int sprx[] = {0, -1, 0, 1, 1, 1, 0, -1, -1}, spry[] = {0, -1, -1, -1, 0, 1, 1, 1, 0};
    for(int i = 0; i < 12; i++){
        int nowx = x + movex[i], nowy = y + movey[i];
        if(nspr >= n) ans = "OK";
        else if(nowx > 9 || nowx < 0 || nowy > 9 || nowy < 0) ;
        else{
            for(int j = 0; j < 9; j++){
                if(nowx == spr[nspr].first + sprx[j] && nowy == spr[nspr].second + spry[j]){
//                    cout <<"! (" <<nowx <<", " <<nowy <<")" <<endl;
                    loop(nowx, nowy, nspr + 1, spr);
                }
            }
        }
    }
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void)
{
    int tensuu[20],i,j,W,K,box;
    for(i=0;i<20;i++)
        scanf("%d",&tensuu[i]);
    for(j=0;j<9;j++)
        for(i=0;i<9;i++)
        {
            if(tensuu[i]<tensuu[i+1])
            {
                box=tensuu[i];
                tensuu[i]=tensuu[i+1];
                tensuu[i+1]=box;
            }
            if(tensuu[i+10]<tensuu[i+11])
            {
                box=tensuu[i+10];
                tensuu[i+10]=tensuu[i+11];
                tensuu[i+11]=box;
            }
        }
    W=tensuu[0]+tensuu[1]+tensuu[2];
    K=tensuu[10]+tensuu[11]+tensuu[12];
    printf("%d %d\n",W,K);
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define mx 1000009
ll ar[mx+10];

void sieve(){
    ar[0]=1;
    ar[1]=1;
    for(ll i=2;i<=sqrt(mx);i++){
        for(ll j=i*2;j<=mx;j+=i){
            ar[j]=1;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    sieve();
    //for(ll i=0;i<50;i++) cout<<ar[i]<<" ";
    //cout<<endl;
    ll t;
    cin>>t;
    if(ar[t]==0){
        //cout<<"riyad"<<endl;
        cout<<t<<endl;
        return 0;
    }
    for(ll i=t+1;t<=mx;i++){
        if(ar[i]==0){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 8064
#include <iostream>

using namespace std;

int gcd(int a, int b) 
{
    int ma = max(a, b);
    int mi = min(a, b);
    int tmp;
    
    while (mi) {
        tmp = mi;
        mi = ma % mi;
        ma = tmp;
    }
    return ma;
}

int main()
{
    int a, b;
    long lcm_ans;
    long gcd_ans;

    while (cin >> a >> b) {
        gcd_ans = gcd(a, b);
        lcm_ans = a * (b / gcd_ans);
        cout << gcd_ans << ' ' << lcm_ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

// I/O
int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
//


// Solve
void dfs(int G[100][100], int n, int *d, int *f, int u) {
    static int t = 0;
    d[u] = ++t;
    for(int i = 0; i < n; ++i) {
        if(!G[u][i] || d[i]) continue;
        dfs(G, n, d, f, i);
    }
    f[u] = ++t;
}

int main(int argc, char **argv) {
    int n = get_uint();
    int G[100][100] = {};
    for(int i = 0; i < n; ++i) {
        int u = get_uint() - 1;
        int k = get_uint();
        for(int j = 0; j < k; ++j) G[u][get_uint() - 1] = 1;
    }
    int d[100], f[100] = {};
    for(int i = 0; i < n; ++i)
        if(!f[i]) dfs(G, n, d, f, i);
    for(int i = 0; i < n; ++i) {
        put_uint(i + 1), putchar_unlocked(' ');
        put_uint(d[i]), putchar_unlocked(' ');
        put_uint(f[i]), putchar_unlocked('\n');
    }
    return 0;
}



Measured memory_bytes: 2056
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        int n = r.i();
        int digit = 1;
        while((n = n>>1) > 0)
            digit++;
        println(1<<digit-1);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 21076