akhauriyash/Code-Regression huggingface dataset:
while True:

    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break

    for i in range(a):
        for j in range(b):
            if i != 0 and i != a-1 and j != 0 and j != b-1:
                print(".", end="")
            else:
                print("#", end="")

        print()
    print()


Measured memory_bytes: 7000
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,m; cin>>n>>m;
	vector<queue<int>> a;
	rep(i,n){
		queue<int> q;
		rep(i,m){
			int p; cin>>p; p--; q.push(p);
		}
		// cerr << q.front() << endl;
		a.PB(q);
	}
	int ans = n;
	bool flg[m]; memset(flg,true,sizeof(flg));

	REPS(i,m){
		vector<PII> c;
		rep(j,m) c.PB(MP(0,j));
		rep(k,n){
			while(!flg[a[k].front()]){
				a[k].pop();
				if(a[k].empty()) break;
			}
			// cerr<<a[k].front()<<' ';
			c[a[k].front()].first++;
			// cerr << a[k].front() <<endl;
		}
		// cerr<<endl;
		sort(RALL(c));
		chmin(ans,c[0].first);
		flg[c[0].second]=false;
		// cerr << c[0].first SP c[0].second << endl;
	}
	// cerr << endl;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << '\n';
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << '\n';
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3652
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  let base_idx = partition(arr, 0, n - 1);
  arr[base_idx] = `[${arr[base_idx]}]`;
  console.log(arr.join(` `));
})();

function partition(arr, p, r) {
   let x  = arr[r];
   let i = p - 1;
   for (let j = p; j < r; j++) {
     if (arr[j] <= x) {
       [arr[i], arr[j]] = [arr[j], arr[++i]];
     }
   }
   [arr[i + 1], arr[r]] = [arr[r], arr[i + 1]];
   return i + 1;
}



Measured memory_bytes: 33656
#include <iostream>
#include <vector>
using namespace std;
	int abs(int x) {
				return max(x,-x);
			}
	int max3(int x, int y, int z){
		if (x >= y) {
			if (x >= z) {
						return x;
			}
			else {
				return z;
			}
		}
		else{
			if (y >= z) {
					return y;
			}
				else {
					return z;
				}
			}
		}
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << abs(a-b)+abs(b-c)+abs(c-a)-max3(abs(a-b),abs(b-c),abs(c-a)) << endl;
	
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int A[55], B[55], C[55], D[55];

int main() {
  int N = in();
  int M = in();
  int Q = in();
  for (int i = 0; i < Q; ++i) {
    A[i] = in() - 1;
    B[i] = in() - 1;
    C[i] = in();
    D[i] = in();
  }

  vector<int> xs(N + M - 1, 0);
  for (int i = 0; i < M - 1; ++i) {
    xs[N + i] = 1;
  }

  int res = 0;
  do {
    int x[10];
    int cur = 1, pos = 0;
    for (int i = 0; i < N + M - 1; ++i) {
      if (xs[i] == 1) {
        ++cur;
      } else {
        x[pos++] = cur;
      }
    }

    int score = 0;
    for (int i = 0; i < Q; ++i) {
      if (x[B[i]] - x[A[i]] == C[i]) {
        score += D[i];
      }
    }
    chmax(res, score);
  } while (next_permutation(xs.begin(), xs.end()));

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

  return 0;
}


Measured memory_bytes: 3756
import java.util.Scanner;

public class Main{

	static String s = "";
	static String ans = "";

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		s = sc.next();
		solve();
		System.out.println(ans.length());
	}

	public static void solve() {
		String str;
		for (int i = s.length(); i > 0; i--) {
			for (int j = 0; i + j <= s.length(); j++) {
				str = s.substring(j, i + j);
				if (isACGT(str)) {
					ans = str;
					return;
				}
			}
		}
	}

	public static boolean isACGT(String str) {
		for (int i = 0; i < str.length(); i++) {
			if (!(str.charAt(i) == 'A' || str.charAt(i) == 'C' || str.charAt(i) == 'G' || str.charAt(i) == 'T')) {
				return false;
			}
		}
		return true;
	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+7;
int h[N], f[N];
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &h[i]);
	}
	for(int i = 2; i <= n; i++)
	{
		f[i] = 2e9;
		for(int j = 1; j <= 2; j++)
		{
			if(i-j>0)
			{
				f[i] = min(f[i], f[i-j]+abs(h[i]-h[i-j]));
			}
		}
	}
	printf("%d\n", f[n]);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	string s;
	int ans=0;
	int x  = 0;
	cin >>n>>s;
	rep(i, n) {
		if (s[i] == 'I') {
			x++;
		}else{
			x--;
		}
		chmax(ans, x);
	}
	cout<<ans<<endl;
}

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

int main(){
    int n , k;
    string s ;
    cin >> n >> k >> s ;
    int ans ;
    int happy = 0;
    for (size_t i = 0; i < n-1; i++)
    {
        if (s.at(i) == s.at(i+1))
        {
            happy ++ ;
        }
        
    }
    int a = happy + 2*k ;
    if (a >= n-1)
    {
        ans = n-1 ;
    }else
    {
        ans = a ;
    }
    cout << ans << endl ;
    
}

Measured memory_bytes: 512
n = gets.to_i
array_p = gets.split(" ").map!{|i | i.to_i}

swap = 0

array_p.each_with_index do |num, index|
    unless num == (index + 1)
    swap = swap + 1
  end
end

(swap == 0 || swap == 2) ? result = "YES" : result = "NO"

puts result


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, C;
  cin >> N >> C;
  vector<vector<pair<int, int>>> R(C);
  for (int i = 0; i < N; i++){
    int s, t, c;
    cin >> s >> t >> c;
    c--;
    R[c].push_back(make_pair(s, t));
  }
  for (int i = 0; i < C; i++){
    sort(R[i].begin(), R[i].end());
  }
  vector<vector<pair<int, int>>> R2(C);
  for (int i = 0; i < C; i++){
    if (!R[i].empty()){
      R2[i].push_back(R[i][0]);
      int cnt = R[i].size();
      for (int j = 1; j < cnt; j++){
        if (R2[i].back().second == R[i][j].first){
          R2[i].back().second = R[i][j].second;
        } else {
          R2[i].push_back(R[i][j]);
        }
      }
    }
  }
  vector<int> cnt(1000002, 0);
  for (int i = 0; i < C; i++){
    int sz = R2[i].size();
    for (int j = 0; j < sz; j++){
      cnt[R2[i][j].first - 1]++;
      cnt[R2[i][j].second]--;
    }
  }
  for (int i = 1; i <= 100001; i++){
    cnt[i] += cnt[i - 1];
  }
  int ans = 0;
  for (int i = 0; i <= 100001; i++){
    ans = max(ans, cnt[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9236
N=int(input())
s=input()
list=list(s.split())
for i in range(N):
    list[i]=int(list[i])
count=0
while(True):
    for i in range(N):
        list[i]/=2
        if list[i]!=int(list[i]):
            break
    if list[i]!=int(list[i]):
        break
    count+=1
print(count)


Measured memory_bytes: 3060
n, m = map(int, input().split())
paths = set()

zero_mask = "".join(["0" for x in range(n)])
full_mask = "".join(["1" for x in range(n)])

paths_cnt = 0

for i in range(m) :
    _a, _b = map(int, input().split())
    paths.add((_a - 1, _b - 1))
    paths.add((_b - 1, _a - 1))

def mask_idx(s, idx) :
    newmask = s[:idx] + "1" + s[idx + 1:] 
    return newmask 

def dfs(cur_idx, mask) :
    
    global paths_cnt
    new_mask = mask_idx(mask, cur_idx)
    # print("DBG : ", cur_idx, new_mask, full_mask)
    
    if new_mask == full_mask :
        paths_cnt += 1
    for i in range(n) : 
        if i != cur_idx and new_mask[i] != '1' and (cur_idx, i) in paths:
            dfs(i, new_mask)
            
dfs(0, zero_mask)
print(paths_cnt)
    

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <algorithm>
#include <queue>

int h,w;

bool mat[60][60];
bool access[60][60];
char ch;
using namespace std;

queue<int> q;

bool inBound(int x,int y)
{
    return x>=0 && x<=h-1 && y>=0 && y<=w-1;
}

int bfs()
{
    //push (0,0)
    q.push(0);
    q.push(0);
    int depth = 0 ;
    int len = 0;
    int x,y;
    while(!q.empty()){
        len = q.size()/2;
        for(int i = 0;i<len;i++){
            x = q.front();
            q.pop();
            y = q.front();
            q.pop();
            if(x==h-1&&y==w-1)return depth;
            if(access[x][y])continue;
            else{
                access[x][y]=true;
                //up
                if(inBound(x-1,y)&&!mat[x-1][y]){
                    q.push(x-1);
                    q.push(y);
                }
                //down
                if(inBound(x+1,y)&&!mat[x+1][y]){
                    q.push(x+1);
                    q.push(y);
                }
                //left
                if(inBound(x,y-1)&&!mat[x][y-1]){
                    q.push(x);
                    q.push(y-1);
                }
                //right
                if(inBound(x,y+1)&&!mat[x][y+1]){
                    q.push(x);
                    q.push(y+1);
                }
            }
        }
        depth+=1;
    }
    return -1;
}
int main()

{
    cin>>h>>w;
    int white = 0;
    for(int i = 0;i<h;i++)
        for(int j = 0;j<w;j++){
            cin>>ch;
            if(ch=='#')
                mat[i][j]=true;     
            else{
                white++;
            }
        }
    /*
    for(int i = 0;i<h;i++){
        for(int j = 0;j<w;j++){
            cout<<mat[i][j]<<" ";
        }
        cout<<endl;
    }
    */
    int path = bfs();     
    if(path==-1){
        cout<<"-1"<<endl;
    }
    else{
        cout<<white-path-1<<endl;
    }
    return 0;
}


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

int main(){
    int H,W,N;
    cin >> H;
    cin >> W;
    cin >> N;
    int ans;
    int m = max(H,W);
    if(N%m==0){
        ans = N/m;
    }else{
        ans = N/m + 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	
	int x;
	int f[n][10];
	int p[n][11];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 10; j++){
			cin >> f[i][j];
		}
	}
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 11; j++){
			cin >> p[i][j];
		}
	}
	
	int ans = INT_MIN;
	for(int i = 1; i < (1<<10); i++){
		int tmp = 0;
		for(int j = 0; j < n; j++){
			int cover = 0;
			for(int k = 0; k < 10; k++){
				if(((1<<k) & i) && f[j][k] == 1)	cover++;
			}
			tmp += p[j][cover];
		}
		ans = max(ans, tmp);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
    string s;cin>>s;
    int tmp=0;
    rep(i,s.size()){
        if(tmp==0 and s[i]=='C')tmp++;
        if(tmp==1 and s[i]=='F')tmp++;
    }
    cout<<(tmp==2 ? "Yes" :  "No")<<endl;
    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main(){
   string S;
   cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

string S;

bool canJump(int start, int end){
    for (int i = start; i + 1 <= end; i++) {
        if (S[i] == '#' && S[i+1] == '#') return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D >> S;
    S = '#' + S + '#';

    if (!canJump(A, C) || !canJump(B, D)) {
        cout << "No" << endl;
        return 0;
    }

    if (C > D) {
        bool overtake = false;
        for (int i = B; i <= D; i++) {
            if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
                overtake = true;
            }
        }
        if (!overtake) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int const MOD = 1000000007;
long long dp[100010];
int broken[1000001];
int main()
{
    int N, M;
    cin >> N >> M;

    for (int i = 0; i < M; i++)
    {
        int step;
        cin >> step;
        broken[step] = 1;
    }

    dp[0] = 1;
    for (int i = 0; i < N; i++)
    {
        if (broken[i] == 1) 
            continue;
        dp[i+1] = (dp[i+1] + dp[i]) % MOD;
        dp[i+2] = (dp[i+2] + dp[i]) % MOD;
    }
    cout << dp[N] << endl;
   	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define Endl endl
typedef long long ll;
const int MAXN = (int)2e5 + 5;
int n, k;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n >> k)
	{
		int mx = (n - 1)*(n - 2) / 2;
		if (k <= mx)
		{
			int cnt = 0, sum = n - 1 + mx - k;
			cout << sum << endl;
			for (int i = 1; i < n&&cnt != sum; ++i)
				for (int j = i + 1; j <= n&&cnt != sum; ++j)
					cnt++, cout << i << ' ' << j << endl;
		}
		else
			cout << -1 << endl;
	}
}
/*
5 3
5 8
*/

Measured memory_bytes: 256
a, b = gets.split("\s").map(&:to_i)
100 / 0.08
price = -1
1250.times do |i|
  a_i = ((i+1) * 0.08).to_i
  b_i = ((i+1) * 0.1).to_i
  
  if(a_i == a && b_i == b)
    price = i+1
    break
  end
end

puts price

Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(10**8)

A, B = map(int, input().split())

def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    return gcd(b%a, a)

def lcm(a, b):
    return (a*b) // gcd(a, b)

print(lcm(A, B))

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

using namespace std;

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

typedef long long ll;

const int MAX_N=4e2,MAX_C=4e2,MOD=1e9+7;

int N,C;
int A[MAX_N],B[MAX_N];

ll dp[MAX_N+1][MAX_C+1];    //dp[i][j]=giまで使って、引数の和がjになる積の組み合わせの和
ll pw[MAX_C+1][MAX_C+1];

int main(){
    scanf("%d %d",&N,&C);
    REP(i,N){
        scanf("%d",&A[i]);
    }
    REP(i,N){
        scanf("%d",&B[i]);
    }
    FOR(i,1,MAX_C+1){
        pw[i][0]=1;
        FOR(j,1,MAX_C+1){
            pw[i][j]=pw[i][j-1]*i%MOD;    //pw[i][j]=i^j
        }
    }
    FOR(i,1,MAX_C+1){
        REP(j,MAX_C+1){
            pw[i][j]+=pw[i-1][j];    //累積和を取る
            pw[i][j]%=MOD;
        }
    }
    dp[0][0]=1;
    FOR(i,1,N+1){
        REP(j,C+1){
            ll sum=0;
            REP(k,j+1){
                ll t=(pw[B[i-1]][k]-pw[A[i-1]-1][k]+MOD)%MOD;    //引き算をすると負になる場合があるのでMODを足すのを忘れない
                sum+=dp[i-1][j-k]*t;
                sum%=MOD;
            }
            dp[i][j]=sum;
        }
    }
    printf("%lld\n",dp[N][C]);
    return 0;
}


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

int main(){
        int n;
        scanf("%d", &n);
        std::vector<int> x(n), y(n), v(n);;
        for(int i=0; i<n; i++){
                scanf("%d %d", &x[i], &y[i]);
                v[i] = i;
        }

        double sum = 0, cnt = 0;
        do {
                cnt++;
                double d = 0;
                for(int i=0; i<n-1; i++){
                        d += std::hypot(x[v[i]]-x[v[i+1]], y[v[i]]-y[v[i+1]]);
                }
                sum += d;
        }while(std::next_permutation(v.begin(), v.end()));

        printf("%.10lf\n", sum/cnt);
        return 0;
}

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

namespace _20170705
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("../../TextFile1.txt"));

            var sep = new char[] {' '};
            var temp = Console.ReadLine().Split(sep).Select(long.Parse);
            long N = temp.ElementAt(0);
            long M = temp.ElementAt(1);

            var P = Console.ReadLine().Split(sep).Select(x => long.Parse(x) - 1).ToArray();
            var A = new long[N - 1];
            var B = new long[N - 1];
            var C = new long[N - 1];
            var th = new long[N - 1];
            for (int i = 0; i < N-1; i++)
            {
                temp = Console.ReadLine().Split(sep).Select(long.Parse);
                A[i] = temp.ElementAt(0);
                B[i] = temp.ElementAt(1);
                C[i] = temp.ElementAt(2);
            }

            for (int i = 0; i < M-1; i++)
            {
                long a = P[i] < P[i + 1] ? P[i] : P[i + 1];
                long b = P[i] < P[i + 1] ? P[i+1] : P[i];

                for (;a < b ; a++)
                {
                    th[a]++;
                }
            }

            long sum = 0;
            for (int i = 0; i < N-1; i++)
            {
                long a = A[i] * th[i];
                long b = B[i] * th[i] + C[i];
                sum += a < b ? a : b;
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 25044
#include<stdio.h>
void swap(int tree[],int a,int b){
	int temp=tree[a];
	tree[a]=tree[b];
	tree[b]=temp;
}
void heapify(int tree[],int n,int i){
	int c1=2*i+1;
	int c2=2*i+2;
	int max=i;
	if(i>=n)
		return;
	if(c1<n&&tree[c1]>tree[max])
		max=c1;
	if(c2<n&&tree[c2]>tree[max])
		max=c2;
	if(max!=i){
		swap(tree,i,max);
		heapify(tree,n,max);
	}
}
void build_heap(int tree[],int n){
	int j;
	for(j=((n-1)/2);j>=0;j--){
	heapify(tree,n,j);		
	}
}
void heap_sort(int tree[],int n){
	build_heap(tree,n);
	int k;
	for(k=n-1;k>=0;k--){
		swap(tree,k,0);
		heapify(tree,k,0);
	}
}
int main(){
	int a[100010];
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		}
	heap_sort(a,n);
	printf("%d",a[n/2]-a[n/2-1]);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    ll n, K;
    cin >> n >> K;
    vector<ll> p(n), c(n);
    vector<pair<ll,ll>> r(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> c[i];
    rep(i,n) {
        ll score = 0;
        ll j=i;
        ll cycle=0;
        while(true) {
            ll next = p[j]-1;
            score += c[next];
            ++cycle;
            if (next == i)
                break;
            j = next;
        }
        r[i].first = score;
        r[i].second = cycle;
    }
    ll ans=-Inf;
    rep(i,n) {
        ll k=K;
        ll si = 0;
        ll cycle = r[i].second;
        if (k > cycle && r[i].first > 0) {
            si += r[i].first*((k/cycle)-1);
            k %= cycle;
            k += cycle;
        } else {
            if (k > cycle)
                k = cycle;
        }
        ll m=-Inf;
        ll score = 0;
        ll j=i;
        while(k>0) {
            ll next = p[j]-1;
            score += c[next];
            updatemax(m, score);
            j = next;
            --k;
        }
        updatemax(ans, si+m);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3364
INF = int(1e9 + 7)


def main():
    N, *an = map(int, open(0).read().split())
    ans = INF
    for i in range(min(an), max(an) + 1):
        tmp = 0
        for ai in an:
            tmp += (ai - i) ** 2
        ans = min(ans, tmp)
    print(ans)
    return


main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;i++)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    cin>>b[i];
  }
  rep(i,n){
    cin>>c[i];
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());

  long long count=0;
  rep(i,n){
    auto Iter=lower_bound(a.begin(),a.end(),b[i]);
    auto Iter2=upper_bound(c.begin(),c.end(),b[i]);
    count+=(Iter-a.begin())*(c.end()-Iter2);
  }
  cout<<count<<'\n';
  return(0);
}

Measured memory_bytes: 4528
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

signed main(){
	static int K,A,B;
	cin>>K>>A>>B;
	if(B-A<2){
		cout<<K+1<<endl;
	}
	else{
		K-=A-1;
		if(K%2==0){
			cout<<A+(K/2)*(B-A)<<endl;
		}
		else{
			cout<<A+(K/2)*(B-A)+1<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int n, m; cin >> n >> m;
    vector<int> ar(m,0);
    rep(i,n){
        int a; cin >> a;
        rep(j,a){
            int b; cin >> b;
            ar[b-1]++;
        }
    }
    int ans = 0;
    rep(i,m){
        if (ar[i] == n) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int n;
LL a[100000+5],b[100000+5];
LL sum=0;
int main(){
    cin>>n;
    for(int i=0;i<n+1;i++)
        scanf("%lld",&a[i]);
    for(int i=0;i<n;i++){
        scanf("%lld",&b[i]);
        if(b[i]>a[i]){
            sum+=min(b[i],a[i]+a[i+1]);
            a[i+1]-=b[i]-a[i];
            if(a[i+1]<0)
                a[i+1]=0;
        }
        else
            sum+=b[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define INF 1<<30
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n, ans, cnt[26], len;
bool first[26], used[10];
vector<int> v, S[105];
vector<string> s;

void dfs(int i) {
	if(i == v.size()) {
		ll a = 0, b = 0, t = 1;
		rep(j, len) {
			{
				int sz = S[n-1].size();
				int l = sz - 1 - j;
				if(l >= 0) a += cnt[S[n-1][l]] * t;
			}
			rep(k, n-1) {
				int sz = S[k].size();
				int l = sz - 1 - j;
				if(l >= 0) b += cnt[S[k][l]] * t;
			}
			t *= 10;
			if(a % t != b % t) break;
		}

		if(a == b) {
			ans++;
		}

		return;
	}

	int k = v[i];
	rep(j, 10) {
		if(used[j]) continue;
		if(first[k] && j == 0) continue;

		cnt[k] = j;
		used[j] = true;
		dfs(i + 1);
		used[j] = false;
		cnt[k] = -1;
	}
}

int main() {
	while(cin >> n && n) {
		s.clear(); s.resize(n);
		memset(first, 0, sizeof(first));

		set<char> st;
		len = 0;

		rep(i, n) {
			cin >> s[i];

			S[i].clear();
			len = max(len, int(s[i].size()));

			rep(j, s[i].size()) {
				st.insert(s[i][j]);
				S[i].push_back(s[i][j]-'A');
			}

			if(s[i].size() >= 2) {
				first[s[i][0]-'A'] = true;
			}
		}

		v.clear();
		each(it, st) {
			v.push_back(*it - 'A');
		}

		ans = 0;
		memset(cnt, -1, sizeof(cnt));
		memset(used, 0, sizeof(used));

		dfs(0);

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

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

using namespace std;

int g1[81][81];
int g2[81][81];
bool dp[81][81][6480];


int main() {
	int H, W;
	cin>>H>>W;
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin>>g1[i][j];
		}
	}
	
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin>>g2[i][j];
		}
	}
	
	dp[0][0][abs(g1[0][0] - g2[0][0])] = true;

	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			for (int k = 0;k < 6399;++k) {
				if (dp[i][j][k]) {
					dp[i][j+1][abs(k - abs(g1[i][j+1] - g2[i][j+1]))] = true;
					dp[i][j+1][abs(k + abs(g1[i][j+1] - g2[i][j+1]))] = true;
					dp[i+1][j][abs(k - abs(g1[i+1][j] - g2[i+1][j]))] = true;
					dp[i+1][j][abs(k + abs(g1[i+1][j] - g2[i+1][j]))] = true;
				}
			}
		}
	}
	
	for (int i = 0;i < 6399;++i) {
		if (dp[H-1][W-1][i]) {
			cout<<i<<endl;
			break;
		}
	}
	
	return 0;
}


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

map<int, int> M;
vector<int> X;

void rem(int x, int val)
{
    auto it = M.find(x);
    
    if(it->second == val)
        M.erase(it);
    else
        it->second -= val;
}

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int N;
    cin >> N;
    
    for(int i=1; i<=N; i++)
    {
        int x;
        cin >> x;
        
        M[x]++;
        X.push_back(x);
    }
    
    int ans = 0;
    
    for(int goal = (1LL << 30); goal > 1; goal /= 2)
    {
        for(auto x : X)
        {
            int y = goal - x;
            
            if(x == y)
            {
                if(M[x] > 1)
                {
                    ans++;
                    rem(x, 2);
                }
            }
            else
            {
                if(M.count(x) && M.count(y))
                {
                    ans++;
                    rem(x, 1), rem(y, 1);
                }
            }
        }
        
        X.clear();
        
        for(auto &it : M)
        {
            for(int i=0; i<it.second; i++)
                X.push_back(it.first);
        }
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 10484
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  deque<int> A(N);
  rep(i, 0, N) cin >> A[i];

  rep(i, 0, N) {
    if (i + 1 < A[i]) {
      cout << -1 << endl;
      return 0;
    }
  }

  vi ans;
  while (sz(A)) {
    rrep(i, 0, sz(A)) {
      if (i + 1 == A[i]) {
        ans.pb(i);
        A.erase(A.begin() + i);
        break;
      }
    }
  }

  reverse(all(ans));
  for (int x : ans) {
    cout << x + 1 << endl;
  }
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long long n, ans = 0, i;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		if (i % 3 && i % 5)
		{
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3164
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 404000;
int n,a[N];
ll qzsum[N],qzxor[N],ans;
int main() {
	read(n); rep(i,1,n) read(a[i]);
	rep(i,1,n) qzsum[i]=qzsum[i-1]+a[i],qzxor[i]=qzxor[i-1]^a[i];
	rep(i,1,n) {
		int r=i-1,L=i,R=n;
		while (L<=R) {
			int mid=(L+R)>>1;
			if (qzsum[mid]-qzsum[i-1]==(qzxor[mid]^qzxor[i-1]))
				r=mid,L=mid+1; else R=mid-1;
		}
		ans+=r-i+1;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 6656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0018
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] num = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(num);
            Array.Reverse(num);

            Console.WriteLine(num[0] + " " + num[1] + " " + num[2] + " " + num[3] + " " + num[4]);
        }
    }
}



Measured memory_bytes: 18464
S = input()
T = input()
N = len(S)
# SからTの変換
d1 = {}
# TからSの変換
d2 = {}

for i in range(N):
    if S[i] not in d1:
        d1[S[i]] = T[i]
    else:
        if d1[S[i]] != T[i]:
            print("No")
            exit()
        else:
            pass

    if T[i] not in d2:
        d2[T[i]] = S[i]
    else:
        if d2[T[i]] != S[i]:
            print("No")
            exit()
        else:
            pass
print("Yes")


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

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
    return 0;
}

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

#define MAX_STONES      100000
#define min(a, b)       ( (a) < (b) ? (a) : (b) )
#define SANITY          0
#define DEBUG           0

int
main(void)
{
    int dp[MAX_STONES], heights[MAX_STONES], n;

    scanf("%d", &n);
    
    #if SANITY
    if(n < 2 || n > MAX_STONES)
    {
        fprintf(stderr, "The number of stones is outside the bounds\n");
        return 1;
    }
    #endif

    /* Read the stone heights */
    for(int i = 0; i < n; i++)
    {
        scanf("%d", &heights[i]);
        #if SANITY
        if(heights[i] < 1 || heights[i] > 10000)
        {
            fprintf(stderr, "The stone height is outside the bounds\n");
            return 2;
        }
        #endif
    }

    /* Build the table */
    dp[0] = 0;
    dp[1] = abs(heights[1] - heights[0]);
    for(int i = 2; i <= n; i++)
    {
        int one_skip_cost, two_skip_cost;
        one_skip_cost = abs(heights[i] - heights[i-1]) + dp[i-1];
        two_skip_cost = abs(heights[i] - heights[i-2]) + dp[i-2];
        dp[i] = one_skip_cost < two_skip_cost ? one_skip_cost : two_skip_cost;        
    }

    #if DEBUG
    for(int i = 0; i < n; i++)
        printf("%d\t", dp[i]);
    putchar('\n');
    #endif

    /* Output the result */
    printf("%d\n", dp[n-1]);

}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=2e5+5;
const ld pi=3.14159265359;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll n,m,p,ans,pe;
map<ll,ll> vis,mm;
string s;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;
	while(m--){
		cin>>p>>s;
		if(vis[p])continue;
		if(s=="AC"){
			pe+=mm[p];
			vis[p]=1;
			ans++;
		}else{
			mm[p]++;
		}
	}
	cout<<ans<<" "<<pe<<"\n"; 
	return 0;
}



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

string shuffle(string cards, int h){
	string head = cards.substr(0,h);
	string tail = cards.substr(h,cards.size()-h);
	return tail+head;
}

int main(){
	int h,m;
	string cards;

	while(1){
		cin>>cards;
		if(cards=="-") break;

		cin>>m;
		for(int i=0;i<m;i++){
			cin>>h;
			cards=shuffle(cards,h);
		}
		cout<<cards<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 3200
#!ruby -pal
exit if$_[0]==?0
t=[?+,?-,?*]
$_=$F.permutation(4).to_a.product(t.product(t,t),[1,2,3].product([1,2])).map{|a,b,c|c.inject(a.zip(b).flatten){|s,r|r*=2;s[r-2..r]=?(+s[r-2..r]*""+?);s}*""}.find{|i|eval(i)==10}||0

Measured memory_bytes: 8880
from collections import deque
n,q=map(int,input().split())
edge=[[] for _ in range(n)]
for _ in range(n-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  edge[a].append(b)
  edge[b].append(a)
def dfs(edge):
  visited=[-1]*n
  stack=deque([0])
  visited[0]=0
  while stack:
    p=stack.pop()
    for c in edge[p]:
      if visited[c]==-1:
        visited[c]=0
        cnt[c]+=cnt[p]
        stack.append(c)
  return cnt
cnt=[0]*n
for _ in range(q):
  k,x=map(int,input().split())
  k-=1
  cnt[k]+=x
ans=dfs(edge)
print(*ans)

Measured memory_bytes: 54524
#include <stdio.h>
#define tmnmx int
tmnmx min(tmnmx p0,tmnmx p1){
  return(p0<p1?p0:p1);
}
tmnmx abs(tmnmx p){
  return(p<0?-p:p);
}

int main(){
  int n,i,j,h[100005],c[100005],a[2];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  c[0]=0;
  c[1]=abs(h[0]-h[1]);
  for(i=2;i<n;i++){
    for(j=0;j<2;j++){
      a[j]=abs(h[i-j-1]-h[i])+c[i-j-1];
    }
    c[i]=min(a[0],a[1]);
  }
  printf("%d",c[n-1]);
  return(0);
}

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

int main() {
    int a, b; cin >> a >> b;
    if (a <= 0 && 0 <= b) cout << "Zero" << endl;
    else if (a > 0) cout << "Positive" << endl;
    else {
        int num = b - a + 1;
        if (num % 2 == 0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		double A = scan.nextDouble();
		double B = scan.nextDouble();
		double N = scan.nextDouble();
		double answer = 0;

		if (B - 1 <= N) answer = Math.floor(A * (B - 1) / B) - A * Math.floor((B - 1) / B);
		else answer = Math.floor(A * N / B) - A * Math.floor(N / B);

		System.out.println((long)answer);
	}
}

Measured memory_bytes: 37332
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()

if ('N' in s and 'S' not in s) or ('N' not in s and 'S' in s):
    print('No')
    sys.exit(0)
if ('W' in s and 'E' not in s) or ('W' not in s and 'E' in s):
    print('No')
    sys.exit(0)
print('Yes')


Measured memory_bytes: 61832
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c)
        cout << "Yes" << endl;
    else if (a + b <= c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from collections import defaultdict
from collections import deque

def main():
    n, m = map(int, input().split())
    routes = defaultdict(list)
    for _ in range(m):
        a, b = map(int, input().split())
        routes[a].append(b)
        routes[b].append(a)

    rec = [0] * (n + 1)
    rec[1] = 1
    pos_queue = deque([1])
    while len(pos_queue) > 0:
        p = pos_queue.popleft()
        for next_p in routes[p]:
            if not rec[next_p]:
                rec[next_p] = p
                pos_queue.append(next_p)

    print("Yes")
    print("\n".join(map(str, rec[2:])))


if __name__ == '__main__':
    main()


Measured memory_bytes: 45948
#include<stdio.h>
#define N 500000

int tmp[N], cnt;

void MergeSort(int data[], int left, int right){
    int mid,i,j,k;
    if(left>=right)return;
    mid = (left + right) / 2;
    MergeSort(data, left, mid);
    MergeSort(data, mid+1, right);
    for(i=left;i<=mid;i++) tmp[i] = data[i];
    for(i=mid+1,j=right;i<=right;i++,j--) tmp[i] = data[j];
    i = left;
    j = right;
    for(k=left;k<=right;k++,cnt++){
        if(tmp[i] <= tmp[j]) data[k] = tmp[i++];
        else data[k] = tmp[j--];
    }
}

int main(){
    int n, data[N], i;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d", &data[i]);
    MergeSort(data, 0, n-1);
    for(i=0; i<n-1; i++) printf("%d ", data[i]);
    printf("%d\n%d\n", data[n-1], cnt);
    return 0;
}


Measured memory_bytes: 5596
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		if(d==7||d==5||d==3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 22996
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]


def main():
    n = ni()

    print(n * (n - 1) // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<cstdio>
int main()
{
	int k;
	scanf("%d",&k);
	while(k>0)
	{
		int last1=-100,last2=-100,flag=0;
		for(int i=1;i<=10;i++)
		{
			int x;
			scanf("%d",&x);
			if(flag==0)
			{
				if(x>last1)
					last1=x;
				else if(x>last2)
					last2=x;
				else
				{
					printf("NO\n");
					flag=1;
				}
			}
		}
		if(flag==0)
			printf("YES\n");
		k--;
	}
	return 0;
}

Measured memory_bytes: 2524
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll N;
    cin >> N;
    ll A[N];
    ll B[N];
    ll C[N];
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N) cin >> C[i];
    sort(A,A+N);
    sort(B,B+N);
    sort(C,C+N);
    ll D[N];
    rep(i,N) D[i] = 0;
    rep(i,N){
        if(B[i]>A[0]){
            ll r = N;
            ll l = 0;
            ll m = 0;
            while(r-l>1){
                m = (r+l)/2;
                if(A[m]>=B[i]) r = m;
                else l = m;
            }
            D[i] = r;
        }
    }
    ll out = 0;
    ll sum = 0;
    ll R[N];
    rep(i,N) R[i] = 0;
    rep(i,N){
        if(C[i]>B[0]){
            ll r = N;
            ll l = 0;
            ll m = (r+l)/2;
            while(r-l>1){
                m = (r+l)/2;
                if(B[m]>=C[i]) r = m;
                else l = m;
            }
            R[i] = r;
            if(i==0) rep(j,r) sum += D[j];
            else if(R[i]>R[i-1]){
                for(ll j=R[i-1];j<R[i];j++) sum += D[j];
            }
            out += sum;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>
#include <string>
#include<iostream>
using namespace std;
int main()
{
    // 入力
    int N;
    cin>>N;
    int Y;
    cin>>Y;
    int y=Y/1000;
    for(int i=0;i<=N;i++){
    	for(int j=0;j<=N-i;j++){
    		int k=N-j-i;
    		if(i+j*5+k*10==y) {
    			cout<<k<<" "<<j<<" "<<i<<endl;
    			return 0;
    		}
    	}
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
   lli A,B,L,R,N,M,K,sum=0,num=0,flag=1;
   cin >> N >> M;
   Vec(P,string,N," ");
   Vec(Q,string,M," ");
   rep(i,0,N)cin>>P[i];
   rep(i,0,M)cin>>Q[i];
   rep(i,0,N-M+1)rep(j,0,N-M+1){
      flag=1;
      rep(l,0,M)rep(r,0,M){
         if(P[i+l][j+r]!=Q[l][r])flag=0;
      }
      if(flag)num=1;
   }
   if(num)Out("Yes");
   else Out("No");
}

Measured memory_bytes: 256