akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<climits>
 
using namespace std;
 
#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()
 
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<int,int>> vpi;
typedef long long LL;
 
const long long OO = 2e18;
const double pi=2*acos(0.0);
 
bool isprime(long long int a){
    if(a==1){
        return false;
    }
    for(int i=2;i*i<=a;i++){
        if(a%i==0){
            return false;
        }
    }
    return true;
} 
 
bool iscoprime(int a,int b){
    int i;
    for(i=2;i<=min(a,b);i++){
        if(a%i==0 && b%i==0){
            return false;
        }
    }
    return true;
}
 
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}
 
int maxA(vi a){
    int m=0;
    for(int i=0;i<a.size();i++){
        m=max(m,a[i]);
    }
    return m;
}
 
int minA(vi a){
    int m=100000;
    for(int i=0;i<a.size();i++){
        m=min(m,a[i]);
    }
    return m;
}
 
vi freqN(vi a, int n){
    vi f(n);
    f={0};
    for(int i=0;i<a.size();i++){
        f[a[i]]++;
    }
    return f;
}
 
vi freqA(vi a){
    vi f(26);
    f={0};
    for(int i=0;i<a.size();i++){
        f[a[i]-'0']++;
    }
    return f;
}
 
bool mycomp(const pair<long int,long int>&p1 , const pair<long int,long int>&p2){
    if(p1.second < p2.second) return true;
    else if(p1.second==p2.second) return p1.first<p2.first;
    else return false;
}
 
unsigned int rightmostsetbit(unsigned int n){
    return n & -n;
}
 
bool cmp(pair<lld,lld>&p1 , pair<lld,lld>&p2){
    if((p1.first*p1.second)==(p2.first*p2.second)) return p1.second>p2.second;
    return (p1.first*p1.second)>(p2.first*p2.second);
}
 
int main(){
fast;
cin.tie(0);
string s;
cin>>s;
lld n=s.length();
for(lld i=0;i<n;i++){
    cout<<"x";
}

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(void)
{
	int a,b,c,d=0,e=0;
	while(scanf("%d,%d,%d",&a,&b,&c) != EOF)
	{
		if(a+b>c&&b+c>a&&c+a>b)
		{
			if(a*a+b*b==c*c)
			{
				d++;
			}
			else if(a==b)
			{
				e++;
			}
		}
	}
	cout << d << endl;
	cout << e << endl;
	return 0;
}

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

int main() {
	int n,x;
	cin >> n >> x;
	int k=1; 
	int s=0;
	for (int i=0; i<n; i++){
		int l;
		cin >> l;
		s+=l;
		if (s<=x) k++;
	}
	cout << k;
	return 0;
}

Measured memory_bytes: 256
<?php
list($N, $L) = explode(" ", trim(fgets(STDIN)));
$a = array_merge([0], explode(" ", trim(fgets(STDIN))));;

$last = false;
for($i = 1; $i <= $N - 1; $i++){
    if($L <= $a[$i] + $a[$i + 1]){
        $last = $i;
        break;
    }
}
if(!$last){
    echo 'Impossible' . "\n";
}else{
    echo 'Possible' . "\n";
    for($i = $N - 1; $last < $i; $i--){
        echo $i . "\n";
    }
    for($i = 1; $i < $last; $i++){
        echo $i . "\n";
    }
    echo $last . "\n";
}


Measured memory_bytes: 14068
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
template<typename T>
string ts(T v)
{
	string res="{";
	bool r=true;
	for(const auto &x:v)
	{
		if(!r)res+=",";
		r=false;
		res+=to_string(x);
	}
	res+="}";
	return res;
}
vi v;
int n,m,k;
char grid[10][10];
vector<vi> perRows,perCols;
void go(vi c,int cur,bool r)
{
	if(cur==(r==0?m:n))
	{
		if(r)perRows.pb(c);
		else perCols.pb(c);
		return;
	}
	c.pb(v[cur]);
	go(c,cur+1,r);
	c.pop_back();
	go(c,cur+1,r);
}
int get(vi rows,vi cols)
{
	bool done[n][m];
	forn(i,n)forn(j,m)done[i][j]=1;
	for(auto i:rows)
	{
		forn(j,m)done[i][j]=0;
	}
	for(auto i:cols)
	{
		forn(j,n)done[j][i]=0;
	}
	int ans=0;
	forn(i,n)
	{
		forn(j,m)
		{
			if(grid[i][j]=='#'&&done[i][j])ans++;
		}
	}
	return ans;
}
void solve()
{
	vi c;
	cin>>n>>m>>k;
	forn(i,n)v.pb(i);
	go(c,0,1);
	v.clear();
	c.clear();
	forn(i,m)v.pb(i);
	go(c,0,0);
	forn(i,n)
	{
		forn(j,m)
		{
			cin>>grid[i][j];
		}
	}
	int x=perRows.size(),y=perCols.size();
	int ans=0;
	forn(i,x)
	{
		forn(j,y)
		{
			vi a=perRows[i],b=perCols[j];
			if(get(a,b)==k)ans++;
		}
	}
	cout<<ans<<endl;
	


}
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
   //	cin>>t;
    while(t--)
   	solve();
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define prep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int x;
  cin >> x;
  if(x == 3 || x == 5 || x == 7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

void fnDictionary(set<string> &a_sesKey, vector<string> &a_vsFind)
{
  int iCommandCnt;
  cin >> iCommandCnt;

  for (int i = 0; i < iCommandCnt; i++)
  {
    string sCommand;
    string sKey;
    cin >> sCommand >> sKey;

    if (sCommand[0] == 'i')
      a_sesKey.insert(sKey);
    else if (sCommand[0] == 'f')
    {
      auto itsesKey = a_sesKey.find(sKey);
      if (itsesKey != end(a_sesKey))
        a_vsFind.push_back("yes");
      else
        a_vsFind.push_back("no");
    }
  }
}

void fnResult(const vector<string> &a_cnvsFind)
{
  for (int i = 0; i < a_cnvsFind.size(); i++)
    cout << a_cnvsFind[i] << endl;
}

void fnResultOut(int a_iFound)
{
  cout << a_iFound << endl;
}

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

  set<string> sesKey;
  vector<string> vsFind;

  fnDictionary(sesKey, vsFind);
  fnResult(vsFind);
  
  return 0;
}

Measured memory_bytes: 50668
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
  string str;
  vector<int> arr(1, 0);
  cin >> str;
  char ch='R';

  rep(i, str.length()){
    if(str[i] == ch){
      arr[arr.size()-1]++;
    }else{
      ch = str[i];
      arr.push_back(1);
    }
  }

  for (int i = 0; i < arr.size()-1; i += 2){
    rep(j, arr[i]-1)
      cout << 0 << " ";
    cout << (arr[i] / 2 + arr[i+1] / 2 + arr[i] % 2) << " ";
    cout << (arr[i] / 2 + arr[i+1] / 2 + arr[i+1] % 2) << " ";
    rep(j, arr[i+1]-1){
      cout << 0;
      if(j != arr[i+1]-2 || i != arr.size()-2)
        cout << " ";
      else
        cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(aa) (aa).begin(), (aa).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
//#define SIZE 200105
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
typedef pair<pair<ll, ll>,int> PP;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<pill,int> PA;
//ll MOD;
ll MOD;// = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};

ll dp[2000*3+5][2000*3+5]={0};
int N;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>N>>MOD;
	dp[1][0]=1;
	dp[2][0]=1;
	dp[2][1]=1;
	dp[3][0]=1;
	dp[3][1]=5;
	rep(i,3*N+1){
		if(i>3){
			for(int j=0;j<=i;j++){
				dp[i][j]=dp[i-1][j];
				if(j>0){
					dp[i][j]+=(dp[i-2][j-1]*(i-1));
					dp[i][j]%=MOD;
					dp[i][j]+=(dp[i-3][j-1]*(((i-1)*(i-2)))%MOD);
					dp[i][j]%=MOD;
				}
			}
		}
		
	}
	ll ans=0;
	rep(i,N+1){
		ans+=dp[3*N][i];
		ans%=MOD;
	}

	cout<<ans<<endl;
	/*rep(i,3*N){
		ll hoge=0;
		rep(j,(i+1)/3+1){
			hoge+=dp[i+1][j];
			hoge%=MOD;
		}
		cout<<i+1<<" "<<hoge<<endl;
	}*/
}

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

int main() {
    string s, ans;
    cin >> s;
    ans = s.substr(0, 3);
    cout << ans << endl;
    return 0;
}

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

typedef pair<int, int> P;

void Main() {
  int m, n;
  cin >> m >> n;
  P p[n];

  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    p[i] = P(b, a);
  }
  sort(p, p + n);

  int ans = 0, t = 0;
  for (int i = 0; i < n; i++) {
    P tmp = p[i];
    if (t <= tmp.second) {
      ans++;
      t = tmp.first;
    }
  }

  cout << ans << endl;
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    ll l;
    cin >> n >> l;

    vector<ll> knots(n);
    rep(i, n) cin >> knots[i];

    int k = [&]() -> int {
        rep(i, n - 1) {
            if (knots[i] + knots[i + 1] >= l) {
                return i;
            }
        }
        return -1;
    }();

    if (k == -1) {
        cout << "Impossible" << endl;
        ret();
    }

    vector<int> ans;
    ans.push_back(k);
    for (int i = k - 1; i >= 0; i--) {
        ans.push_back(i);
    }

    for (int i = k + 1; i < n - 1; i++) {
        ans.push_back(i);
    }

    cout << "Possible" << endl;
    reverse(ans.begin(), ans.end());
    for (int i : ans) cout << i + 1 << endl;

}


Measured memory_bytes: 4692
import sys
input = sys.stdin.readline
f = lambda:map(int,input().split())
n,m = f()
ll = [list(f()) for _ in range(m)]
l = [0]*n
d = {}
for p,y in sorted(ll,key=lambda k:k[1]):
  l[p-1] += 1
  d[y] = str(p).zfill(6)+str(l[p-1]).zfill(6)
for l in ll:
  print(d[l[1]])

Measured memory_bytes: 43828
# -*- coding:utf-8 -*-
N = int(input())
H = list(map(int, input().split()))

flg = True
h_p = H[0]
for h_c in H[1:]:
    if h_c < h_p:
        flg = False
        break

    if h_c > h_p:
        h_p = h_c - 1
    else:
        h_p = h_c


print('Yes') if flg else print('No')


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int n,h,w;
    cin>>n>>h>>w;
    cout<<((n-h+1)*(n-w+1))<<endl;
    
    
    return 0;
}


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

using namespace std;


double rast(double x1,double y1,double x2, double y2)
{
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}



int main()
{
   // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector <int> a(n);
    for (int i=0;i<n;i++)
        cin >> a[i];
    a[0]--;

    for (int i=1;i<n;i++)
    {
        if (a[i-1]>a[i])
        {
            cout << "No";
            return 0;
        }
        if (a[i-1]<a[i])
            a[i]--;
    }

    cout << "Yes";
}


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

int  main()
{
	long n,x; cin >> n >> x;
	vector <long> a(n+1);
	rep(i, n)
		cin >> a[i];
	a[n] = x;
	sort(a.begin(), a.end());
	long ans = LONG_MAX;
	vector <long> b;
	for(long i = 0; i < n; i++)
	{
		ans = min(abs(a[i] - a[i+1]), ans);
		b.push_back(abs(a[i] - a[i+1]));
		// cout << abs(a[i] - a[i+1]) << endl;
	}
	long cnt = 0;
	while (ans > 0)
	{
		cnt = 0;
		rep(i, b.size())
		{
			if (b[i] % ans == 0)
				cnt++;
		}
		if (cnt == b.size())
		{
			break;
		}
		ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5072
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int r = sc.nextInt();
      if(r < 1200) System.out.println("ABC");
      if(r >= 1200 && r < 2800) System.out.println("ARC");
      if(r >= 2800) System.out.println("AGC");
      sc.close();
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

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

    double sum_p = 0;
    for (int i = 1; i <= n; i++) {
        double p = 1.0/n;
        for (int count = i; count < k; count*=2) p /= 2;
        sum_p += p;
    }

    cout << setprecision(12) << fixed << sum_p << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007


int main()
{
	int n, k;
	cin >> n >> k;
	if(k == 0){
		cout << (long long int)n * n << endl;
		return 0;
	}
	long long int ans = 0;
	for(int i = k + 1; i <= n; i++){
		ans += (n / i) * (i - k) + max(0, n % i - k + 1);
		// cout << i << " " << ans << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back      
#define F first
#define S second
#define SS stringstream
#define sqr(x) ((x)*(x))
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define CC(x) cout << (x) << endl
#define pw(x) (1ll<<(x))
#define buli(x) __builtin_popcountll(x)
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define M 1000000007
#define N 211

#define TASK "1"

using namespace std;

int a[N];
int q[N][N];
int f[N];



void ae(int x, int y, int fl) {
	q[x][y] += fl;
}

int s;
int S, T;
int n;

void go(int x) {
	if (x == T) return;
	for (int i = 0; i <= T; i++) if (q[x][i] >= s && f[i] == -1) {
		f[i] = x;
		go(i);
	}
}

int main(){
	#ifdef home
		freopen(TASK".in","r",stdin);	
		freopen(TASK".out","w",stdout);
	#endif		
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];

	S = n;
	T = S + 1;
	long long ans = 0;

	for (int i = 0; i < n; i++) {
		if (a[i] > 0) {
			ans += a[i];
			ae(S, i, a[i]);
		} else {
			ae(i, T, -a[i]);
		}
	}
	for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) if ((j + 1) % (i + 1) == 0) ae(j, i, 1e9 + 5);


	for (s = pw(29); s >= 1; s /= 2) {
		for (;;) {
			for (int i = 0; i <= T; i++) f[i] = -1;
			go(S);
			if (f[T] == -1) break;
			int x = T;
			while (x != S) {
				q[f[x]][x] -= s;
				q[x][f[x]] += s;
				x = f[x];
			}
			ans -= s;
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
    unsigned int N;
    int count;
    
    scanf("%d", &N);
    
    count = 0;
    
    while (N > 3){
        switch (N % 3){
          case 0:
            N /= 3;
            break;
          
          case 1:
          case 2:
            N = N / 3 + 1;
            break;
        }
//printf("<%d>", N);
        count++;
    }
    
    count++;
    
    printf("%d\n", count);
    
    return (0);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int miner,maxer;
int main(){
	ios::sync_with_stdio(0);
	
	int n,k;
	cin>>n>>k;
	miner=-1000000;
	maxer=1000000;
	miner=max(miner,k-n+1);
	maxer=min(maxer,k+n-1);
	for(int i=miner;i<=maxer;i++)cout<<i<<' ';
	return 0;
}

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

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		int[] tmp = new int[3];
		int answer = 0;

		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}

		for (int i = 1; i < n - 1; i++) {
			tmp[0] = p[i - 1];
			tmp[1] = p[i];
			tmp[2] = p[i + 1];

			Arrays.sort(tmp);

			if (p[i] == tmp[1]) answer++;
		}

		System.out.println(answer);
	}
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll A, B,C,D;
	cin >> A >> B >> C >> D;
	
	--A;
	//ll ans = 0;
	ll minc = A/C;
	ll mind = A/D;
	ll mint = A/(C*D/__gcd(C,D));
	
	ll mac = B/C;
	ll mad = B/D;
	ll mat = B/(C*D/__gcd(C,D));
	
	ll not_ok = (mac+mad-mat) - (minc+mind-mint);
	cout << B-A-not_ok;

}


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

int get(string s, string t, int pos) {
    int itr = 0, cnt = 0;
    for(int itr = 0; itr < t.length(); itr++) {
        if(s[itr + pos] != t[itr]){
            cnt++;
        }
    }
    return cnt;
}
int main() {
    int t = 1;
    while(t--) {
        string s;
        string t;
        cin>>s>>t;
        int ans = 1000000;
        for(int i=0; i + t.length() <= s.length(); i++) {
            ans = min(ans, get(s, t, i));
        }        
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
board=['#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.','.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#']
while 1:
  h,w=map(int,input().split())
  if h==0 and w==0:
    break
  for i in range(h):
    if i%2==0:
      print(board[0][:w])
    else:
      print(board[1][:w])
  print('')


Measured memory_bytes: 5616
# -*- coding: utf-8 -*-
import collections
h, w = map(int,input().split())
a = []
for i in range(h):
    a.append(list(input()))

tmp = []
for i in range(h):
    for j in a[i]:
        tmp.append(j)
#print(tmp)
c = collections.Counter(tmp)
tmp2 = list(set(tmp))
four = 0
two = 0
odd = 0
for i in tmp2:
    if c[i] % 4 == 0:
        four += 1
    elif c[i] % 2 == 0:
        two += 1
    else:
        odd += 1

if h % 2 == 1 and w % 2 == 1:
    if odd == 1 and two <= (h // 2 + w // 2):
        ans = "Yes"
    else:
        ans = "No"
elif h % 2 == 0 and w % 2 == 0:
    if two == 0 and odd == 0:
        ans = "Yes"
    else:
        ans = "No"
elif h % 2 == 0 and w % 2 == 1:
    if odd == 0 and two <= h // 2:
        ans = "Yes"
    else:
        ans = "No"
elif h % 2 == 1 and w % 2 == 0:
    if odd == 0 and two <= w // 2:
        ans = "Yes"
    else:
        ans = "No"
print(ans)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
	string s;
	cin >> s;
	cout << s.substr(0,4) << " " << s.substr(4) << endl;
	return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.range;
//standard input/output

void main()
{
	auto S = readln.chomp;
	int res = 700;

	if(S[0] == 'o') res += 100;
	if(S[1] == 'o') res += 100;
	if(S[2] == 'o') res += 100;

	writeln(res);
	/*
	int res = 700;
	foreach(i; S) if(i == 'o') res += 100;
	writeln(res);
	*/

	/*
	int res = 700;
	res += 100 * S.count('o');
	writeln(res);
	*/

}


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

int grid[50][50];
int n, m;

bool check(int y) {
    int win = 0, draw = 0;
    for (int x = 0; x < n; x++) {
        if (y == x) continue;
        if (grid[y][x] == 1) win++;
        if (grid[y][x] == 0) draw++;
    }
    return win <= (n - 1) / 2 && win + draw >= (n - 1) / 2;
}

ll ans;
void dfs(int cur) {
    int x = cur % n;
    int y = cur / n;
    if (cur == n * n) {
        ans++;
        return;
    }
    // 自分自身 or 既に埋まってる
    if (y == x || grid[y][x] != 0) {
        if (check(y)) dfs(cur + 1);
        return;
    }
    grid[y][x] = 1;
    grid[x][y] = -1;
    if (check(y)) dfs(cur + 1);
    grid[y][x] = -1;
    grid[x][y] = 1;
    if (check(y)) dfs(cur + 1);
    grid[y][x] = grid[x][y] = 0;
}

int main() {
    while (cin >> n, n) {
        cin >> m;
        memset(grid, 0, sizeof(grid));
        for (int i = 0; i < m; i++) {
            int x, y;
            cin >> x >> y;
            x--;
            y--;
            grid[x][y] = 1;
            grid[y][x] = -1;
        }
        ans = 0;
        dfs(0);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    
    int anv[114514];
    int i,count=0;
    for(i=0;i<n;i++){
        scanf("%d",&anv[i]);
        while(anv[i]%2==0){
            anv[i]/=2;
            count++;
        }
    }
    
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 256
def run(s, K):
    sub_list = []
    for i in range(len(s)):
        for j in range(i, i+K):
            if j+1 > len(s):
                break
            sub_list.append(s[i:j+1])
    sub_list = sorted(set(sub_list))
    return sub_list[K-1]


def main():
    s = input()
    K = int(input())
    print(run(s, K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5068
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<ll, ll>P;
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; }
void SAY(bool YES){cout<<(YES?"YES":"NO")<<endl;};
void Say(bool Yes){cout<<(Yes?"Yes":"No")<<endl;};

const ll MOD = 1000000007;

int main(){

    ll N, M;
    cin >> N >> M;
    if(abs(N - M) >= 2){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    if(N == M)ans = 2;
    for(ll i = 1; i <= N; i++)ans = (ans * i) % MOD;
    for(ll i = 1; i <= M; i++)ans = (ans * i) % MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

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

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

multiset<ll> st;
ll ar[M],dp[M];

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

	ll n,sm = 0,i,ans;

	cin >> n;
	for(i=1;i<=3*n;++i)
		cin >> ar[i];

	for(i=1;i<=n;++i)
	{
		sm += ar[i];
		st.insert(ar[i]);
	}

	dp[n] = sm;

	for(i=n+1;i<=2*n;++i)
	{
		sm += ar[i];
		st.insert(ar[i]);
		auto v = *(st.begin());
		sm -= v;
		auto it = st.lower_bound(v);
		st.erase(it);
		dp[i] = sm;
	}

	sm = 0;
	st.clear();
	for(i=2*n+1;i<=3*n;++i)
	{
		st.insert(ar[i]);
		sm += ar[i];
	}

	ans = -1e18;
	ans = max(ans,dp[2*n]-sm);

	for(i=2*n;i>=n+1;i--)
	{
		sm += ar[i];
		st.insert(ar[i]);
		auto v = *(st.rbegin());
		sm -= v;
		auto it = st.lower_bound(v);
		st.erase(it);
		ans = max(ans,dp[i-1]-sm);
	}

	cout << ans << "\n";
}

Measured memory_bytes: 11432
#include<stdio.h>
int main()
{
    int a1,a2,a3,s1[100],d1,d2,d3,i,min;
    scanf("%d%d%d",&a1,&a2,&a3);
    d1=a1-a2;
    d2=a2-a3;
    d3=a3-a1;
    if(d1<0)
    {
        d1=d1*(-1);
    }
    if(d2<0)
    {
        d2=d2*(-1);
    }
    if(d3<0)
    {
        d3=d3*(-1);
    }
    s1[0]=d1+d2;
    s1[1]=d2+d3;
    s1[2]=d3+d1;
    min=s1[0];
    for(i=0;i<3;i++)
    {
        if(min>s1[i])
        {
            min=s1[i];
        }
    }
    printf("%d\n",min);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)

int main(){
    string S,T;
    cin >> S >> T;

    int count=0;
    rep(i,0,3){
        if(S[i] == T[i]) count++;

    }
    cout << count << endl;
}


Measured memory_bytes: 256
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import Counter
def resolve():
    N = ir()
    S = []
    for i in range(N):
        S.append(sr())
    print(len(Counter(S).keys()))
resolve()

Measured memory_bytes: 128196
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>

using namespace std;

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

#define inf 0x3f3f3f3f
#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

int main() {
	int N; cin >> N;
	vector<pii> A(N);
	REP(i, N) {
		cin >> A[i].first;
		A[i].second = i;
	}

	sort(ALL(A));

	ull cnt = 0;
	REP(i, N) {
		int f = A[i].first;
		int s = A[i].second;
		
		cnt += ((s & 1) != (i & 1));
	}

	cout << cnt/2 << endl;

	return 0;
}


Measured memory_bytes: 1024
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 area = a * b;
                int length = 2 * (a + b);
                System.out.println(area + " " + length);
                sc.close();
        }
}


Measured memory_bytes: 26116
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int a[100100]; 
int main() {
  int n, x;
  cin >> n >> x;
  rep(i,n) cin >> a[i];
  ll ans = 0;
  rep(i,n-1) {
    ll rem = a[i] + a[i+1] - x;
    if (rem <= 0) continue;
    ans += rem;
    if (rem <= a[i+1]) {
      a[i+1] -= rem;
    }
    else {
      rem -= a[i+1];
      a[i+1] = 0;
      a[i] -= rem;
    }
  }
  cout << ans << endl;
  return 0;
}

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

const int limit=1000000001;
bool inserted[limit];

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

  map<int, bool> m;

  int a;
  int ans=0;
  for(int i=0; i<n; i++){
    cin >> a;
    auto it = m.find(a);
    if(it != m.end()){
      if(m[a])ans--;
      else ans++;
      m[a]=!m[a];
    }else{
      m[a]=true;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 4864
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;
 
class DandA {
    static void Main(string[] args) {
        int[] nr = ReadLineIntArray();
        if (nr[0] < 10) {
              Console.WriteLine(nr[1] + (100 * (10 - nr[0])));
          } else {
              Console.WriteLine(nr[1]);
          }
    }
 
    static string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    static string[] strAry = new string[] {"L", "R", "U", "D"}; 
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private long ReadLineLong() {return long.Parse(Console.ReadLine());}
    static private double ReadLineDouble() {return double.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private double[] ReadLineDoubleArray() {return Console.ReadLine().Trim().Split().Select(a => double.Parse(a)).ToArray();}
    static private decimal[] ReadLineDecimalArray() {return Console.ReadLine().Trim().Split().Select(a => decimal.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
 
    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 13396
a={}
for i=1,3 do
    table.insert(a,io.read("*n"))
end
table.sort(a)
if (a[2]-a[1])%2==0 then
    print((a[2]-a[1])//2+a[3]-a[2])
else
    print((a[2]-a[1]+1)//2+a[3]-a[2]+1)
end

Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int a,p,ap=0;
  cin >> a >> p;

  ap= a*3+p;

  cout << ap/2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int n,k,flag=0;
	scanf("%d %d",&n,&k);
	int p=k,c=n-k; 
	int a[n];
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int i=0;i<c;i++)
	{
		int s1,s2;
		s1=a[p-k];
		s2=a[p];
		p++; 
		
		if(s1<s2) printf("Yes\n");
		else printf("No\n");
	}

	
	return 0;
 } 

Measured memory_bytes: 3868
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    v = [[] for i in range(n)]
    for i in range(m):
        a,b,c = LI()
        v[a].append((b,c))

    B = 1<<n
    dp = [[float("inf")]*n for i in range(B)]
    for i,c in v[0]:
        dp[1<<i][i] = c
    for b in range(B):
        for i in range(n):
            if not b&(1<<i):
                continue
            for j,c in v[i]:
                if b&(1<<j):
                    continue
                nb = b|(1<<j)
                nd = dp[b][i]+c
                if nd < dp[nb][j]:
                    dp[nb][j] = nd
    ans = dp[B-1][0]
    if ans == float("inf"):
        print(-1)
    else:
        print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()



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

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

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  int N;
  cin >> N;
  ll s,t,u;
  s=1;
  t=1;
  u=1;
  rep(i,N){
    s*=10;
    s%=1000000007;
  }
  rep(i,N){
    t*=9;
    t%=1000000007;
  }
  rep(i,N){
    u*=8;
    u%=1000000007;
  }
  
  ll ans;
  ans = (s-2*t+u)%1000000007;
  if(ans<0){
    ans = ans+1000000007;
  }
  cout << ans << endl;
  
    
}

      
      
       





      

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,m,a[1000],b[1000],s[1000]={};
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<m;i++){
        cin>>b[i];
        for(int j=0;j<n;j++){
            if(a[j]<=b[i]){
                s[j]++;
                break;
            }
        }
    }
    cout<<max_element(s,s+n)-s+1<<endl;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int x, a, b; cin >> x >> a >> b;
  auto c1 = std::abs(x-a);
  auto c2 = std::abs(x-b);
  auto ans = c1 < c2 ? "A" : "B";
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll n,a,b;cin >> n >> a >> b;
    cout << max((b-a)*(n-2)+1,0LL) <<endl;
}

Measured memory_bytes: 3604
import sys

MOD = 10**9 + 7

N, K = map(int, input().split())

maxS = N*N//2
if K > maxS or K%2:
    print(0)
    sys.exit()

dp = [[0]*(maxS+1) for j in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    dp2 = [[0]*(maxS+1) for j in range(N+1)]
    for j in range(i+1):
        for s in range(0, maxS+1, 2):
            s0 = s-2*j
            if s0 < 0: continue
            dp2[j][s] = (2*j+1)*dp[j][s0]
            if j+1 <= N:
                dp2[j][s] += (j+1)*(j+1)*dp[j+1][s0]
            if j-1 >= 0:
                dp2[j][s] += dp[j-1][s0]
            dp2[j][s] %= MOD
    dp = dp2

print(dp[0][K])


Measured memory_bytes: 4976
IDENTIFICATION DIVISION.
PROGRAM-ID. 164C.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
  SELECT STDIO ASSIGN TO KEYBOARD. 
*>
DATA DIVISION.
FILE SECTION.
FD STDIO.
01 INP        PIC X(2200000).
*>
WORKING-STORAGE SECTION.
01 N          PIC  9(06) COMP.
01 TBL1.
   03 A       PIC  9(10) COMP OCCURS 200000.
01 TBL2.
   03 SA      PIC  9(9) OCCURS 200000.
01 P1         PIC  9(7) COMP.
01 P2         PIC  9(7) COMP.
01 I          PIC  9(6) COMP.
01 CNT        PIC  9(18) COMP.
01 OUT        PIC  Z(17)9.
*> 
PROCEDURE DIVISION.
  ACCEPT N.
*>
  OPEN INPUT STDIO.
  READ STDIO.
  CLOSE STDIO.
*>
  MOVE ZERO TO TBL2.
  MOVE 1 TO P1.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
    MOVE INP(P1:P2 - P1) TO A(I)
    IF (I > A(I))
      ADD 1 TO SA(I - A(I))
    END-IF
    COMPUTE P1 = P2 + 1
  END-PERFORM.
*>
  MOVE 0 TO CNT.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N - 2
    IF (I + A(I) <= N)
      COMPUTE CNT = CNT + SA(I + A(I))
    END-IF
  END-PERFORM.
*>
  MOVE CNT TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 9344
/*
 *  Created on: 12-July-2020
 *      Author: ankur314
 */
#include <bits/stdc++.h>
#define lli long long int
#define li long int
#define db double
#define ldb long double
#define vr vector
#define it iterator
#define fi(i,a,n) for(int i=a;i<n;i++)
#define fli(i,a,n) for(long int i=a;i<n;i++)
#define flli(i,a,n) for(long long int i=a;i<n;i++)
#define pb push_back
#define ppf() pop_front()
#define pii pair<int,int>
#define MOD 1000000007
#define INF 1000000005
#define PI acos(-1)
#define maxn 1000005

#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define debug4(x,y,z,w) cerr<<x<<" "<<y<<" "<<z<<" "<<w<<"\n"

#define prAr(a, n) {for(int i = 0; i < n; i++) {cout<<a[i]<<" ";} cout<<"\n";}
#define inAr(a, n) for(int i = 0; i < n; i++) cin>>a[i];
#define prMat(a, n, m) {for(int i = 0; i < n; i++) {for(int j = 0; j < m; j++) {cout<<a[i][j]<<" ";} cout<<"\n";} }
#define inMat(a, n, m) {for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) cin>>a[i][j]; }
#define nl cout<<"\n";

using namespace std;

void solve()
{
    int n; cin >> n;
    int a[n];
    fi (i,0,n) cin >> a[i];
    lli dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    fi(i,2,n)
    {
        dp[i] = min(abs(a[i]-a[i-1]) + dp[i-1], abs(a[i]-a[i-2]) + dp[i-2]);
    }
    cout << dp[n-1];
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    // freopen("/Users/administrator/Desktop/CODES/compile/testcase","r",stdin);
    // freopen("output.txt","w",stdout);
    // time_t start, end;
    int t = 1;
    // cin >> t;
    // time(&start);
    while(t--)
    {
        solve();
    }
    // time(&end);
    // double time_taken = double(end - start);
    // cerr << "Time taken by program is : " << fixed << time_taken << setprecision(5) << "seconds";
    return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int a, b; cin >> a >> b;
	for (int i=0; i<max(a,b); i++) cout << min(a, b);
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
function Main(input){
  input = input.split("\n");
  //山の数Ｎを格納する
  inputStr = input[0].split(" ");
  const N = Number.parseInt(inputStr[0]);
  //数値変換しつつ配列D_arrとしてダムに溜まった水を格納する
  inputStr = input[1].split(" ");
  var D_arr = inputStr.map(inputStr => Number.parseInt(inputStr));
  //総降水量Sを求める
  var S = 0;
  var ans = [];
  for(var i=0 ; i<N ; i++ ){
    S += D_arr[i];
    ans.push(0);
  }
  ans[0] = S;

  //総和(S=ans[0])から、他のダムに溜まった雨の量を減らす式
  //漸化式の関係上、偶数番目のダムの値×2を引いていく
  for( i=1 ; i<N ; i = i+2 ){
    ans[0] -= 2*D_arr[i];
  }
 
  //切っ掛けとなるなる山1の降水量は求まったので後は順次計算していく。
  for( var i=1 ; i<N ; i++){ 
    if(i===N-1){
      ans[i] = 2*D_arr[i] - ans[0];
    } else {
      ans[i] = 2*D_arr[i-1] - ans[i-1];
    }
  }
  //結果出力
  console.log(ans.join(" "));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 38964