akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1000006;
const ll MOD = 1000000007;

typedef pair<ll, ll> pii;
pii pt[21];
vector<pii> slope;

bool cmp (const pii &p1, const pii &p2) {
    return p1.first * p2.second < p1.second * p2.first;
}

bool sm (const pii &p1, const pii &p2) {
    return p1.first * p2.second == p1.second * p2.first;
}

pii operator - (const pii &p1, const pii &p2) {
    pii ret = {p1.first - p2.first, p1.second - p2.second};
    if (ret.second < 0) {
        ret.first *= -1;
        ret.second *= -1;
    } else if (ret.second == 0) {
        ret.first = abs(ret.first);
    }
    return ret;
}
int ans;

bool vis[21];
pii id[21];
void check () {
    sort(slope.begin(), slope.end(), cmp);
    int cnt = 1;
    int cur = 0;
    REP1 (i, SZ(slope)) {
        if (i == SZ(slope) || !sm(slope[i], slope[i-1])) {
            cur += cnt * (cnt - 1) / 2;
            cnt = 0;
        }
        cnt++;
    }
    ans = max(ans, cur);
}

void dfs (int idx, int n) {
    if (idx == n) {
        slope.clear();
        REP (i, n) {
            slope.emplace_back(pt[id[i].first] - pt[id[i].second]);
        }
        check();
    } else {
        int f = -1;
        REP (i, n * 2) {
            if (!vis[i]) {
                f = i;
                break;
            }
        }
        assert(f != -1);
        vis[f] = true;
        for (int j=f+1; j<n*2; j++) {
            if (!vis[j]) {
                id[idx] = pii(f, j);
                vis[j] = true;
                dfs(idx+1, n);
                vis[j] = false;
            }
        }
        vis[f] = false;
    }
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    int n;
    cin >> n;
    REP (i, n) {
        cin >> pt[i].first >> pt[i].second;
    }

    dfs(0, n/2);

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



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> v,dp;


signed main()
{
    int n,i,k,j;
    cin >> n >> k;
    v.resize(n);
    dp.resize(n);
    fill(begin(dp),end(dp),LONG_LONG_MAX);
    for(i =0;i < n;i++){
        cin >> v[i];
    }
    dp[0] = 0;
    dp[1] = abs(v[1]-v[0]);
    for(i = 2;i < n;i++){
        for(j = 1;j <= min(i,k);j++)
            dp[i] = min(dp[i-j]+abs(v[i]-v[i-j]),dp[i]);
                    
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
  long long int a,b,c,k,max;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
  if(a >= k){
    max = k;
  }else if(a+b >= k){
    max = a;
  }else{
    max = a;
    k -= (a + b);
    max = a - k;
  }
  printf("%lld\n",max);
  return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll n,s,A[200001],ans=0,mod=998244353;
ll dp[3001][3001]={0};
int main(){
    cin>>n>>s;
    rep(i,n) cin>>A[i];
    rep(i,n) if(A[i]<=s) dp[i+1][A[i]]=i+1+(i+1)*(n-i-1)*(A[i]==s);
    rep(i,n)rep(j,s+1){
        if(j<s){
            (dp[i+1][j]+=dp[i][j])%=mod;
            if (j>=A[i]) (dp[i+1][j]+=dp[i][j-A[i]])%=mod;
        }
        else{
            (dp[i+1][j]+=dp[i][j])%=mod;
            if (j>=A[i]) (dp[i+1][j]+=(n-i)*dp[i][j-A[i]])%=mod;
        }
    }
    cout<<dp[n][s];
}

Measured memory_bytes: 71936
n = int(input())
s = input()
r = [0]*n
g = [0]*n
b = [0]*n
for i in range(n-1, -1, -1):
  if i != n-1:
    r[i] = r[i+1]
    b[i] = b[i+1]
    g[i] = g[i+1]
  if s[i] == "R":
    r[i] += 1
  if s[i] == "G":
    g[i] += 1
  if s[i] == "B":
    b[i] += 1

ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    if s[i] == s[j]:
      continue
    key = ["R", "G", "B"]
    key.remove(s[i])
    key.remove(s[j])
    k = key[0]
    if 2*j-i >= n:
      if k == "R":
        ans += r[j+1]
      if k == "G":
        ans += g[j+1]
      if k == "B":
        ans += b[j+1]
      continue
    if s[i] != s[2*j-i] and s[j] != s[2*j-i]:
      if k == "R":
        ans += r[j+1]-1
      if k == "G":
        ans += g[j+1]-1
      if k == "B":
        ans += b[j+1]-1
    else:
      if k == "R":
        ans += r[j+1]
      if k == "G":
        ans += g[j+1]
      if k == "B":
        ans += b[j+1]
    

print(ans)

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

using namespace std;

constexpr int N = 200000;
constexpr int M = 26;

char s[N+1];
vector<int> pos;
bitset<M> vis;

int main() {
  scanf("%s", s);
  int n = strlen(s);
  pos.push_back(n);
  int i = n-1;
  while(i >= 0) {
    for(; i>=0; --i) {
      vis[s[i]-'a'] = true;
      if(vis.all()) {
        pos.push_back(i);
        vis.reset();
        break;
      }
    }
    --i;
  }
  string ans;
  i = 0;
  while(true) {
    vis.reset();
    int j = i;
    for(; j<pos.back(); ++j)
      vis[s[j]-'a'] = true;
    for(int k = 0; k<M; ++k)
      if(!vis[k]) {
        ans.push_back('a'+k);
        break;
      }
    pos.pop_back();
    if(pos.empty())
      break;
    while(s[i] != ans.back())
      ++i;
    ++i;
  }
  printf("%s\n", ans.c_str());
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
struct Node
{
	int key;
	Node *next,*prev;
};
char com[20];
Node *nil;
Node* listSearch(int key)
{
	Node *cur=nil->next;
	while(cur!=nil&&cur->key!=key)
	{
		cur=cur->next;
	}
	return cur;
}
void init()
{
	nil=(Node *)malloc(sizeof(Node));
	nil->next=nil;
	nil->prev=nil;
}
void printList()
{
	Node *cur=nil->next;
	int isf=0;
	while(1)
	{
		if(cur==nil)break;
		if(isf++>0)printf(" ");
		printf("%d",cur->key);
		cur=cur->next;
	}
	printf("\n");
}
void deleteNode(Node *t)
{
	if(t==nil)return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}
void deleteFirst()
{
	deleteNode(nil->next);
}
void deleteLast()
{
	deleteNode(nil->prev);
}
void deleteKey(int key)
{
	deleteNode(listSearch(key));
}
void insert(int key)
{
	Node *x=(Node *)malloc(sizeof(Node));
	x->key=key;
	x->next=nil->next;
	nil->next->prev=x;
	nil->next=x;
	x->prev=nil;
}
int main()
{
	int key,n;
	
	scanf("%d",&n);
	init();
	for(int i=0;i<n;i++)
	{
		scanf("%s",com);
		if(com[0]=='i'){
		scanf("%d",&key);
		insert(key);
		}
		else 
		{
			if(com[6]=='F')deleteFirst();
			else if(com[6]=='L')deleteLast();
			else 
			{
				scanf("%d",&key);
				deleteKey(key);
			}
		}
	}
	printList();
	return 0;
}

Measured memory_bytes: 33928
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, a[100000];
string ans = "second";

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2)ans = "first";
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  ll x,y;
  cin>>x>>y;
  
  ll ans=0;

  if(x==0){
    if(y>0) ans=y;
    if(y<0) ans=1-y;
  }
  if(x>0){
    if(x<=y) ans=y-x;
    if(0<y && y<x) ans=x-y+2;
    if(-x<=y && y<=0) ans=x+y+1;
    if(y<-x) ans=1-(x+y);
  }
  if(x<0){
    if(-x<=y) ans=x+y+1;
    if(0<y && y<-x) ans=1-(x+y);
    if(x<=y && y<=0) ans=y-x;
    if(y<x) ans=x-y+2;
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
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 ll MOD = 1000000000+7;

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

    cout << (n+1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin>>N;
  int arr[1000000];
  int dp[1000000];
  for(int i=0;i<N;i++)
  {
    cin>>arr[i];
  }
  dp[0]=0;
  dp[1]=abs(arr[0]-arr[1]);
  for(int i=2;i<N;i++)
  {
    dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
  }
  cout<<dp[N-1];
  return 0;
}

Measured memory_bytes: 4736
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int A[1000];
int B[1000];

int na = 0;
int nb = 0;
int ia;
int ib;
int current;
ll ans;

void selectA(){
  current = A[ia];
  ia--;
  na++;
}
void selectB(){
  current = B[ib];
  ib--;
  nb++;
}
void P(ll n, int r){
  rep(i, r){
    ans *= n;
    ans %= mod;
    n--;
  }
}

int main(){
  int N, M;
  cin >> N >> M;
  rep(i, N) cin >> A[i];
  rep(i, M) cin >> B[i];
  sort(A, A + N);
  sort(B, B + M);
  ia = N - 1;
  ib = M - 1;
  ans = 1;
  int fixed = 0;
  rrep(i, N * M + 1, 1){
    if(i == A[ia] && i == B[ib]){
      selectA();
      selectB();
    }else if(i == A[ia]){
      selectA();
      P(nb, 1);
    }else if(i == B[ib]){
      selectB();
      P(na, 1);
    }else{
      P(na * nb - fixed, 1);
    }
    fixed++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


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

  int ans = 0;
  while (n > 0){
    n /= k;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s, t []byte
	fmt.Scan(&s, &t)
	ans := 10000
	for i := 0; i <= len(s)-len(t); i++ {
		var cnt int
		for j := i; j < i+len(t); j++ {
			if s[j] != t[j-i] {
				cnt++
			}
		}
		ans = min(ans, cnt)
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1788
#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 a,b;
  cin >>a>>b;
  cout << (a+b)%24 << endl;
}
      
       




Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

using namespace std;

int main() {
  int N;
  string S;
  cin >> N >> S;
  stack<char> st;
  for(char c : S) {
    if(st.empty()) {
      st.push(c);
    } else if(st.top() == '(' && c == ')') {
      st.pop();
    } else {
      st.push(c);
    }
  }

  int open_cnt = 0;
  int close_cnt = 0;
  while(!st.empty()) {
    char c = st.top();
    st.pop();
    if(c == '(') {
      open_cnt++;
    } else {
      close_cnt++;
    }
  }
  string ans = string(close_cnt, '(') + S + string(open_cnt, ')');
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//this code is written by Itst
using namespace std;

int main(){
	int L , R; cin >> L >> R;
	if(R - L > 2019){puts("0"); return 0;}
	long long Mn = 1e9;
	for(int i = L ; i <= R ; ++i)
		for(int j = i + 1 ; j <= R ; ++j)
			Mn = min(Mn , 1ll * i * j % 2019);
	cout << Mn << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	char c; cin >> c;
	cout << (char)(c+1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<long long int> 
#define pb push_back
#define f(i,x,n) for (i=x;i<n;i++)

void printvec(vector<ll> a){
    if(a.size() == 0){
        return; 
    }
    for(int i = 0; i < a.size(); i++){
        cout << a[i] << " ";
    }
    cout << endl;
    return;
}
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
void solve(){
    string s;
    cin >> s;
    int ans=0,temp=0;
    for(int i=0;i<3;i++){
        if(s[i]=='R')
        temp++;
        else
        temp=0;
        ans=max(ans,temp);
    }
    cout << ans <<endl;

}
int main(){
	ios_base::sync_with_stdio(false); 
     	cin.tie(NULL);
	int t=1;
	
	while(t--)
	solve();	
	
}

Measured memory_bytes: 3652
from math import floor
a, b = map(int,input().split())

ans = 0
while True:
    ans += 1
    if floor(ans * 0.08) == a and floor(ans * 0.1) == b:
        print(ans)
        exit()
    elif floor(ans * 0.08) > a and floor(ans * 0.1) > b:
        break
print('-1')


Measured memory_bytes: 2940
def main():
    n = int(input())
    s = [int(input()) for i in range(n)]
    s = sorted(s)
    ans = sum(s)
    if ans%10 != 0:
        print(ans)
        exit()
    else:
        for i in s:
            if (ans - i)%10 != 0:
                print(ans-i)
                exit()
        print(0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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


int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}


int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;

    static const double pi = 3.141592653589793;
    double hh = 30 * h + 0.5 * m;
    double mm = 6 * m;
    double theta = (abs(hh-mm) * pi) / 180;
    double c = cos(theta);

    double ans = sqrt(pow(a,2) + pow(b,2) - 2*a*b*c);
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}


Measured memory_bytes: 4208
# 下、右、上、左、右下、右上、左下、左上
dy = [1, 0, -1, 0, 1, -1, 1, -1]
dx = [0, 1, 0, -1, 1, 1, -1, -1]

H, W = map(int, input().split())
field = []

for i in range(H):
    field.append(list(input()))

for y in range(H):
    for x in range(W):

        if field[y][x] == '#':
            continue

        cnt = 0

        for k in range(8):
            ny = y + dy[k]
            nx = x + dx[k]

            if ny < 0 or H <= ny\
                    or nx < 0 or W <= nx:
                continue

            if field[ny][nx] == '#':
                cnt += 1

        field[y][x] = str(cnt)

for y in range(H):
    print("".join(field[y]))


Measured memory_bytes: 3188
def main():
    q,h,s,d = map(int,input().split())
    n = int(input())
    # one per yen
    one = min([q*4,h*2,s])
    # two per yen
    two = d

    if one*2 > two:
        print((n//2)*two + (n%2)*one)

    else:
        print(n*one)



if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
<?php 
$arr = array();
while($line = trim(fgets(STDIN))) {
   
    list($name,$page) = explode(" ",trim($line));
    $name = trim($name);
    $page = intval($page);
    	
    $arr[$name][] = $page;
}
// var_dump($arr);
ksort($arr);
foreach($arr as $k => $v) {
    sort($v);
    echo $k . PHP_EOL;
    echo implode(" ",$v) . PHP_EOL;
}


Measured memory_bytes: 9328
#include<stdio.h>

int A[1000000],n;

int BS(int key){
  int left=0,right=n,mid;
  while(left<right){
    mid=(left+right)/2;
    if(key==A[mid]){
      return 1;
    }
    if(key>A[mid]){
      left=mid+1;
    }
    else if(key<A[mid]){
      right=mid;
    }
  }
    return 0;
}

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



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

 signed main() {
   int x;
   cin>>x;
   if(x%11==0)cout<<(x/11)*2;
   else{
     if(x%11<7)cout<<(x/11)*2+1;
     else cout<<(x/11)*2+2;
   }
   cout<<endl;
   return 0;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;
#define DEBUG(x) cout << x << '\n'

int n, a[MAXN];
void run(){
    cin >> n;
    int s = 0;
    for(int i = 1; i <= n; i++) cin >> a[i], s ^= a[i];
    for(int i = 1; i <= n; i++) cout << (s ^ a[i]) << ' ';
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios::sync_with_stdio(false);

    run();
}


Measured memory_bytes: 4288
b = input()
ans = ''
for i in range(len(b)):
    tmp = b[i]
    if tmp == 'A':
        ans += 'T'
    elif tmp == 'T':
        ans += 'A'
    elif tmp == 'C':
        ans += 'G'
    elif tmp == 'G':
        ans += 'C'

print(ans)


Measured memory_bytes: 2940
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(int i = a; i < n; ++i)
#define pb push_back
#define mp make_pair
//#define f first
//#define sex second

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <set>
#include <ostream>
#include <queue>
#include <functional>
#include <sstream>
#include <map>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
#pragma comment(linker, "/STACK:228228000")
const ll mod = 998244353228;

ll n, res;
ll pr, co;



int main()
{
	/*

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	*/


	cin >> n;

	forn(i, 0, n)
	{
		ll a;
		cin >> a;
		if (a == pr)
			co++;
		else
		{
			res += (co) / 2;
			co = 1;
			pr = a;
		}
	}
	res += co / 2;

	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.length();
    int i,j,flag=0;
    for(i=0;i<l-1;i++)
    {
        for(j=i+1;j<l;j++)
        {
            if(s[i]==s[j])
            {
                flag=1;
            }
            if (flag==1)
                break;
        }
        if (flag==1)
                break;
    }
    if (flag==1) cout<<"no"<<endl;
    else cout<<"yes"<<endl;
    return 0;

}


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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

int s[maxn];
int pre[maxn];
void solve(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
    }
    for(int i=n;i;i--){
        pre[i] = pre[i+1] + s[i];
    }
    long long ans = 0;
    for(int i=1;i<n;i++){
        ans += s[i]*pre[i+1];
    }
    cout<<ans<<endl;
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
   // printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long ans=1,mod=1e9+7,cnt;
main()
{
	int N;cin>>N;
	vector<pair<int,int> >A;
	for(int i=0;i<2*N;i++)
	{
		int a;cin>>a;
		A.push_back(make_pair(a,i<N));
	}
	sort(A.begin(),A.end());
	for(pair<int,int>p:A)
	{
		if(p.second)
		{
			if(cnt>0)ans=ans*cnt%mod;
			cnt--;
		}
		else
		{
			if(cnt<0)ans=ans*-cnt%mod;
			cnt++;
		}
	}
	cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;

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

        n = n % 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
        cout << "hon" << endl;
    }else if(n == 0 || n == 1 || n == 6 || n == 8){
        cout << "pon" << endl;
    }else{
        cout << "bon" << endl;
    }
    
    return 0;
}

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

ifstream in("tree.in");
ofstream out("tree.out");

const int DIM = 100005;

bool oki[DIM]; int siz[DIM];
vector<int> edg[DIM];

void dfs(int x, int f, int sz) {
    siz[x] = 1;
    for (int y : edg[x]) if (y != f) {
        dfs(y, x, sz); siz[x] += siz[y];
        oki[siz[y]] = oki[sz - siz[y]] = true; } }

int main(void) {
    int n = 1, v = 1;
    string str; cin >> str;
    for (char ch : str) {
        if (n == str.length())
            break;
        if (ch == '1') {
            edg[n + 1].push_back(v);
            edg[v].push_back(n + 1);
            v = n + 1; ++n; }
        else {
            edg[n + 1].push_back(v);
            edg[v].push_back(n + 1);
            ++n; } }
    dfs(1, 0, n);
    bool ans = true;
    for (int i = 1; i <= n; ++i) {
        bool ok = str[i - 1] == '1';
        if (oki[i] != ok) {
            ans = false; } }
    if (!ans) {
        cout << -1; return 0; }
    for (int x = 1; x <= n; ++x) {
        for (int y : edg[x]) if (x < y) {
            cout << x << " " << y << "\n"; } }
    return 0; }


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, R;
	cin >> N >> R;

	if (N >= 10)
	{
		cout << R << endl;
	}
	else
	{
		cout << R + 100 * (10 - N) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N=int(input())
F=[int(input().replace(" ", ""), 2) for _ in range(N)]
P=[[int(x) for x in input().split()] for _ in range(N)]
C=[sum(map(int, format(i, "b"))) for i in range(2**10)]
print(max([sum([p[C[f&i]] for f,p in zip(F, P)]) for i in range(1, 2**10)]))


Measured memory_bytes: 3064
#include<stdio.h>
int main() {
	int n;
	int i, j;
	int a, b, c;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &a, &b, &c);
		if (a > c) {
			j = c;
			c = a;
			a = j;
		}
		if (b > c) {
			j = c;
			c = b;
			b = j;
		}
		if (a * a + b * b == c * c)printf("YES\n");
		else printf("NO\n");
	}
}


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

int main() {
  int n;
  string s;
  int i;
  int flag;
  
  cin >> n;
  i = -1;
  flag = 0;
  while (++i < n)
  {
    cin >> s;
    if (s == "Y")
    {
      flag = 1;
      break;
    }
  }
  if (flag)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
int main()
{
  int h,w,k; cin >> h >> w >> k;
  vector<int> s(4);
  rep(i,4) {
    cin >> s[i];
    s[i]--;
  }
  vector<vector<char>> c(h, vector<char>(w));
  rep(i,h) rep(j,w) cin >> c[i][j];

  using pi = pair<int,int>;
  using pii = pair<int,pi>;  
  queue<pii> q;  
  q.push({0, {s[0], s[1]}});
  vector<vector<int>> d(h, vector<int>(w, -1));
  d[s[0]][s[1]] = 0;
  vector<int> dx = {1, 0, -1, 0};
  vector<int> dy = {0, 1, 0, -1};
  while( !q.empty() ) {
    pii p = q.front(); q.pop();
    int dd = p.first;
    int x = p.second.first, y = p.second.second;
    rep(i,4) {
      rep1(j,k) {	
	int nx = x + dx[i]*j;
	int ny = y + dy[i]*j;
	if(0 <= nx && nx < h && 0 <= ny && ny < w) {
	  if(c[nx][ny] == '@') break;
	  if(d[nx][ny] == d[x][y] + 1) continue;
	  if(0 <= d[nx][ny]) break;
	  d[nx][ny] = d[x][y] + 1;
	  q.push({d[nx][ny], {nx, ny}});
	}
	else break;
      }
    }	  
  }

  // rep(i,h) {
  //   rep(j,w) cout << d[i][j] << " ";
  //   cout << "\n";
  // }
  
  cout << d[s[2]][s[3]] << "\n";
  
  return 0;
}


Measured memory_bytes: 11972
import itertools
import math
import fractions

n,m = map(int,input().split())
a = list(map(int,input().split()))	

a.sort(reverse=True)
sum = sum(a)
#print(a[m-1])
if a[m-1] >= 1/(4*m)*sum:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 5048
#include <iostream>


using namespace std;

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

int main()
{
	int n;
	cin >> n;
	int ans, num, a, b;
	cin >> a >> b;
	ans = gcd(a, b);
	for (int i = 2; i < n; i++)
	{
		cin >> num;
		ans = gcd(ans, num);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
	int N;
	vector<int> A;

	int count = 0;

	cin >> N;

	struct Pos
	{
		int x, y;
	};

	Pos start;
	start.x = 0;
	start.y = 0;
	int elapsed = 0;
	for (int i = 0; i < N; ++i)
	{
		int T1;
		Pos goal;
		cin >> T1 >> goal.x >> goal.y;
		T1 -= elapsed;
		for (int j = T1; j != 0; --j)
		{
			if (start.x != goal.x)
			{
				if (start.x < goal.x)
				{
					start.x++;
				}
				else
				{
					start.x--;
				}
			}
			else
			{
				if (start.y < goal.y)
				{
					start.y++;
				}
				else
				{
					start.y--;
				}
			}
		}

		if (start.x != goal.x || start.y != goal.y)
		{
			printf("No");
			return 0;
		}
		elapsed += T1;
	}

	printf("Yes");

	return 0;
}

Measured memory_bytes: 256
url = "https://atcoder.jp//contests/abc057/tasks/abc057_d"

import collections

def main():
    n = int(input())
    cards = list(map(int, input().split()))
    c_cards = collections.Counter(cards)
    credit = 0
    r = 0

    for k in c_cards:
        surplus = c_cards[k] - 1
        r += surplus
        if c_cards[k] > 1:
            n -= surplus
            if credit > 0:
                credit = abs(credit - surplus%2)
            else:
                credit += surplus%2
            c_cards[k] -= surplus
    if credit > 0:
        n -= credit
    print(n)



if __name__ == '__main__':
    main()


Measured memory_bytes: 21940
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=1000000007;
ll MOD=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    while(true){
    int n,m,q;
    cin >> n >> m >> q;
    if (n==0) break;
    vector<string> s(n),ss(m);
    vector<char> h(m,'0');
    rep(i,q){
        string t,tt;
        cin >> t >> tt;
        rep(j,n){
            if (t[j]=='1') s[j].push_back('1');
            else s[j].push_back('0');
        }
        rep(j,m){
            if (tt[j]!=h[j]) {
                ss[j].push_back('1');
                if (h[j]=='1') h[j]='0';
                else h[j]='1';
            }
            else ss[j].push_back('0');

        }
    }
    // rep(i,n) cout << s[i] << endl;
    // rep(j,m) cout << ss[j] << endl;
    vector<int> ans(m,-1);
    rep(i,n){
        rep(j,m){
            if (s[i]==ss[j]){
                if (ans[j]==-1) ans[j]=i;
                else ans[j]=inf; 
            }
        }
    }
    string e;
    rep(i,10){
        e+=to_string(i);
    }
    rep(i,26){
        e.push_back('A'+i);
    }
    rep(i,m){
        if (ans[i]==-1 || ans[i]==inf) cout << "?";
        else cout << e[ans[i]];
    }
    cout << endl;
}}



Measured memory_bytes: 3948
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(void) {
	char c;
	cin >> c;
	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' ||  c == 'u') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
/*author : Yashvardhan
Saturday, January 12, 2019
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

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

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int dp[100005];
int hs[100005];
int mem[100005];
int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int solve(int n){
	if(n == 1) return 0;
	else if(n == 2) return abs(hs[2]-hs[1]);
	else{
		int dp1,dp2;
		dp1 = mem[n-1];
		dp2 = mem[n-2];

		if(dp1 == -1) dp1 = solve(n-1);
		if(dp2 == -1) dp2 = solve(n-2);

		int val = min(dp1+abs(hs[n-1]-hs[n]),dp2+abs(hs[n-2]-hs[n]));
		mem[n] = val;
		return val;
	}
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin>>n;

	for(int i = 1; i <= n ; i++){
		cin>>hs[i];
		mem[i] = -1;
	}
	cout<<solve(n)<<endl;
	

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
int main(){
    int n;
    cin >>n;
    n %= 10;
    if(n == 2|| n == 4|| n ==5|| n==7|| n==9){
        cout << "hon" << endl;
    }
    else if(n== 0 || n== 1|| n==6 || n==8){
        cout << "pon" << endl;
    }
    else{
        cout << "bon" <<endl;
    }
}

Measured memory_bytes: 3636
#include <stdio.h>
     
    int main(int argc, char args[])
    {
    	int a,b,c;
      
      	scanf("%d %d %d", &a, &b, &c);
      	if (a <= 0 || a > 100 || 
            b <= 0 || b > 100 ||
            c <= 0 || c > 100) 
        {
        	return 1;
        }
      	
      	int tmp = b;
      	// swap a and b
      	b = a;
      	a = tmp;
      
      	tmp =c;
      	c = a;
      	a = tmp;
      
      	printf("%d %d %d", a,b,c);
      	return 0;
    }

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)
class union_find {
public:
vector<int> par,rank,lsize;
union_find(int n): par(n),rank(n),lsize(n){
   for (int i=0;i < n;i++){
      par[i]=i;
      rank[i]=0;
      lsize[i]=1;
   }
}

int find(int x){
   if (par[x]==x){
      return x;
   }
   else{
      return par[x] = find(par[x]); 
   }
}

void unite(int x ,int y){
   x=find(x);
   y=find(y);
   if (x==y) return;
   if (rank[x] < rank[y]){
      lsize[y] += lsize[x];
      lsize[x] = -1;
      par[x] = y;
   }else{
      lsize[x] += lsize[y];
      lsize[y] = -1;
      par[y]=x;
      if (rank[x]==rank[y]) rank[x]++;
   }   
}

bool same(int x, int y){
   return find(x) == find(y);
}

int size(int x){
   if (lsize[x] == -1){
      x=find(x);
   }
   return lsize[x];
}
};

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    union_find tree(n);
    rep(i,m){
        int x,y;
        cin >> x >> y;
        x--;y--;
        tree.unite(x,y);
    }
    int ans=0;
    rep(i,n){
        if (tree.same(v[i]-1,i)) ans++;
    }
    cout << ans << endl; 
}


Measured memory_bytes: 1792
n,a,b,c,d=map(int,input().split())
s=input()

s="#"+s+"#"

def solve():
    can_reach=True

    for i in range(a,c+1):
        if s[i]=="#" and s[i+1]=="#":
            can_reach=False
            break
    
    for i in range(b,d+1):
        if s[i]=="#" and s[i+1]=="#":
            can_reach=False
            break

    if not can_reach:
        print("No")
        return

    if c>d:
        snuke_can_over=False
        for i in range(b,d+1):
            if s[i-1]=="." and s[i]=="." and s[i+1]==".":
                snuke_can_over=True
                break
        
        if not snuke_can_over:
            print("No")
            return
    
    print("Yes")


if __name__ == "__main__":
    solve()

Measured memory_bytes: 9368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const long double PI = acos(-1);
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<"\n"
#define o2(a, b) cout<<a<<" "<<b<<"\n"
#define o3(a, b, c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define o4(a, b, c, d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"
#define i1(a) cin>>a
#define i2(a, b) cin>>a>>b
#define i3(a, b, c) cin>>a>>b>>c
#define i4(a, b, c, d) cin>>a>>b>>c>>d
#define fi first
#define se second

ll power(ll a, ll b, ll z = MOD)
{
	ll res = 1;
	a = (a%z);
	while(b)
	{
		if(b&1)
			res = (res*a)%z;
		a = (a*a)%z;
		b = b>>1;
	}
	return res;
}

ll inverse(ll a, ll z = MOD)
{
	return power(a, z-2, z);
}

ll extend(ll a, ll b, ll &x, ll &y)
{
	if(b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll x1, y1;
	ll g = extend(b, a%b, x1, y1);
	x = y1;
	y = x1- (a/b)*y1;
	return g;
}

ll mat_power(ll a, ll b, ll c, ll d, ll n, ll z = MOD)
{
	ll a0 = 1, b0 = 0, c0 = 0, d0 = 1;
	while(n)
	{
		if(n&1)
		{
			ll a1 = a0, b1 = b0, c1 = c0, d1 = d0;
			a0 = (a1*a + b1*c)%z;
			b0 = (a1*b + b1*d)%z;
			c0 = (c1*a + d1*c)%z;
			d0 = (c1*b + d1*d)%z;
		}
		ll a1 = a, b1 = b, c1 = c, d1 = d;
		a = (a1*a1 + b1*c1)%z;
		b = (a1*b1 + b1*d1)%z;
		c = (c1*a1 + d1*c1)%z;
		d = (c1*b1 + d1*d1)%z;
		n = n>>1;
	}
	return c0;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	i1(n);
	string s;
	i1(s);
	int r = 0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i] == 'R')
			r++;
	}
	int ans = min(r, n-r);
	int c = 0;
	for(int i=0;i<r;i++)
	{
		if(s[i] == 'W')
			c++;
	}
	ans = min(ans, c);
	o1(ans);
	return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int N;

	cin >> N;

	vi h(N);

	REP(i, N) {
		cin >> h[i];
	}

	vi dp(N);

	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);

	REP(i, N) {
		if (i <2)continue;

		dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));

	}

	cout << dp[N-1] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
int n,d,min,max;
long long sum;
scanf("%d%d",&n,&d);
min = max = sum = d;
while(--n > 0){
scanf("%d",&d);
  if(d < min) min = d;
  if(d > max) max = d;
  sum += d;
}
printf("%d %d %lld\n",min,max,sum);
return 0;
}


Measured memory_bytes: 2140
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
#define mod 1000000007
//#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;


int main(){
    ll n;
    cin>>n;
    ll dp[n+1];
    if(n<3){
        cout<<0<<endl;
        return 0;
    }
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = 0;
    dp[3] = 1;
    for(ll i = 4;i<n+1;i++){
        dp[i] = 1;
        rep(j,i-3+1){
            dp[i] = (dp[i]+dp[j])%mod;
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 3620
def main() :
    W, H, x, y, r = [int(i) for i in input().split()]

    if ((x-r)>=0) and ((x+r)<=W) and ((y-r)>=0) and ((y+r)<=H) :
        print("Yes")
    else :
        print("No")

if __name__ == '__main__' :
    main()

Measured memory_bytes: 7768
#include <stdio.h>
#include<math.h>
int count=0;
void isprime(int);
int main(){
    int n,i,x;
    double y;
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d",&x);
        isprime(x);
    }
    printf("%d\n",count);
    return 0;
}
void isprime(int x){
    int n,i,j;
    double y;
    if(x==2){
        count++;
        return;
    }
    if(x<2 || x%2==0)return;
    j=3;
    y=sqrt(x);
    while(j<=y){
        if(x%j==0)return;
        j=j+2;
    }
    count++;
}



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

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int r, g, b, n;
  while (cin >> r >> g >> b >> n) {
    int cnt = 0;
    for (int i = 0; i <= n / r; i++) {
      for (int j = 0; j <= (n - i*r) / g; j++) {
        if ((n - i*r - j*g) % b == 0) {
          cnt++;
        }
      }
    }
    cout << cnt << '\n';
  }
}
 

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

int main() {
  int H, W;

  while (1) {
    cin >> H >> W;

    if (H == 0 && W == 0) {
      break;
    }

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {

        if(i == 0 || i == H - 1 || j == 0 || j == W - 1) {
          cout << "#";
        }
        else {
          cout << ".";
        }
        
      }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3112
#include<cstdio>
#include<cstring>
using namespace std;
char s[1000001];
int n;
int main()
{
	scanf("%s",s);
	n=strlen(s);
	for(int i=0;i<n;i++)
	{
		if(s[i]=='7')
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 1736
#include <stdio.h>
#include <vector>

const int MAX_N = 100000;
int x[MAX_N];
bool ok[MAX_N];
std::vector<std::pair<int, int> > G[MAX_N];


bool dfs(int s, int now) {
    x[s] = now;
    ok[s] = true;
    for (auto e: G[s]) {
        int to = e.first;
        int cost = e.second;
        if (!ok[to]){
            if (!dfs(to, now + cost)) {
                return false;
            }
        } else if (x[to] - now != cost){
            return false;
        }
    }
    return true;
}

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    for (int i = 0; i < M; ++i) {
        int L, R, D;
        scanf("%d %d %d", &L, &R, &D);
        L--;
        R--;
        G[L].push_back(std::make_pair(R, D));
        G[R].push_back(std::make_pair(L, -D));
    }
    for (int i = 0; i < N; ++i) {
        ok[i] = false;
    }

    for (int i = 0; i < N; ++i) {
        if (!ok[i]) {
            if (!dfs(i, 0)) {
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 11136
n,y = map(int,input().split())
if y%1000 != 0:
  print(-1,-1,-1)
  quit()
M0 = y//10000
for ml in range(M0+1):
  M1 = (y-10000*ml)//5000
  for fv in range(M1+1):
    th = (y-10000*ml-5000*fv)//1000
    if ml+fv+th == n:
      print(ml,fv,th)
      quit()
print(-1,-1,-1)

Measured memory_bytes: 3064
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions

import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n = ni()
    d = []
    for i in range(n):
        s = sys.stdin.readline()
        d.append(s[0])

    c = collections.Counter(d)

    initial = ["M", "A", "R", "C", "H"]
    pairs = itertools.combinations(initial, 3)
    ans = 0
    for x, y, z in pairs:
        ans += c[x] * c[y] * c[z]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 6996
X = int(input())

prime = [True] * (100010)

prime[0] = False;
prime[1] = False;
for i in range(4,100010,2):
    prime[i] = False

i = 3
while(i*i<=100008):
    if prime[i]:
        for j in range(i+i,100008,i):
            prime[j] = False
    i += 2

for i in range(X,100008):
    if prime[i]:
        print(i)
        break


Measured memory_bytes: 39604
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        
        int w=sc.nextInt();
        int n=sc.nextInt();
        int t;
        
        int[] values = new int[w];
        
        for(int i=0;i<values.length;i++)
        {
            values[i]=i+1;
        }
        
        for(int i=0;i<n;i++)
        {
            String str = sc.next();
            String[] ab=str.split(",");
            int a=Integer.parseInt(ab[0])-1;
            int b=Integer.parseInt(ab[1])-1;
            
            t=values[a];
            values[a]=values[b];
            values[b]=t;
        }
        for(int i=0;i<w;i++)
        {
            System.out.printf("%d\n",values[i]);
        }
    }
}

Measured memory_bytes: 17300