akhauriyash/Code-Regression huggingface dataset:
from collections import deque


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1] * (n + 1)
        self.rnk = [0] * (n + 1)

    def find_root(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find_root(self.root[x])
            return self.root[x]

    def unite(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1

    def isSameGroup(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def size(self, x):
        return -self.root[self.find_root(x)]


n, m = map(int, input().split())
adj = [[] for _ in range(n+1)]
others = []
UF = UnionFind(n)
for _ in range(m):
    u, v, s = map(int, input().split())
    if not UF.isSameGroup(u, v):
        adj[u].append([v, s])
        adj[v].append([u, s])
        UF.unite(u, v)
    else:
        others.append([u, v, s])

que = deque()
que.append(1)
seen = [0] * (n+1)
seen[1] = 1
val = [0] * (n+1)
plus_min = float('inf')
minus_min = float('inf')
while que:
    v = que.pop()
    for us in adj[v]:
        u, s = us
        if seen[u] == 0:
            que.append(u)
            seen[u] = -seen[v]
            val[u] = s - val[v]
            if seen[u] == -1:
                minus_min = min(minus_min, val[u])
                if minus_min <= 1:
                    print(0)
                    exit()
            else:
                plus_min = min(plus_min, val[u])

x = []
for u, v, s in others:
    if seen[u] != seen[v]:
        if val[u] + val[v] != s:
            print(0)
            exit()
    else:
        if (s - val[u] - val[v]) % 2 == 1:
            print(0)
            exit()
        x_cand = ((s - val[u] - val[v]) // 2) * seen[u]
        if x_cand <= 0:
            print(0)
            exit()
        if plus_min + x_cand <= 0 or minus_min - x_cand <= 0:
            print(0)
            exit()
        if x:
            if x_cand != x[0]:
                print(0)
                exit()
        else:
            x.append(x_cand)

if x:
    print(1)
else:
    if plus_min >= 0:
        print(max(0, minus_min - 1))
    else:
        print(max(0, minus_min - 1 - (-plus_min + 1) + 1))


Measured memory_bytes: 125420
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int i=0;
  {
    while(b<=a){
      b=b*2;
      ++i;
    }
    while(c<=b){
      c=c*2;
      ++i;
    }
  }
  if(i<=k)
    cout<<"Yes\n";
  else
    cout<<"No\n";
}

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

int main(){
  int n, debt = 100000;
  cin >> n;

  for (int i = 1; i <= n; i++){
    debt *= 105;
    debt /= 100;
    if (debt % 1000 > 0){
      debt /= 1000;
      debt++;
      debt *= 1000;
    }
  }
  cout << debt << "\n";

  return 0;
}

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

typedef long long ll;

const ll mod = 1e9 + 7;

ll pow(ll a, ll x){ // a to the xth power
    if(!x) return 1;
    if(x % 2){
        return pow(a, x / 2) * pow(a, x / 2) % mod * a % mod;
    }
    else{
        return pow(a, x / 2) * pow(a, x / 2) % mod;
    }
}

int main(){
    ll n; cin>>n;
    ll res = (mod * 5 + pow(10, n) - pow(9, n) - pow(9, n) + pow(8, n)) % mod;
    cout<<res<<endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("APPROVED");}else{puts("DENIED");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    int flag = 1;

    rep(i,n){
        if(a[i] % 2 == 0){
            if(a[i] %3 != 0 && a[i] % 5 != 0)flag = 0;
        }
    }
    if(flag)yn;
    return 0;
}
 
 


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
    int f= 0;
    string n;
    cin >> n;
    int num = atoi(n.c_str());
    const char *x= n.c_str();
    int sum=0;
    for(int i=0; i<strlen(x); i++){
        sum+= (int)(x[i]-48);
    }
    if(num%sum==0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
priority_queue<int>q;
struct node{
	int a,b;
	bool operator<(const node &x)const{
		return a<x.a;
	}
}t[maxn];
int n,m;
int ans;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++){
		t[i].a=read(),t[i].b=read();
	}
	sort(t+1,t+1+n);
	for(int i=1,j=1;i<=m;i++){
		for(;j<=n;j++){
			if(i<t[j].a)break;
			q.push(t[j].b);
	    }
		if(!q.empty()){
			ans+=q.top();
			q.pop();
		}
	}
	printf("%d",ans);
	return 0;
} 

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

#define MAX_N 200010
ll bit[MAX_N + 1], n;

ll sum(int i){
  ll s = 0;
  while(i > 0){
    s += bit[i]; // s += bit[i];
    i -= i & -i; // xの下のビットをみる
  }
  return s;
}

void add(int i,ll x){
  // 親に更新伝えて行く
  while(i <= n){
    bit[i] += x;
    i += i & -i; // xのもっとも下の立っている最も下のビット
  }
}

void cocomp(VLL &v){
    VLL p(v);
    sort(all(p));
    map<ll,ll> mp;
    ll cnt = 1;
    int n = v.size();
    rep(i,n){
        if(mp[p[i]] != 0){
            continue;
        }else{
            mp[p[i]] = cnt;
            cnt++;
        }
    }
    rep(i,n){
        v[i] = mp[v[i]];
    }
}

int main(){
  scanf("%lld",&n);
  VLL a(n);
  rep(i,n) scanf("%lld",&a[i]);
  cocomp(a);
  ll ans = 0;
  rep(j,n){
    ans += j - sum(a[j]);
    add(a[j],1);
  }
  printf("%lld\n",ans);
  return 0;
}



Measured memory_bytes: 18484
# coding: utf-8
# Your code here!
N=int(input())
H=list(map(int,input().split()))

cnt=0
for i in range(max(H)):
    flg=0
    for j in range(N):
        if flg==0:
            if H[j]!=0:
                H[j]-=1
                cnt+=1
                flg=1
            else:
                flg=0
        else:
            if H[j]!=0:
                H[j]-=1
            else:
                flg=0
print(cnt)

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

int main() {
  int X,A,B; cin >> X >> A >> B;
  if(B-A<=0){
   cout << "delicious" << endl;
  }else if(B-A>0 && B-A<=X){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }

  return 0;
}


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

int main() {
  long long N;
  cin >> N;
  
  vector<long long> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  
  vector<long long> D(N);
  for(int i=0; i<N; i++){
    D[i]=(A[i]-(i+1));
  }
  
  //bはDの中央値
  sort(D.begin(), D.end());
  long long median = D[N>>1];
    
  
  
  long long answer=0;
  for(int i=0; i<N; i++){
    answer+= abs(D[i]-median);
  }
  cout << answer << endl;
    
}

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

typedef long long ll;

struct st
{
    ll num;
    ll cnt;
};

bool cmp(struct st &a,struct st &b)
{
    return a.num < b.num;
}


const int N = 1e5+10;

st s[N];

int main()
{
    ll n,k;
    ll a,b;
    cin >> n >> k;

    for (int i = 0; i < n; i ++ )
    {
        cin >> a >> b;
        s[i].num = a;
        s[i].cnt = b;
    }

    sort(s,s+n,cmp);

    ll sum = 0;
    for (int i = 0; i < n; i ++ )
    {
        sum += s[i].cnt;
        if(k <= sum)
        {
            cout << s[i].num << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int c = b;
  if (c < 10) {
    c += a*10;
  } else if (c < 100) {
    c+=a*100;
  } else if (c < 1000) {
    c+= a*1000;
  }
  int sq = sqrt(c);
  if (sq*sq==c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0; 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
int main(void){
    int n,m; cin>>n>>m;
    vector <vector<int>> graph(n ,vector <int>( ));
    vector <int> deg(n);
    for(int i=0;i<m;i++){
        int x,y; cin>>x>>y; x--; y--;
        
        graph[x].push_back(y);
        deg[y]++;
    }
    priority_queue <int, vector <int>, greater<int>> que;
    for(int v=0;v<n;v++){
        if(deg[v] == 0) que.push(v);
    }
    vector <int> topo(n);
    int x = 0;
    while(!que.empty()){
        int v = que.top(); que.pop();
        topo[x++] = v;
        for(int i=0;i<graph[v].size();i++){
            int nv = graph[v][i];
            deg[nv]--;
            if(deg[nv]==0) que.push(nv);
        }
    }
    //以上でトポロジカルソートが完了したよ！次はそれを使ってDPで最長のパスを求めよう!
    vector <int> dp(100100);
    int res = 0;
    for(int i=0;i<n;i++){
        int v = topo[i];
        for(int j=0;j<graph[v].size();j++){
            int nv = graph[v][j];
            chmax(dp[nv], dp[v]+1);
        }
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        chmax(ans,dp[i]);
    }
    cout<<ans<<endl;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;
LL n, k;

int main() {
	cin >> s >> k;
	n = s.size();
	
	int ans = 1;
	if(k < n) {
		inc(i, k) { if(s[i] != '1') { ans = s[i] - '0'; break; } }
	} else {
		inc(i, n) { if(s[i] != '1') { ans = s[i] - '0'; break; } }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

const MOD: i64 = 1_000_000_007;

fn vertical(p: (char, char)) -> bool {
    p.0 == p.1
}

fn main() {
    let _ = scan!(usize);
    let s1 = scan!();
    let s2 = scan!();

    let mut skip = false;
    let mut ans = if s1.chars().nth(0).unwrap() == s2.chars().nth(0).unwrap() {
        3
    } else {
        skip = true;
        3 * 2
    };
    let preds = s1.chars().zip(s2.chars());
    let curs = s1[1..].chars().zip(s2[1..].chars());
    for (pred, cur) in preds.zip(curs) {
        if skip {
            skip = false;
            continue;
        }
        if vertical(cur) {
            if vertical(pred) {
                ans *= 2
            } else {
                ans *= 1;
            }
        } else {
            skip = true;
            if vertical(pred) {
                ans *= 2;
            } else {
                ans *= 3;
            }
        }
        ans %= MOD;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
{-# LANGUAGE BangPatterns #-}
import Data.Int
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as BS

solve :: Int -> Int -> V.Vector (Int,Int) -> V.Vector Int64
solve n m edges = V.create $ do
  -- m 番目の島から順番に島同士が「繋がっていく」と考える

  -- j = assocs ! i : i 番目の島の親が j
  -- assocs <- VM.new n
  -- forM_ [0..n-1] $ \i -> VM.write assocs i i
  assocs <- V.thaw $ V.enumFromN 0 n

  -- numberOfElements ! i : i番目の島と同じ連結成分に属する島の個数
  numberOfElements <- VM.replicate n 1

  let getRoot !i = do
        !j <- VM.read assocs i
        if i == j
          then return i
          else do k <- getRoot j
                  VM.write assocs i k
                  return k

      -- i 番目の島と j 番目の島を繋いで、新たに繋がった組み合わせの個数を返す
      unify !i !j = do
        !i' <- getRoot i
        !j' <- getRoot j
        if i' == j'
          then return 0
          else do
          let !k = min i' j'
          VM.write assocs i' k
          VM.write assocs j' k
          !n1 <- VM.read numberOfElements i'
          !n2 <- VM.read numberOfElements j'
          VM.write numberOfElements k (n1 + n2)
          return $! n1 * n2
  result <- VM.new m
  VM.write result (m-1) $ fromIntegral n * (fromIntegral n - 1) `quot` 2
  forM_ [m-1,m-2..1] $ \i -> do
    let (a,b) = edges V.! i
    convenience <- unify a b
    prevInconveniences <- VM.read result i
    VM.write result (i-1) (prevInconveniences - convenience)
  return result

readIntPair :: IO (Int, Int)
readIntPair = do
  [a,b] <- BS.words <$> BS.getLine
  case (BS.readInt a, BS.readInt b) of
    (Just (a', _), Just (b', _)) -> return (a',b')

main = do
  (n,m) <- readIntPair -- 2 <= n <= 10^5, 1 <= m <= 10^5
  edges <- V.replicateM m $ do
    (a,b) <- readIntPair
    return (a-1, b-1)
  -- maxIncovenience < n * (n - 1) / 2 < 10^10 (2^32 < 10^10)
  let result = solve n m edges
  V.forM_ result print


Measured memory_bytes: 6140
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
int kaijo(int x){
  if(x==1)
    return 1;
  return x * kaijo(x-1);
}
int main()
{
  int N, M;
  cin >> N >> M;
  int num = 0;
  num = N * (N - 1) /2+ M * (M - 1) /2;
  cout << num << endl;

}

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

int main()
{
    char inputS[11], inputT[11], inputU[11];
    int redBallsNum, blueBallsNum;

    scanf("%s %s", inputS, inputT);
    scanf("%d %d", &redBallsNum, &blueBallsNum);
    scanf("%s", inputU);

    if (strcmp(inputU, inputS) == 0)
    {
        redBallsNum--;
    }
    else if (strcmp(inputU, inputT) == 0)
    {
        blueBallsNum--;
    }

    printf("%d %d \n", redBallsNum, blueBallsNum);

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if((a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
}

Measured memory_bytes: 128
from math import acos, hypot, isclose, sqrt
from typing import List, Tuple


def intersection(circle: Tuple[int, int, int],
                 polygon: List[Tuple[float, float]]) -> float:
    x, y, r = circle
    area = 0.0

    for p1, p2 in zip(polygon, polygon[1:] + [polygon[0]]):
        ps = seg_intersection(circle, (p1, p2))
        for pp1, pp2 in zip([p1] + ps, ps + [p2]):
            c = cross(pp1, pp2)
            if c == 0:
                continue
            d1 = hypot(*pp1)
            d2 = hypot(*pp2)
            if le(d1, r) and le(d2, r):
                area += c / 2
            else:
                t = acos(dot(pp1, pp2) / (d1 * d2))
                sign = c // abs(c)
                area += sign * r * r * t / 2

    return area


def cross(v1: Tuple[float, float], v2: Tuple[float, float]) -> float:
    x1, y1 = v1
    x2, y2 = v2
    return x1 * y2 - x2 * y1


def dot(v1: Tuple[float, float], v2: Tuple[float, float]) -> float:
    x1, y1 = v1
    x2, y2 = v2
    return x1 * x2 + y1 * y2


def seg_intersection(circle: Tuple[int, int, int],
                     seg: Tuple[Tuple[float, float],
                                Tuple[float, float]]) -> List[Tuple[float, float]]:
    x0, y0, r = circle
    p1, p2 = seg
    x1, y1 = p1
    x2, y2 = p2

    p1p2 = (x2 - x1) ** 2 + (y2 - y1) ** 2
    op1 = (x1 - x0) ** 2 + (y1 - y0) ** 2
    rr = r * r
    dp = dot((x1 - x0, y1 - y0), (x2 - x1, y2 - y1))

    d = dp * dp - p1p2 * (op1 - rr)
    ps = []

    if isclose(d, 0.0, abs_tol=1e-9):
        t = - dp / p1p2
        if ge(t, 0.0) and le(t, 1.0):
            ps.append((x1 + t * (x2 - x1), y1 + t * (y2 - y1)))
    elif d > 0.0:
        t1 = (- dp - sqrt(d)) / p1p2
        if ge(t1, 0.0) and le(t1, 1.0):
            ps.append((x1 + t1 * (x2 - x1), y1 + t1 * (y2 - y1)))
        t2 = (- dp + sqrt(d)) / p1p2
        if ge(t2, 0.0) and le(t2, 1.0):
            ps.append((x1 + t2 * (x2 - x1), y1 + t2 * (y2 - y1)))

    return ps


def le(f1: float, f2: float) -> bool:
    return f1 < f2 or isclose(f1, f2, abs_tol=1e-9)


def ge(f1: float, f2: float) -> bool:
    return f1 > f2 or isclose(f1, f2, abs_tol=1e-9)


if __name__ == "__main__":
    n, r = [int(i) for i in input().split()]
    ps: List[Tuple[float, float]] = []

    for _ in range(n):
        x, y = map(lambda x: float(x), input().split())
        ps.append((x, y))

    print("{:.6f}".format(intersection((0, 0, r), ps)))



Measured memory_bytes: 7348
h, w = map(int, input().split())
hd, hm, wd, wm = h // 2, h % 2, w // 2, w % 2
s = hd * wd * 2  + hm * wd + wm * hd + hm * wm
if h == 1 or w == 1:
    s = 1
print(s)


Measured memory_bytes: 9092
#include <bits/stdc++.h>
#define ri register int
#define ll long long
using namespace std;
int read()
{
    int num=0;
    int flg=1;
    char c=getchar();
    while(!isdigit(c))
    {
        if(c=='-')
        {
            flg=-1;
        }
        c=getchar();
    }
    while(isdigit(c))
    {
        num=(num<<1)+(num<<3)+(c^48);
        c=getchar();
    }
    return num*flg;
}

int main()
{
    return 0&(int)puts(abs(read()-read())<=1?"Brown":"Alice");
}

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

#define ll long long

using namespace std;

int main(){
	ll m,f,r,k;
	
	while(1){
		cin>>m>>f>>r;
		if(m==-1 && f==-1 && r==-1) break;
		if(m==-1 || f==-1) cout<<"F\n";
		  else{
		  	k=m+f;
		  	if(k>=80) cout<<"A\n";
		  	  else if(k>=65) cout<<"B\n";
		  	    else if(k>=50) cout<<"C\n";
		  	      else if(r>=50) cout<<"C\n";
					else if(k>=30) cout<<"D\n";
		  	          else cout<<"F\n";
		  }
	}
}


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

#define ED return 0;
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) int(pow(x,y))
const long long mod = 1000000007;

int main() {
    int A, B;
    cin >> A >> B;
    cout << (A-1)*(B-1) << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

mod = 998244353
N, S = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
dp = [0] * (S+1)
dp[0] = pow(2, N, mod)
two_inv = pow(2, mod-2, mod)
for i, a in enumerate(A):
    for j in range(a, S+1)[::-1]:
        dp[j] = (dp[j] + dp[j-a] * two_inv) % mod
print(dp[S])


Measured memory_bytes: 68412
#include <stdio.h>

int search(int,int,int[]);

int main(){
  int n,q,i,key,ans=0;
  int S[100000];

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&S[i]);
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);

    ans += search(key,n,S);
  
  }
  printf("%d\n",ans);
  

  return 0;
}

int search(int key,int n,int S[]){
  int i,left,right,middle;
  
  left = 0;
  right = n;

  while(left < right){
    middle = (left + right)/2;
    if(S[middle] == key) return 1;
    else if(key < S[middle])right = middle;
    else left = 1 + middle;
  }
  return 0;
}



Measured memory_bytes: 2124
n, l = map(int, input().split())

taste_lists = list()
for i in range(n):
    taste = l+i
    taste_lists.append(taste)

eat = 0
if taste_lists[0] > 0 and taste_lists[-1] > 0:
    eat = taste_lists[0]
elif taste_lists[0] < 0 and taste_lists[-1] < 0:
    eat = taste_lists[-1]
else:
    eat = 0

taste_lists.remove(eat)
ans = 0
for i in taste_lists:
    ans += i

print(ans)

Measured memory_bytes: 9100
vec = [[1,0],[0,1],[-1,0],[0,-1]]

def dfs(nw,nh):
    global count
    count += 1
    visited[nh][nw] = True
    for x,y in vec:
        new_w = nw + x
        new_h = nh + y
        if (0 <= new_w) and (new_w) < w:
            if (0 <= new_h) and (new_h) < h:
                if (lis_f[new_h][new_w] == ".") and (visited[new_h][new_w] == False):
                    dfs(new_w,new_h)
                    
while(True):
    w,h = map(int,input().split())
    if (w,h) == (0,0):
        break
    lis_f = []
    for _ in range(h):
        lis_f.append(list(input()))
    
    visited = [[False for _ in range(w)] for _ in range(h)]
    count = 0
    
    id_w = 0
    id_h = 0
    set_w = 0
    set_h = 0
    while(id_h < h):
        while(id_w < w):
            #print(lis_f[id_h][id_w])
            if lis_f[id_h][id_w] == "@":
                set_w = id_w
                set_h = id_h
            id_w += 1
        id_h += 1
        id_w = 0
    
    #print(set_w,set_h)
    
    dfs(set_w,set_h)
    print(count)            


Measured memory_bytes: 5992
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String res = "hon";
        String s = sc.next();
        if(s.endsWith("0") || s.endsWith("1") || s.endsWith("6") || s.endsWith("8")) {
            res = "pon";
        } else if(s.endsWith("3")) {
            res = "bon";
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 35744
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  string s;cin >> s;
  int count=0;
  int ans = 0;
  rep(i,SZ(s)){
    if(s[i]=='A'||s[i]=='C'||s[i]=='T'||s[i]=='G'){
      count++;
      ans = max(ans,count);
    }
    else{
      ans = max(ans,count);
      count = 0;
    }
  }
  cout << ans << endl;
}


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


int main()
{	
	int n; cin >> n;
	float count = 0;
	for(int i = 1; i<=n ;i++){
		if(i&1) count++;
	}
	float ans = count / n;
	cout << ans << endl;
   
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define h_max 251

int H;
int A[h_max];

int main(){
  int i,j;
  
  scanf("%d",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    
    if(i/2 > 0){
      printf("parent key = %d, ",A[i/2]);
    }
    
    if(i*2 <= H){
      printf("left key = %d, ",A[i*2]);
    }
    
    if(i*2+1 <= H){
      printf("right key = %d, ",A[i*2+1]);
    }
    
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    char A,B,C;
    cin >> A >> B >> C;
    if(1 ==((A == B) + (C == A) + (B == C) )){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    string a[n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    int cnt=0;
    sort(a,a+n);
    for(int i=0; i<n; i++)
    {
        if(a[i]==a[i+1])
        {
            cnt++;
        }
    }
    cout<<n-cnt;


}




Measured memory_bytes: 9872
//A smoothe sea never made a skilled sailor.
//KEEP IT SIMPLE STUPID
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define print(o) for(auto it=(o).begin();it!=(o).end();it++) cout<<*it<<" ";
#define vll vector<ll>
#define pb push_back
#define FOR(n) for(ll i=0;i<n;i++)
#define FORr(a,b) for(ll i=a;i<=b;i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    ll a[3][3];
    bool v[3][3];
    memset(v,false,sizeof(v));
    for(ll i=0;i<3;i++)
    {
        for(ll j=0;j<3;j++)
        {
            cin>>a[i][j];
            v[i][j]=false;
        }
    }
    ll n;
    cin>>n;
    while(n--)
    {
        ll x;
        cin>>x;
        for(ll i=0;i<3;i++)
    {
        for(ll j=0;j<3;j++)
        {
            if(a[i][j]==x)
            {
                v[i][j]=true;
            }
        }
    }
    }
    if(v[1][1])
    {
        if((v[0][0]&&v[2][2])||(v[0][2]&&v[2][0])||(v[0][1]&&v[2][1])||(v[1][0]&&v[1][2]))
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    if(v[1][0])
    {
        if(v[0][0]&&v[2][0])
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    if(v[1][2])
    {
        if(v[0][2]&&v[2][2])
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    if(v[0][1])
    {
        if(v[0][0]&&v[0][2])
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    if(v[2][1])
    {
        if(v[2][0]&&v[2][2])
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

int main() {
  int t;
  while (1) {
    cin >> t;
    if (t == 0) break;

    int n;
    cin >> n;
    int s, f, sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> s >> f;
      sum += f - s;
    }

    if (sum >= t) {
      cout << "OK" << endl;
    } else {
      cout << t - sum << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>
int main(void){
	int a,b,answer;
	scanf("%d %d",&a,&b);
	if(a<0||12<a){
		printf("a is error");
		return 0;
	}
 if(b<0||31<b){
		printf("b is error");
		return 0;
	}
	answer=a-1;
	if(a<=b){
	  answer+=1;
	}
	printf("%d",answer);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 1 << 17;
int n, A, B, maxn;
int ans[N], suf[N], pre[N];
int d1(int a, int x) {
	return (!x ? 0 : a & pre[x - 1]) | ((a & suf[x + 1]) >> 1);
}
int d2(int a, int x, int c) {
	return (!x ? 0 : a & pre[x - 1]) | ((a & suf[x]) << 1) | (c << x);
}
void out(int a) {
	for(int i = 30; ~i; --i) printf("%d", a >> i & 1);
	puts("");
}
void dfs(int st, int n, int A, int B) {
	if(n == 1) {
		ans[st] = A, ans[st + 1] = B;
		return;
	}
	int x;
	rep(i, 0, n - 1) if((A >> i & 1) ^ (B >> i & 1)) x = i;
	int a = d1(A, x), b = d1(B, x), c = a ^ 1;
	dfs(st, n - 1, a, c);
	dfs(st + (1 << n - 1), n - 1, c, b);
	rep(i, st, st + (1 << n - 1) - 1) ans[i] = d2(ans[i], x, A >> x & 1);
	rep(i, st + (1 << n - 1), st + (1 << n)) ans[i] = d2(ans[i], x, B >> x & 1);
}
int main() {
#ifdef fwat
#endif
	n = gi(), A = gi(), B = gi();
	maxn = (1ll << 31) - 1;
	rep(i, 0, 18) suf[i] = ((1ll << 31) - 1) << i & maxn;
	rep(i, 0, 18) pre[i] = (1 << i + 1) - 1;
	if(__builtin_popcount(A ^ B) % 2 == 0) return puts("NO"), 0;
	puts("YES");
	dfs(0, n, A, B);
	rep(i, 0, (1 << n) - 1) printf("%d%c", ans[i], i == (1 << n) - 1 ? '\n':' ');
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong m;
string s;
vector<llong> p;
vector<llong> ans;

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

    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '0') p.push_back(i);
    }
    
    llong idx = n;
    while (idx > 0) {
        auto itr = upper_bound(p.rbegin(), p.rend(), idx - m, greater<>());
        
        itr--;
        if (idx == *itr) {
            cout << -1 << endl;
            return 0;
        }
        
        ans.push_back(idx - *itr);
        idx = *itr;
        while (idx < p.back()) p.pop_back();
    }

    reverse(ans.begin(), ans.end());
    for (auto v:ans) {
        cout << v << ' ';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2676
N = int(input())
T, A = map(int, input().split())
H = [int(h) for h in input().split()]

def tempreture(x):
    return T - x * 0.006

t_ave = [tempreture(h) for h in H]

delta = [abs(t - A) for t in t_ave]

print(delta.index(min(delta))+1) 

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}
long long Pow(long long base,long long x){
    if (x == 0) return 1;
    if (x%2 == 1) return (base*Pow(base,x-1))%MOD;
    long long y = Pow(base, x/2);
    return y*y%MOD;
}

long long d[101][4][4][4],n,ans;
int main(){
    d[0][1][1][1] = 1;
    cin >> n;
    for(int l = 0; l < n; l++){
        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 4; j++){
                for(int k = 0; k < 4; k++){
                    for(int a = 0; a < 4; a++){
                        if (i == 0 && j == 2 && a == 3) continue;
                        if (i == 0 && k == 2 && a == 3) continue;
                        if (j == 0 && k == 2 && a == 3) continue;
                        if (j == 2 && k == 0 && a == 3) continue;
                        if (j == 0 && k == 3 && a == 2) continue;
                        d[l+1][j][k][a] += d[l][i][j][k];
                        d[l+1][j][k][a] %= MOD;
                    }
                }
            }
        }
    }
    ans = 0;
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            for(int k = 0; k < 4; k++){
                ans += d[n][i][j][k];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
}
  



Measured memory_bytes: 256
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	let X = parseInt(input[0][0], 10);
	if (X >= 30) console.log('Yes');
	else console.log('No');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s.begin(), s.end());
    long long res = 0;
    int i = 0;
    while (i < n) {
        int I = i;
        while (i < n && s[i] == s[I]) {
            i++;
        }
        int k = i - I;
        res += (long long)k*(k-1)/2;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 5760
#include<iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    int a;
    long sum = 0;
    int min_a = (int)1e9 + 1;
    int cnt = 0;
    for(int i=0; i<N; i++){
        cin >> a;
        sum += abs(a);
        min_a = min(min_a, abs(a));
        if(a < 0){
            cnt++;
        }
    }
    if(cnt % 2 == 0) cout << sum << endl;
    else cout << sum - min_a * 2 << endl;    
    return 0;
}

Measured memory_bytes: 256
s = input()
ls = [0 for i in range(len(s))]
a = []
cur = 'R'
for x in s[1:]:
    if cur[-1] == x:
        cur += x
    else:
        a.append(cur)
        cur = x
a.append(cur)
num = 0
for i, x in enumerate(a):
    if i%2 == 0:
        ls[len(x)-1+num] += len(x) - len(x)//2
        ls[len(x)+num] += len(x)//2
        num += len(x)
    else:
        ls[num] += len(x) - len(x)//2
        ls[num-1] += len(x)//2
        num += len(x)
print(*ls)

Measured memory_bytes: 12436
H, W = map(int, input().split())
ans = [[0 for i in range(W)] for j in range(H)]
mark = []
for i in range(H):
    mark.append(input())

ans[0][0] = 1
mod = 10**9 + 7
for i in range(H):
    for j in range(W):
        if mark[i][j] == '#':
            continue
        if i > 0:
            ans[i][j] += ans[i-1][j]
        if j > 0:
            ans[i][j] += ans[i][j-1]
        ans[i][j] %= mod

print(ans[H-1][W-1])

Measured memory_bytes: 44612
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    string s; cin >> s;
    int res = 700;
    for(int i=0; i<3; i++){
        if(s.at(i)=='o') res += 100; 
    }
    
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct pnt{
	int x,y;
	pnt(){}
	pnt(int _x,int _y){
		x=_x;y=_y;
	}
};
bool operator <(pnt x,pnt y){
	return x.x < y.x || x.x == y.x && x.y<y.y;
}
pnt operator-(pnt x,pnt y){
	return pnt(x.x-y.x,x.y-y.y);
}
int operator*(pnt x,pnt y){
	return x.x*y.y-x.y*y.x;
}
int n;
pnt a[222];
#define mod 998244353
int add(int x,int y){
	return (x+y)%mod;
}
int sub(int x,int y){
	return add(x,mod-y);
}
int p2[222];
int main(){
	scanf("%d",&n);
	p2[0] = 1;
	for(int i=0; i<n; i++){
		scanf("%d%d",&a[i].x,&a[i].y);
		p2[i+1]=add(p2[i],p2[i]);
	}
	int res = p2[n];
	res = sub(res, 1);
	res = sub(res, n);
	res = sub(res, n*(n-1)/2);
	for(int i=0; i<n; i++)for(int j=0; j<n; j++)
		if(a[i] < a[j]){
			int w = 0;
			for(int k=0; k<n; k++)
			if(a[i] < a[k] && a[j] < a[k] && (a[j]-a[i])*(a[k]-a[i]) == 0)
				w++;
			res = sub(res, sub(p2[w],1));
		}
	printf("%d\n",res);
	return 0;
}


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

void count(string a,string b)
{
	int n=a.size();
	int m=b.size();
	int dp[n+1][m+1];
	for(int i=0;i<=n;i++)
		dp[i][0]=0;
	for(int i=0;i<=m;i++)
		dp[0][i]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			int c;
			if(a[i-1]==b[j-1])
				 c=dp[i-1][j-1]+1;
				else
					c=max(dp[i-1][j],dp[i][j-1]);
				dp[i][j]=c;
		}
	}
	/*for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        cout<<dp[i][j]<<" ";
        cout<<endl;}*/
	int i=n,j=m;
	string s="";
	while(i>0&&j>0)
	{
		if(dp[i-1][j]==dp[i][j-1])
		{
            if(dp[i][j]==dp[i-1][j])
            {
            	j--;
            }
            else if(a[i-1]==b[j-1])
            {
            	s+=a[i-1];
            	i--;
            	j--;
            	//cout<<a[i-1];
            }
		}
		else
		{
			if(dp[i-1][j]>dp[i][j-1])
				i--;
			else
				j--;
		}
	}
	reverse(s.begin(),s.end());
	cout<<s;
}

int main()
{
	string a,b;
	cin>>a>>b;
	count(a,b);

}

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

int main()
{
    int L, R, d;
    int cnt = 0;
    cin >> L >> R >> d;

    for(int i=L; i<=R; i++){
        if(i%d == 0) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3548
import sys

def hantei(s):
  for i in range(len(s)//2):
    if s[i] != s[-1-i]:
      return False
  
  return True

s = input()
n = len(s)

if not hantei(s):
  print('No')
  sys.exit(0)
    
if not hantei(s[0:(n-1)//2]):
  print('No')
  sys.exit(0)
  
if not hantei(s[(n+1)//2 : n]):
  print('No')
  sys.exit(0)

print('Yes')

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=1e6+10;
const int mod=1e9+7;
int a[N],b[N];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        a[i]=x+y;
        b[i]=x-y;
    }
    sort(a,a+n);
    sort(b,b+n);
    cout<<max(a[n-1]-a[0],b[n-1]-b[0])<<endl;
    return 0;

}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int a, b; scanf("%d %d", &a, &b);
  int N = 1000;
  vector<int> poles(N, 1);
  for (int i = 2; i <= N; ++i) {
    poles[i] = poles[i - 1] + i;
  }
  int most = poles[999];
  int ans = -1;
  for (int c = 1; c <= most; ++c) {
    for (int i = 1; i + 1 <= 999; ++i) {
      if (poles[i] - c == a and poles[i + 1] - c == b) {
        ans = c;
        break;
      }
    }
    if (ans != -1) { break; }
  }
  printf("%d\n", ans);
  return 0;
}


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

int main(){//挿入ソート

    int v,n,A[1000];
    cin >> n;

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

    for (int i = 0; i < n; i++){
            if (i != n - 1){
                cout << A[i] << " ";
            } else {
                cout << A[i];
            }
        }

        cout << endl;
    
    for (int i = 1; i <= n-1; i++){

        v = A[i];
        int j = i - 1;

        while (j >= 0 && A[j] > v){
            A[j + 1] = A[j];
            j--;
        }

        A[j + 1] = v;

        for (int i = 0; i < n; i++){
            if (i != n - 1){
                cout << A[i] << " ";
            } else {
                cout << A[i];
            }
        }

        cout << endl;
    }

    return 0;
    
}


Measured memory_bytes: 3076
#include <stdio.h>
#include <limits.h>

int players[36];
int min, n;

void dfs(int power, int no, int total)
{
	if (no == n){
		min = min > abs(power - total) ? abs(power - total) : min; 
		return;
	}
	dfs(power + players[no], no + 1, total - players[no]);
	dfs(power, no + 1, total);
}

int main(void)
{
	while (scanf("%d", &n), n){
		int sum, i;
		
		sum = 0;
		for (i = 0; i < n; i++){
			scanf("%d", players + i);
			sum += players[i];
		}
		min = INT_MAX;
		dfs(0, 0, sum);
		printf("%d\n", min);
	}
	return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    long long ct, ca;
    ct = 1;
    ca = 1;
    REP(i, n)
    {
        long long t, a;
        cin >> t >> a;
        long long x = (ct + t - 1) / t;
        long long y = (ca + a - 1) / a;
        long long maxv = max(x, y);
        ct = maxv * t;
        ca = maxv * a;
    }
    cout << ct + ca << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
//typedef vector<int> vi;
//typedef vector<vi> vvi;
//typedef vector<string> vs;
//typedef pair<int, int> pii;
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}



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

	int n;
	cin >> n;
	set<string> p;

	REP(i, n) {
		string s;
		cin >> s;
		p.insert(s);
	}

	cout << p.size() << endl;

}

Measured memory_bytes: 19140
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for ai in range(A+1):
    for bi in range(B+1):
        for ci in range(C+1):
            total = 500*ai + 100*bi + 50*ci
            if total == X:
                cnt += 1
print(cnt)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from collections import defaultdict
from bisect import bisect_left
def resolve():
    S,T=input(),input()
    if(not (set(S)>=set(T))):
        print(-1)
        return

    D=defaultdict(list)
    for i,s in enumerate(2*S):
        D[s].append(i)

    n=len(S)
    now=0
    ans=0
    for t in T:
        i=bisect_left(D[t],now)
        ans+=D[t][i]-now+1
        now=(D[t][i]+1)%n
    print(ans)
resolve()

Measured memory_bytes: 54896
<?php
$n = trim(fgets(STDIN));
while ($line = fgets(STDIN)) {
    $dies[] = explode(" ", trim($line));
}
$flg = 0;
for ($i = 0; $i < $n - 2; $i++) {
    if ($dies[$i][0] === $dies[$i][1]) {
        if ($dies[$i + 1][0] === $dies[$i + 1][1]) {
            if ($dies[$i + 2][0] === $dies[$i + 2][1]) {
                echo 'Yes';
                $flg = 1;
                break;
            }
        }
    }
}
if ($flg == 0) {
    echo 'No';
}

Measured memory_bytes: 16096
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N, X, Y;
  cin >> N >> X >> Y;
  X--; Y--;
  vvll A(N, vll(N, INF));
  vll count(N, 0);

  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      A.at(i).at(j) = abs(j-i);
      chmin(A.at(i).at(j), abs(i-X)+1LL+abs(j-Y));
      chmin(A.at(i).at(j), abs(i-Y)+1LL+abs(j-X));
      count.at(A.at(i).at(j))++;
    }
  }
  
  for(int i = 1; i <= N-1; i++){
    cout << count.at(i)/2 << endl;
  }
}

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

using namespace std;

typedef long long ll;

int main(){
string S; cin >> S; int N = (int) S.size();
  int res = 0;
  for(int i = 0; i < N ; i++){
    if( !(i % 2 )){ // iが偶数の時、AtCodeerはgを出すものとする
      if( S[i] == 'p'){ res--;}}
    else{
      if( S[i] == 'g'){ res++;}}
    
  }
  cout << res <<endl; return 0;}

Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#define for1(i,a,b) for(int i=a;i<=b;++i)
#define for2(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	std::ios::sync_with_stdio(false);
	char a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<(a==b||b==c||c==d?"Bad":"Good");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void call (int n);

int main(){
	int n;
	std::cin>>n;
	call(n);
	return 0;
}

void call(int n){
	for(int i=1;i<=n;i++){
		int x = i;
		if ( x % 3 == 0 ){
			cout << " " << i;
			continue;
		}
		do{
			if ( x % 10 == 3 ){
				cout << " " << i;
				break;
			}
			x /= 10;
		}while(x);
	}
	cout << endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
string S, T, B = "~";
bool isOK(string A1, string A2) {
	for (int i = 0; i < A1.size(); i++) {
		if (A1[i] != '?' && A1[i] != A2[i])return false;
	}
	return true;
}
int main() {
	cin >> S >> T;
	for (int i = 0; i <= (int)S.size() - (int)T.size(); i++) {
		string U = S.substr(i, T.size());
		if (isOK(U, T) == true) {
			string V = S;
			for (int j = i; j < i + T.size(); j++)V[j] = T[j - i];
			for (int j = 0; j < i; j++) { if (V[j] == '?')V[j] = 'a'; }
			for (int j = i + T.size(); j < V.size(); j++) { if (V[j] == '?')V[j] = 'a'; }
			B = min(B, V);
		}
	}
	if (B == "~")cout << "UNRESTORABLE" << endl;
	else cout << B << endl;
	return 0;
}



Measured memory_bytes: 256