akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s; cin >> s;
	ll k; cin >> k;
	ll n = s.size();
	string kek = "";

	ll scd = n, trd = n;
	for (ll i = 1; i < n; i++) {
		if (s[i] != '0') {
			scd = i;
			break;
		}
	}

	for (ll i = scd + 1; i < n; i++) {
		if (s[i] != '0') {
			trd = i;
			break;
		}
	}

	for (ll i = 0; i < n; i++) {
		kek += '0';
	}
	ll ans = 0;
	if (k == 3) {
		for (ll i = 0; i < n; i++) {
			for (ll j = i + 1; j < n; j++) {
				for (ll k = j + 1; k < n; k++) {
					if (i == 0) ans += (s[0] - '1') * 9 * 9;
					else ans += 9 * 9 * 9;
				}
			}
		}
		for (ll j = scd; j < n; j++) {
			for (ll k = j + 1; k < n; k++) {
				if (j == scd) ans += (s[scd] - '1') * 9;
				else ans += 9 * 9;
			}
		}
		for (ll k = trd; k < n; k++) {
			if (k == trd) ans += (s[trd] - '0');
			else ans += 9;
		}
	} else if (k == 2) {
		for (ll i = 0; i < n; i++) {
			for (ll j = i + 1; j < n; j++) {
				if (i == 0) ans += (s[0] - '1') * 9;
				else ans += 9 * 9;
				
			}
		}
		for (ll j = scd; j < n; j++) {
			if (j == scd) ans += (s[scd] - '0');
			else ans += 9;
		}
	} else {
		for (ll i = 0; i < n; i++) {
			if (i == 0) ans += s[0] - '0';
			else ans += 9;
		}
	}
	cout << ans << endl;
	return 0;
}

/*
3
0 1
3 0
1 0
*/

Measured memory_bytes: 256
import heapq

def prim(n, path):
  selected = {}
  paths = []
  hq = []
  selected[0] = True

  if 0 not in path:
    return []

  for s,d,w in path[0]:
    heapq.heappush(hq, (w, [0,d,w]))

  while len(hq) != 0:
    k,root = heapq.heappop(hq)
    if root[1] in selected: continue
    selected[root[1]] = True
    paths.append(root)
    for s,d,w in path[root[1]]:
      heapq.heappush(hq, (w, [s,d,w]))
  return paths

V,E = map(int, raw_input().split())
path = {}
for _ in xrange(E):
  s,t,w = map(int, raw_input().split())
  if s not in path:
    path[s] = []
  path[s].append([s,t,w])
  if t not in path:
    path[t] = []
  path[t].append([t,s,w])
result = prim(V, path)
sumcost = 0
for s,d,v in result:
  sumcost += v
print sumcost

Measured memory_bytes: 69288
// #include <stdio.h>
// #include <string.h>
//#include <iostream>
#include <math.h>
#include <iostream>
#include <utility>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <map>
#include <string>
#include <set>


using namespace std;
typedef pair<int, int> XY;// Pair型変数の宣言
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
    

int main()
{
  	int Nmax = 100000;
  
//    char String[Nmax];
    ll N;
    int i,j,k;

/*   
    // int型スタック
    stack<int> stack;   
    stack.push(777);
    stack.push(778);
    stack.push(779);
  
	int tmpsl = stack.top();  // LAST要素の参照
 // 	int tpmsf = stack.back(); // FIRST要素の参照
 //	printf("%d %d \n",tmpsl,tmpsf);
    stack.pop();// LAST要素の削除（取出しではない）
 // 	if( stack.empty() == true) printf("empty stack\n");
     
    // int型キュー
    queue<int> que;
  	que.push(999);
  	que.push(998);   
  	que.push(997);    
  	int tmpqs = que.front(); // FIRST要素の参照
  	int tmpqe = que.back();  // LAST要素の参照
 //	printf("%d %d \n",tmpqs,tmpqe);
  	que.pop();  // FIRST要素の削除（取出しではない）
  //	if( que.empty() == true) printf("empty que\n");
    
    // ２次元座標を扱うキュー
    queue<XY> xyque; // ２次元座標型変数のキュー
  	XY p; 
  	xyque.pop();	// FIRST要素の削除。キューが空のときは削除が予約されて次のPOPが即削除される
  	xyque.push( XY(5,5) );
    xyque.push( XY(5,5) );
   	p = xyque.front();  // FIRST要素からのコピー
 // 	printf("%d %d\n", p.first, p.second);
  	
    
  que.back();
  //  sort(&(que.front()), &(que.back()));
        
  */ 
      
    // 入力読込
    // 文字列
 //   scanf("%s", String);   
    

    ll sum=0;
    scanf("%lld ", &N);
    
    if(N==1){
        sum = 0;
    }
    else if(N==2){
        sum = 1;
    }
    else{
      //  sum = N%2; 
        sum = 1;
        for(i=3;i<=N;i++){
            sum = sum + (i-1);
        }
    }
    
    // 文字列の長さをチェック
    // 文字列は配列の0からlen-1に格納されてる
//    len = strlen( String );
//  	printf("%d\n",len);
    
    
  
    
    // 結果出力
  	cout << sum << endl;
   
  
  return 0;
   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
	int n,k; cin >> n >> k;
	vector<int>A(n);
	rep(i,n) cin >> A[i];
	int ans;
	if ((n-1)%(k-1) == 0) ans = (n-1)/(k-1);
	else ans = ((n-1)/(k-1))+1;
	cout << ans <<  endl;
}

Measured memory_bytes: 3696
s = input().strip()
left = int(s[:2])
right = int(s[2:])
if (left == 0 or left > 12) and 1 <= right <= 12:
    print('YYMM')
elif 1 <= left <= 12 and (right == 0 or right > 12):
    print('MMYY')
elif 1 <= left <= 12 and 1 <= right <= 12:
    print('AMBIGUOUS')
else:
    print('NA')

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n, m; cin >> n >> m;
    vector<int> target(m);
    rep(i, m) cin >> target[i];
    vector<int> score(n);
    rep(i, m) {
        int tmp = 0;
        rep(j, n) {
            int b; cin >> b;
            if(b == target[i]) {
                score[j]++;
                tmp++;
            }
        }
        score[target[i]-1] += n - tmp;
    }

    rep(i, n) cout << score[i] << '\n';
    return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define MOD 100000000000000000
#define UB upper_bound
#define LB lower_bound
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
/////number of edges in a graph equal (v[i].size() ka summation of all the vertices)//
int main()
{
    fast;
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif	
    ll int n,m;
    cin>>n>>m;
    long double a[n];
    long double q;
    ll int i,count=0;
    q=(long double)1/(((long double)4)*m);
    //cout<<q<<endl;
    long double z=0;
    for(i=0;i<n;i++)
    	{
    		cin>>a[i];
    		z=z+a[i];
    	}
    	z=q*z;
    for(i=0;i<n;i++)
    {
    	if(a[i]>=z)
    		count++;
    }


    	if(count>=m)
    		cout<<"Yes\n";
    	else
    		cout<<"No\n";
    }
    



Measured memory_bytes: 256
N = int(input())
lists = list(map(lambda x: int(x), input().split()))
sum = 0

for index, i in enumerate(lists):
  if(index+1 >= len(lists)):
    break
  tmp_list = lists[index+1:len(lists)]
  for t in tmp_list:
    sum += t*i
      
print(sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int Q = 20;
const int N = 1e5+10;

int remq = Q;
char a[N];

bool query(int x) {
    if (a[x] != -1) return a[x];
    if (!--remq) exit(2);
    cout << x << endl;
    fflush(stdout);
    string s; cin >> s;
    if (s[0] == 'V') exit(0);
    return a[x] = (s[0] == 'M');
}

int main() {
    memset(a, -1, sizeof a);
    int n; cin >> n;
    int l = 0, r = n/2;
    if ((query(l) == query(r)) ^ ((r - l) % 2)) {
        l = n/2;
        r = n-1;
    } else {
        l = 0;
        r = n/2;
    }
    while (1) {
        int mid = (l+r+1)/2;
        if ((query(l) == query(mid)) ^ ((mid - l) % 2)) {
            l = mid;
        } else {
            r = mid;
        }
    }
    return 0;
}


Measured memory_bytes: 980
/**
 *    author:  tesnik      
**/
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
    long k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
 
    long l = -1000000000000000001LL;
    long r = 1000000000000000001LL;
    while (r > l + 1) {
        long m = (l + r) / 2;
        long s = 0;
        // count a[i] + a[j] < m
        for (int i = 0; i < n; i++) {
            if (a[i] > 0) {
                int ll = -1; // <= m
                int rr = n; // > m
                while (rr > ll + 1) {
                   int mm = (ll + rr) / 2;
                   if ((long)a[i] * a[mm] <= m) {
                       ll = mm;
                   } else {
                       rr = mm;
                   }
                }
                s += rr;
            } else {
                int ll = -1; // > m
                int rr = n; // <= m
                while (rr > ll + 1) {
                    int mm = (ll + rr) / 2;
                    if ((long)a[i] * a[mm] > m) {
                        ll = mm;
                    } else {
                        rr = mm;
                    }
                }
                s += n - rr;
            }
        }
        for (int i = 0; i < n; i++) {
            if ((long)a[i] * a[i] <= m) s--;
        }
        s /= 2;
        if (s < k) {
            l = m;
        } else {
            r = m;
        }
//        cout << m << " " << s << "\n";
    }
    cout << r << "\n";
 
    return 0;

  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	int N,T,A;
	scanf("%d %d %d",&N,&T,&A);
	float H[N],alt[N];
	for (int i = 0; i < N; ++i)
	{
		scanf("%f",&H[i]);
		H[i] = T-(H[i]*0.006);
		if(A < H[i]){
			H[i] -= A;
		}else{
			H[i] = A-H[i];
		}
		alt[i]=H[i];
	}

	for (int i = N-1; i > 0; --i)
	{
		if(H[i] < H[i-1]){
			float tmp = H[i];
			H[i] = H[i-1];
			H[i-1] = tmp;
		}
	}
	
	int a;
	for (int i = 0; i < N; ++i)
	{
		if(alt[i] == H[0]){
			a = i+1;
			break;
		}
	}
	printf("%d",a);

	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W,K;
string C[50];
string B[50];

ll dfs() {
	ll tot=0;
	int y,x,i;
	
	FOR(x,H) {
		char pre='0';
		int num=0;
		FOR(y,W) {
			if(B[y].size()<=x) {
				pre='0';
				num=0;
			}
			else {
				if(B[y][x]!=pre) pre=B[y][x], num=0;
				num++;
				if(num==K) {
					tot+=(pre-'0')*num;
					FOR(i,K) B[y-i][x]='0';
				}
				if(num>K) {
					tot+=(pre-'0');
					B[y][x]='0';
				}
			}
		}
	}
	if(tot==0) return 0;
	
	FOR(y,W) {
		string s;
		FORR(c,B[y]) if(c!='0') s+=c;
		B[y]=s;
	}
	return tot+dfs()*2;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W>>K;
	FOR(y,H) cin>>C[y];
	ll ma=0;
	FOR(y,H) FOR(x,W) {
		int y2,x2;
		FOR(x2,W) {
			B[x2].clear();
			for(y2=H-1;y2>=0;y2--) if(y2!=y || x2!=x) B[x2]+=C[y2][x2];
		}
		ma=max(ma,dfs());
	}
	cout<<ma<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_N = 1e5+10;
const int INF = (1<<30);

int main(int argc, char const *argv[])
{
	int N, h[MAX_N]={0};
	int dp[MAX_N];
	cin >> N;
	for (int i = 0; i < N; ++i) scanf("%d", &h[i+1]);

	fill(dp, dp+MAX_N, INF);
    dp[0] = 0;
    dp[1] = 0;

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

    cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

double ex(double input)
{
  double tmp = 0;
  double ans = 0;
  for (double i = 0; i <= input; i++)
  {
    tmp += (double)i;
  }
  return tmp / input;
}

int main()
{
    cout.precision(15);
  ll N, K;
  cin >> N >> K;
  vector<double> p(N + 1);
  vector<double> S(N + 1);
  vector<double> Ex(N + 1);
  vector<double> ans(N + 1);
  ll a;
  double total = 0;
  S.at(0) = 0;
  for (ll i = 1; i <= N; i++)
  {
    cin >> a;
    total = 0.0;
    for (int j = 1; j <= a; j++)
    {
      total += (double)j;
    }
    total /= (double)a;
    S.at(i) = total + S.at(i - 1);
  }

  double max_ = 0;
  for (ll i = 0; i <= N - K; i++)
  {
    if (max_ < S.at(i + K) - S.at(i))
    {
      max_ = S.at(i + K) - S.at(i);
    }
  }
  cout << max_ << endl;

  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef pair<int,int> P;
typedef long long ll;

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

	ll ans = 0;
	for(ll x=1;x*(x+1)<N;x++){
		if(N%x==0) ans += (N/x)-1;
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

LL add(LL x, LL y) {
    x += y;
    if (x >= MOD) x -= MOD;
    return x;
}

LL sub(LL x, LL y) {
    x -= y;
    if (x < 0) x += MOD;
    return x;
}

int n; LL a[2];

const int MAXN = 100005;
LL dp[MAXN][2], sum[MAXN][2], back[MAXN][2];

vector<LL> vs; LL s;

int main() {
    GI(n); GLL(a[0]); GLL(a[1]);

    FORN(i, n) {
        GLL(s);
        vs.PB(s);
    }

    vs.PB(4000000000000000000LL);

    memset(dp, 0, sizeof dp); memset(sum, 0, sizeof sum); memset(back, 0, sizeof back);

    dp[0][0] = 1; sum[0][0] = 1; back[0][0] = 0;
    dp[0][1] = 1; sum[0][1] = 1; back[0][1] = 0;

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 2; j++) {  // vs[i] is in set j and vs[i+1] is not in set j
            back[i][j] = (vs[i] - vs[i-1] >= a[j]) ? back[i-1][j] : i;

            int l = back[i][j];
            int r = upper_bound(vs.begin(), vs.end(), vs[i+1] - a[1-j]) - vs.begin();
            r = min(r, i);

            l--; r--; // beginning of previous chunk

            if (l < 0) {
                dp[i][j] = 1;
                l++;
            }

            if (r >= 0 && r >= l) {
                dp[i][j] = add(dp[i][j], sub(sum[r][1-j], (l > 0 ? sum[l-1][1-j] : 0)));
            }

            sum[i][j] = add(sum[i-1][j], dp[i][j]);
        }
    }

    cout << add(dp[n-1][0], dp[n-1][1]) << "\n";

    return 0;
}

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

int main(){
	while(1){
		int r, c;
		scanf(" %d %d", &r, &c);
		if(r==0) break;
		
		if(r%2==1 && c%2==1) printf("no\n");
		else printf("yes\n");		
	}
}

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

using namespace std;

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

    long max = 0;
    long test;
    for (int i = 1; i < N; i++)
    {
        max += i;
    }

    /*
    int index = N / 2;
    test = max - index + (N % (index + 1));

    while (test > max)
    {
        max = test;
        N = index;
        index = N / 2;
        test = max - index + (N % (index + 1));
    }

    if (test > max)
    {
        max = test;
    }
    */

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
str_list = input().split(' ')
int_list = [int(x) for x in str_list]

N, K = int_list[0], int_list[1]

str_list = input().split(' ')
h_list = [int(x) for x in str_list]

count = 0
for h in h_list:
    if h>=K:
        count += 1
print(count)


Measured memory_bytes: 11912
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;cin>>N;
	int H[N];int temp=0,count=0;
	for(int i=0;i<N;i++){
		cin>>H[i];
		if(H[i]>=temp){
			count++;
			temp=H[i];
		}
	}cout<<count<<endl;
}

Measured memory_bytes: 256
n = int(input())
l = [list(map(int,input().split())) for _ in range(n)]

for i in range(n):
    t = l[i][0]
    x = l[i][1]
    y = l[i][2]
    d = x + y
    if d <= t and (d - t) % 2 == 0:
        continue
    else:
        print('No')
        quit()
print('Yes')


Measured memory_bytes: 60248
'use strict';
function Main(stdin){
  const N = Number(stdin.trim());
  let result = 1;
  for(let i = 1; i <= N; i++){
    result = result*i%1000000007;
  }
  console.log(result);
}

// 固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int32_t main(){
    fast;
    int n;
    cin>>n;
    vector<int> a(n,0);
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=0;
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
            for(int k=j+1;k<n;k++){
                set<int> s;
                s.insert(a[k]);
                s.insert(a[i]);
                s.insert(a[j]);
                if(s.size()!=3)
                    continue;
                if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[k]+a[j]>a[i])
                    ans++;
            }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3660
def main():
    n, m, l = [int(x) for x in input().split()]

    a = readMatrix(n, m)
    b = readMatrix(m, l)

    printMatrix(multiplyAB(a, b))

def readMatrix(r, c):
    m = []
    for _ in range(r):
        m.append([int(x) for x in input().split()])

    return m

def multiplyAB(a, b):
    n = len(a)
    m = len(b)
    l = len(b[0])

    c = [[0 for _ in range(l)] for _ in range(n)]

    for i in range(n):
        for j in range(l):
            for k in range(m):
                c[i][j] += a[i][k] * b[k][j]

    return c

def printMatrix(m):
    for r in m:
        print(' '.join([str(x) for x in r]))

if __name__ == '__main__':
    main()



Measured memory_bytes: 6880
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n;
  string s;
  cin >> n >> s;
  string tmp[4]={"SS","SW","WS","WW"};

  REP(i,4) {
    FOR(j,2,n) {
      if((s[j-1] == 'o') ^ (tmp[i][j-1] == 'S') ^ (tmp[i][j-2] == 'S')) {
        tmp[i].push_back('S');
      } else {
        tmp[i].push_back('W');
      }
    }
  }

  REP(i,4) {
    if(((s[n-1] == 'o') ^ (tmp[i][n-1] == 'S') ^ (tmp[i][n-2] == 'S') ^ (tmp[i][0] == 'S'))
       || ((s[0] == 'o') ^ (tmp[i][0] == 'S') ^ (tmp[i][n-1] == 'S') ^ (tmp[i][1] == 'S')))
      continue;
    else {
      cout << tmp[i] << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using ll = long long;
using lli = long long int;

ll n, white, red;
std::vector<ll> vec, white_vec, red_vec;
std::string s;

int main() {
    std::cin >> n;
    red = 0;
    white = 0;
    vec.assign(n+1, 0);
    white_vec.assign(n+1, 0);
    red_vec.assign(n+1, 0);
    std::cin >> s;
    s = " " + s;
    for (ll i = 0; i < s.size(); i++) {
        if (s[i] == 'R') {
            red++;
        }
        else if (s[i] == 'W'){
            white++;
        }
    }
    if (red == 0 || white == 0) {
        std::cout << 0 << std::endl;
        return 0;
    }
    red_vec[0] = red;
    for (ll i = 1; i <= n; i++) {
        if (s[i] == 'W') {
            white_vec[i] = white_vec[i-1] + 1;
            red_vec[i] = red_vec[i-1];
        }
        else {
            red_vec[i] = red_vec[i-1] - 1;
            white_vec[i] = white_vec[i-1];
        }
    }
    ll ans = 5000000;
    for (ll i = 1; i <= n; i++) {
        ll p = std::min(white_vec[i], red_vec[i]);
        ll nw = white_vec[i] - p;
        ll nr = red_vec[i] - p;
        ll c = p + nw + nr;
        if (c < ans) {
            ans = c;
        }
    }
    std::cout << ans << std::endl;
 }


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

void answer1() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> a(n);
  for(int& a_i: a) {
    cin >> a_i;
  }

  long long count = 0;
  long long sum = 0;
  long long count2 = 0;
  long long sum2 = 0;
  bool is_positive = a.at(0) > 0;
  for (int i = 0; i < a.size(); i++) {
    sum += a.at(i);
    sum2 += a.at(i);

    if (is_positive) {
      if (sum <= 0) {
        // 次は1になるまでインクリメント
        long long diff = 1 - sum;
        count += diff;
        sum += diff;
      }
      if (sum2 >= 0) {
        // 次は-1になるまでデクリメント
        long long diff = 1 + sum2;
        count2 += diff;
        sum2 -= diff;
      }
    } else {
      if (sum >= 0) {
        // 次は-1になるまでデクリメント
        long long diff = 1 + sum;
        count += diff;
        sum -= diff;
      }
      if (sum2 <= 0) {
        // 次は1になるまでインクリメント
        long long diff = 1 - sum2;
        count2 += diff;
        sum2 += diff;
      }
    }
    is_positive = ! is_positive;
  }
  cout << min(count, count2) << endl;

}

void answer2() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> a(n);
  for(int& a_i: a) {
    cin >> a_i;
  }

  long long count = 0;
  long long sum = 0;
  long long count2 = 0;
  long long sum2 = 0;

  for (int i = 0; i < a.size(); i++) {
    sum += a.at(i);
    sum2 += a.at(i);
    if (i % 2 == 0) {
      // 偶数番目が正
      if (sum <= 0) {
        count += 1 - sum;
        sum = 1;
      }
      // 偶数番目が負
      if (sum2 >= 0) {
        count2 += 1 + sum2;
        sum2 = -1;
      }
    } else {
      // 奇数番目が負
      if (sum >= 0) {
        count += 1 + sum;
        sum = -1;
      }
      // 奇数番目が正
      if (sum2 <= 0) {
        count2 += 1 - sum2;
        sum2 = 1;
      }
    }
  }
  cout << min(count, count2) << endl;
}

int main() {
  //answer1();
  answer2();
}


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

#define ll long long

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

  ll sum = 0;

  if( k > 0) {
      if( k > a){
        k = k-a;
        sum += a;
      }
      else{
        sum += k;
        cout<<sum<<"\n";
        return 0;
      }
  }

  
  if( k > 0) {
      if( k > b){
        k = k-b;
        sum += 0;
      }
      else{
        sum += 0;
        cout<<sum<<"\n";
        return 0;
      }
  }

  
  if( k > 0) {
      if( k > c){
        k = k-c;
        sum += c;
      }
      else{
        sum -= k;
        cout<<sum<<"\n";
        return 0;
      }
  }


  cout<<sum<<"\n";

  



	return 0;
}

Measured memory_bytes: 3548
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

H, W = ln()

panel = [['.'] + list(s()) + ['.'] for h in xrange(H)]

cur = 1

for i in xrange(H):
    for j in xrange(cur, W + 1):
        if panel[i][j] == '#':
            panel[i][j] = '.'
            cur = j
        else:
            break

success = True
for i in xrange(H):
    for j in xrange(1, W + 1):
        if panel[i][j] == '#':
            success = False
            break
    if not success:
        break

if success:
    print 'Possible'
else:
    print 'Impossible'


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


int main()
{
	ll n,m;
	cin>>n>>m;
	ll a[m];
	ll sum=0;
	for(int i=0;i<m;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>n)
	{
		cout<<-1;
	}
	else
	{
		cout<<n-sum;
	}
}


Measured memory_bytes: 3656
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	h := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	ans := 0
	for i := 0; i < N; i++ {
		h[i] = nextInt(sc)
		if h[i] >= K {
			ans++
		}
	}
	fmt.Println(ans)
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    int N; cin >> N;
    VI A(N); REP(i,N){cin >> A[i]; A[i]--;}
    VI B(N); REP(i,N){cin >> B[i]; B[i]--;}
    VI numA(200200,0), numB(200200,0);
    REP(i,N){
        numA[A[i]]++; numB[B[i]]++;
    }

    VI p(200000); REP(i,200000) p[i] = i;
    auto c = [&](int i, int j){
        return numA[i]>numA[j];
    };
    sort(ALL(p), c);

    VI AA, BB;
    for(int i : p){
        REP(_,numA[i]) AA.push_back(i);
        REP(_,numB[i]) BB.push_back(i);
    }
    REVERSE(BB);

    int ptr = 0, prev = INF;
    RREP(i,N){
        if(BB[i] != AA[i]) continue;

        if(BB[i] != prev) ptr = N-1;
        while(ptr>=0 && (BB[i] == BB[ptr] || AA[ptr]==BB[i])) ptr--;
        if(ptr>=0) swap(BB[i], BB[ptr]);
        else{
            cout << "No" << en;
            return;
        }
        prev = BB[ptr];
    }

    VI q(N); REP(i,N) q[i] = i;
    auto c2 = [&](int i, int j){
        return AA[i]<AA[j];
    };
    sort(ALL(q), c2);
    VI ans(N); REP(i,N) ans[i] = BB[q[i]];
    cout << "Yes" << en;
    REP(i,N) cout << ans[i]+1 << " ";
    cout << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 10516
import math

a, b, h, m = map(int, input().split())

θ = abs(30*h%360 + 0.5*m - 6*m%360)
c_2 = a**2 + b**2 - 2*a*b*math.cos(θ*math.pi/180)
print(math.sqrt(c_2))

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

using namespace std;

#define rep(a,b) for(int (a)=0;(a)<(b);(a)++)

int main(){
    int w,h;
    while(cin>>w>>h){
        if(w==0 && h==0)break;
        int sx,sy;
        int sum=0;
        int dy[]={-1,0,1,0};
        int dx[]={0,-1,0,1};
    
    
        string data[30]={};
    
        for(int i=0;i<h;i++){
            cin>>data[i];
        }
    
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(data[i][j]=='@'){
                    sx=j;sy=i;
                    break;
                }
            }
        }
    
        bool visited[30][30]={};
    
        queue<pair<int,int> > que;
    
        que.push( pair<int,int>(sy,sx) );
        visited[sy][sx]=true;
    
        while(que.size()){
            int qff=que.front().first,qfs=que.front().second;
            sum++;
            rep(i,4){
                if( qff+dy[i]<h && qff+dy[i]>=0 && qfs+dx[i]<w && qfs+dx[i]>=0 && visited[ qff+dy[i] ][ qfs+dx[i] ]==false && data[ qff+dy[i] ][ qfs+dx[i] ]!='#' ){
                    que.push( pair<int,int>(qff+dy[i] , qfs+dx[i]) );
                    visited[ qff+dy[i] ][ qfs+dx[i] ]=true;
                }
            }
            
            que.pop();
        }
        cout<<sum<<endl;
        
//        rep(i,h){rep(j,w)cout<<(visited[i][j]?'*':'_');cout<<endl;}
    }
    
    return 0;
}

Measured memory_bytes: 1232
#Guide Book https://atcoder.jp/contests/abc128/tasks/abc128_b
N = int(input())
Shop_List=[]
for i in range(N):
    Temp_List=list(input().split())
    Temp_List[1]=int(Temp_List[1])
    Temp_List.append(i+1)
    Shop_List.append(Temp_List)


Shop_List_Sorted = sorted(Shop_List, key=lambda x:(x[0], -x[1]))
for k in range(N):
    print(Shop_List_Sorted[k][2])


Measured memory_bytes: 9044
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
#include<algorithm> 
using namespace std;
// main() is where program execution begins.


int main() {
int N, K;
cin >> N >> K;
int arry[N];
int cnt;
long long int mn;

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

long long int dp[N] = {0};
dp[0] = 0;

for (int i = 1; i < min(N,K); ++i)
{
	dp[i] = abs(arry[i] - arry[0]);
}

for (int i = K; i < N; ++i)
{	cnt  = 1;
	mn = INT_MAX;
	while(cnt <= K){
	mn = min(dp[i-cnt] + abs(arry[i] - arry[i-cnt]), mn);
	cnt++;
	}
	dp[i] = mn;
}
   
	cout << dp[N-1] << endl;
   return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int n;
  cin >> n;

  if(n >= 64){
    cout << 64 << endl;
  }
  else if(n >= 32){
    cout << 32 << endl;
  }
  else if(n >= 16){
    cout << 16 << endl;
  }
  else if(n >= 8){
    cout << 8 << endl;
  }
  else if(n >= 4){
    cout << 4 << endl;
  }
  else if(n >= 2){
    cout << 2 << endl;
  }
  else{
    cout << 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Y "Yes"
#define N "No"
using namespace std;

int x, y;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a[13];
	a[1] = 1;
	a[3] = 1;
	a[5] = 1;
	a[7] = 1;
	a[8] = 1;
	a[10] = 1;
	a[12] = 1;
	a[4] = 2;
	a[6] = 2;
	a[9] = 2;
	a[11] = 2;
	a[2] = 3;
	cin >> x >> y;
	if (a[x] == a[y]) cout << Y;
	else cout << N;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i;
	char s[100001];
	scanf("%s",s);
	int len=strlen(s);
	for(i=0;i<=len-1;i+=2)
		{printf("%c",s[i]);}
	printf("\n");
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main() {
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    auto getPositions = [&]() {
        vector<int> res;
        for (int i = 0; i < n && res.size() < k;) {
            if (s[i] == 'o') {
                res.push_back(i);
                i += c+1;
            } else {
                ++i;
            }
        }
        return res;
    };

    vector<int> l, r;
    l = getPositions();
    reverse(s.begin(), s.end());
    r = getPositions();
    rep(i,k) r[i] = n-1-r[i];
    reverse(s.begin(), s.end());
    
    vector<int> lastL(n+1, -1);
    rep(i,k) lastL[l[i]+1] = i;
    rep(i,n) {
        if (lastL[i+1] == -1) lastL[i+1] = lastL[i];
    }
    vector<int> lastR(n+1, -1);
    rep(i, k) lastR[r[i]] = i;
    for (int i = n-1; i >= 0; --i) {
        if (lastR[i] == -1) lastR[i] = lastR[i+1];
    }

    rep(i,n) {
        if (s[i] == 'x') continue;
        int li = lastL[i];
        int ri = lastR[i + 1];
        int cnt = 0;
        if (li != -1) cnt += li+1;
        if (ri != -1) cnt += ri+1;
        if (li != -1 && ri != -1 && r[ri] - l[li] <= c) {
            --cnt;
        }
        if (cnt >= k) continue;
        printf("%d\n", i+1);
    }
    return 0;
}

Measured memory_bytes: 4984
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 998244353;

signed main() {
  int n;
  cin>>n;
  double x,y;
  vector<pair<double,pair<double,double>>> p;
  for(int i=0;i<n;i++){
    cin>>x>>y;
  if(x!=0||y!=0)p.push_back(make_pair(atan2(y,x),make_pair(x,y)));
  }
  sort(p.begin(),p.end());
  int j=0;
  n=p.size();
  double X=0,Y=0;
  double ans=0;
  for(int i=0;i<n;i++){
    while((((p[j%n].first-p[i].first)>=0&&(p[j%n].first-p[i].first)<M_PI)||((p[j%n].first-p[i].first)<0&&(p[j%n].first-p[i].first)<-1*M_PI))&&j!=i+n){
      X+=(p[j%n].second).first;
      Y+=(p[j%n].second).second;
         ans=max(ans,sqrt(X*X+Y*Y));
      j++;
    }
 
    X-=(p[i].second).first;
      Y-=(p[i].second).second;
         ans=max(ans,sqrt(X*X+Y*Y));
  }
  cout<< std::fixed<< std::setprecision(50)<<ans;
  
  



  return 0;
}


Measured memory_bytes: 512
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

bool ll[5002][5002], rr[5002][5002];

int main()
{
  int N, K;
  cin >> N >> K;
  
  vector<int> V;
  for (int i=0; i<N; i++) {
    int a;
    cin >> a;
    if (a <= K) V.push_back(a);
  }
  N = V.size();
  ll[0][0] = rr[0][0] = 1;
  for (int i=0; i<N; i++) {
    for (int j=0; j<=K; j++) {
      ll[i+1][j] = ll[i][j];
      if (j >= V[i]) ll[i+1][j] |= ll[i][j-V[i]];
    }
  }
  for (int i=0; i<N; i++) {
    for (int j=0; j<=K; j++) {
      rr[i+1][j] = rr[i][j];
      if (j >= V[N-1-i]) rr[i+1][j] |= rr[i][j-V[N-1-i]];
    }
  }

  int res = 0;
  for (int i=0; i<N; i++) {
    // ll[i] + rr[N-1-i] = [K-V[i], K-1]?
    int cnt = 0;
    for (int j=K-V[i]; j<=K-1; j++) cnt += rr[N-1-i][j];
    int found = 0;
    for (int j=0; j<K; j++) {
      if (ll[i][j] && cnt > 0) found = 1;
      // manipulate for j+1
      if (K-V[i]-j-1 >= 0) cnt += rr[N-1-i][K-V[i]-j-1];
      cnt -= rr[N-1-i][K-1-j];
    }
    res += 1 - found;
  }
  cout << res << endl;
}


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

using namespace std;

typedef long long ll;

#define MOD (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()

ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}



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

ll n;
cin>>n;

for(int i=1;i<=9;i++)
{
  ll temp=100*i+10*i+i;
if(temp>=n)
  {
    cout<<temp;
    break;
  }
}



return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cassert>
#include<queue>
#include<cstdio>
#include<ctime>
#include<climits>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

struct P
{
  vector<int> A;
  int cost;
  P(vector<int> A2=vector<int>(),int cost=inf):cost(cost)
  {
    A = A2;
  }

  bool operator < (const P& a)const
  {
    return cost > a.cost;
  }

};

int N;
map<vector<int>,int> mincost;
map<vector<int>,int> rmincost;
vector<int> initial;
bool found;

void computeR(int step)
{
  priority_queue<P> Q;
  {
    initial.resize(N);
    rep(i,N)initial[i] = i+1;
    Q.push(P(initial,0));
    rmincost[initial] = 0;
  }

  //clock_t st,ed;
  //st = clock();
  while(!Q.empty())
    {
      P p = Q.top(); Q.pop();
      if(p.cost >= step)continue;

      //ed = clock();
      //if((double)(ed-st)/(double)CLOCKS_PER_SEC >= 1.0)return;      

      rep(s,N)
	{
	  REP(t,s+2,N+1)
	    {
	      vector<int> next = p.A;
	      reverse(next.begin()+s,next.begin()+t);
	      if(rmincost.find(next) == rmincost.end())
		{
		  rmincost[next] = p.cost + 1;
		  Q.push(P(next,p.cost+1));
		}
	    }
	}

    }
}

void compute(vector<int> &vec)
{
  mincost[vec] = 0;
  priority_queue<P> Q;
  Q.push(P(vec,0));

  int ans = inf;
  found = false;
  while(!Q.empty())
    {
      P p = Q.top(); Q.pop();

      //if(p.cost >= ans)continue;


      if(rmincost.find(p.A) != rmincost.end())
	{
	  found = true;
	  cout << p.cost + rmincost[p.A] << endl;
	  return;
	  //ans = min(ans,p.cost + rmincost[p.A]);
	  continue;
	}

      if(p.cost >= 4)continue;

      rep(s,N)
	{
	  REP(t,s+2,N+1)
	    {
	      vector<int> next = p.A;
	      reverse(next.begin()+s,next.begin()+t);
	      if(mincost.find(next) == mincost.end())
		{
		  mincost[next] = p.cost + 1;
		  Q.push(P(next,p.cost+1));
		}
	    }
	}
    }
  found = true;
  cout << N-1 << endl;
}

int main()
{

  int a = scanf("%d",&N);
  
  computeR(4);
  //cout << "---------" << endl;
  vector<int> vec(N);
  rep(i,N)cin >> vec[i];

  compute(vec);


  return 0;
}

Measured memory_bytes: 83808
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count=0;
        for(int i=a; i<=b; i++){
            if(c%i==0){count++;}        
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26352
A, B, C = map(int, input().split())
array = [A, B, C]
count = 0
if (A % 2 == 1 and B % 2 == 0 and C % 2 == 0) or (A % 2 == 0 and B % 2 == 1 and C % 2 == 1):
    count += 1
    B += 1
    C += 1
elif (A % 2 == 0 and B % 2 == 1 and C % 2 == 0) or (A % 2 == 1 and B % 2 == 0 and C % 2 == 1):
    count += 1
    A += 1
    C += 1
elif (A % 2 == 0 and B % 2 == 0 and C % 2 == 1) or (A % 2 == 1 and B % 2 == 1 and C % 2 == 0):
    count += 1
    A += 1
    B += 1
if max(A, B, C) == A:
    count = count + (A - B) // 2 + (A - C) // 2
elif max(A, B, C) == B:
    count = count + (B - A) // 2 + (B - C) // 2
else:
    count = count + (C - A) // 2 + (C - B) // 2
print(count)


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

const int INF = 1 << 28;

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

    vector<int> s(n), t(m);
    for (auto &i : s) cin >> i;
    for (auto &i : t) cin >> i;

    vector<int> r(s);
    int c = 0;
    int l = 0;
    int ans1 = 0;
    for (int i = 0; ans1 >= 0 && i < m; i++) {
        for (int j = 0; j < t[i]; j++) {
            if (c != s[l]) {
                int k = l + 1;
                while (k < n && c != s[k]) k++;
                if (k == n) {ans1 = INF; break;}
                ans1 += (k - l);
                s[k] = !c;
            }
            l++;
        }
        c = c ? 0 : 1;
    }

    c = 1;
    l = 0;
    int ans2 = 0;
    for (int i = 0; ans2 >= 0 && i < m; i++) {
        for (int j = 0; j < t[i]; j++) {
            if (c != r[l]) {
                int k = l + 1;
                while (k < n && c != r[k]) k++;
                if (k == n) {ans2 = INF; break;}
                ans2 += (k - l);
                r[k] = !c;
            }
            l++;
        }
        c = c ? 0 : 1;
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <stdlib.h>
#include <string.h> // 文字列処理の関数
#include <ctype.h> // 文字変換(大文字/小文字)の関数

int main() {
char buf[5];
scanf("%s",buf);
int i,j;
if ((buf[0]=='A'&& buf[1]=='C') ||(buf[1]=='A'&& buf[2]=='C') ||(buf[2]=='A'&& buf[3]=='C') ||(buf[3]=='A'&& buf[4]=='C'))
printf("Yes\n");
else
printf("No\n");
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1.0)
int main()
{
    map<int,int>mp;
    int n,i,j,k,l;
    cin>>n;
    for(i=1;i<n;i++)
    {
        cin>>j;
        mp[j]++;
    }
    for(i=1;i<=n;i++)
    {
        cout<<mp[i]<<endl;
    }

    return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll H, W;
vector<string> s;

int main() {
    cin >> H >> W;
    s.assign(H + 2, string(W + 2, '.'));
    REP(i, H) {
        SCIN(in);
        s[i + 1] = "." + in + ".";
    }
    FOR(h, 1, H + 1) FOR(w, 1, W + 1) {
        if(s[h][w] == '#') {
            bool judge = false;
            REP(i, 4) {
                if(s[h + dy[i]][w + dx[i]] == '#') {
                    judge = true;
                    break;
                }
            }
            if(!judge) {
                cout << "No"
                     << "\n";
                return 0;
            }
        }
    }
    cout << "Yes"
         << "\n";
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

size_t powST(const size_t base, const size_t exp) {
	size_t result = 1;

	for (size_t i = 0; i < exp; i++) {
		result *= base;
	}

	return result;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t N, K;

	scanf("%zu %zu", &N, &K);

	printf("%zu\n", K * powST(K - 1, N - 1));

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <numeric>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline bool Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+" ";
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,k;
    cin >> n >> m >> k;
    ll ans = 0;
    COMinit();
    rep(i,n){
        rep(j,m-1){
            ans += (j+1)*n*(m-j-1)%MOD;
            ans %= MOD;
        }
    }
    rep(i,n-1){
        rep(j,m){
            ans += (i+1)*m*(n-i-1)%MOD;
            ans %= MOD;
        }
    }
    PRINT(ans*COM(n*m-2,k-2)%MOD);
}


Measured memory_bytes: 4992