akhauriyash/Code-Regression huggingface dataset:
A,B,C = input().split()
array =[A,B,C]

array.sort()

if "5" in array[0]:
    del array[0]
    if "5" in array[0]:
        del array[0]
        if "7" in array[0]:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
else:
    print("NO")


Measured memory_bytes: 7020
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())



N = ni()
MAX = 3500
EPS = 10**(-6)
ha,wa,na = 0,0,0

for h in range(MAX+1):
    for w in range(MAX+1):
        if 4*h*w - N*w - N*h > 0:            
            if abs((N*h*w) / (4*h*w - N*w - N*h)) - ((N*h*w) // (4*h*w - N*w - N*h)) == 0:
                ha = h
                wa = w
                na = (N*h*w) // (4*h*w - N*w - N*h)
                
print(ha,na,wa)

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

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

    std::vector<int> h;
    for (int i = 0; i < n; ++i) {
        int buf = 0;
        std::cin >> buf;
        h.push_back(buf);
    }

    std::sort(h.begin(), h.end(), std::greater<int>());

    int min = INT32_MAX;
    for (int i = 0; i <= n - k; ++i) {
        int diff = h[i] - h[i + k - 1];
        if (diff < min) {
            min = diff;
        }
    }

    std::cout << min << std::endl;

    return 0;
}

Measured memory_bytes: 892
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut cnt = 0;
    if s[0] == '1' { cnt += 1; }
    if s[1] == '1' { cnt += 1; }
    if s[2] == '1' { cnt += 1; }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
    unsigned short num;
    unsigned short i;
    unsigned short ielt[100];
    unsigned short work;
    scanf("%d", &num);
    for(i = 0;i < num;i++){
	scanf("%d", &ielt[i]);
    }
    for(i = 0;i < num - 1;i++){
        printf("%d ", ielt[num - 1 - i]);
    }
    printf("%d\n", ielt[0]);
    return 0;
}


Measured memory_bytes: 2040
N, Q = map(int, input().split())
s = '.' + input() + '.'
TD = [input().split() for _ in range(Q)]
 
def check(x):
    #Q回の呪文後の位置をチェック
    #1 <= x <= N
    for t, d in TD:
        if s[x] == t:
            if d == 'L':
                x -= 1
            else:
                x += 1
        else:
            continue
 
        if x == 0:
            return -1
        if x == N + 1:
            return 1
    return 0
 
ok = 0
ng = N + 1
while ng - ok > 1:
    mid = (ok + ng) // 2
    if check(mid) == -1:
        ok = mid
    else:
        ng = mid
l = ok
 
 
ok = N + 1
ng = 0
while ok - ng > 1:
    mid = (ok + ng) // 2
    if check(mid) == 1:
        ok = mid
    else:
        ng = mid
 
r = ng
 
print(r - l)

Measured memory_bytes: 41392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Nmax=200010;
//ll a[Nmax];

int main() {
	int a,b,cnt;
	cin >> a >> b;
	cnt += a-1;
	if(a <= b) cnt++;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
typedef long long ll;
const ll INF = 1LL<<60;
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; }

const int MOD = 1000000007;

int H, W;
vector<string> a;
// DP初期化
int dp[1100][1100] = {0};

void add(int &a, int b){
    a += b;
    if(a >= MOD) a -= MOD;
}

int main() 
{
    cin >> H >> W;
    vector<string> a(H);
    rep(i, H) cin >> a[i];

    dp[0][0] = 1;

    rep(i, H){
        rep(j, W){
            if(j+1 < W && a[i][j+1] == '.') add(dp[i][j+1], dp[i][j]);
            if(i+1 < H && a[i+1][j] == '.') add(dp[i+1][j], dp[i][j]);
        }

    }
    cout << dp[H-1][W-1] << endl;

    return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int32_t main()
{
	IOS;
	int a;
	double d;
	cin >> a >> d;
	int b = round(d * 100);
	int ans = a * b;
	ans /= 100;
	cout << ans;
	return 0;
}


Measured memory_bytes: 3676
def BubbleSort1(A):
    ans=0
    for i in range(len(A)):
        for j in range(len(A)-1,i,-1):
            if A[j-1]>A[j]:
                A[j],A[j-1]=A[j-1],A[j]
                ans+=1
    
    return ans

    
cnt=int(input())
a=[int(x) for x in input().split()]


ans=BubbleSort1(a)

for i in range(len(a)):
    if i:
        print(" ",end="")
    print(a[i],end="")
print()
print(ans)


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

int main(){
    int x;
    cin>>x;
    int h = x / 3600;
    int m = (x / 60) % 60;
    int s = x % 60;
    cout<<h<<":"<<m<<":"<<s<<endl;
    
    return 0;
}


Measured memory_bytes: 3072
#include<stdio.h>
#include<stdlib.h>
#define N 4
int ansArr[N][N]={{ 1, 2, 3, 4},
                  { 5, 6, 7, 8},
                  { 9,10,11,12},
                  {13,14,15, 0}};
int x[N*N]={3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2};
int y[N*N]={3,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3};
int heuristic[N*N][N*N];
int curMinCost=46;
int tempArr[N][N];
void searchMinCost(int[N][N],int,int);
int main(void)
{
  int i,j;
  for(i=0;i<N*N;i++)
    {
      for(j=0;j<N*N;j++)
        {
          heuristic[i][j]=abs(y[i]-y[j])+abs(x[i]-x[j]);
        }
    }
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      scanf("%d",&tempArr[i][j]);
  searchMinCost(tempArr,0,0);
  printf("%d\n",curMinCost);
  return 0;
}
void searchMinCost(int tempArr[N][N],int lastMove,int curCost)
{
  int h=0;
  int i,j;
  int blankI,blankJ;
  int index;
  int nextArr[N][N];
  for(i=0;i<N;++i)
    {
      for(j=0;j<N;++j)
        {
          nextArr[i][j]=tempArr[i][j];
          if(tempArr[i][j]==0)
            {
              blankI=i;
              blankJ=j;
            }
          else if(tempArr[i][j]!=ansArr[i][j])
            {
              h+=heuristic[tempArr[i][j]][ansArr[i][j]];
            }
        }
    }
  if(h==0)
    {
      if(curCost<curMinCost) curMinCost=curCost;
      return;
    }
  if(curCost+h>curMinCost) return;
  if(blankI>0&&lastMove!=3)
    {
      index=blankI-1;
      nextArr[blankI][blankJ]=nextArr[index][blankJ];
      nextArr[index][blankJ]=0;
      searchMinCost(nextArr,1,curCost+1);
      nextArr[index][blankJ]=nextArr[blankI][blankJ];
      nextArr[blankI][blankJ]=0;
    }
  if(blankJ>0&&lastMove!=4)
    {
      index=blankJ-1;
      nextArr[blankI][blankJ]=nextArr[blankI][index];
      nextArr[blankI][index]=0;
      searchMinCost(nextArr,2,curCost+1);
      nextArr[blankI][index]=nextArr[blankI][blankJ];
      nextArr[blankI][blankJ]=0;
    }
  if(blankI<N-1&&lastMove!=1)
    {
      index=blankI+1;
      nextArr[blankI][blankJ]=nextArr[index][blankJ];
      nextArr[index][blankJ]=0;
      searchMinCost(nextArr,3,curCost+1);
      nextArr[index][blankJ]=nextArr[blankI][blankJ];
      nextArr[blankI][blankJ]=0;
    }
  if(blankJ<N-1&&lastMove!=2)
    {
      index=blankJ+1;
      nextArr[blankI][blankJ]=nextArr[blankI][index];
      nextArr[blankI][index]=0;
      searchMinCost(nextArr,4,curCost+1);
    }
}


Measured memory_bytes: 2084
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

class AtCoder
{
    const int MOD = 1000000007;
    
    public void Slove()
    {
        var n = int.Parse(Console.ReadLine());
        var array = Console.ReadLine().Split().Select(int.Parse)
            .OrderBy(x => x)
            .ToArray();
        if(array[n / 2] == array[n / 2 - 1]|| (n & 1) == 1)
        {
            System.Console.WriteLine(0);
        }
        else
        {
            System.Console.WriteLine(array[n / 2] - array[n / 2 - 1]);
        }
    }
    static void Main()
    {
        var ac = new AtCoder();
        ac.Slove();
    }
}

Measured memory_bytes: 22112
N = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
    if i not in d:
        d[i] = 1
    else:
        d[i] +=1
if len(d) == 1 and list(d.keys())==[0]:
    print('Yes')
elif len(d) == 2:
    for i in d:
        if i == 0 and d[i] * 3 != N or i != 0 and d[i] * 3 != 2 * N:
            print('No')
            exit()
    print('Yes')
elif len(d) == 3:
    s = 0
    for i in d:
        s ^= i
        if d[i] * 3 != N:
            print('No')
            exit()
    if s != 0:
        print('No')
    else:
        print('Yes')
else:
    print('No')


Measured memory_bytes: 92912
import math
a,b,angle = map(int,input().split())

rad = (angle / 180) * math.pi

c = (a**2 + b**2 - 2 * a * b * math.cos(rad)) ** 0.5
s = (a+b+c)/2
S = (s*(s-a)*(s-b)*(s-c))**0.5
print(format(S,".5f"))
print(format(a+b+c,".5f"))
print(format((2*S)/a,".5f"))


Measured memory_bytes: 5728
// コッホ曲線
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>

using namespace std;

typedef struct st
{
    double x;
    double y;
}st_Coordinate;

int n;

void Koch_curve(st_Coordinate p1, st_Coordinate p2, int n);

int main(void)
{
    st_Coordinate st_start, st_end;

    st_start.x = 0; st_start.y = 0;
    st_end.x = 100; st_end.y = 0;

    scanf("%d", &n);

    if( n > 0 )
    {
        // コッホ曲線の作成
        Koch_curve(st_start, st_end, 0);
        // 求めた点の2重表示を防ぐため、最後の点だけ別に表示
        printf("%lf %lf\n", st_end.x, st_end.y);
    }
    else
    {
        printf("%lf %lf\n", st_start.x, st_start.y);
        printf("%lf %lf\n", st_end.x, st_end.y);
    }

    return 0;
}

// コッホ曲線を作成する関数
// p1 : 左端の点の座標
// p2 : 右端の点の座標
// count : 関数のcall回数
void Koch_curve(st_Coordinate p1, st_Coordinate p2, int count)
{
    double split_x, split_y;
    st_Coordinate s, t, u;

    if( count == n )
    {
        // call回数が規定値に到達した
        return;
    }

    // call回数の加算
    count++;

    split_x = ( p2.x - p1.x ) / 3.0;
    split_y = ( p2.y - p1.y ) / 3.0;

    // 左端の座標
    s.x = p1.x + split_x;
    s.y = p1.y + split_y;
    // 右端の座標
    t.x = p2.x - split_x;
    t.y = p2.y - split_y;

    // 正三角形の頂点の座標 ( t を60°だけ回転させる)
    u.x = ( cos( M_PI / 3.0 ) * ( t.x - s.x ) )
            + ( ( -1 ) * sin( M_PI / 3.0 ) * ( t.y - s.y ) ) + s.x;

    u.y = ( sin( M_PI / 3.0 ) * ( t.x - s.x ) )
            + ( cos( M_PI / 3.0 ) * ( t.y - s.y ) ) + s.y;

    if( count < n )
    {
        Koch_curve(p1, s, count);
        Koch_curve(s, u, count);
        Koch_curve(u, t, count);
        Koch_curve(t, p2, count);
    }
    else
    {
        // 座標の表示
        printf("%lf %lf\n", p1.x, p1.y);
        printf("%lf %lf\n", s.x, s.y);
        printf("%lf %lf\n", u.x, u.y);
        printf("%lf %lf\n", t.x, t.y);
        //printf("%lf %lf\n", p2.x, p2.y);
    }

    return;
}



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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 405;

int d;
vi c(27);
vvi a(N,vi(27));

void f(vi &v){
  int res = 0;
  vi last(27,-1);
  rep(i,0,d){
    last[v[i]]=i;
    fr(j,1,26)
      res-=(i-last[j])*c[j];
    res+=a[i][v[i]];
    cout<<res<<endl;
  }
}


void solve() {

  
  cin>>d;
  fr(i,1,26)
    cin>>c[i];
  rep(i,0,d)
    fr(j,1,26)
      cin>>a[i][j];
  
  vi v(d);
  rep(i,0,d)
    cin>>v[i];
  f(v);
}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
   //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}







int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


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


Measured memory_bytes: 3680
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7

a,b,c = map(int,input().split())
if b-a == c-b:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 6472
import math

n = int(input())

lim = n

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers

# 関数の呼び出し
prime = callIsPrime(n+1)

arr = [0] * len(prime)

for i in range(len(prime)):
  j = 1
  while n >= prime[i] ** j :
    arr[i] += int(n / prime[i] ** j)
    j += 1
  
ans = 1
for i in arr :
  if i != 0:
    ans *= i+1

print(ans % (10 ** 9 + 7))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;



void Main(){

  ll ans=0;
  vector<int> x(5);

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

}

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

  return 0;
}


Measured memory_bytes: 3612
N = int(input())
w = list(map(int, input().rstrip().split()))

T = 1
minimum = 10**9
for i in range(N-1):
  a = sum(w[0:T])
  b = sum(w[T:])
  c = abs(a-b)
  if c < minimum:
    minimum = c
  T += 1

print(minimum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,LL> PL;

const int MOD=1000000007;
const int INF=1001001001;
const LL LINF=100100100100100;

LL n;
LL a[200010];
vector<LL> g[200010];
LL dp[200010];
LL ans[200010];

void dfs(LL v,LL p){
  LL ima=lower_bound(dp,dp+200010,a[v])-dp;
  LL old=dp[ima];
  dp[ima]=a[v];
  ans[v]=lower_bound(dp,dp+200010,LINF)-dp-1;
  for(LL w:g[v]){
    if(w==p)continue;
    dfs(w,v);
  }
  dp[ima]=old;
}
  
int main(){
  cin>>n;
  for(LL i=0;i<n;i++)cin>>a[i];
  for(LL i=0;i<n-1;i++){
    LL u,v;cin>>u>>v;u--;v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for(LL i=0;i<200010;i++)dp[i]=LINF;
  dp[0]=-LINF;
  dfs(0,-1);
  for(LL i=0;i<n;i++)cout<<ans[i]<<endl;
  return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<ld> Point;
typedef vector<vector<int>> Graph;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<P>> testify;
    rep(i, n) {
        cin >> a[i];
        // debug(a[i]);
        vector<P> temp;
        rep(j, a[i]) {
            int c, b;
            cin >> c >> b;
            c--;
            temp.push_back(P(c, b));
        }
        testify.push_back(temp);
    }
    int ma = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        bool ok = true;
        int cnt = 0;
        rep(i, n) {
            if (bit & (1 << i)) {
                // do something
                cnt++;
                rep(j, a[i]) {
                    int to = testify[i][j].first;
                    int honest = testify[i][j].second;
                    // bool x = bit & (1 << to)
                    // debug(x);
                    // debug(to);
                    // if ((bit & (1 << to)) != honest) {
                    if (((bit >> to) & 1) != honest) {
                        ok = false;
                        goto check;
                    }
                }
            }
        }
    check:
        if (ok) ma = max(ma, cnt);
    }
    out(ma);
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();

        PrintWriter out = new PrintWriter(System.out);

        LinkedList<Long> ans = make(n, a, b);

        Iterator<Long> it = a < b ? ans.descendingIterator() : ans.iterator();

        it.hasNext();
        out.print(it.next());

        while (it.hasNext()) {
            out.print(" " + it.next());
        }

        out.println();
        out.flush();
    }

    LinkedList<Long> make(long n, long a, long b) {

        if (a < b) return make(n, b, a);
        LinkedList<Long> ans = new LinkedList<>();


        if (a * b >= n && n >= a + b - 1) {
            for (long i = 1; i <= b; i++) {
                for (long j = Math.min(a, n - b + i) - 1; j >= 0; j--)
                    ans.addLast(n - j);
                n -= Math.min(a, n + i - b);
//                debug(n, i, ans);
            }
        } else {
            ans.add(-1L);
        }

        return ans;
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 73520
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
using mint = modint998244353;
struct S{mint val, len, tens, ones;};
S op(S a, S b) {return S{a.val*b.tens+b.val, a.len+b.len, a.tens*b.tens, a.ones*b.tens+b.ones};}
S e() {return S{0, 0, 1, 0};}
S mapp(mint f, S x) {return S{f == -1 ? x.val : f*x.ones, x.len, x.tens, x.ones};}
mint comp(mint f, mint g) {return f == -1 ? g : f;}
mint id() {return -1;}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, Q;
  cin >> N >> Q;
  vector<S> init(N);
  mint b = 1;
  IREP(i, N) init[i] = S{1, 1, 10, 1};
  lazy_segtree<S, op, e, mint, mapp, comp, id> seg(init);
  REP(q, Q) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    seg.apply(l, r, d);
    cout << seg.all_prod().val.val() << "\n";
  }
}


Measured memory_bytes: 15608
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int N;
	cin>>N;
	
	int maxi = Inf;
	
	int ans = 0;
	
	for(int i=0;i<N;i++){
		int A;
		cin>>A;
		
		if(A<maxi){
			ans ++;
		}
		
		maxi = min(maxi,A);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define itn int
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

int main() {
	string s;
	cin >> s;
	long long ans = 0;
	int cnt = 0;
	for (char c : s) {
		if (c == 'B') {
			++cnt;
		} else {
			ans += cnt;
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector< pair<int, int> > A(N);
    for(int i=0; i<N; i++) {
        int v; cin >> v;
        A[i] = make_pair(v, i+1);
    }

    sort(A.begin(), A.end());
    for(int i=0; i<N; i++) {
        cout << A[i].second << " \n"[i + 1 == N];
    }
    return 0;
}


Measured memory_bytes: 1536
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  string str;

  cin >> str;

  ll ans = 700;
  if (str[0] == 'o') ans += 100;
  if (str[1] == 'o') ans += 100;
  if (str[2] == 'o') ans += 100;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 3
#define LIM 50
int buf[N][N];
int tmp[N][N];
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
void empty(int *,int *);
void swap(int *,int*);
int cal();
int dfs(int,int,int,int,int);

int main(){
  int i,j,k,x,y,ans;
  for(i = 0;i<N;i++){
    for(j=0;j<N;j++){
      scanf("%d",&buf[i][j]);
    }
  }
  empty(&x,&y);
  
  for(k = 0;k<LIM;k++){

    for(i = 0;i<N;i++){
      for(j = 0;j<N;j++){
	tmp[i][j] = buf[i][j];
      }
    }
    
    ans = dfs(x,y,-1,0,k);
    if(ans !=-1){
      printf("%d\n",ans);
      break;
    }


    for(i =0;i<N;i++){
      for(j=0;j<N;j++){
	buf[i][j] = tmp[i][j];
      }
    }
    
    ans = -1;

    if(k == 49){
      printf("%d\n",ans);
    }
  }
	
  return 0;
}

void swap(int *a,int *b){
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}



int dfs(int x,int y,int p,int depth,int lim){
  int i,h,nx,ny,res;
  h = cal();
  if(h==0) {return depth;}
  if(depth +h >lim) {return -1;}
  
  for(i=0;i<4;i++){
    nx = x+dx[i];
    ny = y+dy[i];
    if(~p && i ==(p+2)%4) continue;
    if(!(0 <=nx && nx <3 && 0 <=ny && ny <3)) continue;

    swap(&buf[y][x],&buf[ny][nx]);
    
    res = dfs(nx,ny,i,depth+1,lim);
    
    if(~res) {return res;}
    swap(&buf[y][x],&buf[ny][nx]);
  }
  return -1;
}

int cal(){
  int i,a,sum=0;
  for(i = 0;i<9;i++){
    a = buf[i/3][i%3];
    if(a) {
      a--;
      sum += abs(i/3 - a/3) +abs(i%3 - a%3);
    }
  }
  return sum;
}




void empty(int *x ,int *y){
  int i,j;
  for(i = 0 ;i <N ;i++){
    for(j = 0;j<N;j++){
      if(buf[i][j]==0)
	{
	  *x = j;
	  *y = i;
	  return ;
	}
    }
  }
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  string s;
  cin >> s;
  cout << s.substr(0,5) << " " << s.substr(6,7) << " " << s.substr(14,5) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    int x,n,p,min,ans;
    int P[1000]={0};
    cin>>x>>n;
    for(int i=1;i<=n;i++){
        cin>>p;
        P[p]=1;
    }
    for(int i=x;i<1000000;i++){
        if(P[i]==0){
            min=abs(i-x);
            ans=i;
            break;
        }
    }
    for(int i=x;i>-1000000;i--){
        if(P[i]==0){
            if(min>abs(i-x)){
                ans=i;
            }
            if(min==abs(i-x)){
                ans=std::min(ans,i);
            }
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
for b in range(N):
    r = b + 1
    for a in range(b):
        while r<N and L[r]<L[a]+L[b]: r += 1
        ans += r-(b+1)
print(ans)

Measured memory_bytes: 3188
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



n, m = LI()
ret = 0
A = LI()
for a in A:
    if a >= sum(A) / (4 * m):
        ret += 1


if ret >= m:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 39280
import numpy as np

H, W = map(int, input().split())

grid = np.zeros((H, W), dtype=int)

for h in range(H):
    S = input()
    for i, s in enumerate(S):
        if s == '#':
            grid[h][i] = 1

# print(grid)


def is_safe(h, w):
    ns = []
    ns.append((h-1, w))
    ns.append((h, w-1))
    ns.append((h+1, w))
    ns.append((h, w+1))

    safe = False
    for n in ns:
        if 0 <= n[0] and n[0] < H \
           and 0 <= n[1] and n[1] < W \
           and grid[n[0]][n[1]] == 1:
            safe = True

    if safe is False:
        print("No")
        exit(0)

    
for h in range(H):
    for w in range(W):
        if grid[h][w] == 1:
            is_safe(h, w)

print("Yes")
exit(0)


Measured memory_bytes: 20080
#include<stdio.h>

int main(void){
    int a[2][100],s[1000]={0},n,i,j,k;

    scanf("%d",&n);

    for(i=0;i<2;i++){
        for(j=0;j<n;j++){
            scanf("%d",&a[i][j]);
        }
    }

    for(k=0;k<n;k++){
        for(i=0;i<=k;i++){
            s[k]=s[k]+a[0][i];
            }
        for(j=i-1;j<n;j++){
            s[k]=s[k]+a[1][j];
        }
    }

    for(i=0;i<n;i++){
        if(s[0]<s[i]){
            s[0]=s[i];
        }
    }

    printf("%d",s[0]);

    return 0;
}


Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll m,k;
	cin>>m>>k;
	ll l=0,r=m;
	for(ll i=0;i<k;i++){
		ll x,y;
		cin>>x>>y;
		l=max(l,x);
		r=min(r,y);
	}
	if(r>=l){
		cout << r-l+1;
	}
	else{
		cout << 0;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 1;i<=n;i++)

int main(){
	int n;
	cin >> n;
	vector<int>a(n+1);
	rep(i,n)cin >> a[i];
	map<ll,ll> dic;

	rep(i,n) dic[i-a[i]]+=1;
	ll ans = 0;
	rep(i,n){
		ans += dic[i+a[i]];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 26568
main = getContents >>= print . area_of_polygon . map (map read . splitOn ',') . lines

area_of_polygon (p1:p2:p3:ps) = heron a b c + area_of_polygon (p1:p3:ps)
 where
  (a,b,c) = (distance p1 p2, distance p2 p3, distance p3 p1)
  distance [x1,y1] [x2,y2] = sqrt $ (x2-x1)^2 + (y2-y1)^2
  heron a b c = sqrt $ z * (z-a) * (z-b) * (z-c)
   where z = (a + b + c) / 2 
area_of_polygon _ = 0

splitOn c xs
 | null xs = []
 | head xs == c = splitOn c (tail xs)
 | otherwise = (takeWhile (/= c)) xs : splitOn c (dropWhile (/= c) xs)

Measured memory_bytes: 4176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

const unsigned long long BASE = 1e9 + 7;

int main()
{
    int n, x;
    cin >> n;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        if ((i + 1) % 2 == 1 && x % 2 == 1)
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> p;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

mint choose(int n, int r) {
  mint x = 1, y = 1;
  rep(i, r) {
    y *= i + 1;
    x *= n - i;
  }
  return x / y;
}

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

  mint ans = 1;
  ll t = n;
  mint cur = 2;
  
  while (t > 0) {
    if(t % 2) ans *= cur;
    cur *= cur;
    t /= 2;
  }
  ans -= 1;
  ans -= choose(n, a) + choose(n, b);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int a,b;
int cnt,ans;
int count(int s){
  if(s/10==0) return cnt;
  else {
    cnt++;
    count(s/10);
  }
}
int main(){
  while(scanf("%d %d",&a,&b)!=EOF){
    cnt=1;
    ans=count(a+b);
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 2580
N, T = map(int, input().split())
ct = [list(map(int, input().split())) for i in range(N)]
ans = 10000000
for i in ct:
    if i[1] <= T:
        ans = min(i[0], ans)
if ans == 10000000:
    ans = "TLE"
print(ans)


Measured memory_bytes: 3060
s = input()
n = len(s)
ans = [0]*n
s += "e"
start = 0
end = 0
r = 0
l = 0
for i in range(n):
    if s[i] == "L" and s[i+1] == "R" or s[i+1] == "e":
        end = i
        tmps = s[start:end+1]
        tmpn = len(tmps)
        #print(tmps,r-1,l)
        numr = r - 1
        numl = l
        #print(start,end)
        for j in range(tmpn):
            if tmps[j] == "R" and tmps[j+1] == "L":
                indexr = start + j
                indexl = start + j + 1
                break
        #print(indexr,indexl)
        if numl % 2 == 1:
            ans[indexr] += 1
        if numr % 2 == 1:
            ans[indexl] += 1
        ans[indexr] += 1 + numr // 2 + numl // 2 
        ans[indexl] += 1 + numr // 2 + numl // 2 
        start = i + 1
        r = 0
        l = 0
    else:
        if s[i] == "R":
            r += 1
        else:
            l += 1
print(*ans)

Measured memory_bytes: 6512
def is_all(t):
    for i in range(len(t)-1):
        if t[i]!=t[i+1]:
            return False
    return True

s=input()
n=len(s)
k=int(input())
cor=[1]
ans=0
c=1
if is_all(s):
    print(n*k//2)
    exit()
i=0
while i<n-1:
    if s[i]==s[i+1]:
        cor[0]+=1
        i+=1
    else:
        i+=1
        break
while i<n-1:
    if s[i]==s[i+1]:
        cor.append(1)
        while i<n-1:
            if s[i]==s[i+1]:
                cor[-1]+=1
                i+=1
            else:
                break
    i+=1
#print(cor)
if s[0]==s[-1]:
    for i in range(1,len(cor)-1):
        ans+=cor[i]//2
    ans*=k
    ans+=(cor[0]+cor[-1])//2*(k-1)
    print(ans+cor[0]//2+cor[-1]//2)
else:
    for i in range(len(cor)):
        ans+=cor[i]//2
    print(ans*k)

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

int main()
{
    int x[4];
    int y[4];
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    

    int a = y[1] - y[0];
    int b = x[0] - x[1];
    
    x[2] = x[1] - a;
    y[2] = y[1] - b;
    x[3] = x[0] - a;
    y[3] = y[0] - b;
    
    cout << x[2] << " " <<  y[2] << " "
         <<  x[3] << " " << y[3] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int m;
  cin >> m;
  cout << (24-m) + 24 << endl;
}

Measured memory_bytes: 256
n=int(input())
A=[int(i) for i in input().split()]
A.sort()
prod=1
for i in range(0,n):
  prod=prod*A[i]
  #print(prod)
  if(prod==0):
      break
  if(prod>1000000000000000000):
    prod=-1
    break
print(prod)


Measured memory_bytes: 21788
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int n, x, t; 

int main(){

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


    cin >> n >> x >> t;


    int ans = n / x;
    if(n % x) ans ++;
    ans *= t;
    cout << ans << endl;

    return 0;
}

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

int a[3005][3005];
ll dp[3005][3005][4];

int main() {
  int R, C, n;
  cin >> R >> C >> n;
  rep(i,n) {
    int r, c, v;
    cin >> r >> c >> v;
    a[r-1][c-1] = v;
  }

  rep(i,R)rep(j,C) {
    for (int k = 2; k >= 0; k--) {
      chmax(dp[i][j][k+1], dp[i][j][k]+a[i][j]);
    }
    rep(k,4) {
      chmax(dp[i+1][j][0], dp[i][j][k]);
      chmax(dp[i][j+1][k], dp[i][j][k]);
    }
  }

  ll ans = 0;
  rep(k,4) chmax(ans, dp[R-1][C-1][k]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 320304
N=int(input())
h=list(map(int, input().split()))

# m=min(h)
# for i in range(N):
# 	h[i]-=m
# ans=m
ans=0
def func(a):
	global ans

	if len(a)==0 or a==[0]:
		return
	
	m=min(a)
	for i in range(len(a)):
		a[i]-=m
	ans+=m


	for i in range(len(a)):
		if a[i]==0:
			break
	p=i
	tmp1=a[0:p]
	tmp2=a[p+1:N]


	func(tmp1)
	func(tmp2)

func(h)

print(ans)



# j=0

# while True:
# 	tmp=[]
# 	tmp.append(h[j])
# 	for i in range(j+1,N):
# 		if i>=1 and i+1<=N-1:
# 			if h[i]<h[i-1] and h[i]<h[i+1]:
# 				break
# 		tmp.append(h[i])
# 	j=i
# 	ans+=max(tmp)
# 	print(j, tmp, ans)
# 	if j>=N-1:
# 		break
	
# print(ans)

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

int main() {
  ll h;
  cin >> h;
  
  ll ans = 0;
  ll num = 1;
  while (h > 0) {
    h /= 2;
    ans += num;
    num *= 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define TT pair<long long, long long>
#define ordered_set tree<TT, null_type, less<TT>, rb_tree_tag, tree_order_statistics_node_update>
#define fo(i,n)   for(i=0;i<n;i++)
#define mem(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define mp make_pair
#define For(m) for(auto it = m.begin();it!=m.end();it++)
#define fi first
#define se second
typedef long long ll;
typedef long double mytype;
vector<ll> v[200005];
ll mod=1e9 + 7;
pair<ll,ll> dfs(ll x,ll p){
    ll i,black=1,white=1;
    pair<ll,ll> sum={1,1};
    fo(i,v[x].size()){
        if(v[x][i]!=p){
            pair<ll,ll> temp=dfs(v[x][i],x);
            white=(white*(temp.fi+temp.se))%mod;
            black=(black*temp.se)%mod;
        }
    }
    sum.fi=black;
    sum.se=white;
    return sum;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //priority_queue <int, vector<int>, greater<int> > pq;
    //cout << fixed << setprecision(9) <<ans<<endl;
    //ordered_set os;//os.order_of_key();//os.find_by_order();
    ll l,r,count,n,m,sum=0,ans=0,i,j,k,tt,t,x,y,z,c,a[200005]={},b[200005]={};
    string ss;
    set<ll> s;
    map<ll,ll> ma;
    cin>>n;
    fo(i,n-1){
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    pair<ll,ll> res=dfs(1,-1);
    cout<<(res.fi + res.se)%mod<<endl;
}

Measured memory_bytes: 14976
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long
#define ar array 
 
 
int main() {
	FAST;
 
	//int t;
	//cin >> t;
	//while(t--) 
	{
		int a,b,c;
		cin>>a>>b>>c;
		map<int,int> m;
		m[a]++,m[b]++,m[c]++;
		if(m[5]==2&&m[7]==1)
		{
			cout<<"YES\n";
		}
		else
		{
			cout<<"NO\n";
		}
	}
}


Measured memory_bytes: 3572
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
// const int MOD = 1e9 + 7;
const int MOD = 10007;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int n, r, s, p, k;
int buc[1005];
char pre[N], gre[N];

int main() {
    cin >> n >> k >> r >> s >> p;
    buc['r'] = r;
    buc['s'] = s;
    buc['p'] = p;
    scanf("%s", pre + 1);
    for (int i = 1; i <= n; i++) {
        if (pre[i] == 's') pre[i] = gre[i] = 'r';
        else if (pre[i] == 'p') pre[i] = gre[i] = 's';
        else pre[i] = gre[i] = 'p';
    }
    for (int i = 1; i <= n; i++) {
        if (i + k <= n && gre[i] == gre[i + k]) gre[i + k] = '#';
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (pre[i] == gre[i]) ans += buc[gre[i]];
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
	int a,b,c;
	int x,i=0;
	scanf("%d %d %d",&a,&b,&c);
	for(x=a;x<=b;x++){
		if(c%x==0){
			i=i+1;
		}else{
			
		}
	}
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
using namespace std;

int main()
{
    long x, y, z;
    string s, t;

    cin >> x >> y >> z ;
    
    long count=0;
    for(int i=1;i<x;i++){
        if (i*(y+z) + z <= x)count++;
        // if (i*(y+z) + z > x)break;
    }


    cout <<  count;

    return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	double A, B, H, M, t, ans;

	cin >> A >> B >> H >> M;

	H = (60 * H + M) * 0.50;
	M = M * 6.0;
	t = max(H, M) - min(H, M);
	t = min(t, 360.0 - t);
	t = t * PI / 180.0;

	ans = A * A + B * B - 2 * A * B * cos(t);
	ans = sqrt(ans);

	printf("%.15lf\n", ans);

	return 0;
}


Measured memory_bytes: 4228
t = int(input())

import fractions

for _ in range(t):
    a,b,c,d = map(int, input().split())

    if(b > d)|(a < b):
        print('No')
        continue

    if(b <= c):
        print('Yes')
        continue

    c1 = a - (1+(a-c-1)//b)*b
    if(c1 < 0):
        print('No')
        continue

    mod = fractions.gcd(b,d)
    red = c1 % mod

    for i in [0,1]:
        tmp = ((c//mod) + i)*mod + red
        if(c < tmp < b):
            print('No')
            break

        if(i==1):
            print('Yes')

Measured memory_bytes: 71276
#include <set>
#include <iostream>

int main(int argc, char *argv[]) {
  int N;
  int d[101];
  std::cin >> N;
  for (int i = 0; i < N; ++i) {
    std::cin >> d[i];
  }

  std::set<int> v;
  for (int i = 0; i < N; ++i) {
    v.insert(d[i]);
  }

  std::cout << v.size() << std::endl;
}


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

int main() {
    int n, m;
    string number;

    while (cin >> n, n) {
        number = "";
        while (n > 0) {
            m = n % 8;
            if (m > 4) {
                m += 2;
            }
            else if (m == 4) {
                m += 1;
            }
            number = " " + number;
            number[0] = '0' + m;
            n /= 8;
        }
        cout << number << endl;
    }
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}
int xs,ys,xg,yg,n;
ll w,h;
vector<vector<ll>> field;
vector<vector<ll>> f;
bool res = false;

void dfs(int x,int y,int c){
  if(f[x][y] != inf) return ;
  if(x == xg && y == yg){
    res = true;
    return ;
  }
  f[x][y] = 1;
  rep(i,4){
    int nx = x + dx[i],ny = y + dy[i];
    if(value(nx,ny,w,h) && field[nx][ny] == c){
      dfs(nx,ny,c);
    }
  }
  return ;
}

void solve(){
  f = vector<vector<ll>>(w+1,vector<ll>(h+1,inf));
  res = false;
  if(field[xs][ys] != inf){
    dfs(xs,ys,field[xs][ys]);
  }
  if(res){
    cout << "OK" << endl;
    return ;
  }
  cout << "NG" << endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(cin >> w >> h && w+h){
    field = vector<vector<ll>>(w+1,vector<ll>(h+1,inf));
    cin >> xs >> ys >> xg >> yg >> n;
    xs--,ys--,xg--,yg--;
    int c,d,x,y;
    rep(i,n){
      cin >> c >> d >> x >> y;
      --x,--y,--c;
      rep(j,2){
        rep(k,4){
          ll nx = k,ny = j;
          if(d){
            swap(nx,ny);
          }
          field[x+nx][y+ny] = c;
        }
      }
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  int n;
  cin >> n;
  if (n %2 == 0) {
    cout << n << endl;
  }
  else {
    cout << n*2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256