akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int N = 50;
int reach[N][N][N*N+1];
int di[] = {1, -1, 0, 0}, dj[] = {0, 0, 1, -1};

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i,h) cin >> s[i];

    int wall = 0;
    REP(i,h) REP(j,w) wall += (s[i][j] == '#');

    reach[0][0][0] = 1;
    REP(k,N*N){
        REP(i,h) REP(j,w){
            if (!reach[i][j][k]) continue;
            REP(d,4){
                int ii = i + di[d], jj = j + dj[d];
                if (ii < 0 || ii >= h || jj < 0 || jj >= w || s[ii][jj] == '#') continue;
                reach[ii][jj][k+1] = 1;
            }
        }
    }

    int ans = -1;
    REP(k,N*N+1){
        if (reach[h-1][w-1][k]){
            ans = max(ans, h * w - k - 1 - wall);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 24704
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, a, b;
string str;

int main(){
	cin >> n;
    vector<set<ll>> edge(n);
    queue<ll> reef;
    ll use[n];
	for(ll i = 0; i < n-1; i++){
		cin >> a >> b;
		edge[a-1].insert(b-1);
		edge[b-1].insert(a-1);
	}
	for(ll i = 0; i < n; i++){
		if(edge[i].size() == 1){reef.push(i);}
		use[i] = 0;
	}
	
	vector<ll> c(n);
	for(ll i = 0; i < n; i++){cin >> c[i];}
	sort(c.begin(), c.end());
	ll m = 0;
	for(ll i = 0; i < n-1; i++){m += c[i];}
    ll ans[n];
	for(ll i = 0; i < n; i++){
	   ll now = reef.front(); reef.pop();
	   ans[now] = c[i];
	   ll next = *(edge[now].begin());
	   edge[next].erase(now);
	   if(edge[next].size() == 1){reef.push(next);}
	}
	cout << m << endl;
	cout << ans[0];
	for(ll i = 1; i < n; i++){cout << " " << ans[i];}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2048
import java.util.Scanner;
class Main{
    public static void main(String arg[]){
        Scanner scn=new Scanner(System.in);
        int n=scn.nextInt();
        String s=scn.next();
        int k=scn.nextInt();
        //char k-1を見る
        for(int i=0;i<n;i++){
            if(s.charAt(k-1)==s.charAt(i)){ 
                System.out.print(s.charAt(k-1));
            }else{
                System.out.print("*");
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 23252
using System;

public class Hello
{
    public static void Main()
    {
        var a = int.Parse(Console.ReadLine().Trim());
        var b = int.Parse(Console.ReadLine().Trim());
        var c = int.Parse(Console.ReadLine().Trim());
        var d = int.Parse(Console.ReadLine().Trim());
        Console.WriteLine(Math.Min (a,b) + Math.Min(c,d));
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

#define int ll

int h, w, n, k, ans;

int pot[50*50];

int query(int y1, int y2, int x1, int x2)
{
	cout << "? " << y1 << " " << x1 << " " << y2 << " " << x2 << endl;
	int ans;
	cin >> ans;
	return ans;
}

int32_t main()
{
	cin >> h >> w >> n >> k;

	pot[0] = 1;

	for(int i = 1; i < 50*50; ++i)
	{
		pot[i] = pot[i-1]*2%k;
	}

	for(int i = 0; i < h; ++i)
	{
		for(int j = 0; j < w; ++j)
		{
			if(query(i, i, j, j))
			{
				ans += pot[w*i+j];
				ans %= k;
			}
		}
	}

	cout << "! " << ans << endl;
}

Measured memory_bytes: 724
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextStringArray() []string {
  return strings.Split(NextLine()," ")
}
func NextIntArray() []int {
  var s []string = NextStringArray()
  var n int = len(s)
  var a []int = make([]int,n)
  for i:=0;i<n;i++ {
    a[i],_ = strconv.Atoi(s[i])
  }
  return a
}

func main() {
  var n,ave,ans int
  var a []int
  n,_ = strconv.Atoi(NextLine())
  a = NextIntArray()
  ave = 0
  for i:=0;i<n;i++ { ave += a[i] }
  ave = nint(ave,n)
  ans = 0
  for i:=0;i<n;i++ { ans += (a[i]-ave)*(a[i]-ave) }
  fmt.Println(ans)
}
func nint(n int,m int) int {
  var f float64 = float64(n)/float64(m)
  return int(math.Floor(f+0.5))
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> a(N+1);
  vector<int> flag(N+1);
  int count=0;
  int i;
  for(i=1; i<N+1; i++){
    cin >> a.at(i);
  }
  int current=1;
  flag.at(1)=1;
  while(1){
    current=a.at(current);
    count++;
    flag.at(current)++;
    if(flag.at(current)==2){
      cout << -1 << endl;
      break;
    }
    if(current==2){
      cout << count << endl;
      break;
    }
  }
}


Measured memory_bytes: 1024
#include <iostream>
//#include <math.h>
#include <set>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;

int main(){

  int n,q,k;
  vector<vector<int> > v(maxn);
  map<pair<int,int>,ll > m;
  int x[maxn],y[maxn];
  bool used[maxn]={0};
  ll dis[maxn]={0};
  queue<int> que;

  cin >> n;
  rep(i,n-1){
    int a,b;
    ll c;
    cin >> a>>b>>c;
    a--;b--;
    m[make_pair(a,b)]=m[make_pair(b,a)]=c;
    v[a].push_back(b);v[b].push_back(a);
  }

  cin >> q>>k;
  k--;
  rep(i,q){
    cin >> x[i]>>y[i];
    x[i]--;y[i]--;
  }

  que.push(k);
  used[k]=true;
  dis[k]=0;

  while(!que.empty()){
    int arg = que.front();que.pop();
    rep(i,v[arg].size()){
      int next = v[arg][i];
      if(!used[next]){
        dis[next]=dis[arg]+m[make_pair(arg,next)];
        used[next]=true;
        que.push(next);
      }
    }
  }

  rep(i,q){
    cout << dis[x[i]]+dis[y[i]]<<endl;
  }

  return 0;
}


Measured memory_bytes: 22400
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int g(LL  x){
    int res = 0;
    while(x > 0){
        x /= 10;
        res++;
    }
    return res;
}

int f(LL a,LL b){
    return max(g(a),g(b));
}

long long n;

int main()
{
    cin >> n;
    int res = INT_MAX;
    for(LL i=1;i*i<=n;i++){
        if(n%i == 0){
            res = min(res,f(i,n/i));
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

//main.cpp----------------------------


void solve();

ll k, a, b;

int main() {
  cin >> k >> a >> b;

  solve();

  return 0;
}

void solve() {
  ll bis = 1;

  if(a<b&&(b-a)>2) {
    while(k>=2) {
      if(bis<a) {
        k -= (a-bis);
        bis = a;
      }
      if(k-2>=0) {
        k -= 2;
        bis += (b-a);
      }else {
        break;
      }
    }
    cout << bis + k << endl;
  }else {
    cout << bis + k << endl;
  }

}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[300001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size);
	data tmp;
	h->obj[i] = x;
	while (i > 1) {
		if (h->obj[i].key < h->obj[i>>1].key) {
			tmp = h->obj[i>>1];
			h->obj[i>>1] = h->obj[i];
			h->obj[i] = tmp;
			i >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j = i << 1;
		} else break;
	}
	return output;
}

void add_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] += k;
		i += (i & -i);
	}
}

int sum_BIT(int BIT[], int r)
{
	int sum = 0;
	while (r > 0) {
		sum += BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, N, M, l[300001], r[300001];
	data d;
	min_heap h;
	h.size = 0;
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) {
		scanf("%d %d", &(l[i]), &(r[i]));
		d.key = r[i] - l[i] + 1;
		d.id = i;
		push(d, &h);
	}
	
	int j, BIT[2][100001] = {}, ans[100001] = {};
	for (i = 2, ans[1] = N; i <= M; i++) {
		while (h.size > 0 && h.obj[1].key <= i) {
			d = pop(&h);
			add_BIT(M, BIT[0], r[d.id], 1);
			add_BIT(M, BIT[1], M - l[d.id] + 1, 1);
		}
		for (j = i, ans[i] = h.size; j <= M; j += i) ans[i] += N - h.size - sum_BIT(BIT[0], j - 1) - sum_BIT(BIT[1], M - j);
	}
	for (i = 1; i <= M; i++) printf("%d\n", ans[i]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 7572
#include <iostream>
#include<string>
#include<math.h>
using namespace std;
int main(void){
    int n,m=1;
    int a[200];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0) m=m*2;
    }
    cout<<pow(3,n)-m<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
using pii = pair<i32, i32>;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
using vpii = vector<pii>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;
using vvf80 = vector<vf80>;

template<typename T, typename S> bool amax(T &x, S y) { if (x < y) { x = y; return 1; } return 0; }
template<typename T, typename S> bool amin(T &x, S y) { if (y < x) { x = y; return 1; } return 0; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  i32 n;
  cin >> n;
  vu64 a(n);
  rep(i, n) {
    cin >> a[i];
  }
  vu64 sums(n + 1);
  rep(i, n) {
    sums[i + 1] += sums[i] + a[i];
  }
  u64 ans = 1e18;
  int l = 1, r = 3;
  repi(i, 2, n - 1) {
    while (l < i - 1 &&
      labs((sums[i] - sums[l]) - (sums[l] - sums[0])) >
      labs((sums[i] - sums[l + 1]) - (sums[l + 1] - sums[0]))) {
      l++;
    }
    r = max(r, i + 1);
    while (r < n - 1 &&
      labs((sums[n] - sums[r]) - (sums[r] - sums[i])) >
      labs((sums[n] - sums[r + 1]) - (sums[r + 1] - sums[i]))) {
      r++;
    }
    vu64 p;
    p.push_back(sums[l] - sums[0]);
    p.push_back(sums[i] - sums[l]);
    p.push_back(sums[r] - sums[i]);
    p.push_back(sums[n] - sums[r]);
    sort(all(p));
    amin(ans, p[3] - p[0]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3456
import java.util.*;
public class Main{
    
    static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        long[] a = new long[n];
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        long[] b = new long[n];
        long sum = 0;
        for(int i=n-1; i>=0; i--){
            sum += a[i];
            sum %= MOD;
            b[i] = sum;
        }
        
        long ans = 0;
        for(int i=0; i<n-1; i++){
            ans += a[i]*b[i+1]%MOD;
            ans %= MOD;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 61736
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <cstdio>
#include <stack>
using namespace std;
typedef long long ll;


int main(){
    ll a,b,d1=0,d2=0,l,m,n,o=0,q,r,x,y,z,max1=0,ans=0,h,w,j1,a1=0,b1=0;
    string s,t,u;
    cin>>h>>w>>a>>b;
    ll c[w][h]={},p[w]={};
    a1=w-a;
   
    for(ll i=0;i<b;i++){
        for(ll j=0;j<a;j++){
            c[j][i]=1;
            p[j]++;
        }
    }
    for(ll i=b;i<h;i++){
        b1++;
        o=0;
        for(ll j=0;j<w;j++){
            if(p[j]+1==b1){
                o++;
            }
        }
        if(o>=max(a1,a)){
            d2=0;
           for(ll j=0;j<w;j++){
               
              if(d2<max(a1,a)&&p[j]+1==b1){
                c[j][i]=1;
                p[j]++;
                d2++;
              }
           } 
        }else if(o>=min(a,a1)){
            d2=0;
           for(ll j=0;j<w;j++){
               
              if(d2<min(a1,a)&&p[j]+1==b1){
                c[j][i]=1;
                p[j]++;
                d2++;
              }
           } 
        }else{
            d1=1;
            break;
        }
    }
    if(d1==0){
        for(ll i=0;i<h;i++){
            for(ll j=0;j<w;j++){
                cout<<c[j][i];
            }
            cout<<endl;
        }
    }
    else cout<<"No"<<endl;
}
    






Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,b,c;
  cin>>n;
  vector<int> a(n+1);
  long long ans=0;
  rep(i,n+1) cin>>a[i];
  rep(i,n){
    cin>>b;
    c=a[i+1]+a[i];
    ans+=min(c,b);
    a[i+1]=clamp(c-b,0,a[i+1]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
#define N 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
void AIA() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isprim(int x){
	for(int j=2;j*j<=x;j++){
		if(x%j==0){
			return 0;
		}
	}
	return (x!=1);
}

//cout<<fixed<<setprecision(20);
// freopen("stand.in","r",stdin);
// freopen("stand.out","w",stdout);

/*
 _____________              __                ___        ___       __________________________     ____        ____
|             |            /\ \              |   |      |   |     |                          |    \   \      /   /
|   __________|           / /\ \             |   |      |   |     |     _____      _____     |     \   \    /   /
|  |                     / /  \ \            |   |      |   |     |    |     |    |     |    |      \   \  /   /
|  |                    / /    \ \           |   |      |   |     |    |     |    |     |    |       \   \/   /
|  |______             / /      \ \          |   |______|   |     |    |     |    |     |    |        \      /
|         |           / /        \ \         |              |     |    |     |    |     |    |         \    /
|   ______|          / /          \ \        |    ______    |     |    |     |    |     |    |          |  |
|  |                / /============\ \       |   |      |   |     |    |     |    |     |    |          |  |
|  |               / /==============\ \      |   |      |   |     |    |     |    |     |    |          |  |
|  |              / /                \ \     |   |      |   |     |    |     |    |     |    |          |  |
|  |             / /                  \ \    |   |      |   |     |    |     |    |     |    |          |  |
|__|            /_/                    \_\   |___|      |___|     |____|     |____|     |____|          |__|

							<<<<<<<<<<< NEVER GIVE UP !! >>>>>>>>>>>
							<<<<<<<< YOU CAN DO IT IF YOU WANT !! >>>>>>>>
							<<<<<<<<< BELIEVE IN YOURSELF !! >>>>>>>>>
*/

int main()
{
	//cout<<fixed<<setprecision(20);
	//freopen("stand.in","r",stdin);
	//freopen("stand.out","w",stdout);
	AIA();
    char c;
    cin>>c;
    if(c<97){
    	cout<<"A";
	}
	else{
		cout<<"a";
	}
	return 0;
}

Measured memory_bytes: 3648
# -*- coding:utf-8 -*-

a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
        for j in range(b+1):
                for k in range(c+1):
                        if (500*i + 100*j +50*k) == x:
                                count += 1
print(count)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        var p = new int[n+1];
        for(int i = 1; i <= n; i++){
            p[i] = Integer.parseInt(sc.next());
        }
        var c = new int[n+1];
        for(int i = 1; i <= n; i++){
            c[i] = Integer.parseInt(sc.next());
        }
        
        long ans = Long.MIN_VALUE;
        var maxScore = new long[n+1];
        for(int i = 1; i <= n; i++){
            int pos = p[i];
            int move = 1;
            long score = c[pos];
            maxScore[move] = score;
            while(pos != i && move < k){
                pos = p[pos];
                move++;
                score += c[pos];
                maxScore[move] = Math.max(score, maxScore[move-1]);
            }
            ans = Math.max(maxScore[move], ans);
            if(pos == i && score > 0){
                int j = k%move;
                if(j != 0){
                    ans = Math.max(score * (k / move) + maxScore[k%move], ans);
                }else{
                    ans = Math.max(score * (k / move -1) + maxScore[move], ans);
                }
            }
        }
        System.out.println(ans);
    }
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n; scanf("%d",&n);
    vector<int> a(n),b(n);
    rep(i,0,n)scanf("%d",&a[i]);
    rep(i,0,n)scanf("%d",&b[i]);
    ll cnt=0;
    rep(rot,0,1000){
        rep(i,0,n){
            int pre=(i+n-1)%n,nxt=(i+1)%n;
            int sum=b[pre]+b[nxt];
            if(sum<b[i]){
                int add=(b[i]-a[i])/sum;
                b[i]-=sum*add; cnt+=add;
            }
        }
    }
    if(a==b)printf("%lld",cnt);
    else printf("-1");
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		string s;
		cin>>s;
		for(char x:s){
			if(x=='7')return cout <<"Yes",0;
		}
		cout <<"No";
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

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

int num;
void fillNumA( int a[9][9], int n, int i, int j )
{
    while( i < n && j >= 0 )
    {
        a[i][j] = num;
        num++;
        i++;
        j--;
    }
}

void fillNumB( int a[9][9], int n, int i, int j )
{
    while( i + 1 < n && j - 1 >= 0 )
    {
        i++;
        j--;
    }
    while( i >= 0 && j < n )
    {
        a[i][j] = num;
        num++;
        i--;
        j++;
    }
}

int main()
{
    int n, k = 1;
    int a[9][9];

    while( cin >> n, n )
    {
        num = 1;
        cout << "Case " << k++ << ':' << endl;

        bool sw = true;
        for( int i = 0; i < n; i++ )
        {
            if( sw )
                fillNumB( a, n, 0, i );
            if( !sw )
                fillNumA( a, n, 0, i );
            sw = !sw;
        }

        for( int i = 1; i < n; i++ )
        {
            if( sw )
                fillNumB( a, n, i, n - 1 );
            if( !sw )
                fillNumA( a, n, i, n - 1 );
            sw = !sw;
        }

        for( int i = 0; i < n; i++ )
        {    
            for( int j = 0; j < n; j++ )
                cout << setw(3) << a[i][j]; 
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3164
using System;
class Program
 {
   static void Main(string[] args)
   {
     string[] NK;
     NK = Console.ReadLine().Split(' ');

     int tmp = int.Parse(NK[0])%int.Parse(NK[1]);

     if(tmp == 0)
     {
       Console.WriteLine("0");
     }else{
       Console.WriteLine("1");    
     }
     
     //Console.WriteLine(int.Parse(NK[0])%int.Parse(NK[1]));
   }
 }

Measured memory_bytes: 13140
{-# OPTIONS_GHC -Wno-tabs #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	x <- readLn :: IO Int
	putStrLn $ if x >= 30
		then "Yes"
		else "No"

Measured memory_bytes: 3844
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	ans := calc(b) ^ calc(a-1)
	fmt.Println(ans)
}

func calc(a int) int {
	ans := 0
	for i := 0; i < 50; i++ {
		loop := 1 << uint(i+1)
		cnt := (a / loop) * (loop / 2)
		cnt += max(0, (a%loop)-(loop/2)+1)
		if cnt%2 == 1 {
			ans += 1 << uint(i)
		}
	}

	return ans
}

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


Measured memory_bytes: 512
from math import sqrt
while True:
    n=int(input())
    if n==0:break
    s=list(map(int,input().split()))
    ave=0
    for i in s:
        ave+=i
    ave=ave/n
    var=0
    for i in s:
        var+=(i-ave)**2
    var=var/n
    std=sqrt(var)
    print(std)


Measured memory_bytes: 5700
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n = ri()
ls = ril()

res = 0
for x, y in zip([0] + ls, ls):
    if x < y:
        res += y - x
print(res)

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

string A, B, C; long long mod = 1000000007;

string Plus(string V) {
	V[V.size() - 1]++; bool flag = false;
	for (int i = (int)V.size() - 1; i >= 0; i--) {
		if (V[i] <= '9') { flag = true; break; }
		V[i] = '0'; if (i >= 1) { V[i - 1]++; }
	}
	if (flag == false) V = "1" + V;
	return V;
}
string Minus(string V) {
	V[V.size() - 1]--; bool flag = false;
	for (int i = (int)V.size() - 1; i >= 0; i--) {
		if (V[i] >= '0') { flag = true; break; }
		V[i] = '9'; if (i >= 0) { V[i - 1]--; }
	}
	int pos = 0; for (int i = 0; i < V.size(); i++) { if (V[i] != '0') break; pos = i + 1; }
	V = V.substr(pos, (int)V.size() - pos);
	if (V == "") V = "0";
	return V;
}

long long calc(string V) {
	long long res = 0;
	for (int i = 0; i < V.size(); i++) {
		res *= 10LL;
		res += (V[i] - '0');
		res %= mod;
	}
	return res;
}

long long solve(string V) {
	while (V.size() < C.size()) V = "0" + V;

	long long rem = 0;
	for (int i = 0; i <= V.size() - C.size(); i++) {
		string T = V.substr(i, C.size());
		if (T < C) {
			string A = V.substr(0, i); if (A.size() == 0) A = "0";
			for (int j = i + C.size(); j < V.size(); j++) A += "0";

			long long ans = calc(A);
			rem += ans;
		}
		else if (T == C) {
			string A = V.substr(0, i); if (A.size() == 0) A = "0";

			if (C == "0") {
				bool ok = false;
				for (int j = 0; j < A.size(); j++) { if (A[j] != '0') ok = true; }
				if (ok == true) {
					A = Minus(A);

					for (int j = i + C.size(); j < V.size(); j++) A += V[j];
					A = Plus(A);

					long long ans = calc(A);
					rem += ans;
				}
			}
			else {
				for (int j = i + C.size(); j < V.size(); j++) A += V[j];
				A = Plus(A);

				long long ans = calc(A);
				rem += ans;
			}
		}
		else {
			string A = V.substr(0, i); if (A.size() == 0) A = "0"; A = Plus(A);

			if (C == "0") {
				bool ok = false;
				for (int j = 0; j < A.size(); j++) { if (A[j] != '0') ok = true; }
				if (ok == true) {
					A = Minus(A);

					for (int j = i + C.size(); j < V.size(); j++) A += "0";

					long long ans = calc(A);
					rem += ans;
				}
			}
			else {
				for (int j = i + C.size(); j < V.size(); j++) A += "0";

				long long ans = calc(A);
				rem += ans;
			}
		}
		rem %= mod;
	}
	return rem;
}

int main() {
	cin >> A >> B >> C;

	long long V1 = 0; if (A != "0") { V1 = solve(Minus(A)); }
	long long V2 = solve(B); if (A == "0" && C == "0") V2++;
	cout << (V2 - V1 + mod) % mod << endl;
	return 0;
}


Measured memory_bytes: 3256
import java.util.Scanner;
public class Main{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        if(a<b && b<c) System.out.println("Yes");
        else System.out.println("No");

    }

}



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

int main() {
  int N;
  char S[100];
  bool yflg = false;
  cin >> N;

  for(int i = 0; i < N; i++) {
    cin >> S[i];
    if(S[i] == 'Y') yflg = true;
  }
  
  if(yflg) cout << "Four" << endl;
  else cout << "Three" << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)
func main(){
	var a , b float64

	fmt.Scan(&a , &b)
	// int(a)
	// int(b)
	// intb := int(b)
	// r = inta % intb
	fmt.Print(int(a) / int(b))
	fmt.Print(" ")
	fmt.Print(int(a) % int(b))
	fmt.Print(" ")
	fmt.Println(strconv.FormatFloat(a / b, 'f', -1, 64))
}


Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, m;
  cin >> n >> m;
  
  vl G[n];
  ll a, b;
  rep(_, m) {
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  for(ll i: G[0]) for(ll j: G[i]) {
    if(j==n-1) {cout << "POSSIBLE" << newl; return 0;}
  }
  
  cout << "IMPOSSIBLE" << newl;
  return 0;
}

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

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

    int ans = 0;
    for (int i = 0; i < S.length() - 1; i++)
    {
        if (S[i] == 'B' && S[i + 1] == 'W') ans++;
        else if (S[i] == 'W' && S[i + 1] == 'B') ans++;
    }

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,count=0,ans=30;
  cin >> n;
  for(int i = 0;i < n;++i){
    cin >> a;
    while(a%2==0){
      a /= 2;
      ++count;
    }
    if(ans>count){
      ans = count;
    }
      count = 0;
  }
  cout << ans << endl;
}

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

score = -1
for i in range(2**n):
    score_ = 0
    a = [0] * m
    for j in range(n):
        if (i >> j) & 1:
            for k in range(m):
                a[k] += v[j][k+1]
            score_ += v[j][0]
    if min(a) >= x:
        if score == -1:
            score = score_
        else:
            score = min(score_,score)
if score == -1:
    print(-1)
else:
    print(score)

Measured memory_bytes: 74308
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const long INF=1e18;
int main(){
	int N,M;cin>>N>>M;
	vector<int> vec[M];
	priority_queue<int> pq;
	int a,b;int ans=0;
	rep(i,0,N){
		cin>>a>>b;
		if(a<=M) vec[a-1].push_back(b);
	}rep(i,0,M){
		rep(j,0,vec[i].size()) pq.push(vec[i][j]);
		if(!pq.empty()){ ans+=pq.top();pq.pop(); }
	}cout<<ans<<endl;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int a,b,c;cin>>a>>b>>c;if(a==max(a,max(b,c)) )cout<<b+c<<endl;
  else if(b==max(a,max(b,c)) )cout<<a+c<<endl;
  else if(c==max(a,max(b,c)) )cout<<a+b<<endl;
  
}





Measured memory_bytes: 256
import bisect
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]*(N+1)
b = [0]*(M+1)

#累積和の計算
for i in range(1, N+1):
    a[i] = a[i-1] + A[i-1]
for j in range(1, M+1):
    b[j] = b[j-1] + B[j-1]

ans = 0
# j = M
for i in range(N+1):
#     left = 0
#     right = j
    if K - a[i] < 0:
        break
#     while left < right:
#         mid = (left + right)//2
#         if b[mid] < K - a[i]:
#             left = mid + 1
#         elif b[mid] > K - a[i]:
#             right = mid - 1
#     if b[left] <= K - a[i]:
#         j = left
#     else:
#         j = left - 1
    j = bisect.bisect_right(b, K - a[i]) - 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 118812
#include <iostream>

using namespace std;

#define MAX_N 100000

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

bool enough(int t) {
    long long cnt = 0;
    for (int i = 0; i < N; ++i) {
        long long top = (long long) h[i] - (long long) B * t;
        if (top <= 0) continue;
        cnt += top / (A - B);
        if (top % (A - B)) cnt++;
    }
    return cnt <= t;
}

int main(void) {
    cin >> N >> A >> B;
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }

    int lb = 0, ub = 1000000001;
    while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        if (enough(mid)) ub = mid;
        else lb = mid;
    }

    cout << ub << endl;
    return 0;
}

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

int main()
{
    int n, i, j;

    cin >> n;

    pair < double, double > a[n + 5];

    for(i = 0; i < n; i++){
        double x, y;
        cin >> x >> y;
        a[i].first = x;
        a[i].second = y;
    }

    double sum = 0.0, b, c;

    for(i = 0; i < n; i++){
        for(j = i + 1; j < n + i; j++){
            b = (a[i].first - a[j % n].first) * (a[i].first - a[j % n].first);
            c = (a[i].second - a[j % n].second) * (a[i].second - a[j % n].second);
            sum += sqrt(b + c);
        }
    }

    cout << setprecision(10) << fixed << sum / n << endl;

    return 0;
}


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

namespace DifferentDistribution {
    class Program {
        static void Main(string[] args) {
            var n = int.Parse(Console.ReadLine());
            var a = new int[n];
            var b = new int[n];
            int maxa = -1;
            var tmp = new int();
            for (int i = 0; i < n; i++) {
                var s = Console.ReadLine().Split();
                a[i] = int.Parse(s[0]);
                b[i] = int.Parse(s[1]);
                if (a[i] > maxa) {
                    maxa = a[i];
                    tmp = b[i];
                }
            }
            Console.WriteLine((maxa + tmp));
        }
    }
}

Measured memory_bytes: 17320
#include <iostream>
#include <string>

#define MAX 16777216

using namespace std;

bool dic[16777216];

int getStrNum(string str){
	int sum = 0, p=1;
	for(int i=0;i<str.size();++i){
		if(str[i] == 'A')sum += 1*p;
		else if(str[i] == 'C')sum += 2*p;
		else if(str[i] == 'G')sum += 3*p;
		else if(str[i] == 'T')sum += 4*p;
		p*=4;
	}
	return sum;
}

int main(){
	int n, i;
	cin >> n;
	
	string siji, _str;
	for(i=0;i<n;++i){
		cin >> siji >> _str;
		if(siji[0] == 'i'){
			dic[getStrNum(_str)]=true;
		}else{
			if(dic[getStrNum(_str)])cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4580
S = [i for i in input()]

def henkan(a):
    if a == "0":
        a = "1"
    else:
        a = "0"
    return a
    
ans = 0
a = 0
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        a = henkan(S[i+1])
        ans += 1
        S[i+1] = a
print(ans)

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

//DONT WASTE YOUR TIME
//prove yourself
//remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

const ll N= 1e6+55,mod = 1e9+7;

int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	string s;
	cin>>s;
	if((s[0]==s[1] && s[1]==s[2]) || (s[1]==s[2] && s[2]==s[3]) ){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}	
}

Measured memory_bytes: 256
(let* ((n (read-line))
       (len (length n))
       (a (make-array len  :initial-element #\1))
       (b (make-array len  :initial-element #\0)))
  (loop :for x :from 0 :upto (1- len) :by 2 :do(setf (aref a x) #\0))
  (loop :for x :from 0 :upto (1- len) :by 2 :do(setf (aref b x) #\1))
  (princ (min (loop :for x :from 0 :upto (1- len) :count(char= (aref a x) (aref n x)))
              (loop :for x :from 0 :upto (1- len) :count(char= (aref b x) (aref n x))))))

Measured memory_bytes: 16612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,a,b,A[200000],ans=0;
    cin>>n>>a>>b;
    rep(i,n) cin>>A[i];
    rep(i,n-1){
        if((A[i+1]-A[i])*a<=b) ans+=(A[i+1]-A[i])*a;
        else ans+=b;
    }
    cout<<ans;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int, int>pii;
typedef pair<int, pii>pi3;
ll mod = 1000000007;
char m[100][100];
bool flag[100][100];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
	int mx, my;
	cin >> mx >> my;
	int cnt = 0;
	for (int i = 1; i <= mx; i++)for (int j = 1; j <= my; j++)scanf(" %c", &m[i][j]), cnt += m[i][j] == '.';
	queue<pi3>que;
	que.push(make_pair(0, make_pair(1, 1)));
	for (;;)
	{
		if (que.empty())
		{
			printf("-1\n");
			return 0;
		}
		pi3 z = que.front();
		que.pop();
		int x = z.second.first, y = z.second.second;
		if (flag[x][y])continue;
		flag[x][y] = true;
		if (x == mx&&y == my)
		{
			printf("%d\n", cnt - z.first - 1);
			return 0;
		}
		for (int i = 0; i < 4; i++)
		{
			int nx = x + dx[i], ny = y + dy[i];
			if (m[nx][ny] == '.')que.push(make_pair(z.first + 1, make_pair(nx, ny)));
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <float.h>
#include <cfloat>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <errno.h>
#include <cerrno>
#include <assert.h>
#include <cassert> 
#include <map>
#include <memory.h>
#include <cctype>
#include <ctype.h>
#include <math.h>
#include <vector> 
#include <cstdio> 
#include <set>
#include <string.h>
#include <stdio.h>
#include <new>
#include <memory>
#include <cmath>
#include <queue>
#include <cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define mp make_pair 
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define pii pair<int,int>  
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{    
    int a, b, ans = 0;
    cin >> a >> b;
    
    if(a <= 0 && b >= 0)
    {
        cout << "Zero" << endl;
    }
    
    else if (a < 0 && b < 0)
    {
        if((b - a + 1) % 2 == 0)
            cout << "Positive" << endl;
            
        else 
            cout << "Negative" << endl;
    }
    
    else
    {
        cout << "Positive" << endl;
    }
    return 0;
}

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

const int MOD = int(1e9) + 7;
using lint = long long;

struct modint {
  int v;
  modint(long long v_ = 0): v(v_ % MOD) { }
  modint operator+ (modint other) {
    return modint(v + other.v);
  }
  modint operator- (modint other) {
    return modint(v - other.v + MOD);
  }
  modint operator* (modint other) {
    return modint((lint)v * other.v % MOD);
  }
  modint operator+= (modint other) {
    (v += other.v) %= MOD;
    return *this;
  }
  modint operator*= (modint other) {
    v = ((lint)v * other.v) % MOD;
    return *this;
  }
  modint operator-= (modint other) {
    (v += MOD - other.v) %= MOD;
    return *this;
  }
};

int H, W, A, B;

const int MX = int(2.1e5);
modint fac[MX+1], inv[MX+1], invfac[MX+1];

modint comb (int n, int r) {
  return fac[n] * invfac[r] * invfac[n-r];
}

modint ways (int h, int w) {
  return comb(h + w - 2, h - 1);
}

modint ans;

int main() {
  fac[0] = 1;
  fac[1] = 1;
  inv[1] = 1;
  invfac[0] = 1;
  invfac[1] = 1;
  for(int i = 2; i <= MX; i++) {
    fac[i] = fac[i-1] * i;
    inv[i] = inv[MOD % i] * (MOD - MOD / i);
    assert((inv[i] * i).v == 1);
    invfac[i] = invfac[i-1] * inv[i];
  }

  scanf("%d%d%d%d", &H, &W, &A, &B);

  ans = ways(H, W);
  for(int j = 1; j <= B; j++) {
    ans -= ways(H - A, j) * ways(A, W - j + 1);
  }

  printf("%d\n", ans.v);
  return 0;
}

Measured memory_bytes: 2688
import math

N=int(input())

def dig(x,d):
  return int((x%(10**(d+1)))/(10**d))

D=int(math.log10(N))

ans=0

for bits in range(int(2**D)):
  ans+=dig(N,0)
  j=1
  for i in range(1,D+1):
    if (bits>>(i-1))&1:
      j=0
    ans+=int(dig(N,i)*(10**j))
    j+=1
print(int(ans))

Measured memory_bytes: 40432
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

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

    int x[n];
    int y[n];
    for (int i = 0; i< n; i++)
    {
        cin >> x[i] >> y[i];
    }

    // the num of edge 
    int numOfEdge = n * (n - 1) / 2;

    
    // total edges
    int totalEdge = 1;
    int totalPattern = 1;
    for (int i = 1; i <= n; i++)
    {
        totalPattern *= i;
    }
    int pathEdge = n - 1;
    totalEdge = totalPattern * pathEdge;

    int averageEachEdge = totalEdge / numOfEdge;


    // Amount of total edges
    float amount = 0.0f;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i == j) continue;
            float dist = sqrt(pow(abs(x[i] - x[j]), 2.0f) + pow(abs(y[i] - y[j]), 2.0f));
            amount += dist;
        }
    }
    amount /= 2.0f;

    std::cout<<std::fixed<<std::setprecision(10);
    cout << amount * averageEachEdge / totalPattern << endl;

    return 0;
}


Measured memory_bytes: 256