akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

/* !! ATTENTION !!
    MAX_V & infを初期化して
 */

const int MAX_V = 100000;
const int inf = 1<<29;


// 辺を表す構造体 (行き先、　容量、　逆辺) 逆辺はインデックスでもつ
struct edge { int to, cap, rev; };

vector<edge> G[MAX_V]; // グラフの隣接リスト
int level[MAX_V]; // sからの距離(bfsで使う)
int iter[MAX_V]; // どこまで調べ終わったか(dfsで使う)

// add edge of cap which "from -> to"
void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)(G[from].size()-1)});
}

// calculate min Distance from start with bfs
void bfs(int s){
    memset(level, -1, sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(int i=0; i<G[v].size(); i++){
            edge &e = G[v][i];
            if(e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v]+1;
                que.push(e.to);
            }
        }
    }
}

// find increasing path with dfs
int dfs(int v, int t, int f){
    if(v == t) return f;
    for(int &i=iter[v]; i<G[v].size(); i++){
        edge &e = G[v][i];
        if(e.cap > 0 && level[v] < level[e.to]){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        bfs(s);
        if(level[t] < 0) return flow;
        memset(iter, 0, sizeof(iter));
        int f;
        while((f=dfs(s, t, inf)) > 0){
            flow += f;
        }
    }
}

int main(){

    int N; cin >> N;
    vector<pair<int, int>> a(N), b(N);
    for(int i=0; i<N; ++i) cin >> a[i].first >> a[i].second;
    for(int i=0; i<N; ++i) cin >> b[i].first >> b[i].second;

    // 0:start, 1~N:red, N+1~2*N:blue, 2*N+1:tink
    for(int i=0; i<N; ++i) add_edge(0, i+1, 1);
    for(int i=0; i<N; ++i) add_edge(N+i+1, 2*N+1, 1);

    for(int i=0; i<N; ++i){
        for(int j=0; j<N; ++j){
            if(a[i].first < b[j].first && a[i].second < b[j].second){
                add_edge(i+1, N+j+1, 1);
            }
        }
    }

    cout << max_flow(0, 2*N+1) << endl;

}


Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<iomanip>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
int N,a[100001];
int main(){
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];
    vector<int> left(N+1,0),right(N+1,0);
    for(int i = 0; i < N; i++) left[i+1] = GCD(left[i],a[i]);
    for(int i = N-1; i >= 0; i--) right[i] = GCD(right[i+1],a[i]);
    int res = 0;
    for(int i = 0; i < N; i++){
        int l = left[i];
        int r = right[i+1];
        chmax(res,GCD(l,r));
    }
    cout << res << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;

map<string, int> mp[32];
vector<pair<int, string> >arr;
string str;

void init(void);

int main()
{
    int n;
    char ch;

    while (cin >> n, n != 0) {
        init();
        
        for (int i = 0; i < n; i++) {
            ch = '\0';

            while (ch != '\n') {
                cin >> str;
                mp[str[0] - 'a'][str]++;

                ch = getchar();
            }

        }

        ch = getchar();

        if (mp[ch - 'a'].size() == 0) {
            cout << "NA\n";
            continue;
        }

        for (auto x : mp[ch - 'a']) {
            arr.push_back(pair<int, string>{-1 * x.second, x.first});
        }

        sort(arr.begin(), arr.end());

        int f = 0;
        for (int i = 0; i < arr.size() && i < 5; i++) {
            if (f) cout << ' ';
            cout << arr[i].second;

            f = 1;
        }
        cout << '\n';
    }

    return 0;
}

void init(void)
{
    /*
    map<string, int> mp[32];
    vector<pair<int, string> >arr;
    string str;
    */

    for (int i = 0; i < 32; i++) {
        mp[i].clear();
    }

    arr.clear();

    return;
}



Measured memory_bytes: 3204
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int N, K;
int res;
vvi e;
vi used;
vi fact;

const int MAX = 510000;
// Calculate COM(MAX, k) for k<=MAX by O(1) after COMinit() by O(MAX)
// {{{
ll fac[MAX], finv[MAX], inv[MAX];

// 前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
ll COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//}}}

int dfs(int x){
  // xの子供の塗り分け方
  used[x] = 1;
  int cnt = 0;
  rep(i, sz(e[x])){
    if (used[e[x][i]]!=1){
      cnt++;
    }
  }
  // dump(x, cnt, res);
  if (cnt==0) return 0;

  if (x==0){
    res *= COM(K-1, cnt) * fact[cnt] % MOD;
  }
  else{
    res *= COM(K-2, cnt) * fact[cnt] % MOD;
  }
  res %= MOD;
  // dump(x, cnt, res);

  rep(i, sz(e[x])){
    if (used[e[x][i]]!=1){
      dfs(e[x][i]);
    }
  }

  return 0;
};

int solve(){
  cin>>N>>K;

  e = vvi(N, vi());
  rep(i, N-1){
    int a,b;cin>>a>>b;
    a--;b--;
    e[a].pb(b);
    e[b].pb(a);
  }
  dump(e);


  COMinit();
  fact = vi(100001, 0);
  fact[1] = 1;
  res = K;
  rep(i, 2, 100001){
    fact[i] = fact[i-1] * i % MOD;
  }
  used = vi(N, 0);

  dfs(0);

  dump(used);
  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 21632
def main():
    N = int(input()) + 2
    A = list(map(int, input().split()))
    A.insert(0, 0)
    A.append(0)
    D = sum([abs(A[i + 1] - A[i]) for i in range(N - 1)])
    for i in range(1, N - 1):
        print(D - abs(A[i - 1] - A[i]) -
              abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1]))


main()


Measured memory_bytes: 14044
def main():
    n = int(input())
    b=list(map(int,input().split(' ')))
    ans = 0
    for i in range(n):
        if i ==0:
            ans += b[0]
        elif i == n-1:
            ans += b[-1]
        else:
            ans += min(b[i-1],b[i])
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	char a,b;
	scanf("%c %c",&a,&b);
	if(a=='H' && b=='D')
		printf("D");
		else if(a=='H' && b=='H')
			printf("H");
			else if(a=='D' && b=='H')
				printf("D");
				else
					printf("H");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=3e5;
int n,m,a[N],b[N];
struct tt{int x,y;friend bool operator < (tt aa,tt bb)
{if(aa.y!=bb.y)return aa.y<bb.y;else return aa.x<bb.x;}};
priority_queue<tt>q;
int pre(int x){if(x==1)return n;return x-1;}
int nxt(int x){if(x==n)return 1;return x+1;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		if(b[i]<a[i])return puts("-1"),0;
		else if(b[i]>a[i])q.push((tt){i,b[i]});
	}long long ans=0;
	while(!q.empty())
	{
		int i=q.top().x,qq=pre(i),hj=nxt(i);q.pop();//cout<<i<<" "<<b[i]<<endl;
		if(b[i]<a[i])return puts("-1"),0;if(b[i]==a[i])continue;
		if(b[i]-b[qq]-b[hj]<a[i])return puts("-1"),0;
		ans+=(b[i]-a[i])/(b[qq]+b[hj]);b[i]-=(b[i]-a[i])/(b[qq]+b[hj])*(b[qq]+b[hj]);q.push((tt){i,b[i]});
	}
	cout<<ans;
}


Measured memory_bytes: 3700
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stdio.h>
#include <fstream>
#include <cmath>
#include <stdlib.h>
#include <iomanip>
#include <algorithm>
#include <limits.h>
#include <stack>
#include <cmath>
#include <math.h>
#include <array>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false);
#define DEBUG_VIS(x) cerr<<"vis "<<x<<endl;
#define DEBUG_REACH cerr<<"reach here"<<endl;
#define DEBUG_SEQ(x) cerr<<x<<" ";
#define SET_ZERO(x) memset(x,0,sizeof(x));
#define SET_NEGONE(x) memset(x,-1,sizeof(x));
#define SET_INF(x) memset(x,127,sizeof(x));
#define SET_NEGINF(x) memset(x,128,sizeof(x));
#define IS_INF(x) x < 2100000000
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<double,double> pdd;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
const int maxn = 1e6 + 10;
template <class T> T mymin(const T a,const T b){return a < b ? a : b;}
template <class T> T mymax(const T a,const T b){return a > b ? a : b;}
int A,B,C,X,Y;



int main(){
    FAST_IO
    cin>>A>>B>>C>>X>>Y;
    if(2 * C > A + B) cout<<A * X + B * Y<<endl;
    else cout<<min(min(X,Y) * C * 2 + (X - min(X,Y)) * A + (Y - min(X,Y)) * B,max(X,Y) * C * 2)<<endl;
    return 0;
}


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

using namespace std;

int gcd(int a, int b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}

int main() {
	int X;
	cin >> X;
	cout << lcm(X, 360)/X <<endl;



	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n)
{
	vector<pair<ll, ll>> p;
	for (ll i = 2; i * i <= n; i++)
	{
		if ((n % i) != 0)
			continue;
		pair<ll, ll> a = make_pair(i, 0);
		while ((n % i) == 0)
		{
			n /= i;
			a.second += 1;
		}
		p.push_back(a);
	}

	if (n != 1)
		p.push_back(make_pair(n, 1));
	return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a)
{
	ll b = MOD, u = 1, v = 0;
	while (b)
	{
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0)
	{
		u += MOD;
	}
	return u;
}
// 順列
ll permutation(const ll n, const ll m)
{
	ll result = 1;
	for (ll i = n; i > n - m; i--)
	{
		result = (result * i) % MOD;
	}
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x)
{
	if (x == 0)
		return 1;
	ll res = repeat_square(n, x / 2);
	res = res * res % MOD;
	if ((x % 2) == 1)
		res = res * n % MOD;
	return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m)
{
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++)
	{
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

int main() {
	vector<int> x(5);
	rep(i, 5) cin >> x[i];

	rep(i, 5) {
		if (x[i] == 0) {
			cout << i+1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3620
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    x = int(input())
    t = 100
    cnt = 0
    while t < x:
        t *= 1.01
        t = math.floor(t)
        cnt += 1
    print(cnt)


main()


Measured memory_bytes: 63332
import numpy as np

def ii():
    return int(input())


def lii():
    return list(map(int, input().split(' ')))


def lvi(N):
    l = []
    for _ in range(N):
        l.append(ii())
    return l


def lv(N):
    l = []
    for _ in range(N):
        l.append(input())
    return l


def main():
    N = ii()
    A = []
    for _ in range(N):
        a = ii()
        A.append(a)

    ans = 0
    if A[0] != 0:
        return -1

    for i in range(1, N):
        diff = A[i] - A[i-1]
        if diff == 1:
            pass
        elif diff == 0:
            ans += A[i-1]
        elif diff > 1:
            return -1
        else:
            ans += A[i-1]

    ans += A[-1]

    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 20284
table = Array.new(51,0)
a = b = c = d = 10

a.times do |a|
  b.times do |b|
    c.times do |c|
      d.times do |d|
        table[a+b+c+d] += 1
      end
    end
  end
end

while n = gets do
  if n == nil then
    break
  end

  puts table[n.to_i]
end

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

using ll = long long; 

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

  vector <int> X(N);
  for (int i=0; i<N; ++i){
    cin >> X.at(i);
  }

  sort(X.begin(), X.end());
  ll dist_old = 10001000;
  ll dist_new;
  for (int i=X.at(0); i<=X.at(N-1); ++i){
    dist_new = 0;
    for (int j=0; j<N; ++j) {
      dist_new += (X.at(j)-i) * (X.at(j)-i); 
    }
    if (dist_new < dist_old) {
      dist_old = dist_new;
    }
  }

  cout << dist_old << endl;  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)x)<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define EREP(i,a,b) for(int i=a;i<=b;i++)
#define erep(i,n) EREP(i,0,n)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

#define MAX 502
#define INF INT_MAX

int n; //m[h
int cap[MAX][MAX]; //¬¹éÊÌãÀ
bool used[MAX]; //dfsp

//m[hv©çtÖü©ÁÄ, fÈºÌlÅÚ¢ÁÏ¢¬¹é¾¯¬·
int dfs(int v , int t, int f){
  if(v == t) return f; //S[És«Â¢½ç, »ÌpXÖf¬¹é
  used[v] = true;

  //ÂÈªéGbWT·
  rep(i,n){
    int c = cap[v][i];
    if(!used[i] && c > 0){
      int d = dfs(i , t , min(f, c)); //i©çtÖü©ÁÄ, Åå¬ßé
      if(d > 0){ //1Èã¬¹éÈç¬·
        cap[v][i] -= d; //v©çiÖÌeÊª¸é
        cap[i][v] += d; //i©çvÖÌeÊÍ¦é
        return d;
      }
    }
  }
  return 0;
}

//s©çtÖÌÅå¬ðßé
int mf(int s, int t){
  int flow = 0;

  //s©çtÖü©ÁÄ, ª¬¹éÀè, ¬·
  for(;;){
    memset(used , 0 , sizeof(used));
    int f = dfs(s,t,INF);
    if(f == 0) return flow;
    flow += f;
  }
}

int main(void){
  int e,q;

  while(scanf("%d%d%d",&n,&e,&q) != EOF){
    memset(cap,-1,sizeof(cap)); //ÓÌÈ¢êÍ, -1Æ·é

    rep(i,e){
      int from,to;
      scanf("%d%d",&from,&to);
      from--;
      to--;
      cap[from][to] = cap[to][from] = 1;
    }

    int res = mf(0,n-1); // ç©¶ßÅå¬ðoµÄ, c]OtðßÄ¨­

    while(q--){
      int flg,a,b;
      scanf("%d%d%d",&flg,&a,&b);
      a--;
      b--;

      //ÓðÇÁ·éÆ«
      if(flg == 1){
        cap[a][b] = cap[b][a] = 1; //a<->bÌÓðÇÁ
        memset(used,0,sizeof(used));
        res += dfs(0,n-1,INF); //Åå¬ðsÁÄ, V½É
      }
      //ÓðÁ·Æ«
      else{
        if(cap[a][b] != 1){
          if(cap[a][b] != 0) swap(a,b);
          memset(used,0,sizeof(used));
          int tmp = dfs(a,b,1);
          if(tmp != 1){
            memset(used,0,sizeof(used));
            dfs(a,0,1);
            memset(used,0,sizeof(used));
            dfs(n-1,b,1);
            res--;
          }
        }
        cap[a][b] = cap[b][a] = -1;
      }
      printf("%d\n",res);
    }
  }
}

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

int main()
{
    int n;
    cin >> n;
    for(int i=1; i<=n; ++i)
    {
        if(i%3 == 0) cout << " " << i;
        else if(i%10 == 3 || i%100/10 == 3 || i%1000/100 == 3 || i%10000/1000 == 3) cout << " " << i;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3112
s = [str(input())]

l = []

for i in range(4):
  l.append(ord(s[0][i]))
  
cl = sorted(l)

if cl[0] == cl[1] == cl[2]:
  print('No')
elif cl[0] == cl[1] and cl[2] == cl[3]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(long int I=X;I<Y;I++)
#define REP(I,X) for(long int I=X;I>=0;I--)
#define INF 1e9+7
using namespace std;

int main(){
  int N,a;
  cin >> N;
  long int ans = 0;
  FOR(i,0,N){
    cin >> a;
    ans += a;
    ans--;
  }
  cout << ans << endl;
}


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

int main() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	
	double ad = (h*60.0+m)/720.0;
	double bd = m/60.0;
	double diff = min(abs(bd-ad),1.0-abs(bd-ad));

	double ansans = a*a + b*b - 2.0*a*b*cos(diff*2.0*M_PI);
	double ans = sqrt(ansans);

	printf("%.12lf",ans);
}

Measured memory_bytes: 4176
N = int(input())
A = list(map(int,input().split()))

from collections import Counter

A_=Counter(A)
A_.most_common()

Rectangle = [_ for _ in A_.keys() if A_[_] >1]
sq_list=[_ for _ in A_.keys() if A_[_] >= 4]

Rectangle.sort()
sq_list.sort()

ans=0

if len(Rectangle) >= 2:
    a_1 = Rectangle[-1]
    a_2 = Rectangle[-2]
    ans = a_1*a_2
    
if len(sq_list) >= 1:
    s_1 = sq_list[-1]
    if ans < s_1**2:
        ans=s_1**2

print(ans)

Measured memory_bytes: 104028
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a+b)
        cout<<min(a,k)<<endl;
    else
        cout<<2*a+b-k<<endl;
    return 0;
}



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

int K;
string str;
string remake;

int main() {
/*
  vector<int> data(5);
  for (int i = 0; i < 5; i++) {
    cin >> data.at(i);
  }
*/
cin >> K;
cin >> str;

if(str.size()<=K){
    cout << str << endl;
}
else{
    remake = str.substr(0,K);
    cout << remake << "..." << endl;
}
  
}


Measured memory_bytes: 3624
const Main = (input) => {
  // 入力値の整形
  input = input.split(' ').map((num) => {
    return parseInt(num);
  });

  // 計算 制約として、input[1] (Y)は偶数のためMath.flow()は必要なし
  const result = input[0] + input[1] / 2;
  console.log(result);
};

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
// Main('81 58');


Measured memory_bytes: 7372
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if (a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
  return 0;
}


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

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

	int64_t ans = 0;

	for (int64_t i = 1; i <= n; i++)
	{
		if ((i % 3 != 0) && (i % 5 != 0))
		{
			ans += i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3652
while True:
    n = int(input())
    if n == 0: break
    a = list(range(n+1))
    a[:4] = [1, 1, 2, 4]
    for i in range(4, n+1):
        a[i] = a[i-1] + a[i-2] + a[i-3]
    print(a[n]//3650 + bool(a[n]%3650))


Measured memory_bytes: 5592
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <set>
#include <map>
#include <math.h>
#include <bitset>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

typedef long long ll;

const ll INF = 1e18, MOD = 1e9 + 7;
const int INT_MAX = 1e9;

ll n, m;

ll d[100000], h[100000];

int main () 
{
	cin >> n;

	for (int i = 0; i < n; i++)
		scanf ("%lld", &h[i]);

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

	for (int i = 2; i < n; i++)
		d[i] = min (d[i-1] + abs (h[i] - h[i-1]), d[i-2] + abs (h[i] - h[i-2]));

	cout << d[n-1];
}

Measured memory_bytes: 1792
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

S = input()

n1 = S[::2].count("0")+S[1::2].count("1")
n2 = S[::2].count("1")+S[1::2].count("0")

ans = len(S)-max(n1,n2)
print(ans)

Measured memory_bytes: 12452
n=int(input())
a=list(map(int,input().split()))
q=int(input())
b=[0]*q
c=[0]*q
for i in range(q):
  b[i],c[i]=map(int,input().split())

s=sum(a)

#このコードはO(10**10)になる可能性があり、重すぎる
"""
for i in range(q):
  while b[i] in a:
    s+=c[i]-b[i]
    a.remove(b[i])
    a.append(c[i])
  print(s)
"""

cnt_list=[0]*(10**5+1)
for i in range(n):
  cnt_list[a[i]]+=1

for i in range(q):
  s+=(c[i]-b[i])*cnt_list[b[i]]
  cnt_list[c[i]]+=cnt_list[b[i]]
  cnt_list[b[i]]=0
  print(s)

Measured memory_bytes: 85968
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, a: f64, b: f64, n: f64);
    let x = if n >= b - 1. { b - 1. } else { n };
    println!("{}", (a * (x / b)).floor() as usize);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2660
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 1024;

int n;
char a[MAX], b[MAX], c[MAX];

int main(void) {
	//in = fopen("B.in", "rt");
	
	fscanf(in, "%d", &n);
	fscanf(in, "%s %s %s", a, b, c);
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
	    if (a[i] == b[i] && a[i] == c[i]) {
	        continue;
        }
        if (a[i] == b[i] || a[i] == c[i] || b[i] == c[i]) {
            ans++;
            continue;
        }
        ans += 2;
    }
    fprintf(out, "%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

void solve(string s){
    vector<int> a(8);
    for (int i = 0; i < 9; ++i) {
        int y = i/3, x = i%3;
        int val = (s[i] == 'o' ? 0 : (s[i] == 'x' ? 1 : -100));
        a[y] += val; a[x+3] += val;
        if(y == x) a[6] += val;
        else if(y == 2-x) a[7] += val;
    }
    for (int i = 0; i < 8; ++i) {
        if(a[i] == 0) {
            puts("o");
            return;
        }else if(a[i] == 3){
            puts("x");
            return;
        }
    }
    puts("d");
}

int main() {
    string s;
    while(cin >> s){
        solve(s);
    }
    return 0;
}


Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
int N;
int cnt;
vector<tuple<int,int,int>>vt;

int main(){
  cin>>N;
  int l = floor(log2(N));
  int high = 1<<l;
  int x=1;
  while(high/=2){
    vt.push_back(make_tuple(x,x+1,0));
    vt.push_back(make_tuple(x,x+1,high));
    x++;
  }
  high = 1<<l;
  int cur = high;
  x=2;
  while(high/=2){
    if(cur+high<=N){
      vt.push_back(make_tuple(1,x,cur));    
      cur+=high;
    }
    x++;
  }
  cout<<l + 1<<' '<<vt.size()<<'\n';
  for(auto& tp:vt){
    cout<<get<0>(tp)<<' ';
    cout<<get<1>(tp)<<' ';
    cout<<get<2>(tp)<<'\n';
  }
  return 0;
}

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

int main(){
  int n; cin >> n;
  int h[n];
  
  int max=0; int count=0;
  for(int i=0; i<n; i++){
    cin >> h[i];
    if(h[i]>=max){
      count++;
      max = h[i];
    }
  }
  
  cout << count;
  
  return 0;
}

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

int main(){
    while(1){
    string str;
    cin >> str;
    if(str =="0"){
     break;
    }
     int sum=0;
   for (int i =0;i<(int)str.size();i++){
       sum +=str[i]-'0';
    }
   cout <<sum<<endl;
   }
    return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main(){
int N=0; 
int K=0;
int ans=1;
cin>>N>>K;
int buf=0;
buf=K;
  
while(buf<=N){
  buf=buf*K;
  ans++;
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <typeinfo>

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REP1(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define all(x) (x).begin(),(x).end()
*/

using namespace std;

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

    int a, b, x;
    cin >> a >> b >> x;

    if (a <= x && x <= a + b)
        cout << "YES";
    else
        cout << "NO";
}

Measured memory_bytes: 256
l1=[1,3,5,7,8,10,12]
l2=[4,6,9,11]
l3=[2]

a,b=map(int,input().split())
if a in l1 and b in l1:
  print("Yes")
elif a in l2 and b in l2:
  print("Yes")
elif a in l3 and b in l3:
  print("Yes")
else:
  print("No")

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


string s;
bool used[26];
int main(){


    cin >> s;
    for(char c : s){
        used[c-'a'] = true;
    }


    if((int)s.size() != 26){

        for(int j = 0; j < 26; j++){
            if(!used[j]){
                s += (j + 'a');
                cout << s << endl;
                break;
            }
        }


        return 0;
    }
    // 末尾から計算していく
    for(int i = (int)s.size()-1;i>=0;i--){
        // s[i]より後で使えるアルファベットがあるか調べる
        used[s[i]-'a']=false;
        int idx = -1;
        for(int j = s[i]-'a'+1; j < 26; j++){
            if(!used[j]){
                // みつかった場合、それに置き換えて終了
                idx = j;
                break;
            }
        }
        if(idx != -1){
            used[idx] = true;
            string ans = s.substr(0, i);
            ans += (idx + 'a');
            // for(int j = 0; j < 26; j++){
            //     if(!used[j]){
            //         ans+= (j + 'a');
            //     }
            // }
            cout << ans << endl;
            return 0;
        }
        else{
            if(i == 0){
                cout << -1 << endl;
                return 0;
            }
        }
    }


    return 0;
}


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

using namespace std;
 
int main() {
    string s,t;cin>>s>>t;
    int matu  =s.length()-1;
    for(int i = 0;i<=1000;i++){
        char ss  =s[matu];
        char ms[matu+1];
        for(int j = 0;j<matu+1;j++) ms[j] = s[j];
        for(int k = 0;k<matu;k++){
        	s[k+1] = ms[k];
        }
        s[0] = ss;
    
        //cout<<s<<endl;
      if(s == t){
      	cout<<"Yes";
        return 0;
      }
    } 
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int a, b, c;
   cin >> a >> b >> c ;
   if(a == b){
       cout << c << endl;
   }
   else if (a == c){
       cout << b << endl;
   }
   else{
       cout << a << endl;
   }
}

Measured memory_bytes: 3616
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int a;
    int b;
    int c;
    cin >> a >> b >> c;
    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end()), sort(t.begin(), t.end());


    int ls = s.size(), lt = t.size();
    int length;
    if (ls < lt) {
            length = ls;
    } else {
            length = lt;
    }
    
    
    for (int i = 0; i < length; i++) {
        if (s[i] < t[lt - i - 1]) {
            cout << "Yes" << endl;
            return 0;
        }
        else if (s[i] > t[lt - i - 1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    if (ls < lt) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
class Dice:
    def __init__(self, faces = None):
        self.dice = {'N':2, 'E':4, 'S':5, 'W':3}
        self.faces = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6}
        self.currTop = 1
        if faces is not None:
            self.faces = faces

    def top(self):
        return self.currTop

    def topFace(self):
        return self.faces[self.currTop]

    def bottom(self):
        return 7 - self.currTop

    def bottomFace(self):
        return self.faces[self.bottom()]

    def rot(self, direction):
        newTop = self.dice[direction]
        currTop = self.currTop
        self.currTop = newTop
        if direction == 'N':
            self.dice['N'] = 7 - currTop
            self.dice['S'] = currTop
        elif direction == 'S':
            self.dice['N'] = currTop
            self.dice['S'] = 7 - currTop
        elif direction == 'E':
            self.dice['E'] = 7 - currTop
            self.dice['W'] = currTop
        elif direction == 'W':
            self.dice['E'] = currTop
            self.dice['W'] = 7 - currTop

    def yaw(self, direction):
        newDice = {}
        if direction == 'E':
            newDice['N'] = self.dice['E']
            newDice['E'] = self.dice['S']
            newDice['S'] = self.dice['W']
            newDice['W'] = self.dice['N']
        if direction == 'W':
            newDice['N'] = self.dice['W']
            newDice['E'] = self.dice['N']
            newDice['S'] = self.dice['E']
            newDice['W'] = self.dice['S']
        self.dice = newDice

def compareDice(d1, d2):
    d2indexes = [d2index for d2index,d2face in d2.faces.items() if d1.topFace() == d2face]

    for d2topIndex in d2indexes:
        if dbg: print('d2topIndex:%d' % (d2topIndex) )

        # search d1.topFace() in d2 and rotate to make d2.topFace() equal to d1.topFace().
        key = [k for k,v in d2.dice.items() if d2topIndex == v]
        if len(key) == 0:
            d2.rot('N')
            key = [k for k,v in d2.dice.items() if d2topIndex == v]
        d2.rot(key[0])

        if d1.topFace() != d2.topFace() or d1.bottomFace() != d2.bottomFace():
            continue

        # rotate(yaw) to make frontIdx front.
        cnt = 0
        while True:
            if dbg: print('cnt:%d' % (cnt) )
            if cnt > 4:
                break
            d2.yaw('E')
            cnt += 1

            # compare two dices.
            d1State = {k:d1.faces[v] for k,v in d1.dice.items()}
            d2State = {k:d2.faces[v] for k,v in d2.dice.items()}
            if d1State == d2State:
                return True

    return False

dbg = False

n = int(input())
dices = []

for i in range(n):
    faces = {k:v for k,v in zip(range(1,7), map(int, input().split()))}
    dices.append(Dice(faces))

for i in range(n):
    for j in range(i+1,n):
        if dbg: print('%d-%d' % (i,j) )
        ret = compareDice(dices[i], dices[j])
        if dbg: print(ret)
        if ret == True:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 8004
N = int(input())
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(A[N-1])

Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())

int main(void){
  int n;
  while(cin>>n,n){
    vector<PII> time(n);
    vector<int> weight(n);
    REP(i,n){
      cin>>weight[i]>>time[i].first>>time[i].second;
    }
    REP(i,n)FOR(j,i+1,n){
      if(time[i]>time[j]){
        swap(time[i],time[j]);
        swap(weight[i],weight[j]);
      }
    }
    int sumw = 0;
    bool on[101]={};
    bool ok = true;
    REP(i,n){
      int now = time[i].first;
      REP(j,n){
        if(on[j]&&time[j].second<=now){
          on[j] = false;
          sumw -= weight[j];
        }
      }
      on[i] = true;
      sumw += weight[i];
      if(sumw>150){
        ok = false;
        break;
      }
    }
    if(ok)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
/*
 * 0609.cc: Christmas Party
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_M = 100;

/* typedef */

/* global variables */

int as[MAX_M], scs[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < m; i++) (cin >> as[i]), as[i]--;

  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) {
      int bj;
      cin >> bj;
      bj--;

      if (as[i] == bj) scs[j]++;
      else scs[as[i]]++;
    }

  for (int i = 0; i < n; i++) printf("%d\n", scs[i]);
  return 0;
}

Measured memory_bytes: 1144
class Sender:

    def __init__(self):
        self.queue = {}
        self.dict = {
            "Vacant": 0,
            "Male": 1,
            "Female": 2
        }

    def send(self, x) -> bool:
        print(x, flush=True)
        self.queue[x] = self.dict[input()]
        return self.queue[x] == 0

    def compare(self, x, y) -> bool:
        return self.queue[x] == self.queue[y]


n = int(input())
s = Sender()

if s.send(0):
    exit()
if s.send(n - 1):
    exit()
l, r = 0, n-1
m = (n - 1) // 2
q = 2

while not s.send(m):
    q += 1
    if q == 20:
        break
    if ((r - m) % 2 == 0 and not s.compare(r, m)) or ((r - m) % 2 == 1 and s.compare(r, m)):
        l, r = m, r
        m = (r + m) // 2

    else:
        l, r = l, m
        m = (m + l) // 2


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

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

// ref. http://tsutaj.hatenablog.com/entry/2017/03/30/224339
// ref. http://beet-aizu.hatenablog.com/entry/2017/12/01/225955
// ref. https://ei1333.github.io/luzhiled/snippets/structure/segment-tree.html
template< typename Monoid, typename OperatorMonoid = Monoid >
struct LazySegmentTree {
  int sz, height;
  vector< Monoid > data;
  vector< OperatorMonoid > lazy;
  const Monoid M1;
  const OperatorMonoid OM0;

  // M1: mempty for Monoid
  // OM0: mempty for OperatorMonoid
  LazySegmentTree(int n, const Monoid &M1, const OperatorMonoid OM0)
      : M1(M1), OM0(OM0) {
    sz = 1;
    height = 0;
    while(sz < n) sz <<= 1, height++;
    data.assign(2 * sz, M1);
    lazy.assign(2 * sz, OM0);
  }

  void set(int k, const Monoid &x) {
    data[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      data[k] = f(data[2 * k + 0], data[2 * k + 1]);
    }
  }

  inline void eval(int len, int k) {
      if (lazy[k] == OM0) return;
      if (k * 2 + 1 < sz * 2 - 1) {
          lazy[k * 2 + 1] += lazy[k];
          lazy[k * 2 + 2] += lazy[k];
      }
      data[k] += lazy[k] * len;
      lazy[k] = OM0;
  }

  Monoid update(int a, int b, const OperatorMonoid &x) {
      return update(a, b, x, 0, 0, sz);
  }

  Monoid update(int a, int b, const OperatorMonoid &x, int k, int l, int r) {
      int len = r - l;
      eval(len, k);
      if (r <= a || b <= l) return data[k];
      if (a <= l && r <= b) {
          lazy[k] += x;
          return data[k] + lazy[k] * len;
      }
      return data[k] =
          update(a, b, x, k * 2 + 1, l, (l + r) / 2) +
          update(a, b, x, k * 2 + 2, (l + r) / 2, r);
  }

  Monoid query(int a, int b) {
      return query(a, b, 0, 0, sz);
  }

  Monoid query(int a, int b, int k, int l, int r) {
      int len = r - l;
      eval(len, k);
      if (r <= a || b <= l) return M1;
      if (a <= l && r <= b) return data[k];
      Monoid vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      Monoid vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return vl + vr;
  }
};

const int INF = INT_MAX;

int main(void) {
    int n, q;
    cin >> n >> q;

    LazySegmentTree<ll, ll> st(n, 0, 0);

    for (int i = 0; i < q; i++) {
        int op, s, t, x;
        cin >> op;
        if (op == 0) {
            cin >> s >> t >> x;
            st.update(s - 1, t, x);
        } else {
            cin >> s >> t;
            cout << st.query(s - 1, t) << endl;
        }
    }

    return 0;
}




Measured memory_bytes: 7028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}



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

const int N=1e6+10;

int n;
int a[N];
int state=2;
bool primes[N];
int q[N];

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

int main(){
    scanf("%d",&n);
    int now_gcd;
    for(int i=0;i<n;++i){
        int t;
        scanf("%d",&t);
        q[i]=t;
        a[t]++;
    }
    memset(primes,true,sizeof(primes));
    primes[1]=false;
    for(int i=2;i<N;++i){
        if(primes[i]==false) continue;
        int cnt=0;
        cnt+=a[i];
        for(int j=2;i*j<N;++j){
            primes[i*j]=false;
            cnt+=a[i*j];
            if(cnt>1) state=1;
        }
    }
    now_gcd=gcd(q[0],q[1]);
    for(int i=2;i<n;++i){
        now_gcd=gcd(now_gcd,q[i]);
    }
    if(now_gcd!=1) state=0;

    if(state==0) printf("not coprime\n");
    else if(state==1) printf("setwise coprime\n");
    else printf("pairwise coprime\n");
    return 0;
}

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

void Main()
{
    long d, t, s;
    cin >> d >> t >> s;
    if (d <= t*s)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3668
#include<iostream>

using namespace std;


int main(void){

    int n, count = 1;

    cin >> n;

    if(n != 1 && n != 2){
        while(n != 4){
            if(n % 2 == 0){
                n /= 2;
            }else{
                n = 3*n + 1;
            }
            count++;
        }
    }
    

    cout << count + 3 << endl;

    return 0;
}

Measured memory_bytes: 256
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
N = int(input())
w =[]
for i in range(N):
    x =input().strip()
    w.append(x)

#重複回答チェック
from collections import Counter
c =Counter(w)
c_k =list(c.values())
ans =""
if max(c_k) >=2:
    print("No")
    sys.exit()
    
ans ="Yes"
for i in range(N-1):
    if w[i][-1] != w[i+1][0]:
        ans ="No"
        break
print(ans)


Measured memory_bytes: 9424
//__professor_
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define lld long double
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define ub upper_bound
#define lb lower_bound
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define test ll t;cin>>t;while(t--)
#define mod 1000000007
#define inf 1000000000000000001
const double pi  =3.141592653589793238463;
using namespace std;

int main()
{
	FAST;
	ll h,w;
	cin>>h>>w;
	char arr[h][w];
	for(ll i=0;i<h;i++)
	{
		for(ll j=0;j<w;j++)
		{
			cin>>arr[i][j];
		}
	}

	ll dp[h][w];

	for(ll i=0;i<h;i++)
	{
		for(ll j=0;j<w;j++)
		{
			if(arr[i][j]=='#')
			{
				dp[i][j]=-1;
			}
			else
			{
				dp[i][j]=0;
			}
		}
	}



	for(ll i=1;i<h;i++)
	{
		if(arr[i][0]=='#')
		{
			break;
		}
		dp[i][0]=1;

	}

	for(ll j=1;j<w;j++)
	{
		if(arr[0][j]=='#')
			break;
		dp[0][j]=1;
	}


	for(ll i=1;i<h;i++)
	{
		for(ll j=1;j<w;j++)
		{
			if(arr[i][j]=='.')
			{
				if(dp[i-1][j]==-1 || dp[i][j-1]==-1)
				{
					if(dp[i][j-1]==-1 && dp[i-1][j]==-1)
					{
						dp[i][j]=0;
					}
					else
					{
					if(dp[i-1][j]==-1)
					{
						dp[i][j]=dp[i][j-1];
					}
					else if(dp[i][j-1]==-1)
					{
						dp[i][j]=dp[i-1][j];
					}
					}
					
				}
				else
				{
					dp[i][j]=(dp[i][j-1]%mod+dp[i-1][j]%mod)%mod;
				}
			}
				
		}
	}

	// for(ll i=0;i<h;i++)
	// {
	// 	for(ll j=0;j<w;j++)
	// 	{
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	cout<<dp[h-1][w-1];

	return 0;
}



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

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

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	int mi=1010;
	for(i=0;i+3<=S.size();i++) {
		x=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
		mi=min(mi,abs(753-x));
	}
	cout<<mi<<endl;
	
	
}


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


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int H,W,i,j;
    while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0)break;
    for(i=0;i<H;i++){
       for(j=0;j<W;j++){
         printf("#");
       }
       printf("\n");
    }
    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2032
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    int N,A,B,C;
    cin>>N>>A>>B>>C;
    vint l(N);
    REP(i,N) cin>>l[i];

    int ans=1e18;
    REP(_S,pow(4,N)){
        int S=_S;
        int a=0,b=0,c=0;
        int cost=0;
        for(int i=0;i<N;i++,S/=4){
            if(S%4<3){
                int &t=(S%4==0? a:S%4==1? b:c);
                if(t>0) cost+=10; 
                t+=l[i];
            }
        }
        if(a and b and c){
            cost+=abs(a-A)+abs(b-B)+abs(c-C);
            ans=min(ans,cost);
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int count = sc.nextInt();
    String str = sc.next();
    int out = 0;

    for (int i = 0; i < count -2; i++) {
      if ('A' == str.charAt(i) && 'B' == str.charAt(i + 1) && 'C' == str.charAt(i + 2)) {
            out++;
      }
    }
    System.out.println(out);
  }
}


Measured memory_bytes: 21716