akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
using namespace std;
 
int main()
{
  int T,N;
  while(cin >> T,T)
    {
      vector<int> t(T+1);
      for(int i=0;i<T;i++)
	cin >> t[i];
      cin >> N;
 
      vector<int> D(101);
      for(int i=0;i<101;i++)
	D[i] = (1<<29);
 
      int mexday = 0;
      for(int i=0;i<N;i++)
	{
	  int d,m;
	  cin >> d >> m;
	  D[d] = min(D[d],m);
	  mexday = max(mexday,d);
	}
    
      int dayMin[mexday+1];
      int dp[T][mexday+1];
      for(int i=0;i<T;i++)
	for(int j=0;j<=mexday;j++)
	  dp[i][j] = dayMin[j] = (1<<29);
 
      dp[0][1] = 0;
      dayMin[1] = dp[0][1];
 
      for(int i=2;i<=mexday;i++)
	{
	  for(int j=0;j<min(i+1,T);j++)
	    {
	      if(!j)
		{
		  dp[j][i] = min(dp[j][i],dayMin[i-1]+1); 
		  dp[j][i] = min(dp[j][i],dp[T-1][i-1]+(D[i]>=t[j]?0:1));
		  dayMin[i] = min(dp[j][i],dayMin[i]);
		  continue;
		}
	      if(dp[j-1][i-1] == (1<<29))
		continue;
	    
	      if(D[i]>=t[j])
		dp[j][i] = min(dp[j][i],dp[j-1][i-1]);
	      else
		dp[0][i] = min(dp[0][i],dp[j][i]+1);
	      dayMin[i] = min(dp[j][i],dayMin[i]);      
	    }
	}
     
      int ans = (1<<29);
      for(int i=0;i<T;i++)
	ans = min(ans,dp[i][mexday]);
      assert(ans != (1<<29));
      cout << ans << endl;
    }
  return 0;
}

Measured memory_bytes: 1204
n=int(input())
lst=[None]*n
for i in range(n):
    a,b,c=map(int,input().split())
    lst[i]=[a,b,c]
lst=sorted(lst,key=lambda x:x[2],reverse=True)
for i in range(101):
    for j in range(101):
        switch=0
        x,y,z=lst[0]
        height=z+abs(i-x)+abs(j-y)
        for k in range(1,n):
            x,y,z=lst[k]
            if z==0:
                if abs(i-x)+abs(j-y)<height:
                    switch=1
                    break
            elif abs(i-x)+abs(j-y)+z!=height:
                switch=1
                break
        if switch==0:
            print(i,j,height)

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

using namespace std;

#define ll long long
#define M 1005000
#define ii pair<ll, ll>
#define fi first
#define se second

ll n, m, x, y, ans;
vector<ll> mp[M];
multiset<ll> s;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    
    cin >> n >> m;
    for (int i = 0; i < n; i++){
        cin >> x >> y;
        if (x <= m) mp[x].push_back(y);
    }
    for (int i = 1; i <= m; i++){
        if (mp[i].size() > 0){
            for (ll v : mp[i]) s.insert(-v);
            mp[i].clear();
            break;
        }
    }
    for (int i = 1; i <= m; i++){
        if (mp[i].size() > 0) for (ll v : mp[i]) s.insert(-v);
        if (s.size() > 0){
            ans += -(*s.begin());
            s.erase(s.begin());
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 29440
NN = 17
MI = [1<<100] * ((1<<NN+1)-1)
def update(a, x):
    i = (1<<NN) - 1 + a
    MI[i] = min(MI[i], x)
    while True:
        i = (i-1) // 2
        MI[i] = min(MI[2*i+1], MI[2*i+2])
        if i == 0:
            break

def rangemin(a):
    l = a + (1<<NN)
    r = ((1<<NN+1)-2)
    mi = 1<<100
    while l < r:
        if l%2:
            mi = min(mi, MI[l-1])
            l += 1
        if r%2:
            r -= 1
            mi = min(mi, MI[r-1])
        l >>= 1
        r >>= 1
    return mi

N, M = map(int, input().split())
X = []
for _ in range(M):
    l, r, c = map(int, input().split())
    X.append((l, r, c))

X = sorted(X)
update(1, 0)
for l, r, c in X:
    mi = rangemin(l)
    update(r, mi + c)

ans = MI[(1<<NN) - 1 + N]
print(ans if ans < 1<<100 else -1)


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

int n;
int cnt;
int base[3] = {3, 5, 7};

void solution(int x, int len, int pick_cnt[]) {
    if (to_string(x).length() == len) {
        if (x > n) {
            return;
        }
        
        if (pick_cnt[0] && pick_cnt[1] && pick_cnt[2]) {
            cnt++;
        }
        return;
    }
    
    for (int i = 0; i < 3; i++) {
        x *= 10;
        x += base[i];
        pick_cnt[base[i] / 2 - 1]++;
        solution(x, len, pick_cnt);
        pick_cnt[base[i] / 2 - 1]--;
        x -= base[i];
        x /= 10;
    }
    
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    cin >> n;
    
    for (int i = 3; i <= to_string(n).length(); i++) {
        int pick_cnt[3] = {0, };
        solution(0, i, pick_cnt);
    }
    
    cout << cnt << '\n';
    
    return 0;
}


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


def main():
    k, a, b = map(int, input().split())

    if k + 1 < a:
        print(k + 1)
    else:
        if a + 2 >= b:
            print(k + 1)
        else:
            count = k + 1 - a
            ans = count % 2
            exchange_count = count // 2
            ans += exchange_count * b - (exchange_count - 1) * a
            print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int n,m;
  cin >> n;
  vector<string> b(n);
  rep(i,n) cin >> b[i];
  cin >> m;
  vector<string> r(m);
  rep(i,m) cin >> r[i];
  
  int ans=0;
  rep(i,n){
    int score=0;
    rep(j,n){
      if(b[i]==b[j]) score++;
    }
    rep(j,m){
      if(b[i]==r[j]) score--;
    }
    
    ans=max(ans,score);
  }
  cout << ans << endl;
  
  return 0;
}


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

using namespace std;
int main(){
  int64_t a,b,c,d;
  cin >> a >> b >> c >> d;
  
  int64_t x,y,z,w;
  x = a*c;
  y = a*d;
  z = b*c;
  w = b*d;
  
  int64_t ans = max(max(x,y),max(z,w));
  
  cout << ans << endl;
}

Measured memory_bytes: 3628
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define pb push_back
using ll = long long;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(){
  int N = 0;
  int temp = 0;
  vector<int> A;
  vector<int> B;
  vector<int> C;

  int ans = 0;

  cin >> N;
  REP(i,N){
    cin >> temp;
    A.pb(temp);
  }
  REP(i,N){
    cin >> temp;
    B.pb(temp);
  }
  REP(i,N-1){
    cin >> temp;
    C.pb(temp);
  }

  REP(i,N){
    ans = ans + B[A[i]-1];
    if(i > 0){
      if(A[i]- A[i-1] == 1)ans = ans + C[A[i]-2];
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}

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

    vector<int>a(n);
    rep(i,n)cin>>a[i];

    int cnt=0;

    rep(i,n) if(a[a[i]-1]==i+1)cnt++;

    cout<<cnt/2<<endl;

}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
      	int A = input.nextInt();
      	int B = input.nextInt();
      	int C = input.nextInt();
      
      	if (B / A >= C) {
        	System.out.print(C);
        } else {
        	System.out.print(B / A);
        }
      	

    }
 
}


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

int main() {
  int N, D, x[200010], y[200010];
  cin >> N >> D;
  for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
  
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (sqrt(pow(x[i], 2) + pow(y[i], 2)) <= D) count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 5236
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    char a[3];
    scanf("%s",a);
    int count=0,i=0;
    while(i<3)
    {
        if(a[i]=='R')
            count++;
        i++;
    }
    if(a[1]!='R'&&count!=0)
        printf("1\n");
    else if(a[1]=='R'&&count!=0)
        printf("%d\n",count);
    else
        printf("0\n");
    return 0;
}


Measured memory_bytes: 3724
#include<stdio.h>

int main(void)
{
   int n;
   int ans;

   while(1){
      scanf("%d",&n);
      if(n==0)break;
      ans=0;
      while(n>4){//5,25,125,…,5^nが何回かけられたかを数える
         ans+=n/5;
         n/=5;
      }
      printf("%d\n",ans);
   }
   return 0;
}

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

const int64_t MOD = 1000000007;
int64_t ff[2000006];

int64_t fact(int n) {
  if (n == 0) return 1;
  if (n == 1) return 1;
  if (ff[n] != 0) return ff[n];
  ff[n] = (fact(n-1) * n) % MOD;
  return ff[n] % MOD;
}

int64_t pm(int64_t a, int64_t b) {
  if (b == 0) return 1;
  if (b == 1) return a % MOD;
  int64_t v = pm(a, b/2) % MOD;
  v = v * v % MOD;
  if (b % 2) {
    return v * a % MOD;
  }
  return v;
}

int main() {
  int64_t ans = 0;
  int N;
  int K;
  std::cin >> K;
  std::string s;
  std::cin >> s;
  N = s.size();

  int64_t st = N + K;
  for (; st >= N; --st) {
    int64_t v = pm(26, N + K - st) * pm(25, st - N) % MOD;
    v = v*fact(st - 1) % MOD;
    v = v*pm(fact(st-N), MOD-2) % MOD;
    v = v*pm(fact(N-1), MOD-2) % MOD;
    ans += v;
    ans = ans % MOD;
  }

  printf("%lld\n", ans % MOD);
}


Measured memory_bytes: 51156
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long LL;
const LL Maxn=1e18+1;
LL x,y,a[100];
int main()
{
	//x 2*x 2*2*x 
	int sz=0;
	scanf("%lld%lld",&x,&y);
	a[0]=1;
	for(sz=1;a[sz-1]<Maxn;sz++)
		a[sz]=a[sz-1]*2;
	for(int i=0;i<sz;i++)
		if(x*a[i]>=y)
		{
			if(x*a[i]>y) i--;
			printf("%d\n",i+1);
			return 0;
		}
	return 0;
}


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

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

    bool ans = false;
    for(int i = 0; i < n; ++i) {
        ans |= a[i] & 1;
    }

    cout << (ans ? "first" : "second") << endl;
}


Measured memory_bytes: 640
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll A,B,H,M;cin>>A>>B>>H>>M;
    ld th=(H*60.0+M)/(12*60)*2*PI;
    ld tm=(M)/60.0*2*PI;
    ld Ax=A*cos(th);
    ld Ay=A*sin(th);
    ld Bx=B*cos(tm);
    ld By=B*sin(tm);
    ld d=hypot(Bx-Ax,By-Ay);
    cout<<dcml(16)<<d<<"\n";
}


Measured memory_bytes: 4184
n = int(input())
s = input()

def search(x):
    d = set()
    for i in range(n-2*x+1):
        d.add(s[i:i+x])
        if s[i+x:i+2*x] in d:
            return True
    return False

l = 0
r = n//2+1
while r > l+1:
    mid = (r+l)//2
    if search(mid):
        l = mid
    else:
        r = mid
print(l)

Measured memory_bytes: 6388
program inscribed_bicycle
  implicit none
  real(8) :: x(3), y(3), r(3), a, b, c, h
  real(8) :: a2, b2, c2
  character(64) :: s
  read(*,*) x(1), y(1)
  read(*,*) x(2), y(2)
  read(*,*) x(3), y(3)
  r(1) = sqrt((x(2)-x(1))**2.d0+(y(2)-y(1))**2.d0)
  r(2) = sqrt((x(3)-x(2))**2.d0+(y(3)-y(2))**2.d0)
  r(3) = sqrt((x(1)-x(3))**2.d0+(y(1)-y(3))**2.d0)
  a = minval(r)
  c = maxval(r)
  b = sum(r)-a-c
  a2 = a*a
  b2 = b*b
  c2 = c*c
  h = sqrt(2.d0*(a2*b2+b2*c2+c2*a2)-a2*a2-b2*b2-c2*c2)/(2.d0*c)
  write(s,'(f32.16)') c*h/(a+b+c+2.d0*h)
  write(*,'(a)') trim(adjustl(s))
  stop
end program inscribed_bicycle

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using static Reader;

public static class P
{
    public static void Main()
    {
        long n, k;
        long[] a;
        n = NextLong;
        k = NextLong;
        a = Enumerable.Repeat(0, (int)n).Select(_ => NextLong - 1).ToArray();
        
        var accum = new long[n + 1];
        for (int i = 1; i < accum.Length; i++)
            accum[i] = (accum[i - 1] + a[i - 1]) % k;
        long res = 0;
        Dictionary<long, long> count = accum.Distinct().ToDictionary(x => x, _ => 0L);
        var max = Min(k, accum.Length);
        for (int i = 0; i < max; i++)
        {
            res += count[accum[i]];
            count[accum[i]]++;
        }
        for (int i = (int)max; i < accum.Length; i++)
        {
            count[accum[i - k]]--;
            res += count[accum[i]];
            count[accum[i]]++;
        }
        Console.WriteLine(res);
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = 0;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }


    public static long NextLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (long)(Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }
}


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

int main() {
  int N, ans=0;
  string YN = "No";
  cin >> N;
  vector<int> item(N);
  
  for (int i = 0; i < N; i++) cin >> item.at(i);
  
  sort(item.begin(), item.end());
  for (int j = 0; j < N-1; j++) ans = ans + item.at(j);
  if (item.at(N-1) < ans) YN = "Yes";

  cout << YN << endl;
}

Measured memory_bytes: 3620
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
INF=10**9

def dfs(cur,a,b,c):
  if cur==N:
    #1本目にはコストはかからないので30引く
    return abs(A-a)+abs(B-b)+abs(C-c)-30 if min(a,b,c)>0 else INF
  #cur本目の竹を使わない
  ret0=dfs(cur+1,a,b,c)
  #cur本目の竹をAにつなぐ(MP10)
  ret1=dfs(cur+1,a+l[cur],b,c)+10
  #cur本目の竹をBにつなぐ(MP10)
  ret2=dfs(cur+1,a,b+l[cur],c)+10
  #cur本目の竹をCにつなぐ(MP10)
  ret3=dfs(cur+1,a,b,c+l[cur])+10
  
  return min(ret0,ret1,ret2,ret3)
  
print(dfs(0,0,0,0))

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<ll>> cake(n,vector<ll>(3));
  for(int i=0; i<n; ++i) for(int j=0; j<3; ++j){
    cin >> cake[i][j];
  }
  ll ans =0;
  for(int i=0; i<8; ++i){
    vector<ll> score(n,0);
    for(int j=0; j<n; ++j) for(int k=0; k<3; ++k){
      if(i>>k&1) score[j] -= cake[j][k];
      else score[j] += cake[j][k];
    }
    sort(score.rbegin(),score.rend());
    ll nans = 0;
    for(int j=0; j<m; ++j){
      nans += score[j];
    }
    ans = max(ans, nans);
  }
  cout << ans << endl;
}

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


int main ()
{
    int n;
    cin>>n;
    int a[n+1];
    bool b[n+1]= {false};

    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    int s;
    int m=0;
    for(int i=n; i>0; i--)
    {
        s=0;
        for(int j=i; j<=n; j+=i)
        {
            if(b[j]==true)
                s++;
        }
        if(s%2!=a[i])
        {
            b[i]=true;
            m++;
        }

    }
    cout<<m<<endl;
    for(int i=1; i<=n; i++)
    {
        if (b[i]==true)

            cout<<i<<" ";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 1920
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

@mt
def slv(S, T):
    ans = INF
    for i in range(len(S)-len(T)+1):
        t = 0
        for j in range(len(T)):
            if S[i+j] != T[j]:
                t += 1
        ans = min(ans, t)

    return ans


def main():
    S = read_str()
    T = read_str()
    print(slv(S, T))


if __name__ == '__main__':
    main()


Measured memory_bytes: 83816
#pragma GCC optimize("Ofast")
  #pragma GCC target("avx,avx2,fma")
  #include <bits/stdc++.h>
  using namespace std;
  //---------------------------------//
  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define deb(x...)
  #endif
 //------------------------------//

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  all(x)       (x).begin(), (x).end()
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;


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

  int main(){
    IOS
    	solve();
    //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow

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

int main ()
{

  
  long long int N,M;
  long long int A,B;
  long long int count=0;
 
  cin >>N>>M;
  long long int tab[N+5];//obs
  vector<long long int> cores[100005];//linked roads
 
 
  for(long long int i=1;i<=N;i++)
   {
     cin>>tab[i];
   }
 
  for(long long int i=0;i<M;i++)
    {
      cin>>A>>B; //road A linked to B
      cores[A].push_back(B);
      cores[B].push_back(A);
    }
 
for(long long int i=1;i<=N;++i)
{

    bool good=true;
   for(long long int it :cores[i])
    {   
        if(tab[it] >= tab[i]){
            good = false;
            break;
        }    
    }
    if(good){
        count++;
    }
}
 
 cout<<count;
 
return 0;
}

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

int main(){
	int n,m;
	cin >>n>>m;
	vector<int> l(m),r(m);
	rep(i,m){
		cin >>l[i]>>r[i];
		l[i]--;r[i]--;
	}
	vector<int> s(n,0);
	int le=0,ri=n;
	rep(i,m){
		le = max(l[i],le);
		ri = min(r[i],ri);
	}
	if (ri-le<0)
		cout << "0";
	else
		cout <<ri-le+1;

}

Measured memory_bytes: 1408
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = map(int, raw_input().split())
cnt = 0
while N > 0:
    N /= K
    cnt += 1
print cnt

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

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

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<ll,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

constexpr int MAX_A = 7368792;

bool solve(){
    int n, q;
    cin >> n >> q;
    if(n == 0) return true;
    vector<pair<int,string> > v;
    vector<P> cnt;
    for(int i=0;i<n;i++){
        string en;
        int ey, wy;
        cin >> en >> ey >> wy;
        v.emplace_back(make_pair(wy-ey+1,en));
        cnt.emplace_back(P(wy-ey+1,1));
        cnt.emplace_back(P(wy+1,-1));
    }
    sort(v.begin(), v.end());
    sort(cnt.begin(), cnt.end());
    cnt.emplace_back(P(INF,0));
    for(int i=0;i<int(cnt.size())-1;i++){
        cnt[i+1].second += cnt[i].second;
    }
    for(int i=0;i<q;i++){
        int y;
        cin >> y;
        if(y < v[0].first || (--lower_bound(cnt.begin(),cnt.end(),P(y+1,0)))->second != 1){
            cout << "Unknown" << endl;
            continue;
        }
        auto p = --upper_bound(v.begin(), v.end(), make_pair(y,string("~")));
        cout << p->second << " " << y-p->first+1 << endl;
    }
    return false;
}

int main(){
    while(!solve());
    return 0;
}


Measured memory_bytes: 3112
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

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


int dfs(int N, int M, int id, std::vector<int>& A, int prv,
        std::vector<int>& a, std::vector<int>& b,
        std::vector<int>& c, std::vector<int>& d){
    std::vector<int> B(A);
    if(id == N){
        int ans(0);
        for(int i(0), i_len(a.size()); i < i_len; ++i){
            if(A[b[i]-1] - A[a[i]-1] == c[i]) ans += d[i];
        }
        return ans;
    }
    int ans(0);
    for(int i(prv); i <= M; ++i){
        B[id] = i;
        chmax(ans, dfs(N, M, id+1, B, i, a, b, c, d));
    }
    return ans;
}


int main(){
    int N, M, Q; std::cin >> N >> M >> Q;
    std::vector<int> a(Q), b(Q), c(Q), d(Q);
    for(int i(0); i < Q; ++i){
        std::cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    std::vector<int> A(N, 0);
    std::cout << dfs(N, M, 0, A, 1, a, b, c, d) << std::endl;
    return 0;
}


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

int main() {
	float f;
	while (cin >> f && f >= 0.0) {
		bool n[12];
		int j = 0;
		for (int i = 7; i >= -4; --i, ++j) {
			if (f >= pow(2, i)) {
				n[j] = true;
				f -= (float)pow(2, i);
			}
			else {
				n[j] = false;
			}
		}
		if (f == 0) {
			for (int i = 0; i < 12; ++i) {
				if (n[i]) { cout << '1'; }
				else { cout << '0'; }
				if (i == 7) { cout << '.'; }
				if (i == 11) { cout << endl; }
			}
		}
		else {
			cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    int x, y, z;
    cin >> x >> y >> z;

    cout << z << ' ' << x << ' ' << y << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x,reverse=True)
dist = []
for i in range(len(x)-1):
    dist.append(x[i]-x[i+1])
dist = sorted(dist,reverse=True)
ext = n-1
for i in range(ext):
    if not dist:
        print(0)
        exit()
    dist.pop(0)
print(sum(dist))

Measured memory_bytes: 13968
n = int(raw_input())
c = [int(raw_input()) for i in range(n)]
mod = 1000000007

dp = [0] * len(c)
last = [-1] * 200001
dp[0] = 1
last[c[0]] = 0
for i in range(1, len(c)):
    dp[i] = dp[i - 1]
    if last[c[i]] >= 0 and last[c[i]] < i - 1:
        dp[i] = (dp[i] + dp[last[c[i]]]) % mod
    last[c[i]] = i

print dp[-1]

Measured memory_bytes: 21992
N, K = map(int, input().split())

snukes = [0] * N

for i in range(K):
    d = int(input())
    arr = list(input().split())
    for j in range(d):
        snukes[int(arr[j]) - 1] += 1

non_zero_values = 0
for i in range(N):
    if snukes[i] == 0:
        non_zero_values += 1

print(non_zero_values)

Measured memory_bytes: 8928
n,p=map(int,input().split())
arr=list(map(int,input().split()))
dp=[[0]*(n+1) for _ in range(2)]
dp[0][0]=1
for i in range(n):
  if arr[i]%2==0:
    dp[0][i+1]=dp[0][i]*2
    dp[1][i+1]=dp[1][i]*2
  else:
    dp[0][i+1]=dp[0][i]+dp[1][i]
    dp[1][i+1]=dp[0][i]+dp[1][i]
print(dp[p][n])

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


int main(){
  int x;
  cin >> x;
  if(x == 7 || x ==5 || x ==3) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n; cin >> n;
    ll sum = 0;
    vector<ll> A(n + 1);
    for(int i = 1; i <= n; i++)
    {
        cin >> A[i];
        sum += A[i];
    }
    vector<ll> B;
    for(int i = 2; i < n; i += 2)
    {
        sum -= 2 * A[i];
    }
    B.push_back(sum);
    for(int i = 1; i < n; i++)
    {
        B.push_back(2 * A[i] - B.back());
    }
    for(int i = 0; i < n; i++)
    {
        cout << B[i] << " ";
    }
    cout << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int t[n];
	for(int i= 0;i<n;i++)cin>>t[i];
	int x = t[n-1];
	int j = 0,i;
	for(i = 0;i<n-1;i++){
		if(x >= t[i]){
			swap(t[i],t[j]);
			j++;
			
		}
		if(t[i]<=t[j]);
	}
	swap(t[j],t[n-1]);
	for(int k = 0;k<n;k++){
		if(k)cout<<" ";
		if(k == j){
			cout<<"["<<t[k]<<"]";
			continue;
		}
		cout<<t[k];
	}
	cout<<endl;
}


Measured memory_bytes: 3496
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]
#まず,足場k+1番目までについて,それぞれ最小コスト入れる
if n>k-1:
  for i in range(k):
    dp.append(abs(h[i+1]-h[0]))
else:
  print(abs(h[n-1]-h[0]))
  exit()


#k+2番目以降について,それぞれ最小コストを求める
for i in range(k+1,n):
  #最小のものの候補配列を作る
  temp=[]
  for j in range(k):
    temp.append(abs(h[i]-h[i-j-1])+dp[i-j-1])
  dp.append(min(temp))

print(dp[n-1])

Measured memory_bytes: 57824
#include <stdio.h>

main()
{

  int i, j, n, k, flag, count=0;
  int A[100];

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

  flag=1;
  while(flag){
	flag=0;
	for(j=n-1; j>=1; j--){
	  if(A[j]<A[j-1]){
		k = A[j];
		A[j] = A[j-1];
		A[j-1] = k;
		flag=1;
		count++;
	  }
	}
  }
  
  
  for(i=0; i<n; i++){
	printf("%d", A[i]);
	if(i== n-1) printf("\n");
	else printf(" ");
  }
  printf("%d\n", count);

return 0;
}

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

template<int64_t mod_ = 1'000'000'007>
class ModInt {
private:
	int64_t integer_;

public:
	ModInt(const int64_t initial_number = 0)
		: integer_(initial_number){}
	
	// 四則演算
	ModInt operator+(const int64_t operand)
	{
		int64_t ret{integer_ + operand};
		if (ret >= mod_)
			ret -= mod_;
		return ModInt(ret);
	}
	ModInt operator-(const int64_t operand)
	{
		int64_t ret{integer_ - operand};
		if (ret < 0)
			ret += mod_;
		return ModInt(ret);
	}
	ModInt operator*(const int64_t operand)
	{
		return ModInt(integer_ * operand % mod_);
	}
	ModInt operator/(const int64_t operand)
	{
		int64_t ret{1}, pow_ope{operand};
		for (int64_t pow_mod{mod_ - 2}; pow_mod > 0; pow_mod >>= 1)
		{
			if (pow_mod & 1)
				ret = ret * pow_ope % mod_;
			pow_ope = pow_ope * pow_ope % mod_;
		}
		return (*this) * ModInt(ret);
	}

	// 代入
	ModInt& operator=(const int64_t operand)
	{
		integer_ = operand;
		return *this;
	}
	ModInt& operator+=(const int64_t operand)
	{
		*this = *this + operand;
		return *this;
	}
	ModInt& operator-=(const int64_t operand)
	{
		*this = *this - operand;
		return *this;
	}
	ModInt& operator*=(const int64_t operand)
	{
		*this = *this * operand;
		return *this;
	}
	ModInt& operator/=(const int64_t operand)
	{
		*this = *this / operand;
		return *this;
	}

	// その他
	operator int64_t() { return integer_; }
};

template<int64_t mod_ = 1'000'000'007>
class Combination {
public:
	std::vector<ModInt<mod_>> inv, fact, finv;

	Combination(const int max = 200'000)
		: inv(max + 1), fact(max + 1), finv(max + 1)
	{
		inv[0] = inv[1] = fact[0] = fact[1] = finv[0] = finv[1] = 1;
		for (int num{2}; num <= max; num++)
		{
			inv[num] = (mod_ - (int64_t)inv[mod_ % num] * (mod_ / num) % mod_) % mod_;
			fact[num] = num * fact[num - 1] % mod_;
			finv[num] = inv[num] * finv[num - 1] % mod_;
		}
	}

	int64_t getCombi(const int n, const int r)
	{
		if (r < 0 || n < 0 || n - r < 0) return 0;
		return fact[n] * finv[r] * finv[n - r];
	}

	int64_t getPerm(const int n, const int r)
	{
		if (r < 0 || n < 0 || n - r < 0) return 0;
		return fact[n] * finv[n - r];
	}
};

int64_t solve();

int main()
{
	int Q;
	scanf("%d", &Q);
	for (int i{}; i < Q; i++)
		printf("%lld\n", solve());

	return 0;
}

constexpr int64_t mod{1'000'003};
Combination<mod> combi(mod);

int64_t pow(int64_t a, int64_t b)
{
	ModInt<mod> ret(1), tmp(a);
	while (b)
	{
		if (b & 1) ret *= tmp;
		tmp *= tmp;
		b >>= 1;
	}
	return (int64_t)ret;
}

int64_t solve()
{
	int64_t x, d, n;
	scanf("%lld%lld%lld", &x, &d, &n);
	if (x == 0) return 0ll;
	if (d == 0) return pow(x, n);
	ModInt<mod> xd_inv(ModInt<mod>(mod - x) / ModInt<mod>(d));
	if ((int64_t)xd_inv <= n - 1) return 0ll;
	// 0 < x < mod, d > 0, n-1 <-x/d < mod
	return ModInt<mod>(combi.getPerm(xd_inv, n)) * pow(mod - d, n);
}

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    LL n;
    cin >> n;
    vector<LL> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    LL m=0;
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {
            m = max(m, abs(v[i] - v[j]));
        }
    }

    cout << m << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N = int(readline())
k = -1
for i in range(1,1000):
    if i*(i-1)//2 == N:
        k = i
        print('Yes')
        break
if k == -1:
    print('No')
    exit()

print(k)
ans = [[] for i in range(k)]

import itertools

for i,(a,b) in enumerate(itertools.combinations(range(k),2),1):
    ans[a].append(i)
    ans[b].append(i)

for aaa in ans:
    print(len(aaa),*aaa)



Measured memory_bytes: 9520
#include <bits/stdc++.h>
using namespace std;
int N, A, B;
int main()
{
	scanf("%d%d%d", &N, &A, &B);
	if ((N == 1 && (A != B)) || (B < A))cout<<0<<endl;
	else if (N == 1 && (A == B))cout<<1<<endl;
	else printf("%lld\n", (long long)((long long )(N - 2) * (B - A) + 1) );
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int N;
  int s[200];
  int i;
  int count1 = 0;
  int count2 = 0;
  
  scanf("%d",&N);
  
  for(i = 0; i < N; i++){
   scanf("%d ",&s[i]);
  }
  
  while(1){
    for(i = 0; i < N; i++){
      if(s[i] % 2 == 0){
        count1 ++; 
      }
      s[i] = s[i] / 2;
    }
    if(count1 == N){
      count2 ++;
      count1 = 0;
    }
    else	break;
  }
  
  printf("%d", count2);
  
  return 0; 
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    int ans = 0;
    rep(i,101){
        int tmp = 0;
        rep(j,n)if(a[j] > i){
            tmp++;
            while(j < n && a[j] > i)j++;
            j--;
        }
        //cout << i << " " << tmp << endl;
        if(tmp)ans += tmp;
        else break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,K,C;
ll A[100001];
int B[100001];
vector<int> ans;



int main(){
    cin >> N;
    ll ans = 0;
    ll cnt = 1;
    while(N>=1){
        ans += cnt;
        if(N==1){
            cout << ans << endl;
            break;
        }else{
            cnt *= 2;
            N/=2;
        }
    }
    
}




Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    c = [SS() for _ in range(3)]

    ans = ''.join(c[i][i] for i in range(3))
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9916
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	a, b, c = MAP()
	if a + b > c:
		print("No")
	else:
		if (c - (a+b))**2 - 4*a*b > 0:
			print("Yes")
		else:
			print("No")


if __name__=='__main__':
	main()


Measured memory_bytes: 5148
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int a,b;
	double ans;
	cin>>a>>b;
	for(int i=1;i<=a;i++){
		int j=i;
		double cnt=1;
		while(b>j){
			j*=2;
			cnt/=2;
		}
		ans+=cnt;
	}
	printf("%.1000lf\n",ans/a);
	return 0;
}


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

int main()
{
    vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin >> s;
    int ans;
    for(int i = 0; i < 7; ++i)
    {
        if(s == days[i])
        {
            ans = 7 - i;
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;

const int INF = 1e9 + 10;
const ll INFLL = 3e18;

ll bs(vector<int>& v, int x, bool hi){
	
	int l = 0;
	int r = v.size() - 1;
	int ans = 0;
	
	while(l <= r){
		
		int mid = (l + r)/2;
		if(hi){ // procurando maior
			if(v[mid] <= x){
				l = mid + 1;
			} else {
				r = mid - 1;
				ans = v.size() - mid;
			}
		} else { // procurando menores
			if(v[mid] >= x){
				r = mid - 1;
			} else {
				l = mid + 1;
				ans = mid + 1;
			}
		}
	}
	
	return ans;
}

int main(){
	
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	vector<int> a(n), b(n), c(n);
	
	for(int i = 0 ; i < n ; i ++)
		cin >> a[i];
	
	for(int i = 0 ; i < n ; i ++)
		cin >> b[i];
	
	for(int i = 0 ; i < n ; i ++)
		cin >> c[i];
	
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	
	ll ans = 0;
	
	for(int i = 0 ; i < n ; i ++){
		
		ll smalla = bs(a, b[i], 0);
		ll smallb = bs(c, b[i], 1);
		ans += smalla*smallb;
	}
	
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

const ll MX=1E16+1000;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll k;
	cin>>k;
	ll n=50;
	cout<<n<<'\n';
	vector<ll> res(n);
	for(int i=0;i<n;++i) res[i]=i+(k/n);
	for(int i=0;i<k%n;++i)
		for(int j=0;j<n;++j)
			if(j==i) res[j]+=n;
			else res[j]--;
	for(ll x:res) cout<<x<<' ';
	cout<<endl;
}




Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n,0),b(n,0);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    vector<pair<ll,int> > res(n);
    for(int i = 0; i < n; i++){
        res[i].first = a[i] - b[i];
        res[i].second = i;
    }

    sort(all(res));

    int ans = -1;
    int now = n-1;
    for(int i = 0; i < n; i++){
        if(res[i].first>=0){
            ans = i;
            ans += n-now;
            if(res[now].first == a[res[now].second] - b[res[now].second]) ans--;
            break;
        }

        while(res[i].first<0){
            if(res[now].first <= 0) break;
            if(abs(res[i].first)<res[now].first ){
                res[now].first -= abs(res[i].first);
                if(res[now].first==0) now--;
                res[i].first = 0;
            }else{
                res[i].first += res[now].first;
                res[now].first = 0;
                now--;
            }
        }

        if(res[i].first < 0) break;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3328
fun max(x: Int, y: Int): Int {
    return if(x > y) x else y
}


fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }

    var ans = 1
    var d = 1

    while (d * d <= M) {
        if (M%d==0) {
            val e = M/d
            if (M/N >= d)
                ans = max(ans, d)
            if (M/N >= e)
                ans = max(ans, e)
        }
        d += 1
    }
    println(ans)
}

Measured memory_bytes: 38052
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> vec(m);
for(int i=0;i<m;i++){
  cin>>vec.at(i);
}
int sum=0;
for(int i=0;i<m;i++){
  if(vec.at(i)<x){
      sum++;
  }
}
cout<<min(sum,m-sum)<<endl;
}


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

using namespace std;

const long long md = (long long) 1e9 + 7;

void solve() {
    string s;
    cin >> s;

    const int n = s.size();

    long long dp[n + 1][4];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= 3; j++) {
            dp[i][j] = 0;
        }
    }

    dp[0][0] = 1;
    for (int j = 0; j <= 3; j++) {
        for (int i = 1; i <= n; i++) {
            if (s[i - 1] - 'A' == j - 1) {
                dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
            } else if (s[i - 1] == '?') {
                dp[i][j] = (j == 0 ? 0LL : dp[i - 1][j - 1]) + 3LL * dp[i - 1][j];
            } else {
                dp[i][j] = dp[i - 1][j];
            }
            dp[i][j] %= md;
        }
    }

    cout << dp[n][3] % md;

}

int main() {
    solve();
    return 0;
}

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

int main(){
  int n,tri[3];

  cin >> n;

  for(int i=0;i<n;i++){
    cin >> tri[0] >> tri[1] >> tri[2];
    sort(tri,tri+3);
    if( (tri[0]*tri[0]+tri[1]*tri[1]) == tri[2]*tri[2] ) cout << "YES" << endl;
    else cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 1168
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

using ll = int64_t;

ll dp[105][100005] = {};

int main(int, const char**)
{
    int N, W;
    cin >> N >> W;
    rep(i, N)
    {
        int w, v;
        cin >> w >> v;
        rep(j, W + 1)
        {
            if(j - w >= 0)
            {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w] + v);
            }
            else
            {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 81712
import bisect
import sys
readline = sys.stdin.buffer.readline


def main():
    n = int(readline())
    a = list(map(int,readline().rsplit()))
    b = list(map(int,readline().rsplit()))
    c = list(map(int,readline().rsplit()))
    a_s = sorted(a)
    c_s = sorted(c)
    ans = 0
    for i in b:
        d = bisect.bisect_left(a_s, i)
        e = n - bisect.bisect_right(c_s, i)
        ans += d * e
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21088
n = gets.to_i
coins = gets.split.map(&:to_f)
dp = Array.new(n+1){Array.new(n+1, 0.0)}
dp[0][0] = 1.0
coins.each.with_index(1) do |p, i|
  dp_cur = dp[i]
  dp_prev = dp[i-1]
  (0..i).each do |j|
    dp_cur[j] += dp_prev[j-1] * p if j > 0
    dp_cur[j] += dp_prev[j] * (1 - p)
  end
end
puts dp[n][(n+1)/2..-1].inject(:+)


Measured memory_bytes: 198652